diff --git a/lib/junit-4.10.jar b/lib/junit-4.10.jar
new file mode 100644
index 00000000000..bf5c0b9c6ad
Binary files /dev/null and b/lib/junit-4.10.jar differ
diff --git a/out/production/k2js/com/google/dart/compiler/common/Name.class b/out/production/k2js/com/google/dart/compiler/common/Name.class
index f77a6855acb..9b3436f7a60 100644
Binary files a/out/production/k2js/com/google/dart/compiler/common/Name.class and b/out/production/k2js/com/google/dart/compiler/common/Name.class differ
diff --git a/out/production/k2js/com/google/dart/compiler/util/AstUtil.class b/out/production/k2js/com/google/dart/compiler/util/AstUtil.class
index 76e4d9911de..b1ce9a82abf 100644
Binary files a/out/production/k2js/com/google/dart/compiler/util/AstUtil.class and b/out/production/k2js/com/google/dart/compiler/util/AstUtil.class differ
diff --git a/out/production/k2js/com/google/dart/compiler/util/Lists.class b/out/production/k2js/com/google/dart/compiler/util/Lists.class
index 92c839e1020..8e57bffa68b 100644
Binary files a/out/production/k2js/com/google/dart/compiler/util/Lists.class and b/out/production/k2js/com/google/dart/compiler/util/Lists.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/generate/CodeGenerator.class b/out/production/k2js/org/jetbrains/k2js/generate/CodeGenerator.class
index e794109dcaa..f0e5c0e4eca 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/generate/CodeGenerator.class and b/out/production/k2js/org/jetbrains/k2js/generate/CodeGenerator.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/AbstractTranslator.class b/out/production/k2js/org/jetbrains/k2js/translate/AbstractTranslator.class
index 3f86cfd3798..0a82871b1cd 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/AbstractTranslator.class and b/out/production/k2js/org/jetbrains/k2js/translate/AbstractTranslator.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/ContextType$1.class b/out/production/k2js/org/jetbrains/k2js/translate/ContextType$1.class
index f489b64427d..f5d89742260 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/ContextType$1.class and b/out/production/k2js/org/jetbrains/k2js/translate/ContextType$1.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/ContextType$2.class b/out/production/k2js/org/jetbrains/k2js/translate/ContextType$2.class
index ab684b234af..26d4a350b88 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/ContextType$2.class and b/out/production/k2js/org/jetbrains/k2js/translate/ContextType$2.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/ContextType$3.class b/out/production/k2js/org/jetbrains/k2js/translate/ContextType$3.class
index 231222fecab..14b7059c19e 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/ContextType$3.class and b/out/production/k2js/org/jetbrains/k2js/translate/ContextType$3.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/ContextType.class b/out/production/k2js/org/jetbrains/k2js/translate/ContextType.class
index 7c41c676395..c6ee6638d33 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/ContextType.class and b/out/production/k2js/org/jetbrains/k2js/translate/ContextType.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$FunctionVariableDeclaration.class b/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$FunctionVariableDeclaration.class
index 149152d0eea..7b64b371e27 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$FunctionVariableDeclaration.class and b/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$FunctionVariableDeclaration.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$NamespacePropertyDeclaration.class b/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$NamespacePropertyDeclaration.class
index 3f5f71dea97..b31289d3086 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$NamespacePropertyDeclaration.class and b/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$NamespacePropertyDeclaration.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$State.class b/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$State.class
index 3bd12cb1a98..836a1ca7a38 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$State.class and b/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator$State.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator.class b/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator.class
index 6898b26059a..bfc2ad5e431 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator.class and b/out/production/k2js/org/jetbrains/k2js/translate/DeclarationTranslator.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/ExpressionTranslator.class b/out/production/k2js/org/jetbrains/k2js/translate/ExpressionTranslator.class
index 1e2b9ce9bbf..1e1fb9084c9 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/ExpressionTranslator.class and b/out/production/k2js/org/jetbrains/k2js/translate/ExpressionTranslator.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/FunctionTranslator.class b/out/production/k2js/org/jetbrains/k2js/translate/FunctionTranslator.class
index f77c2090441..d6aea207751 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/FunctionTranslator.class and b/out/production/k2js/org/jetbrains/k2js/translate/FunctionTranslator.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/NamespaceTranslator.class b/out/production/k2js/org/jetbrains/k2js/translate/NamespaceTranslator.class
index 09d4a4aba40..9d33225639d 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/NamespaceTranslator.class and b/out/production/k2js/org/jetbrains/k2js/translate/NamespaceTranslator.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/OperationTranslator.class b/out/production/k2js/org/jetbrains/k2js/translate/OperationTranslator.class
index 4435469276e..84b0ed10ac4 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/OperationTranslator.class and b/out/production/k2js/org/jetbrains/k2js/translate/OperationTranslator.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/TranslationContext.class b/out/production/k2js/org/jetbrains/k2js/translate/TranslationContext.class
index 4d58e36836a..cab077100a6 100644
Binary files a/out/production/k2js/org/jetbrains/k2js/translate/TranslationContext.class and b/out/production/k2js/org/jetbrains/k2js/translate/TranslationContext.class differ
diff --git a/out/production/k2js/org/jetbrains/k2js/translate/jet/Library.jet b/out/production/k2js/org/jetbrains/k2js/translate/jet/Library.jet
deleted file mode 100644
index b88e5eb0287..00000000000
--- a/out/production/k2js/org/jetbrains/k2js/translate/jet/Library.jet
+++ /dev/null
@@ -1,670 +0,0 @@
-namespace jet
-
-namespace typeinfo {
- class TypeInfo {
- fun isSubtypeOf(other : TypeInfo<*>) : Boolean
- fun isInstance(obj : Any?) : Boolean
- }
-
- fun typeinfo() : TypeInfo
- fun typeinfo(expression : T) : TypeInfo
-}
-
-namespace io {
- fun print(message : Any?)
- fun print(message : Int)
- fun print(message : Long)
- fun print(message : Byte)
- fun print(message : Short)
- fun print(message : Char)
- fun print(message : Boolean)
- fun print(message : Float)
- fun print(message : Double)
-
- fun println(message : Any?)
- fun println(message : Int)
- fun println(message : Long)
- fun println(message : Byte)
- fun println(message : Short)
- fun println(message : Char)
- fun println(message : Boolean)
- fun println(message : Float)
- fun println(message : Double)
-
- fun readLine() : String?
-}
-
-// Can't write a body due to a bootstrapping problem (see JET-74)
-fun Any?.equals(other : Any?) : Boolean// = this === other
-
-// Returns "null" for null
-fun Any?.toString() : String// = this === other
-
-fun String?.plus(other: Any?) : String
-
-trait Iterator {
- fun next() : T
- val hasNext : Boolean
-}
-
-trait Iterable {
- fun iterator() : Iterator
-}
-
-class Array(val size : Int, init : fun(Int) : T = null ) {
- fun get(index : Int) : T
- fun set(index : Int, value : T) : Unit
-
- fun iterator() : Iterator
-
- val indices : IntRange
-}
-
-class ByteArray(val size : Int) {
- fun get(index : Int) : Byte
- fun set(index : Int, value : Byte) : Unit
-
- fun iterator() : Iterator
-
- val indices : IntRange
-}
-
-class ShortArray(val size : Int) {
- fun get(index : Int) : Short
- fun set(index : Int, value : Short) : Unit
-
- fun iterator() : Iterator
-
- val indices : IntRange
-}
-
-class IntArray(val size : Int) {
- fun get(index : Int) : Int
- fun set(index : Int, value : Int) : Unit
-
- fun iterator() : Iterator
-
- val indices : IntRange
-}
-
-class LongArray(val size : Int) {
- fun get(index : Int) : Long
- fun set(index : Int, value : Long) : Unit
-
- fun iterator() : Iterator
-
- val indices : IntRange
-}
-
-class FloatArray(val size : Int) {
- fun get(index : Int) : Float
- fun set(index : Int, value : Float) : Unit
-
- fun iterator() : Iterator
-
- val indices : IntRange
-}
-
-class DoubleArray(val size : Int) {
- fun get(index : Int) : Double
- fun set(index : Int, value : Double) : Unit
-
- fun iterator() : Iterator
-
- val indices : IntRange
-}
-
-class CharArray(val size : Int) {
- fun get(index : Int) : Char
- fun set(index : Int, value : Char) : Unit
-
- fun iterator() : Iterator
-
- val indices : IntRange
-}
-
-class BooleanArray(val size : Int) {
- fun get(index : Int) : Boolean
- fun set(index : Int, value : Boolean) : Unit
-
- fun iterator() : Iterator
-
- val indices : IntRange
-}
-
-trait Comparable {
- fun compareTo(other : T) : Int
-}
-
-trait Hashable {
- fun hashCode() : Int
- fun equals(other : Any?) : Boolean
-}
-
-class Boolean : Comparable {
- fun not() : Boolean
-
- fun xor(other : Boolean) : Boolean
-
- fun equals(other : Any?) : Boolean
-}
-
-class String() : Comparable {
- fun get(index : Int) : Char
- val length : Int
-
- fun plus(other : Any?) : String
-
- fun equals(other : Any?) : Boolean
- fun equalsIgnoreCase(other: String?) : Boolean
-
- fun substring(start: Int): String
- fun substring(start: Int, end: Int): String
-
- fun startsWith(prefix: String, toffset: Int): Boolean
- fun startsWith(prefix: String): Boolean
- fun endsWith(suffix: String): Boolean
-
- fun trim(): String
-}
-
-trait Range> {
- fun contains(item : T) : Boolean
-}
-
-class IntRange(val start : Int, size : Int, reversed : Boolean = false) : Range, Iterable {
- fun iterator () : Iterator
-
- fun contains (elem: Int) : Boolean
-
- val size : Int
-
- val end : Int
-
- val reversed : Boolean
-}
-
-class LongRange(val start : Long, size : Long, reversed : Boolean = false) : Range, Iterable {
- fun iterator () : Iterator
-
- fun contains (elem: Long) : Boolean
-
- val size : Long
-
- val end : Long
-
- val reversed : Boolean
-}
-
-abstract class Number : Hashable {
- abstract val dbl : Double
- abstract val flt : Float
- abstract val lng : Long
- abstract val int : Int
- abstract val chr : Char
- abstract val sht : Short
- abstract val byt : Byte
-// fun equals(other : Double) : Boolean
-// fun equals(other : Float) : Boolean
-// fun equals(other : Long) : Boolean
-// fun equals(other : Byte) : Boolean
-// fun equals(other : Int) : Boolean
-// fun equals(other : Short) : Boolean
-// fun equals(other : Char) : Boolean
-}
-
-class Double : Number, Comparable {
- override fun compareTo(other : Double) : Int
- fun compareTo(other : Float) : Int
- fun compareTo(other : Long) : Int
- fun compareTo(other : Int) : Int
- fun compareTo(other : Short) : Int
- fun compareTo(other : Byte) : Int
- fun compareTo(other : Char) : Int
-
- fun plus(other : Double) : Double
- fun plus(other : Float) : Double
- fun plus(other : Long) : Double
- fun plus(other : Int) : Double
- fun plus(other : Short) : Double
- fun plus(other : Byte) : Double
- fun plus(other : Char) : Double
-
- fun minus(other : Double) : Double
- fun minus(other : Float) : Double
- fun minus(other : Long) : Double
- fun minus(other : Int) : Double
- fun minus(other : Short) : Double
- fun minus(other : Byte) : Double
- fun minus(other : Char) : Double
-
- fun times(other : Double) : Double
- fun times(other : Float) : Double
- fun times(other : Long) : Double
- fun times(other : Int) : Double
- fun times(other : Short) : Double
- fun times(other : Byte) : Double
- fun times(other : Char) : Double
-
- fun div(other : Double) : Double
- fun div(other : Float) : Double
- fun div(other : Long) : Double
- fun div(other : Int) : Double
- fun div(other : Short) : Double
- fun div(other : Byte) : Double
- fun div(other : Char) : Double
-
- fun mod(other : Double) : Double
- fun mod(other : Float) : Double
- fun mod(other : Long) : Double
- fun mod(other : Int) : Double
- fun mod(other : Short) : Double
- fun mod(other : Byte) : Double
-
- fun rangeTo(other : Double) : Range
- fun rangeTo(other : Float) : Range
- fun rangeTo(other : Long) : Range
- fun rangeTo(other : Int) : Range
- fun rangeTo(other : Short) : Range
- fun rangeTo(other : Byte) : Range
- fun rangeTo(other : Char) : Range
-
- fun inc() : Double
- fun dec() : Double
- fun plus() : Double
- fun minus() : Double
-}
-
-class Float : Number, Comparable {
- fun compareTo(other : Double) : Int
- override fun compareTo(other : Float) : Int
- fun compareTo(other : Long) : Int
- fun compareTo(other : Int) : Int
- fun compareTo(other : Short) : Int
- fun compareTo(other : Byte) : Int
- fun compareTo(other : Char) : Int
-
- fun plus(other : Double) : Double
- fun plus(other : Float) : Float
- fun plus(other : Long) : Float
- fun plus(other : Int) : Float
- fun plus(other : Short) : Float
- fun plus(other : Byte) : Float
- fun plus(other : Char) : Float
-
- fun minus(other : Double) : Double
- fun minus(other : Float) : Float
- fun minus(other : Long) : Float
- fun minus(other : Int) : Float
- fun minus(other : Short) : Float
- fun minus(other : Byte) : Float
- fun minus(other : Char) : Float
-
- fun times(other : Double) : Double
- fun times(other : Float) : Float
- fun times(other : Long) : Float
- fun times(other : Int) : Float
- fun times(other : Short) : Float
- fun times(other : Byte) : Float
- fun times(other : Char) : Float
-
- fun div(other : Double) : Double
- fun div(other : Float) : Float
- fun div(other : Long) : Float
- fun div(other : Int) : Float
- fun div(other : Short) : Float
- fun div(other : Byte) : Float
- fun div(other : Char) : Float
-
- fun mod(other : Double) : Double
- fun mod(other : Float) : Float
- fun mod(other : Long) : Float
- fun mod(other : Int) : Float
- fun mod(other : Short) : Float
- fun mod(other : Byte) : Float
- fun mod(other : Char) : Float
-
- fun rangeTo(other : Double) : Range
- fun rangeTo(other : Float) : Range
- fun rangeTo(other : Long) : Range
- fun rangeTo(other : Int) : Range
- fun rangeTo(other : Short) : Range
- fun rangeTo(other : Byte) : Range
- fun rangeTo(other : Char) : Range
-
- fun inc() : Float
- fun dec() : Float
- fun plus() : Float
- fun minus() : Float
-}
-
-class Long : Number, Comparable {
- fun compareTo(other : Double) : Int
- fun compareTo(other : Float) : Int
- override fun compareTo(other : Long) : Int
- fun compareTo(other : Int) : Int
- fun compareTo(other : Short) : Int
- fun compareTo(other : Byte) : Int
- fun compareTo(other : Char) : Int
-
- fun plus(other : Double) : Double
- fun plus(other : Float) : Float
- fun plus(other : Long) : Long
- fun plus(other : Int) : Long
- fun plus(other : Short) : Long
- fun plus(other : Byte) : Long
- fun plus(other : Char) : Long
-
- fun minus(other : Double) : Double
- fun minus(other : Float) : Float
- fun minus(other : Long) : Long
- fun minus(other : Int) : Long
- fun minus(other : Short) : Long
- fun minus(other : Byte) : Long
- fun minus(other : Char) : Long
-
- fun times(other : Double) : Double
- fun times(other : Float) : Float
- fun times(other : Long) : Long
- fun times(other : Int) : Long
- fun times(other : Short) : Long
- fun times(other : Byte) : Long
- fun times(other : Char) : Long
-
- fun div(other : Double) : Double
- fun div(other : Float) : Float
- fun div(other : Long) : Long
- fun div(other : Int) : Long
- fun div(other : Short) : Long
- fun div(other : Byte) : Long
- fun div(other : Char) : Long
-
- fun mod(other : Double) : Double
- fun mod(other : Float) : Float
- fun mod(other : Long) : Long
- fun mod(other : Int) : Long
- fun mod(other : Short) : Long
- fun mod(other : Byte) : Long
- fun mod(other : Char) : Long
-
- fun rangeTo(other : Double) : Range
- fun rangeTo(other : Float) : Range
- fun rangeTo(other : Long) : LongRange
- fun rangeTo(other : Int) : LongRange
- fun rangeTo(other : Short) : LongRange
- fun rangeTo(other : Byte) : LongRange
- fun rangeTo(other : Char) : LongRange
-
- fun inc() : Long
- fun dec() : Long
- fun plus() : Long
- fun minus() : Long
-
- fun shl(bits : Int) : Long
- fun shr(bits : Int) : Long
- fun ushr(bits : Int) : Long
- fun and(other : Long) : Long
- fun or(other : Long) : Long
- fun xor(other : Long) : Long
- fun inv() : Long
-}
-
-class Int : Number, Comparable {
- fun compareTo(other : Double) : Int
- fun compareTo(other : Float) : Int
- fun compareTo(other : Long) : Int
- override fun compareTo(other : Int) : Int
- fun compareTo(other : Short) : Int
- fun compareTo(other : Byte) : Int
- fun compareTo(other : Char) : Int
-
- fun plus(other : Double) : Double
- fun plus(other : Float) : Float
- fun plus(other : Long) : Long
- fun plus(other : Int) : Int
- fun plus(other : Short) : Int
- fun plus(other : Byte) : Int
- fun plus(other : Char) : Int
-
- fun minus(other : Double) : Double
- fun minus(other : Float) : Float
- fun minus(other : Long) : Long
- fun minus(other : Int) : Int
- fun minus(other : Short) : Int
- fun minus(other : Byte) : Int
- fun minus(other : Char) : Int
-
- fun times(other : Double) : Double
- fun times(other : Float) : Float
- fun times(other : Long) : Long
- fun times(other : Int) : Int
- fun times(other : Short) : Int
- fun times(other : Byte) : Int
- fun times(other : Char) : Int
-
- fun div(other : Double) : Double
- fun div(other : Float) : Float
- fun div(other : Long) : Long
- fun div(other : Int) : Int
- fun div(other : Short) : Int
- fun div(other : Byte) : Int
- fun div(other : Char) : Int
-
- fun mod(other : Double) : Double
- fun mod(other : Float) : Float
- fun mod(other : Long) : Long
- fun mod(other : Int) : Int
- fun mod(other : Short) : Int
- fun mod(other : Byte) : Int
- fun mod(other : Char) : Int
-
- fun rangeTo(other : Double) : Range
- fun rangeTo(other : Float) : Range
- fun rangeTo(other : Long) : LongRange
- fun rangeTo(other : Int) : IntRange
- fun rangeTo(other : Short) : IntRange
- fun rangeTo(other : Byte) : IntRange
- fun rangeTo(other : Char) : IntRange
-
- fun inc() : Int
- fun dec() : Int
- fun plus() : Int
- fun minus() : Int
-
- fun shl(bits : Int) : Int
- fun shr(bits : Int) : Int
- fun ushr(bits : Int) : Int
- fun and(other : Int) : Int
- fun or(other : Int) : Int
- fun xor(other : Int) : Int
- fun inv() : Int
-}
-
-class Char : Number, Comparable {
- fun compareTo(other : Double) : Int
- fun compareTo(other : Float) : Int
- fun compareTo(other : Long) : Int
- fun compareTo(other : Int) : Int
- fun compareTo(other : Short) : Int
- override fun compareTo(other : Char) : Int
- fun compareTo(other : Byte) : Int
-
- fun plus(other : Double) : Double
- fun plus(other : Float) : Float
- fun plus(other : Long) : Long
- fun plus(other : Int) : Int
- fun plus(other : Short) : Int
- fun plus(other : Byte) : Int
- fun plus(other : Char) : Int
-
- fun minus(other : Double) : Double
- fun minus(other : Float) : Float
- fun minus(other : Long) : Long
- fun minus(other : Int) : Int
- fun minus(other : Short) : Int
- fun minus(other : Byte) : Int
- fun minus(other : Char) : Int
-
- fun times(other : Double) : Double
- fun times(other : Float) : Float
- fun times(other : Long) : Long
- fun times(other : Int) : Int
- fun times(other : Short) : Int
- fun times(other : Byte) : Int
- fun times(other : Char) : Int
-
- fun div(other : Double) : Double
- fun div(other : Float) : Float
- fun div(other : Long) : Long
- fun div(other : Int) : Int
- fun div(other : Short) : Int
- fun div(other : Byte) : Int
- fun div(other : Char) : Int
-
- fun mod(other : Double) : Double
- fun mod(other : Float) : Float
- fun mod(other : Long) : Long
- fun mod(other : Int) : Int
- fun mod(other : Short) : Int
- fun mod(other : Byte) : Int
- fun mod(other : Char) : Int
-
- fun rangeTo(other : Double) : Range
- fun rangeTo(other : Float) : Range
- fun rangeTo(other : Long) : LongRange
- fun rangeTo(other : Int) : IntRange
- fun rangeTo(other : Short) : IntRange
- fun rangeTo(other : Byte) : IntRange
- fun rangeTo(other : Char) : IntRange
-
- fun inc() : Char
- fun dec() : Char
- fun plus() : Int
- fun minus() : Int
-}
-
-class Short : Number, Comparable {
- fun compareTo(other : Double) : Int
- fun compareTo(other : Float) : Int
- fun compareTo(other : Long) : Int
- fun compareTo(other : Int) : Int
- override fun compareTo(other : Short) : Int
- fun compareTo(other : Byte) : Int
- fun compareTo(other : Char) : Int
-
- fun plus(other : Double) : Double
- fun plus(other : Float) : Float
- fun plus(other : Long) : Long
- fun plus(other : Int) : Int
- fun plus(other : Short) : Int
- fun plus(other : Byte) : Int
- fun plus(other : Char) : Int
-
- fun minus(other : Double) : Double
- fun minus(other : Float) : Float
- fun minus(other : Long) : Long
- fun minus(other : Int) : Int
- fun minus(other : Short) : Int
- fun minus(other : Byte) : Int
- fun minus(other : Char) : Int
-
- fun times(other : Double) : Double
- fun times(other : Float) : Float
- fun times(other : Long) : Long
- fun times(other : Int) : Int
- fun times(other : Short) : Int
- fun times(other : Byte) : Int
- fun times(other : Char) : Int
-
- fun div(other : Double) : Double
- fun div(other : Float) : Float
- fun div(other : Long) : Long
- fun div(other : Int) : Int
- fun div(other : Short) : Int
- fun div(other : Byte) : Int
- fun div(other : Char) : Int
-
- fun mod(other : Double) : Double
- fun mod(other : Float) : Float
- fun mod(other : Long) : Long
- fun mod(other : Int) : Int
- fun mod(other : Short) : Int
- fun mod(other : Byte) : Int
- fun mod(other : Char) : Int
-
- fun rangeTo(other : Double) : Range
- fun rangeTo(other : Float) : Range
- fun rangeTo(other : Long) : LongRange
- fun rangeTo(other : Int) : IntRange
- fun rangeTo(other : Short) : IntRange
- fun rangeTo(other : Byte) : IntRange
- fun rangeTo(other : Char) : IntRange
-
- fun inc() : Short
- fun dec() : Short
- fun plus() : Int
- fun minus() : Int
-}
-
-class Byte : Number, Comparable {
- fun compareTo(other : Double) : Int
- fun compareTo(other : Float) : Int
- fun compareTo(other : Long) : Int
- fun compareTo(other : Int) : Int
- fun compareTo(other : Short) : Int
- fun compareTo(other : Char) : Int
- override fun compareTo(other : Byte) : Int
-
- fun plus(other : Double) : Double
- fun plus(other : Float) : Float
- fun plus(other : Long) : Long
- fun plus(other : Int) : Int
- fun plus(other : Short) : Int
- fun plus(other : Byte) : Int
- fun plus(other : Char) : Int
-
- fun minus(other : Double) : Double
- fun minus(other : Float) : Float
- fun minus(other : Long) : Long
- fun minus(other : Int) : Int
- fun minus(other : Short) : Int
- fun minus(other : Byte) : Int
- fun minus(other : Char) : Int
-
- fun times(other : Double) : Double
- fun times(other : Float) : Float
- fun times(other : Long) : Long
- fun times(other : Int) : Int
- fun times(other : Short) : Int
- fun times(other : Byte) : Int
- fun times(other : Char) : Int
-
- fun div(other : Double) : Double
- fun div(other : Float) : Float
- fun div(other : Long) : Long
- fun div(other : Int) : Int
- fun div(other : Short) : Int
- fun div(other : Byte) : Int
- fun div(other : Char) : Int
-
- fun mod(other : Double) : Double
- fun mod(other : Float) : Float
- fun mod(other : Long) : Long
- fun mod(other : Int) : Int
- fun mod(other : Short) : Int
- fun mod(other : Byte) : Int
- fun mod(other : Char) : Int
-
- fun rangeTo(other : Double) : Range
- fun rangeTo(other : Float) : Range
- fun rangeTo(other : Long) : LongRange
- fun rangeTo(other : Int) : IntRange
- fun rangeTo(other : Short) : IntRange
- fun rangeTo(other : Byte) : IntRange
- fun rangeTo(other : Char) : IntRange
-
- fun inc() : Byte
- fun dec() : Byte
- fun plus() : Int
- fun minus() : Int
-}
diff --git a/out/test/k2js/com/google/dart/compiler/backend/js/Test.class b/out/test/k2js/com/google/dart/compiler/backend/js/Test.class
deleted file mode 100644
index 99eaaf28327..00000000000
Binary files a/out/test/k2js/com/google/dart/compiler/backend/js/Test.class and /dev/null differ
diff --git a/src/com/google/dart/compiler/backend/js/JsNamer.java b/src/com/google/dart/compiler/backend/js/JsNamer.java
index 41e99061eda..0c49ad05750 100644
--- a/src/com/google/dart/compiler/backend/js/JsNamer.java
+++ b/src/com/google/dart/compiler/backend/js/JsNamer.java
@@ -16,7 +16,7 @@ import com.google.dart.compiler.backend.js.ast.JsProgram;
*/
public interface JsNamer {
/**
- * Names the shortNames of all JsNames of the program so that they are valid
+ * GlobalNames the shortNames of all JsNames of the program so that they are valid
* JS-identifiers and that there are no clashes and no shadowing.
*/
public void exec(JsProgram program);
diff --git a/src/com/google/dart/compiler/backend/js/JsSourceGenerationVisitor.java b/src/com/google/dart/compiler/backend/js/JsSourceGenerationVisitor.java
index 943183ca94a..ebb836a7228 100644
--- a/src/com/google/dart/compiler/backend/js/JsSourceGenerationVisitor.java
+++ b/src/com/google/dart/compiler/backend/js/JsSourceGenerationVisitor.java
@@ -8,7 +8,7 @@ import com.google.dart.compiler.backend.js.ast.JsBlock;
import com.google.dart.compiler.backend.js.ast.JsContext;
import com.google.dart.compiler.backend.js.ast.JsProgram;
import com.google.dart.compiler.backend.js.ast.JsProgramFragment;
-import com.google.dart.compiler.util.*;
+import com.google.dart.compiler.util.TextOutput;
/**
* Generates JavaScript source from an AST.
diff --git a/src/com/google/dart/compiler/common/Name.java b/src/com/google/dart/compiler/common/Name.java
index 1d345c1d05e..4697b491d96 100644
--- a/src/com/google/dart/compiler/common/Name.java
+++ b/src/com/google/dart/compiler/common/Name.java
@@ -4,19 +4,15 @@
package com.google.dart.compiler.common;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.io.Serializable;
-import java.io.Writer;
+import java.io.*;
import java.nio.charset.Charset;
/**
- * Instead of Strings, we use Names to abstract the underlying representation.
+ * Instead of Strings, we use GlobalNames to abstract the underlying representation.
*
*
- *
Names are globally unique and use identity for equality.
- *
Names are interned, so all references to the same name use the same
+ *
GlobalNames are globally unique and use identity for equality.
+ *
GlobalNames are interned, so all references to the same name use the same
* bytes.
*
* TODO(scottb): use byte[] instead of char[] when the parser is rewritten
diff --git a/src/com/google/dart/compiler/util/AstUtil.java b/src/com/google/dart/compiler/util/AstUtil.java
index ff67441c763..826426b5557 100644
--- a/src/com/google/dart/compiler/util/AstUtil.java
+++ b/src/com/google/dart/compiler/util/AstUtil.java
@@ -8,9 +8,7 @@ import com.google.dart.compiler.InternalCompilerException;
import com.google.dart.compiler.backend.js.ast.*;
import com.google.dart.compiler.backend.js.ast.JsVars.JsVar;
import com.google.dart.compiler.common.SourceInfo;
-import com.sun.org.apache.xpath.internal.functions.Function;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -28,6 +26,16 @@ public class AstUtil {
return invoke;
}
+ public static JsInvocation newInvocation(
+ JsExpression target, List params) {
+ JsInvocation invoke = new JsInvocation();
+ invoke.setQualifier(target);
+ for (JsExpression expr : params) {
+ invoke.getArguments().add(expr);
+ }
+ return invoke;
+ }
+
public static JsNameRef newQualifiedNameRef(String name) {
JsNameRef node = null;
int endPos = -1;
@@ -245,4 +253,9 @@ public class AstUtil {
public static JsExpression in(SourceInfo src, JsExpression propName, JsExpression obj) {
return new JsBinaryOperation(JsBinaryOperator.INOP, propName, obj).setSourceRef(src);
}
+
+ public static JsPropertyInitializer newNamedMethod(JsName name, JsFunction function) {
+ JsNameRef methodName = name.makeRef();
+ return new JsPropertyInitializer(methodName, function);
+ }
}
diff --git a/src/com/google/dart/compiler/util/Lists.java b/src/com/google/dart/compiler/util/Lists.java
index 5d7f6ddc545..b0ca023d280 100644
--- a/src/com/google/dart/compiler/util/Lists.java
+++ b/src/com/google/dart/compiler/util/Lists.java
@@ -4,12 +4,7 @@
package com.google.dart.compiler.util;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
+import java.util.*;
/**
* Utility methods for operating on memory-efficient lists. All lists of size 0
diff --git a/src/com/google/dart/compiler/util/Maps.java b/src/com/google/dart/compiler/util/Maps.java
index 89ea29fdd2a..15274b04902 100644
--- a/src/com/google/dart/compiler/util/Maps.java
+++ b/src/com/google/dart/compiler/util/Maps.java
@@ -6,8 +6,8 @@ package com.google.dart.compiler.util;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Map;
import java.util.LinkedHashMap;
+import java.util.Map;
/**
* Utility methods for operating on memory-efficient maps. All maps of size 0 or
diff --git a/src/org/jetbrains/k2js/K2JSTranslator.java b/src/org/jetbrains/k2js/K2JSTranslator.java
index ba42ccc61cc..92336141801 100644
--- a/src/org/jetbrains/k2js/K2JSTranslator.java
+++ b/src/org/jetbrains/k2js/K2JSTranslator.java
@@ -23,10 +23,11 @@ import org.jetbrains.jet.lang.psi.JetNamespace;
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.java.JavaDefaultImports;
-import org.jetbrains.k2js.translate.GenerationState;
import org.jetbrains.k2js.generate.CodeGenerator;
+import org.jetbrains.k2js.translate.GenerationState;
import java.io.File;
+import java.io.IOException;
import java.util.Collection;
import java.util.List;
@@ -45,8 +46,12 @@ public class K2JSTranslator {
public static void main(String[] args) {
System.setProperty("java.awt.headless", "true");
Arguments arguments = new Arguments();
- arguments.src = "C:\\Dev\\Projects\\jet-contrib\\k2js\\test_files\\test.kt";
+ arguments.src = "test_files\\test_cases\\test.kt";
+ arguments.outputDir = null;
+ translate(arguments);
+ }
+ public static void translate(Arguments arguments) {
Disposable root = new Disposable() {
@Override
public void dispose() {
@@ -93,7 +98,17 @@ public class K2JSTranslator {
// Translate generated psi
CodeGenerator generator = new CodeGenerator();
JsProgram program = generationState.compileCorrectNamespaces(bindingContext, namespaces);
- generator.generate(program);
+ if (arguments.outputDir == null) {
+ generator.generateToConsole(program);
+ } else {
+ File outputFile = new File(arguments.outputDir);
+ try {
+ generator.generateToFile(program, outputFile);
+ }
+ catch (IOException e) {
+ System.out.println("Failed to write to specified file");
+ }
+ }
}
}
diff --git a/src/org/jetbrains/k2js/generate/CodeGenerator.java b/src/org/jetbrains/k2js/generate/CodeGenerator.java
index b65520b8ba9..7a05851f48e 100644
--- a/src/org/jetbrains/k2js/generate/CodeGenerator.java
+++ b/src/org/jetbrains/k2js/generate/CodeGenerator.java
@@ -5,6 +5,10 @@ import com.google.dart.compiler.backend.js.ast.JsProgram;
import com.google.dart.compiler.util.DefaultTextOutput;
import com.google.dart.compiler.util.TextOutput;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
/**
* @author Pavel.Talanov
*/
@@ -16,10 +20,21 @@ public final class CodeGenerator {
}
- public void generate(JsProgram program) {
+ public void generateToConsole(JsProgram program) {
+ generateCode(program);
+ System.out.println(output.toString());
+ }
+
+ private void generateCode(JsProgram program) {
JsSourceGenerationVisitor sourceGenerator =
new JsSourceGenerationVisitor(output);
program.traverse(sourceGenerator, null);
- System.out.println(output.toString());
+ }
+
+ public void generateToFile(JsProgram program, File file) throws IOException {
+ generateCode(program);
+ FileWriter writer = new FileWriter(file);
+ writer.write(output.toString());
+ writer.close();
}
}
diff --git a/src/org/jetbrains/k2js/translate/AbstractTranslator.java b/src/org/jetbrains/k2js/translate/AbstractTranslator.java
index 602fbd5bbc5..9046f80adb7 100644
--- a/src/org/jetbrains/k2js/translate/AbstractTranslator.java
+++ b/src/org/jetbrains/k2js/translate/AbstractTranslator.java
@@ -41,11 +41,6 @@ public abstract class AbstractTranslator {
@NotNull
protected JsScope scope() {
- return context.scope();
- }
-
- @NotNull
- protected JsBlock block() {
- return context.block();
+ return context.enclosingScope();
}
}
diff --git a/src/org/jetbrains/k2js/translate/ClassBodyVisitor.java b/src/org/jetbrains/k2js/translate/ClassBodyVisitor.java
index 7747ffc620d..5572f24304e 100644
--- a/src/org/jetbrains/k2js/translate/ClassBodyVisitor.java
+++ b/src/org/jetbrains/k2js/translate/ClassBodyVisitor.java
@@ -1,13 +1,15 @@
package org.jetbrains.k2js.translate;
-import com.google.dart.compiler.backend.js.ast.JsBlock;
-import com.google.dart.compiler.backend.js.ast.JsFunction;
-import com.google.dart.compiler.backend.js.ast.JsPropertyInitializer;
+import com.google.dart.compiler.backend.js.ast.*;
import com.google.dart.compiler.util.AstUtil;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.psi.*;
+import org.jetbrains.jet.lang.psi.JetClass;
+import org.jetbrains.jet.lang.psi.JetDeclaration;
+import org.jetbrains.jet.lang.psi.JetProperty;
+import org.jetbrains.jet.lang.psi.JetPropertyAccessor;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -31,30 +33,69 @@ public class ClassBodyVisitor extends K2JsVisitor> {
List methods = new ArrayList();
if (expression.getSetter() != null) {
methods.addAll(expression.getSetter().accept(this, context));
+ } else {
+ if (expression.isVar()) {
+ methods.add(generateDefaultSetter(expression, context));
+ }
}
if (expression.getGetter() != null) {
methods.addAll(expression.getGetter().accept(this, context));
+ } else {
+ methods.add(generateDefaultGetter(expression, context));
}
return methods;
}
+ @NotNull
+ private JsPropertyInitializer generateDefaultGetter(JetProperty expression, TranslationContext context) {
+ return AstUtil.newNamedMethod
+ (Namer.getNameForGetter(expression.getName()), generateDefaultGetterFunction(expression, context));
+ }
+
+ @NotNull
+ private JsFunction generateDefaultGetterFunction(JetProperty expression, TranslationContext context) {
+ JsNameRef backingFieldRef = Namer.getBackingFieldNameForProperty(expression.getName()).makeRef();
+ JsReturn returnExpression = new JsReturn(backingFieldRef);
+ return AstUtil.newFunction
+ (context.enclosingScope(), null, Collections.EMPTY_LIST, AstUtil.convertToBlock(returnExpression));
+ }
+
+
+ @NotNull
+ private JsPropertyInitializer generateDefaultSetter(JetProperty expression, TranslationContext context) {
+ return AstUtil.newNamedMethod(
+ Namer.getNameForAccessor(expression.getName(), null), generateDefaultSetterFunction(expression, context));
+ }
+
+ @NotNull
+ private JsFunction generateDefaultSetterFunction(JetProperty expression, TranslationContext context) {
+ JsFunction result = new JsFunction(context.enclosingScope());
+ JsParameter defaultParameter = new JsParameter(context.enclosingScope().declareFreshName(Namer.DEFAULT_SETTER_PARAM_NAME));
+ JsBinaryOperation assignExpression = new JsBinaryOperation(JsBinaryOperator.ASG);
+ assignExpression.setArg1(Namer.getBackingFieldNameForProperty(expression).makeRef());
+ assignExpression.setArg2(defaultParameter.getName().makeRef());
+ return result;
+ }
+
@Override
@NotNull
public List visitPropertyAccessor
(JetPropertyAccessor expression, TranslationContext context) {
List methods = new ArrayList();
- JsPropertyInitializer namedMethod = new JsPropertyInitializer();
- // TODO
- namedMethod.setLabelExpr(Namer.getNameForAccessor("nameForAccessor", expression).makeRef());
- JsFunction methodBody = new JsFunction(context.scope());
- ExpressionTranslator expressionTranslator =
- new ExpressionTranslator(context.newScope(methodBody.getScope()));
- JsBlock methodBlock = AstUtil.convertToBlock(expressionTranslator.translate(expression.getBodyExpression()));
- methodBody.setBody(methodBlock);
- namedMethod.setValueExpr(methodBody);
+ JsPropertyInitializer namedMethod = generateMethodForAccessor(expression, context);
methods.add(namedMethod);
return methods;
}
+ private JsPropertyInitializer generateMethodForAccessor(JetPropertyAccessor expression, TranslationContext context) {
+ JsFunction methodBody = new JsFunction(context.enclosingScope());
+ ExpressionTranslator expressionTranslator =
+ new ExpressionTranslator(context.newFunction(methodBody));
+ JsBlock methodBodyBlock = AstUtil.convertToBlock(expressionTranslator.translate(expression.getBodyExpression()));
+ methodBody.setBody(methodBodyBlock);
+ //TODO figure out naming pattern
+ return AstUtil.newNamedMethod(Namer.getNameForAccessor("nameForAccessor", expression), methodBody);
+ }
+
}
diff --git a/src/org/jetbrains/k2js/translate/ClassTranslator.java b/src/org/jetbrains/k2js/translate/ClassTranslator.java
index 5a22874cc20..2e53af05302 100644
--- a/src/org/jetbrains/k2js/translate/ClassTranslator.java
+++ b/src/org/jetbrains/k2js/translate/ClassTranslator.java
@@ -24,13 +24,13 @@ public class ClassTranslator extends AbstractTranslator {
public JsStatement translateClass(JetClass classDeclaration) {
JsInvocation jsClassDeclaration = new JsInvocation();
- jsClassDeclaration.setQualifier(translationContext().classCreationMethodReference());
+ jsClassDeclaration.setQualifier(Namer.creationMethodReference());
JsObjectLiteral jsClassDescription = translateClassDeclarations(classDeclaration);
jsClassDeclaration.getArguments().add(jsClassDescription);
//getSuperClassName(classDeclaration);
String className = classDeclaration.getName();
JsStatement result = AstUtil.convertToStatement(AstUtil.newAssignment(
- translationContext().getQualifiedReference(getJSName(className)), jsClassDeclaration));
+ translationContext().getNamespaceQualifiedReference(getJSName(className)), jsClassDeclaration));
return result;
}
diff --git a/src/org/jetbrains/k2js/translate/ContextType.java b/src/org/jetbrains/k2js/translate/ContextType.java
index d9a5463db6d..50afc79f6a6 100644
--- a/src/org/jetbrains/k2js/translate/ContextType.java
+++ b/src/org/jetbrains/k2js/translate/ContextType.java
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.translate;
-import com.sun.org.apache.bcel.internal.generic.NEW;
-
/**
* @author Talanov Pavel
*/
diff --git a/src/org/jetbrains/k2js/translate/DeclarationTranslator.java b/src/org/jetbrains/k2js/translate/DeclarationTranslator.java
index 32cfb417e87..a33885ffce4 100644
--- a/src/org/jetbrains/k2js/translate/DeclarationTranslator.java
+++ b/src/org/jetbrains/k2js/translate/DeclarationTranslator.java
@@ -1,16 +1,14 @@
package org.jetbrains.k2js.translate;
-import com.google.dart.compiler.backend.js.ast.*;
+import com.google.dart.compiler.backend.js.ast.JsExpression;
+import com.google.dart.compiler.backend.js.ast.JsName;
+import com.google.dart.compiler.backend.js.ast.JsNameRef;
+import com.google.dart.compiler.backend.js.ast.JsStatement;
import com.google.dart.compiler.util.AstUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* @author Talanov Pavel
*/
@@ -79,7 +77,7 @@ public class DeclarationTranslator extends AbstractTranslator {
@NotNull
public JsStatement translateProperty(JetProperty declaration) {
String propertyName = declaration.getName();
- JsNameRef jsPropertyNameReference = translationContext().getQualifiedReference(getJSName(propertyName));
+ JsNameRef jsPropertyNameReference = translationContext().getNamespaceQualifiedReference(getJSName(propertyName));
JsExpression jsInitExpression = translateInitializer(declaration);
JsExpression result;
if (jsInitExpression != null) {
diff --git a/src/org/jetbrains/k2js/translate/ExpressionTranslator.java b/src/org/jetbrains/k2js/translate/ExpressionTranslator.java
index 5e25f40885c..b121070fc50 100644
--- a/src/org/jetbrains/k2js/translate/ExpressionTranslator.java
+++ b/src/org/jetbrains/k2js/translate/ExpressionTranslator.java
@@ -1,15 +1,8 @@
package org.jetbrains.k2js.translate;
-import com.google.dart.compiler.backend.js.ast.*;
-import com.google.dart.compiler.util.AstUtil;
-import groovyjarjarantlr.collections.AST;
+import com.google.dart.compiler.backend.js.ast.JsNode;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.psi.*;
-import org.jetbrains.jet.lang.resolve.BindingContext;
-import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
-import org.jetbrains.jet.lexer.JetToken;
-
-import java.util.List;
+import org.jetbrains.jet.lang.psi.JetExpression;
/**
* @author Talanov Pavel
diff --git a/src/org/jetbrains/k2js/translate/ExpressionVisitor.java b/src/org/jetbrains/k2js/translate/ExpressionVisitor.java
index c381cf2d2de..854798ba96e 100644
--- a/src/org/jetbrains/k2js/translate/ExpressionVisitor.java
+++ b/src/org/jetbrains/k2js/translate/ExpressionVisitor.java
@@ -8,6 +8,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lexer.JetToken;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -26,6 +27,9 @@ public class ExpressionVisitor extends K2JsVisitor {
if (value instanceof Integer) {
result = context.program().getNumberLiteral((Integer) value);
}
+ if (value instanceof Boolean) {
+ return context.program().getBooleanLiteral((Boolean) value);
+ }
assert result != null;
return result;
}
@@ -35,12 +39,10 @@ public class ExpressionVisitor extends K2JsVisitor {
public JsNode visitBlockExpression(JetBlockExpression jetBlock, TranslationContext context) {
List jetElements = jetBlock.getStatements();
JsBlock jsBlock = new JsBlock();
- ExpressionTranslator expressionTranslator =
- new ExpressionTranslator(context.newBlock(jsBlock));
for (JetElement jetElement : jetElements) {
//TODO hack alert
JetExpression jetExpression = (JetExpression) jetElement;
- JsNode jsNode = jetExpression.accept(this, context.newBlock(jsBlock));
+ JsNode jsNode = jetExpression.accept(this, context.newBlock());
jsBlock.addStatement(AstUtil.convertToStatement(jsNode));
}
assert jsBlock != null;
@@ -51,9 +53,12 @@ public class ExpressionVisitor extends K2JsVisitor {
@NotNull
public JsNode visitReturnExpression(JetReturnExpression jetReturnExpression, TranslationContext context) {
//TODO hack alert
- JsExpression jsExpression = (JsExpression) (jetReturnExpression.getReturnedExpression().accept(this, context));
- JsReturn jsReturnExpression = new JsReturn(jsExpression);
- return jsReturnExpression;
+ if (jetReturnExpression.getReturnedExpression() != null) {
+ JsExpression jsExpression = (JsExpression) (jetReturnExpression.getReturnedExpression().accept(this, context));
+ JsReturn jsReturnExpression = new JsReturn(jsExpression);
+ return jsReturnExpression;
+ }
+ return new JsReturn();
}
@Override
@@ -78,7 +83,11 @@ public class ExpressionVisitor extends K2JsVisitor {
@NotNull
public JsNode visitSimpleNameExpression(JetSimpleNameExpression expression, TranslationContext context) {
String referencedName = expression.getReferencedName();
- return new JsNameRef(context.getJSName(referencedName));
+ if (context.enclosingScope().findExistingName(referencedName) == null) {
+ JsName name = context.enclosingScope().declareName(referencedName);
+ return name.makeRef();
+ }
+ return context.getNamespaceQualifiedReference(context.getJSName(referencedName));
}
@Override
@@ -88,4 +97,27 @@ public class ExpressionVisitor extends K2JsVisitor {
return translator.translateProperty(expression);
}
+ @Override
+ @NotNull
+ public JsNode visitCallExpression(JetCallExpression expression, TranslationContext context) {
+ JsExpression callee = getCallee(expression, context);
+ List arguments = generateArgumentList(expression.getFunctionLiteralArguments(), context);
+ return AstUtil.newInvocation(callee, arguments);
+ }
+
+ @NotNull
+ private JsExpression getCallee(JetCallExpression expression, TranslationContext context) {
+ JsNode jsCallee = expression.getCalleeExpression().accept(this, context);
+ return AstUtil.convertToExpression(jsCallee);
+ }
+
+ @NotNull
+ private List generateArgumentList(List jetArguments, TranslationContext context) {
+ List jsArguments = new ArrayList();
+ for (JetExpression jetExpression : jetArguments) {
+ jsArguments.add(AstUtil.convertToExpression(jetExpression.accept(this, context)));
+ }
+ return jsArguments;
+ }
+
}
diff --git a/src/org/jetbrains/k2js/translate/FunctionTranslator.java b/src/org/jetbrains/k2js/translate/FunctionTranslator.java
index 5599098a130..9eba740dcc6 100644
--- a/src/org/jetbrains/k2js/translate/FunctionTranslator.java
+++ b/src/org/jetbrains/k2js/translate/FunctionTranslator.java
@@ -1,9 +1,6 @@
package org.jetbrains.k2js.translate;
-import com.google.dart.compiler.backend.js.ast.JsFunction;
-import com.google.dart.compiler.backend.js.ast.JsNode;
-import com.google.dart.compiler.backend.js.ast.JsParameter;
-import com.google.dart.compiler.backend.js.ast.JsScope;
+import com.google.dart.compiler.backend.js.ast.*;
import com.google.dart.compiler.util.AstUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetExpression;
@@ -23,11 +20,16 @@ public class FunctionTranslator extends AbstractTranslator {
}
@NotNull
- public JsFunction translateFunction(JetNamedFunction jetFunction) {
- String name = jetFunction.getName();
+ public JsStatement translateFunction(JetNamedFunction jetFunction) {
+ JsNameRef functionName = translationContext().getNamespaceQualifiedReference(getJSName(jetFunction.getName()));
+ JsFunction function = generateFunctionObject(jetFunction);
+ return AstUtil.convertToStatement(AstUtil.newAssignment(functionName, function));
+ }
+
+ private JsFunction generateFunctionObject(JetNamedFunction jetFunction) {
JetExpression jetBodyExpression = jetFunction.getBodyExpression();
- JsFunction result = new JsFunction(scope(), getJSName(name));
- JsNode jsBody = (new ExpressionTranslator(functionBodyContext(result.getScope())))
+ JsFunction result = new JsFunction(scope());
+ JsNode jsBody = (new ExpressionTranslator(functionBodyContext(result)))
.translate(jetBodyExpression);
List jsParameters = translateParameters(jetFunction.getValueParameters());
result.setParameters(jsParameters);
@@ -35,8 +37,8 @@ public class FunctionTranslator extends AbstractTranslator {
return result;
}
- private TranslationContext functionBodyContext(JsScope functionScope) {
- return translationContext().newType(ContextType.FUNCTION_BODY).newScope(functionScope);
+ private TranslationContext functionBodyContext(JsFunction function) {
+ return translationContext().newFunction(function);
}
@NotNull
diff --git a/src/org/jetbrains/k2js/translate/K2JsVisitor.java b/src/org/jetbrains/k2js/translate/K2JsVisitor.java
index 1b6490a520f..ce248446966 100644
--- a/src/org/jetbrains/k2js/translate/K2JsVisitor.java
+++ b/src/org/jetbrains/k2js/translate/K2JsVisitor.java
@@ -1,6 +1,5 @@
package org.jetbrains.k2js.translate;
-import com.google.dart.compiler.backend.js.ast.JsNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetElement;
import org.jetbrains.jet.lang.psi.JetVisitor;
diff --git a/src/org/jetbrains/k2js/translate/Namer.java b/src/org/jetbrains/k2js/translate/Namer.java
index a4760fbcd4d..d8edac49f53 100644
--- a/src/org/jetbrains/k2js/translate/Namer.java
+++ b/src/org/jetbrains/k2js/translate/Namer.java
@@ -1,10 +1,11 @@
package org.jetbrains.k2js.translate;
import com.google.dart.compiler.backend.js.ast.JsName;
+import com.google.dart.compiler.backend.js.ast.JsNameRef;
+import com.google.dart.compiler.util.AstUtil;
+import org.jetbrains.jet.lang.psi.JetProperty;
import org.jetbrains.jet.lang.psi.JetPropertyAccessor;
-import java.util.Set;
-
/**
* @author Talanov Pavel
*/
@@ -23,6 +24,8 @@ public final class Namer {
private static final String CLASS_CREATE_METHOD_NAME = "create";
private static final String SETTER_PREFIX = "_set_";
private static final String GETTER_PREFIX = "_get_";
+ private static final String BACKING_FIELD_PREFIX = "_$_";
+ public static final String DEFAULT_SETTER_PARAM_NAME = "val";
public static JsName getClassObjectName() {
//TODO dummy representation
@@ -30,14 +33,50 @@ public final class Namer {
}
public static JsName getNameForAccessor(String propertyName, JetPropertyAccessor accessor) {
- String name = propertyName;
if (accessor.isGetter()) {
- name += GETTER_PREFIX;
+ return getNameForGetter(propertyName);
}
if (accessor.isSetter()) {
- name += SETTER_PREFIX;
+ return getNameForSetter(propertyName);
}
+ throw new AssertionError("accessor should be a getter or a setter!");
+ }
+
+ public static JsName getBackingFieldNameForProperty(String propertyName) {
+ String name = BACKING_FIELD_PREFIX + propertyName;
return new JsName(null, name, name, name);
}
+ public static JsName getBackingFieldNameForProperty(JetProperty property) {
+ return getNameWithPrefix(property.getName(), BACKING_FIELD_PREFIX);
+ }
+
+ public static JsName getNameForGetter(String propertyName) {
+ return getNameWithPrefix(propertyName, GETTER_PREFIX);
+ }
+
+ public static JsName getNameForSetter(String propertyName) {
+ return getNameWithPrefix(propertyName, SETTER_PREFIX);
+ }
+
+ private static JsName getNameWithPrefix(String name, String prefix) {
+ String resultingName = prefix + name;
+ return new JsName(null, resultingName, resultingName, resultingName);
+ }
+
+ public static JsName getNameForNamespace(String name) {
+ return new JsName(null, name, name, name);
+ }
+
+ public static JsNameRef classObjectReference() {
+ //TODO dummy
+ return AstUtil.newQualifiedNameRef("Class");
+ }
+
+ public static JsNameRef creationMethodReference() {
+ return AstUtil.newQualifiedNameRef("Class.create");
+ }
+
+
+
}
diff --git a/src/org/jetbrains/k2js/translate/NamespaceTranslator.java b/src/org/jetbrains/k2js/translate/NamespaceTranslator.java
index 296a4c939f8..910eac10dae 100644
--- a/src/org/jetbrains/k2js/translate/NamespaceTranslator.java
+++ b/src/org/jetbrains/k2js/translate/NamespaceTranslator.java
@@ -2,10 +2,10 @@ package org.jetbrains.k2js.translate;
import com.google.dart.compiler.backend.js.ast.*;
import com.google.dart.compiler.util.AstUtil;
-import org.jaxen.expr.Expr;
-import org.jetbrains.jet.lang.psi.*;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jet.lang.psi.JetDeclaration;
+import org.jetbrains.jet.lang.psi.JetNamespace;
-import java.beans.Expression;
import java.util.ArrayList;
import java.util.List;
@@ -27,27 +27,37 @@ public class NamespaceTranslator extends AbstractTranslator {
}
public JsBlock translate(JetNamespace namespace) {
- // TODO write namespace change logic
+ // TODO support multiple namespaces
JsBlock block = program().getFragmentBlock(0);
- JsFunction dummyFunc = newNamespace(namespace.getName());
- JsBlock namespaceBlock = new JsBlock();
- dummyFunc.setBody(namespaceBlock);
- TranslationContext newContext = translationContext()
- .newBlock(namespaceBlock).newScope(dummyFunc.getScope()).newNamespace(new JsNameRef(getJSName(namespace.getName())));
- DeclarationTranslator declarationTranslator = new DeclarationTranslator(newContext);
- for (JetDeclaration declaration : namespace.getDeclarations()) {
- namespaceBlock.addStatement(declarationTranslator.translateDeclaration(declaration));
- }
+ JsName namespaceName = Namer.getNameForNamespace(namespace.getName());
+ block.addStatement(namespaceInitStatement(namespaceName));
+ JsFunction dummyFunction = new JsFunction(scope());
+ TranslationContext newContext = translationContext().newNamespace(namespaceName, dummyFunction);
+ JsBlock namespaceDeclarations = translateDeclaration(namespace, newContext);
+ block.addStatement(AstUtil.convertToStatement(newNamespace(namespaceName, namespaceDeclarations, dummyFunction)));
return block;
}
- public JsFunction newNamespace(String namespaceId) {
- JsFunction result = new JsFunction(scope());
+ @NotNull
+ private JsBlock translateDeclaration(JetNamespace namespace, TranslationContext newContext) {
+ DeclarationTranslator declarationTranslator = new DeclarationTranslator(newContext);
+ JsBlock namespaceDeclarations = new JsBlock();
+ for (JetDeclaration declaration : namespace.getDeclarations()) {
+ namespaceDeclarations.addStatement(declarationTranslator.translateDeclaration(declaration));
+ }
+ return namespaceDeclarations;
+ }
+
+ private JsStatement namespaceInitStatement(JsName namespaceName) {
+ return AstUtil.convertToStatement(AstUtil.newAssignment(namespaceName.makeRef(), new JsObjectLiteral()));
+ }
+
+ public JsInvocation newNamespace(JsName name, JsBlock namespaceDeclarations, JsFunction dummyFunction) {
List params = new ArrayList();
- params.add(new JsParameter(getJSName(namespaceId)));
- result.setParameters(params);
- JsExpression invocationParam = new JsNameRef(namespaceId);
- block().addStatement(AstUtil.convertToStatement(AstUtil.newInvocation((result), invocationParam)));
- return result;
+ params.add(new JsParameter(name));
+ dummyFunction.setParameters(params);
+ JsExpression invocationParam = name.makeRef();
+ dummyFunction.setBody(namespaceDeclarations);
+ return AstUtil.newInvocation(dummyFunction, invocationParam);
}
}
diff --git a/src/org/jetbrains/k2js/translate/OperationTranslator.java b/src/org/jetbrains/k2js/translate/OperationTranslator.java
index 95cfcce59d8..7b6c826bb47 100644
--- a/src/org/jetbrains/k2js/translate/OperationTranslator.java
+++ b/src/org/jetbrains/k2js/translate/OperationTranslator.java
@@ -1,6 +1,5 @@
package org.jetbrains.k2js.translate;
-import com.google.dart.compiler.backend.js.ast.JsBinaryOperation;
import com.google.dart.compiler.backend.js.ast.JsBinaryOperator;
import com.google.dart.compiler.backend.js.ast.JsOperator;
import org.jetbrains.jet.lexer.JetToken;
@@ -21,6 +20,12 @@ public final class OperationTranslator {
map.put(JetTokens.MINUS, JsBinaryOperator.SUB);
map.put(JetTokens.MUL, JsBinaryOperator.MUL);
map.put(JetTokens.DIV, JsBinaryOperator.DIV);
+ map.put(JetTokens.EQ, JsBinaryOperator.ASG);
+ map.put(JetTokens.GT, JsBinaryOperator.GT);
+ map.put(JetTokens.GTEQ, JsBinaryOperator.GTE);
+ map.put(JetTokens.LT, JsBinaryOperator.LT);
+ map.put(JetTokens.LTEQ, JsBinaryOperator.LTE);
+ map.put(JetTokens.EQEQ, JsBinaryOperator.EQ);
}
public static JsBinaryOperator getBinaryOperator(JetToken token) {
@@ -29,7 +34,7 @@ public final class OperationTranslator {
if (result instanceof JsBinaryOperator) {
return (JsBinaryOperator)result;
}
- throw new AssertionError("Invalid map");
+ throw new AssertionError("Invalid map: shoild containd token: " + token.toString());
}
diff --git a/src/org/jetbrains/k2js/translate/TranslationContext.java b/src/org/jetbrains/k2js/translate/TranslationContext.java
index 772c83b64d5..f75c262bb9e 100644
--- a/src/org/jetbrains/k2js/translate/TranslationContext.java
+++ b/src/org/jetbrains/k2js/translate/TranslationContext.java
@@ -2,95 +2,104 @@ package org.jetbrains.k2js.translate;
import com.google.dart.compiler.backend.js.ast.*;
import com.google.dart.compiler.util.AstUtil;
-import com.sun.xml.internal.ws.wsdl.writer.document.Binding;
+import org.apache.velocity.runtime.directive.Scope;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.resolve.BindingContext;
+import java.awt.peer.ScrollbarPeer;
+
/**
* @author Talanov Pavel
*/
public class TranslationContext {
- private final JsBlock currentBlock;
- private final JsNameRef currentNamespace;
private final JsProgram program;
- private final BindingContext context;
- private final JsScope enclosingScope;
+ private final BindingContext bindingContext;
private final ContextType type;
- private final JsNameRef classObjectReference;
- private final JsNameRef classCreationMethodReference;
+ private final Scopes scopes;
+ private final JsName currentNamespace;
- private TranslationContext(JsNameRef namespace, JsBlock block, JsProgram program,
- BindingContext bindingContext, JsScope enclosingScope, ContextType type) {
- assert block != null;
+ private static class Scopes {
+
+ public Scopes(JsScope enclosing, JsScope function, JsScope namespace) {
+ this.enclosingScope = enclosing;
+ this.functionScope = function;
+ this.namespaceScope = function;
+ }
+
+ public Scopes(Scopes other) {
+ this(other.enclosingScope, other.functionScope, other.namespaceScope);
+ }
+
+ public final JsScope enclosingScope;
+ public final JsScope functionScope;
+ public final JsScope namespaceScope;
+ }
+
+ private TranslationContext(JsName currentNamespace, JsProgram program,
+ BindingContext bindingContext, Scopes scopes, ContextType type) {
assert program != null;
assert bindingContext != null;
- assert enclosingScope != null;
+ assert scopes != null;
+ assert currentNamespace != null;
assert type != null;
- this.currentBlock = block;
- this.currentNamespace = namespace;
this.program = program;
- this.context = bindingContext;
- this.enclosingScope = enclosingScope;
+ this.bindingContext = bindingContext;
this.type = type;
- this.classObjectReference = new JsNameRef(getJSName("Class"));
- this.classCreationMethodReference = AstUtil.newQualifiedNameRef("Class.create");
+ this.currentNamespace = currentNamespace;
+ this.scopes = scopes;
}
@NotNull
public static TranslationContext rootContext(JsProgram program, BindingContext bindingContext) {
- return new TranslationContext(null, program.getFragmentBlock(0),
- program, bindingContext, program.getRootScope(), ContextType.NAMESPACE_BODY);
+ JsScope rootScope = program.getRootScope();
+ Scopes scopes = new Scopes(rootScope, rootScope, rootScope);
+ return new TranslationContext(null,
+ program, bindingContext, scopes, ContextType.NAMESPACE_BODY);
}
//TODO implement correct factories
@NotNull
- public TranslationContext newNamespace(JsNameRef newNamespace) {
- return new TranslationContext(newNamespace, currentBlock, program,
- context, enclosingScope, type);
+ public TranslationContext newNamespace(JsName namespaceName, JsFunction namespaceDummyFunction) {
+ JsScope newScope = namespaceDummyFunction.getScope();
+ Scopes newScopes = new Scopes(newScope, newScope, newScope);
+ return new TranslationContext(namespaceName, program,
+ bindingContext, newScopes, ContextType.NAMESPACE_BODY);
}
@NotNull
- public TranslationContext newBlock(JsBlock newBlock) {
- return new TranslationContext(currentNamespace, newBlock, program,
- context, enclosingScope, type);
+ public TranslationContext newBlock() {
+ Scopes newScopes = new Scopes(new JsScope
+ (scopes.enclosingScope, "dummy enclosingScope for a block"), scopes.functionScope, scopes.namespaceScope);
+ return new TranslationContext(currentNamespace, program,
+ bindingContext, newScopes, type);
}
@NotNull
- public TranslationContext newScope(JsScope newScope) {
- return new TranslationContext(currentNamespace, currentBlock, program,
- context, newScope, type);
+ public TranslationContext newFunction(JsFunction function) {
+ JsScope functionScope = function.getScope();
+ Scopes newScopes = new Scopes(functionScope, functionScope, scopes.namespaceScope);
+ return new TranslationContext(currentNamespace, program,
+ bindingContext, newScopes, ContextType.FUNCTION_BODY);
}
@NotNull
- public TranslationContext newType(ContextType newType) {
- return new TranslationContext(currentNamespace, currentBlock, program,
- context, enclosingScope, newType);
- }
-
- @NotNull
- public JsNameRef getQualifiedReference(JsName name) {
+ public JsNameRef getNamespaceQualifiedReference(JsName name) {
if (currentNamespace != null) {
- return AstUtil.newNameRef(currentNamespace, name);
+ return AstUtil.newNameRef(currentNamespace.makeRef(), name);
}
return new JsNameRef(name);
}
@NotNull
public JsName getJSName(String jetName) {
- //TODO dummy implemetation
return new JsName(program().getScope(), jetName, jetName, jetName);
}
@NotNull
public BindingContext bindingContext() {
- return context;
- }
-
- @NotNull
- public JsNameRef classObjectReference() {
- return classObjectReference;
+ return bindingContext;
}
@NotNull
@@ -99,24 +108,12 @@ public class TranslationContext {
}
@NotNull
- JsScope scope() {
- return enclosingScope;
- }
-
- @NotNull
- JsBlock block() {
- return currentBlock;
+ JsScope enclosingScope() {
+ return scopes.enclosingScope;
}
@NotNull
ContextType type() {
return type;
}
-
- @NotNull
- JsNameRef classCreationMethodReference() {
- return classCreationMethodReference;
- }
-
-
}
diff --git a/test/com/google/dart/compiler/backend/js/Test.java b/test/com/google/dart/compiler/backend/js/Test.java
deleted file mode 100644
index 8e55a7b6671..00000000000
--- a/test/com/google/dart/compiler/backend/js/Test.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.google.dart.compiler.backend.js;
-
-import com.google.dart.compiler.backend.js.ast.*;
-import com.google.dart.compiler.util.DefaultTextOutput;
-import com.google.dart.compiler.util.TextOutput;
-
-public class Test {
-
- public static void main(String[] args) {
- JsProgram program = new JsProgram("test");
- JsNumberLiteral number = program.getNumberLiteral(2443.3);
- //JsGlobalBlock globalBlock = new JsGlobalBlock(number);
- TextOutput output = new DefaultTextOutput(false);
- JsNameRef varStatement = new JsNameRef("variable");
- JsBinaryOperation plus = new JsBinaryOperation(JsBinaryOperator.ADD, number, number);
- JsBinaryOperation assign = new JsBinaryOperation(JsBinaryOperator.ASG, varStatement, plus);
-
- JsSourceGenerationVisitor sourceGenerator =
- new JsSourceGenerationVisitor(output);
- sourceGenerator.visit(assign, null);
- System.out.println(output.toString());
- }
-}
diff --git a/test/org/jetbrains/k2js/test/TranslatorTests.java b/test/org/jetbrains/k2js/test/TranslatorTests.java
new file mode 100644
index 00000000000..eea79046209
--- /dev/null
+++ b/test/org/jetbrains/k2js/test/TranslatorTests.java
@@ -0,0 +1,72 @@
+package org.jetbrains.k2js.test;
+
+import org.jetbrains.k2js.K2JSTranslator;
+import org.junit.Test;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.NativeObject;
+import org.mozilla.javascript.Scriptable;
+
+import java.io.FileReader;
+import static org.junit.Assert.*;
+
+
+/**
+ * @author Talanov Pavel
+ */
+public class TranslatorTests {
+
+ private final static String TEST_DIR = "test_files/test_cases/";
+
+ private void performTest(String inputFile) throws Exception {
+ K2JSTranslator.Arguments args = new K2JSTranslator.Arguments();
+ args.src = TEST_DIR + inputFile;
+ args.outputDir = getOutputFilename(TEST_DIR + inputFile);
+ K2JSTranslator.translate(args);
+ runWithRhino(args.outputDir);
+ }
+
+ private String getOutputFilename(String inputFile) {
+ return inputFile.substring(0, inputFile.lastIndexOf('.')) + ".js";
+ }
+
+ private void runWithRhino(String inputFile) throws Exception {
+ Context cx = Context.enter();
+ FileReader reader = new FileReader(inputFile);
+ try {
+ Scriptable scope = cx.initStandardObjects();
+ cx.evaluateReader(scope, reader, "test case", 1, null);
+
+ Object foo = scope.get("foo", scope);
+ assertTrue(foo instanceof NativeObject);
+ NativeObject namespaceObject = (NativeObject)foo;
+ Object box = namespaceObject.get("box", namespaceObject);
+ assertTrue(box instanceof Function);
+ Object functionArgs[] = {};
+ Function function = (Function) box;
+ Object result = function.call(cx, scope, scope, functionArgs);
+ String report = "foo.box() = " + Context.toString(result);
+ System.out.println(report);
+
+ } finally {
+ Context.exit();
+ reader.close();
+ }
+ }
+
+ @Test
+ public void test() throws Exception {
+ performTest("test.kt");
+ }
+
+ @Test
+ public void testAssign() throws Exception {
+ performTest("assign.jet");
+ }
+
+ @Test
+ public void namespaceProperties() throws Exception {
+ performTest("localProperty.jet");
+ }
+
+}
diff --git a/test_files/test.kt b/test_files/test.kt
deleted file mode 100644
index c569674a36c..00000000000
--- a/test_files/test.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace foo
-
-var a : Int = 2
-val b : Int = 235456
-var c : Int = 1324
-var myFavouriteName : Int = 1245
-
-
-open class B() {
-
-}
-
-class A() : B() {
- var a : Int
- get() : Int {
- return 4
- }
-
- set() {
-
- }
-}
diff --git a/test_files/test_cases/assign.jet b/test_files/test_cases/assign.jet
new file mode 100644
index 00000000000..45948863891
--- /dev/null
+++ b/test_files/test_cases/assign.jet
@@ -0,0 +1,11 @@
+namespace foo
+
+fun f(): Int {
+ var x: Int = 1
+ x = x + 1
+ return x
+}
+
+fun box() : Boolean {
+ return (true)
+}
\ No newline at end of file
diff --git a/test_files/test_cases/localProperty.jet b/test_files/test_cases/localProperty.jet
new file mode 100644
index 00000000000..2e3600d5cf0
--- /dev/null
+++ b/test_files/test_cases/localProperty.jet
@@ -0,0 +1,15 @@
+namespace foo
+
+val y = 3
+
+fun f(a:Int) : Int {
+ val x = 42
+ val y = 50
+
+ return y
+}
+
+fun box() : Boolean
+{
+ return (f(3) == 50)
+}
diff --git a/test_files/test_cases/test.kt b/test_files/test_cases/test.kt
new file mode 100644
index 00000000000..be2f39a55cc
--- /dev/null
+++ b/test_files/test_cases/test.kt
@@ -0,0 +1,8 @@
+namespace foo
+
+fun box() : Boolean {
+ val a = 2;
+ val b = 3;
+ var c = 4;
+ return (a < c)
+}
\ No newline at end of file