diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 00000000000..09b0cd3eaf8 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +k2js \ No newline at end of file diff --git a/.idea/ant.xml b/.idea/ant.xml new file mode 100644 index 00000000000..2581ca3fe84 --- /dev/null +++ b/.idea/ant.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.idea/artifacts/k2js_jar.xml b/.idea/artifacts/k2js_jar.xml new file mode 100644 index 00000000000..a4f2e6c0057 --- /dev/null +++ b/.idea/artifacts/k2js_jar.xml @@ -0,0 +1,16 @@ + + + $PROJECT_DIR$/out/artifacts/k2js_jar + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 00000000000..00e9e1b79cb --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/.idea/copyright/apache.xml b/.idea/copyright/apache.xml new file mode 100644 index 00000000000..647fcdb02ef --- /dev/null +++ b/.idea/copyright/apache.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 00000000000..ace2e994924 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 00000000000..e206d70d859 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000000..a76f2aecef0 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000000..3b312839bf2 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000000..d10b9ab7f7b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,36 @@ + + + + + + + + + + http://www.w3.org/1999/xhtml + + + + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000000..07c88da7dbd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 00000000000..922003b8433 --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 00000000000..3b000203088 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000000..21cbaa607b2 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examplesForWebDemo/examplesForWebDemo.iml b/examplesForWebDemo/examplesForWebDemo.iml new file mode 100644 index 00000000000..dd784a152e2 --- /dev/null +++ b/examplesForWebDemo/examplesForWebDemo.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/examplesForWebDemo/src/html5/creatures/creatures.js b/examplesForWebDemo/src/html5/creatures/creatures.js new file mode 100644 index 00000000000..a83e29d65ad --- /dev/null +++ b/examplesForWebDemo/src/html5/creatures/creatures.js @@ -0,0 +1,545 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function () { + var Vector = Kotlin.Class.create({initialize:function (x, y) { + this.$x = x; + this.$y = y; + }, get_x:function () { + return this.$x; + }, get_y:function () { + return this.$y; + }, plus:function (v) { + { + return creatures.v_0(this.get_x() + v.get_x(), this.get_y() + v.get_y()); + } + }, minus:function () { + { + return creatures.v_0(-this.get_x(), -this.get_y()); + } + }, minus$0:function (v) { + { + return creatures.v_0(this.get_x() - v.get_x(), this.get_y() - v.get_y()); + } + }, times:function (koef) { + { + return creatures.v_0(this.get_x() * koef, this.get_y() * koef); + } + }, distanceTo:function (v) { + { + return Math.sqrt(this.minus$0(v).get_sqr()); + } + }, rotatedBy:function (theta) { + { + var sin = Math.sin(theta); + var cos = Math.cos(theta); + return creatures.v_0(this.get_x() * cos - this.get_y() * sin, this.get_x() * sin + this.get_y() * cos); + } + }, isInRect:function (topLeft, size) { + { + return this.get_x() >= topLeft.get_x() && this.get_x() <= topLeft.get_x() + size.get_x() && this.get_y() >= topLeft.get_y() && this.get_y() <= topLeft.get_y() + size.get_y(); + } + }, get_sqr:function () { + { + return this.get_x() * this.get_x() + this.get_y() * this.get_y(); + } + }, get_normalized:function () { + { + return this.times(1 / Math.sqrt(this.get_sqr())); + } + } + }); + var RadialGradientGenerator = Kotlin.Class.create({initialize:function (context) { + this.$context = context; + this.$gradients = new Kotlin.ArrayList; + this.$current = 0; + { + this.newColorStops([ + [0, '#F59898'], + [0.5, '#F57373'], + [1, '#DB6B6B'] + ]); + this.newColorStops([ + [0.39, 'rgb(140,167,209)'], + [0.7, 'rgb(104,139,209)'], + [0.85, 'rgb(67,122,217)'] + ]); + this.newColorStops([ + [0, 'rgb(255,222,255)'], + [0.5, 'rgb(255,185,222)'], + [1, 'rgb(230,154,185)'] + ]); + this.newColorStops([ + [0, 'rgb(255,209,114)'], + [0.5, 'rgb(255,174,81)'], + [1, 'rgb(241,145,54)'] + ]); + this.newColorStops([ + [0, 'rgb(132,240,135)'], + [0.5, 'rgb(91,240,96)'], + [1, 'rgb(27,245,41)'] + ]); + this.newColorStops([ + [0, 'rgb(250,147,250)'], + [0.5, 'rgb(255,80,255)'], + [1, 'rgb(250,0,217)'] + ]); + } + }, get_context:function () { + return this.$context; + }, get_gradients:function () { + return this.$gradients; + }, get_current:function () { + return this.$current; + }, set_current:function (tmp$0) { + this.$current = tmp$0; + }, newColorStops:function (colorStops) { + { + this.get_gradients().add(colorStops); + } + }, getNext:function () { + { + var result = this.get_gradients().get(this.get_current()); + this.set_current((this.get_current() + 1) % this.get_gradients().size()); + return result; + } + } + }); + var CanvasState = Kotlin.Class.create({initialize:function (canvas) { + this.$canvas = canvas; + this.$width = this.get_canvas().width; + this.$height = this.get_canvas().height; + this.$context = getContext(); + this.$valid = false; + this.$shapes = new Kotlin.ArrayList; + this.$selection = null; + this.$dragOff = new creatures.Vector_0(0, 0); + this.$interval = 1000 / 30; + { + var tmp$4; + var tmp$3; + var tmp$2; + var tmp$1; + var tmp$0_0; + $(this.get_canvas()).mousedown((tmp$0_0 = this , function (it) { + { + var tmp$0; + tmp$0_0.set_valid(false); + tmp$0_0.set_selection(null); + var mousePos = tmp$0_0.mousePos_0(it); + { + tmp$0 = tmp$0_0.get_shapes().iterator(); + while (tmp$0.hasNext()) { + var shape = tmp$0.next(); + { + if (shape.contains(mousePos)) { + tmp$0_0.set_dragOff(mousePos.minus$0(shape.get_pos())); + shape.set_selected(true); + tmp$0_0.set_selection(shape); + break; + } + } + } + } + } + } + )); + $(this.get_canvas()).mousemove((tmp$1 = this , function (it) { + { + if (tmp$1.get_selection() != null) { + Kotlin.sure(tmp$1.get_selection()).set_pos(tmp$1.mousePos_0(it).minus$0(tmp$1.get_dragOff())); + tmp$1.set_valid(false); + } + } + } + )); + $(this.get_canvas()).mouseup((tmp$2 = this , function (it) { + { + if (tmp$2.get_selection() != null) { + Kotlin.sure(tmp$2.get_selection()).set_selected(false); + } + tmp$2.set_selection(null); + tmp$2.set_valid(false); + } + } + )); + $(this.get_canvas()).dblclick((tmp$3 = this , function (it) { + { + var newCreature = new creatures.Creature_0(tmp$3.mousePos_0(it), tmp$3); + tmp$3.addShape(newCreature); + tmp$3.set_valid(false); + } + } + )); + setInterval((tmp$4 = this , function () { + { + tmp$4.draw(); + } + } + ), this.get_interval()); + } + }, get_canvas:function () { + return this.$canvas; + }, get_width:function () { + return this.$width; + }, set_width:function (tmp$0) { + this.$width = tmp$0; + }, get_height:function () { + return this.$height; + }, set_height:function (tmp$0) { + this.$height = tmp$0; + }, get_size:function () { + { + return creatures.v_0(this.get_width(), this.get_height()); + } + }, get_context:function () { + return this.$context; + }, get_valid:function () { + return this.$valid; + }, set_valid:function (tmp$0) { + this.$valid = tmp$0; + }, get_shapes:function () { + return this.$shapes; + }, set_shapes:function (tmp$0) { + this.$shapes = tmp$0; + }, get_selection:function () { + return this.$selection; + }, set_selection:function (tmp$0) { + this.$selection = tmp$0; + }, get_dragOff:function () { + return this.$dragOff; + }, set_dragOff:function (tmp$0) { + this.$dragOff = tmp$0; + }, get_interval:function () { + return this.$interval; + }, mousePos_0:function (e) { + { + var offset = new creatures.Vector_0(0, 0); + var element = this.get_canvas(); + while (element != null) { + var el = Kotlin.sure(element); + offset = offset.plus(new creatures.Vector_0(el.offsetLeft, el.offsetTop)); + element = el.offsetParent; + } + return (new creatures.Vector_0(e.pageX, e.pageY)).minus$0(offset); + } + }, addShape:function (shape) { + { + this.get_shapes().add(shape); + this.set_valid(false); + } + }, clear:function () { + { + this.get_context().fillStyle = '#FFFFFF'; + this.get_context().fillRect(0, 0, this.get_width(), this.get_height()); + this.get_context().strokeStyle = '#000000'; + this.get_context().lineWidth = 4; + this.get_context().strokeRect(0, 0, this.get_width(), this.get_height()); + } + }, draw:function () { + { + var tmp$0; + if (this.get_valid()) + return; + this.clear(); + { + tmp$0 = creatures.reversed(this.get_shapes()).iterator(); + while (tmp$0.hasNext()) { + var shape = tmp$0.next(); + { + shape.draw(this); + } + } + } + creatures.get_Kotlin().draw(this); + this.set_valid(true); + } + } + }); + var Shape = Kotlin.Class.create({initialize:function () { + this.$selected = false; + }, draw:function (state) { + }, contains:function (mousePos) { + }, get_pos:function () { + return this.$pos; + }, set_pos:function (tmp$0) { + this.$pos = tmp$0; + }, get_selected:function () { + return this.$selected; + }, set_selected:function (tmp$0) { + this.$selected = tmp$0; + }, shadowed:function (receiver, shadowOffset, alpha, render) { + { + receiver.save(); + receiver.shadowColor = 'rgba(100, 100, 100, ' + alpha + ')'; + receiver.shadowBlur = 5; + receiver.shadowOffsetX = shadowOffset.get_x(); + receiver.shadowOffsetY = shadowOffset.get_y(); + render.call(receiver); + receiver.restore(); + } + }, fillPath:function (receiver, constructPath) { + { + receiver.beginPath(); + constructPath.call(receiver); + receiver.closePath(); + receiver.fill(); + } + } + }); + var Creature = Kotlin.Class.create(Shape, {initialize:function (pos, state) { + this.$pos = pos; + this.$state = state; + this.super_init(); + this.$shadowOffset = creatures.v_0(-5, 5); + this.$colorStops = creatures.get_gradientGenerator().getNext(); + this.$relSize = 0.05; + }, get_pos:function () { + return this.$pos; + }, set_pos:function (tmp$0) { + this.$pos = tmp$0; + }, get_state:function () { + return this.$state; + }, get_shadowOffset:function () { + return this.$shadowOffset; + }, get_colorStops:function () { + return this.$colorStops; + }, get_relSize:function () { + return this.$relSize; + }, get_radius:function () { + { + return this.get_state().get_width() * this.get_relSize(); + } + }, get_position:function () { + var tmp$0; + if (this.get_selected()) + tmp$0 = this.get_pos().minus$0(this.get_shadowOffset()); + else + tmp$0 = this.get_pos(); + { + return tmp$0; + } + }, get_directionToLogo:function () { + { + return creatures.get_Kotlin().get_centre().minus$0(this.get_position()).get_normalized(); + } + }, contains:function (mousePos) { + { + return this.get_pos().distanceTo(mousePos) < this.get_radius(); + } + }, circlePath:function (receiver, position, rad) { + { + receiver.arc(position.get_x(), position.get_y(), rad, 0, 2 * Math.PI, false); + } + }, fillCircle:function (receiver, position, rad) { + { + var tmp$0; + this.fillPath(receiver, (tmp$0 = this , function () { + { + tmp$0.circlePath(receiver, position, rad); + } + } + )); + } + }, draw:function (state) { + { + var context = state.get_context(); + if (!this.get_selected()) { + this.drawCreature(context); + } + else { + this.drawCreatureWithShadow(context); + } + } + }, drawCreature:function (context) { + { + var tmp$0; + context.fillStyle = this.getGradient(context); + this.fillPath(context, (tmp$0 = this , function () { + { + tmp$0.tailPath(context); + tmp$0.circlePath(this, tmp$0.get_position(), tmp$0.get_radius()); + } + } + )); + this.drawEye(context); + } + }, getGradient:function (context) { + { + var tmp$0; + var gradientCentre = this.get_position().plus(this.get_directionToLogo().times(this.get_radius() / 4)); + var gradient = context.createRadialGradient(gradientCentre.get_x(), gradientCentre.get_y(), 1, gradientCentre.get_x(), gradientCentre.get_y(), 2 * this.get_radius()); + { + tmp$0 = Kotlin.arrayIterator(this.get_colorStops()); + while (tmp$0.hasNext()) { + var colorStop = tmp$0.next(); + { + gradient.addColorStop(colorStop[0], colorStop[1]); + } + } + } + return gradient; + } + }, tailPath:function (context) { + { + var tailDirection = this.get_directionToLogo().minus(); + var tailPos = this.get_position().plus(tailDirection.times(this.get_radius()).times(1)); + var tailSize = this.get_radius() * 1.6; + var angle = Math.PI / 6; + var p1 = tailPos.plus(tailDirection.rotatedBy(angle).times(tailSize)); + var p2 = tailPos.plus(tailDirection.rotatedBy(-angle).times(tailSize)); + var middlePoint = this.get_position().plus(tailDirection.times(this.get_radius()).times(1)); + context.moveTo(tailPos.get_x(), tailPos.get_y()); + context.lineTo(p1.get_x(), p1.get_y()); + context.quadraticCurveTo(middlePoint.get_x(), middlePoint.get_y(), p2.get_x(), p2.get_y()); + context.lineTo(tailPos.get_x(), tailPos.get_y()); + } + }, drawEye:function (context) { + { + var eyePos = this.get_directionToLogo().times(this.get_radius()).times(0.6).plus(this.get_position()); + var eyeRadius = this.get_radius() / 3; + var eyeLidRadius = eyeRadius / 2; + context.fillStyle = '#FFFFFF'; + this.fillCircle(context, eyePos, eyeRadius); + context.fillStyle = '#000000'; + this.fillCircle(context, eyePos, eyeLidRadius); + } + }, drawCreatureWithShadow:function (context) { + { + var tmp$0_0; + this.shadowed(context, this.get_shadowOffset(), 0.7, (tmp$0_0 = this , function () { + { + var tmp$0; + context.fillStyle = tmp$0_0.getGradient(context); + tmp$0_0.fillPath(this, (tmp$0 = tmp$0_0 , function () { + { + tmp$0.tailPath(context); + tmp$0.circlePath(context, tmp$0.get_position(), tmp$0.get_radius()); + } + } + )); + } + } + )); + this.drawEye(context); + } + } + }); + var Logo = Kotlin.Class.create(Shape, {initialize:function (pos) { + this.$pos = pos; + this.super_init(); + this.$relSize = 0.25; + this.$shadowOffset = creatures.v_0(-3, 3); + this.$imageSize = creatures.v_0(377, 393); + this.$size = this.get_imageSize().times(this.get_relSize()); + }, get_pos:function () { + return this.$pos; + }, set_pos:function (tmp$0) { + this.$pos = tmp$0; + }, get_relSize:function () { + return this.$relSize; + }, get_shadowOffset:function () { + return this.$shadowOffset; + }, get_imageSize:function () { + return this.$imageSize; + }, get_size:function () { + return this.$size; + }, set_size:function (tmp$0) { + this.$size = tmp$0; + }, get_position:function () { + var tmp$0; + if (this.get_selected()) + tmp$0 = this.get_pos().minus$0(this.get_shadowOffset()); + else + tmp$0 = this.get_pos(); + { + return tmp$0; + } + }, drawLogo:function (state) { + { + this.set_size(this.get_imageSize().times(state.get_size().get_x() / this.get_imageSize().get_x()).times(this.get_relSize())); + state.get_context().drawImage(getKotlinLogo(), 0, 0, this.get_imageSize().get_x(), this.get_imageSize().get_y(), this.get_position().get_x(), this.get_position().get_y(), this.get_size().get_x(), this.get_size().get_y()); + } + }, draw:function (state) { + { + var context = state.get_context(); + if (this.get_selected()) { + var tmp$0; + this.shadowed(context, this.get_shadowOffset(), 0.2, (tmp$0 = this , function () { + { + tmp$0.drawLogo(state); + } + } + )); + } + else { + this.drawLogo(state); + } + } + }, contains:function (mousePos) { + { + return mousePos.isInRect(this.get_pos(), this.get_size()); + } + }, get_centre:function () { + { + return this.get_pos().plus(this.get_size().times(0.5)); + } + } + }); + return {Shape_0:Shape, Logo_0:Logo, Creature_0:Creature, RadialGradientGenerator_0:RadialGradientGenerator, CanvasState_0:CanvasState, Vector_0:Vector}; + } + (); + var creatures = Kotlin.Namespace.create({initialize:function () { + creatures.$Kotlin = new creatures.Logo_0(creatures.v_0(300, 100)); + creatures.$gradientGenerator = new creatures.RadialGradientGenerator_0(getContext()); + }, get_Kotlin:function () { + return creatures.$Kotlin; + }, get_gradientGenerator:function () { + return creatures.$gradientGenerator; + }, v_0:function (x, y) { + { + return new creatures.Vector_0(x, y); + } + }, main:function () { + { + var state = new creatures.CanvasState_0(getCanvas()); + state.addShape(creatures.get_Kotlin()); + state.addShape(new creatures.Creature_0(state.get_size().times(0.25), state)); + state.addShape(new creatures.Creature_0(state.get_size().times(0.75), state)); + setTimeout(function () { + { + state.set_valid(false); + } + } + ); + } + }, reversed:function (receiver) { + { + var result = new Kotlin.ArrayList; + var i = receiver.size(); + while (i > 0) { + result.add(receiver.get(--i)); + } + return result; + } + } + }, classes); + creatures.initialize(); +} + +var args = []; +creatures.main(args); diff --git a/examplesForWebDemo/src/html5/creatures/kotlinlogo.png b/examplesForWebDemo/src/html5/creatures/kotlinlogo.png new file mode 100644 index 00000000000..5394223b3d6 Binary files /dev/null and b/examplesForWebDemo/src/html5/creatures/kotlinlogo.png differ diff --git a/examplesForWebDemo/src/html5/creatures/main.kt b/examplesForWebDemo/src/html5/creatures/main.kt new file mode 100644 index 00000000000..46e0d92b8c2 --- /dev/null +++ b/examplesForWebDemo/src/html5/creatures/main.kt @@ -0,0 +1,331 @@ +/* +In this example strange creatures are watching the kotlin logo. You can drag'n'drop them as well as the logo. +Doubleclick to add more creatures but be careful. They may be watching you! +*/ +package creatures +// importing some of the API defined +import jquery.* +import html5.* +import java.util.ArrayList +import js.* +import js.Math +import js.setInterval +import html5.getCanvas +import html5.getKotlinLogo +import jquery.jq +import js.setTimeout +import java.util.List + + +abstract class Shape() { + + abstract fun draw(state : CanvasState) + // these two abstract methods defines that our shapes can be dragged + abstract fun contains(mousePos : Vector) : Boolean + abstract var pos : Vector + + var selected : Boolean = false + + // a couple of helper extension methods we'll be using in the derived classes + fun Context.shadowed(shadowOffset : Vector, alpha : Double, render : Context.() -> Unit) { + save() + shadowColor = "rgba(100, 100, 100, $alpha)" + shadowBlur = 5.0 + shadowOffsetX = shadowOffset.x + shadowOffsetY = shadowOffset.y + render() + restore() + } + + fun Context.fillPath(constructPath : Context.() -> Unit) { + beginPath() + constructPath() + closePath() + fill() + } +} + +val Kotlin = Logo(v(300.0, 100.0)) + +class Logo(override var pos : Vector) : Shape() +{ + val relSize : Double = 0.25 + val shadowOffset = v(-3.0, 3.0) + val imageSize = v(377.0, 393.0) + var size : Vector = imageSize * relSize + // get-only properties like this saves you lots of typing and are very expressive + val position : Vector + get() = if (selected) pos - shadowOffset else pos + + + fun drawLogo(state : CanvasState) { + size = imageSize * (state.size.x / imageSize.x) * relSize + // getKotlinLogo() is a 'magic' function here defined only for purposes of demonstration but in fact it just find an element containing the logo + state.context.drawImage(getKotlinLogo(), 0.0, 0.0, imageSize.x, imageSize.y, position.x, position.y, size.x, size.y) + } + + override fun draw(state : CanvasState) { + val context = state.context + if (selected) { + // using helper we defined in Shape class + context.shadowed(shadowOffset, 0.2) { + drawLogo(state) + } + } else { + drawLogo(state) + } + } + + override fun contains(mousePos: Vector): Boolean = mousePos.isInRect(pos, size) + + val centre : Vector + get() = pos + size * 0.5 +} + +val gradientGenerator = RadialGradientGenerator(getContext()) + +class Creature(override var pos : Vector, val state : CanvasState) : Shape() { + + val shadowOffset = v(-5.0, 5.0) + val colorStops = gradientGenerator.getNext() + val relSize = 0.05 + // these properties have no backing fields and in java/javascript they could be represented as little helper functions + val radius : Double + get() = state.width * relSize + val position : Vector + get() = if (selected) pos - shadowOffset else pos + val directionToLogo : Vector + get() = (Kotlin.centre - position).normalized + + //notice how the infix call can make some expressions extremely expressive + override fun contains(mousePos : Vector) = pos distanceTo mousePos < radius + + // defining more nice extension functions + fun Context.circlePath(position : Vector, rad : Double) { + arc(position.x, position.y, rad, 0.0, 2 * Math.PI, false) + } + + //notice we can use an extension function we just defined inside another extension function + fun Context.fillCircle(position : Vector, rad : Double) { + fillPath { + circlePath(position, rad) + } + } + + override fun draw(state : CanvasState) { + val context = state.context + if (!selected) { + drawCreature(context) + } else { + drawCreatureWithShadow(context) + } + } + + fun drawCreature(context : Context) { + context.fillStyle = getGradient(context) + context.fillPath { + tailPath(context) + circlePath(position, radius) + } + drawEye(context) + } + + fun getGradient(context : Context) : CanvasGradient { + val gradientCentre = position + directionToLogo * (radius / 4) + val gradient = context.createRadialGradient(gradientCentre.x, gradientCentre.y, 1.0, gradientCentre.x, gradientCentre.y, 2 * radius) + for (colorStop in colorStops) { + gradient.addColorStop(colorStop._1, colorStop._2) + } + return gradient + } + + fun tailPath(context : Context) { + val tailDirection = -directionToLogo + val tailPos = position + tailDirection * radius * 1.0 + val tailSize = radius * 1.6 + val angle = Math.PI / 6.0 + val p1 = tailPos + tailDirection.rotatedBy(angle) * tailSize + val p2 = tailPos + tailDirection.rotatedBy(-angle) * tailSize + val middlePoint = position + tailDirection * radius * 1.0 + context.moveTo(tailPos.x, tailPos.y) + context.lineTo(p1.x, p1.y) + context.quadraticCurveTo(middlePoint.x, middlePoint.y, p2.x, p2.y) + context.lineTo(tailPos.x, tailPos.y) + } + + fun drawEye(context : Context) { + val eyePos = directionToLogo * radius * 0.6 + position + val eyeRadius = radius / 3 + val eyeLidRadius = eyeRadius / 2 + context.fillStyle = "#FFFFFF" + context.fillCircle(eyePos, eyeRadius) + context.fillStyle = "#000000" + context.fillCircle(eyePos, eyeLidRadius) + } + + fun drawCreatureWithShadow(context : Context) { + context.shadowed(shadowOffset, 0.7) { + context.fillStyle = getGradient(context) + fillPath { + tailPath(context) + context.circlePath(position, radius) + } + } + drawEye(context) + } +} + +class CanvasState(val canvas : Canvas) { + var width = canvas.width + var height = canvas.height + val size : Vector + get() = v(width, height) + val context = getContext() + var valid = false + var shapes = ArrayList() + var selection : Shape? = null + var dragOff = Vector() + val interval = 1000 / 30 + + { + jq(canvas).mousedown { + valid = false + selection = null + val mousePos = mousePos(it) + for (shape in shapes) { + if (mousePos in shape) { + dragOff = mousePos - shape.pos + shape.selected = true + selection = shape + break + } + } + } + + jq(canvas).mousemove { + if (selection != null) { + selection.sure().pos = mousePos(it) - dragOff + valid = false + } + } + + jq(canvas).mouseup { + if (selection != null) { + selection.sure().selected = false + } + selection = null + valid = false + } + + jq(canvas).dblclick { + val newCreature = Creature(mousePos(it), this @CanvasState) + addShape(newCreature) + valid = false + } + + setInterval({ + draw() + }, interval) + } + + fun mousePos(e : MouseEvent) : Vector { + var offset = Vector() + var element : DomElement? = canvas + while (element != null) { + val el : DomElement = element.sure() + offset += Vector(el.offsetLeft, el.offsetTop) + element = el.offsetParent + } + return Vector(e.pageX, e.pageY) - offset + } + + fun addShape(shape : Shape) { + shapes.add(shape) + valid = false + } + + fun clear() { + context.fillStyle = "#FFFFFF" + context.fillRect(0.0, 0.0, width, height) + context.strokeStyle = "#000000" + context.lineWidth = 4.0 + context.strokeRect(0.0, 0.0, width, height) + } + + fun draw() { + if (valid) return + + clear() + for (shape in shapes.reversed()) { + shape.draw(this) + } + Kotlin.draw(this) + valid = true + } +} + +class RadialGradientGenerator(val context : Context) { + val gradients = ArrayList>() + var current = 0 + + fun newColorStops(vararg colorStops : #(Double, String)) { + gradients.add(colorStops) + } + + { + newColorStops(#(0.0, "#F59898"), #(0.5, "#F57373"), #(1.0, "#DB6B6B")) + newColorStops(#(0.39, "rgb(140,167,209)"), #(0.7, "rgb(104,139,209)"), #(0.85, "rgb(67,122,217)")) + newColorStops(#(0.0, "rgb(255,222,255)"), #(0.5, "rgb(255,185,222)"), #(1.0, "rgb(230,154,185)")) + newColorStops(#(0.0, "rgb(255,209,114)"), #(0.5, "rgb(255,174,81)"), #(1.0, "rgb(241,145,54)")) + newColorStops(#(0.0, "rgb(132,240,135)"), #(0.5, "rgb(91,240,96)"), #(1.0, "rgb(27,245,41)")) + newColorStops(#(0.0, "rgb(250,147,250)"), #(0.5, "rgb(255,80,255)"), #(1.0, "rgb(250,0,217)")) + } + + fun getNext() : Array<#(Double, String)> { + val result = gradients.get(current) + current = (current + 1) % gradients.size() + return result + } +} + +fun v(x : Double, y : Double) = Vector(x, y) + +class Vector(val x : Double = 0.0, val y : Double = 0.0) { + fun plus(v : Vector) = v(x + v.x, y + v.y) + fun minus() = v(-x, -y) + fun minus(v : Vector) = v(x - v.x, y - v.y) + fun times(koef : Double) = v(x * koef, y * koef) + fun distanceTo(v : Vector) = Math.sqrt((this - v).sqr) + fun rotatedBy(theta : Double) : Vector { + val sin = Math.sin(theta) + val cos = Math.cos(theta) + return v(x * cos - y * sin, x * sin + y * cos) + } + + fun isInRect(topLeft : Vector, size : Vector) = (x >= topLeft.x) && (x <= topLeft.x + size.x) && + (y >= topLeft.y) && (y <= topLeft.y + size.y) + + val sqr : Double + get() = x * x + y * y + val normalized : Vector + get() = this * (1.0 / Math.sqrt(sqr)) +} + +fun main() { + val state = CanvasState(getCanvas()) + state.addShape(Kotlin) + state.addShape(Creature(state.size * 0.25, state)) + state.addShape(Creature(state.size * 0.75, state)) + setTimeout({ + state.valid = false + }) +} + +fun List.reversed() : List { + val result = ArrayList() + var i = size() + while (i > 0) { + result.add(get(--i)) + } + return result +} \ No newline at end of file diff --git a/examplesForWebDemo/src/html5/creatures/template.html b/examplesForWebDemo/src/html5/creatures/template.html new file mode 100644 index 00000000000..466bfa8168f --- /dev/null +++ b/examplesForWebDemo/src/html5/creatures/template.html @@ -0,0 +1,32 @@ + + + + + + Canvas demo + + + + + + + + + + + \ No newline at end of file diff --git a/examplesForWebDemo/src/html5/fancyLines/fancylines.js b/examplesForWebDemo/src/html5/fancyLines/fancylines.js new file mode 100644 index 00000000000..27e7e39a3a3 --- /dev/null +++ b/examplesForWebDemo/src/html5/fancyLines/fancylines.js @@ -0,0 +1,103 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function () { + var FancyLines = Kotlin.Class.create({initialize:function () { + this.$context = getContext(); + this.$height = getCanvas().height; + this.$width = getCanvas().width; + this.$x = this.get_width() * Math.random(); + this.$y = this.get_height() * Math.random(); + this.$hue = 0; + }, get_context:function () { + return this.$context; + }, get_height:function () { + return this.$height; + }, get_width:function () { + return this.$width; + }, get_x:function () { + return this.$x; + }, set_x:function (tmp$0) { + this.$x = tmp$0; + }, get_y:function () { + return this.$y; + }, set_y:function (tmp$0) { + this.$y = tmp$0; + }, get_hue:function () { + return this.$hue; + }, set_hue:function (tmp$0) { + this.$hue = tmp$0; + }, line:function () { + { + this.get_context().save(); + this.get_context().beginPath(); + this.get_context().lineWidth = 20 * Math.random(); + this.get_context().moveTo(this.get_x(), this.get_y()); + this.set_x(this.get_width() * Math.random()); + this.set_y(this.get_height() * Math.random()); + this.get_context().bezierCurveTo(this.get_width() * Math.random(), this.get_height() * Math.random(), this.get_width() * Math.random(), this.get_height() * Math.random(), this.get_x(), this.get_y()); + this.set_hue(this.get_hue() + Math.random() * 10); + this.get_context().strokeStyle = 'hsl(' + this.get_hue() + ', 50%, 50%)'; + this.get_context().shadowColor = 'white'; + this.get_context().shadowBlur = 10; + this.get_context().stroke(); + this.get_context().restore(); + } + }, blank:function () { + { + this.get_context().fillStyle = 'rgba(255,255,1,0.1)'; + this.get_context().fillRect(0, 0, this.get_width(), this.get_height()); + } + }, run:function () { + { + var tmp$1; + var tmp$0; + setInterval((tmp$0 = this , function () { + { + tmp$0.line(); + } + } + ), 40); + setInterval((tmp$1 = this , function () { + { + tmp$1.blank(); + } + } + ), 100); + } + } + }); + return {FancyLines_0:FancyLines}; + } + (); + var fancylines = Kotlin.Namespace.create({initialize:function () { + }, main:function () { + { + $(function () { + { + (new fancylines.FancyLines_0).run(); + } + } + ); + } + } + }, classes); + fancylines.initialize(); +} + +var args = []; +fancylines.main(args); diff --git a/examplesForWebDemo/src/html5/fancyLines/template.html b/examplesForWebDemo/src/html5/fancyLines/template.html new file mode 100644 index 00000000000..64a717ea926 --- /dev/null +++ b/examplesForWebDemo/src/html5/fancyLines/template.html @@ -0,0 +1,30 @@ + + + + + + Canvas demo + + + + + + + + + \ No newline at end of file diff --git a/examplesForWebDemo/src/html5/fancyLines/test.kt b/examplesForWebDemo/src/html5/fancyLines/test.kt new file mode 100644 index 00000000000..892bc4695cc --- /dev/null +++ b/examplesForWebDemo/src/html5/fancyLines/test.kt @@ -0,0 +1,64 @@ +/* +This example is based on example from html5 canvas2D docs: + http://www.w3.org/TR/2dcontext/ +Note that only a subset of the api is supported for now. +*/ + +package fancylines + +import js.*; +import html5.*; +import jquery.*; + +fun main() { + //jq is a name for JQuery function + jq { + FancyLines().run(); + } +} + +class FancyLines() { + // we use two 'magic' functions here getContext() and getCanvas() + val context = getContext(); + val height = getCanvas().height; + val width = getCanvas().width; + var x = width * Math.random(); + var y = height * Math.random(); + var hue = 0; + + fun line() { + context.save(); + + context.beginPath(); + + context.lineWidth = 20.0 * Math.random(); + context.moveTo(x, y); + + x = width * Math.random(); + y = height * Math.random(); + + context.bezierCurveTo(width * Math.random(), height * Math.random(), + width * Math.random(), height * Math.random(), x, y); + + hue += Math.random() * 10; + + context.strokeStyle = "hsl($hue, 50%, 50%)"; + + context.shadowColor = "white"; + context.shadowBlur = 10.0; + + context.stroke(); + + context.restore(); + } + + fun blank() { + context.fillStyle = "rgba(255,255,1,0.1)"; + context.fillRect(0.0, 0.0, width, height); + } + + fun run() { + setInterval({line()}, 40); + setInterval({blank()}, 100); + } +} \ No newline at end of file diff --git a/examplesForWebDemo/src/html5/floatingText/hello.js b/examplesForWebDemo/src/html5/floatingText/hello.js new file mode 100644 index 00000000000..289ebedd579 --- /dev/null +++ b/examplesForWebDemo/src/html5/floatingText/hello.js @@ -0,0 +1,162 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function () { + var HelloKotlin = Kotlin.Class.create({initialize:function () { + this.$relX = 0.2 + 0.2 * Math.random(); + this.$relY = 0.4 + 0.2 * Math.random(); + this.$relXVelocity = this.randomVelocity(); + this.$relYVelocity = this.randomVelocity(); + this.$message = 'Hello, Kotlin!'; + this.$textHeightInPixels = 60; + { + hello.get_context().font = 'bold ' + this.get_textHeightInPixels() + 'px Georgia, serif'; + } + this.$textWidthInPixels = hello.get_context().measureText(this.get_message()).width; + }, get_relX:function () { + return this.$relX; + }, set_relX:function (tmp$0) { + this.$relX = tmp$0; + }, get_relY:function () { + return this.$relY; + }, set_relY:function (tmp$0) { + this.$relY = tmp$0; + }, get_absX:function () { + { + return this.get_relX() * hello.get_width(); + } + }, get_absY:function () { + { + return this.get_relY() * hello.get_height(); + } + }, get_relXVelocity:function () { + return this.$relXVelocity; + }, set_relXVelocity:function (tmp$0) { + this.$relXVelocity = tmp$0; + }, get_relYVelocity:function () { + return this.$relYVelocity; + }, set_relYVelocity:function (tmp$0) { + this.$relYVelocity = tmp$0; + }, get_message:function () { + return this.$message; + }, get_textHeightInPixels:function () { + return this.$textHeightInPixels; + }, get_textWidthInPixels:function () { + return this.$textWidthInPixels; + }, draw:function () { + { + hello.get_context().save(); + this.move(); + hello.get_context().shadowColor = '#000000'; + hello.get_context().shadowBlur = 5; + hello.get_context().shadowOffsetX = -4; + hello.get_context().shadowOffsetY = 4; + hello.get_context().fillStyle = 'rgb(242,160,110)'; + hello.get_context().fillText(this.get_message(), this.get_absX(), this.get_absY()); + hello.get_context().restore(); + } + }, move:function () { + { + var relTextWidth = this.get_textWidthInPixels() / hello.get_width(); + if (this.get_relX() > 1 - relTextWidth - this.get_abs(this.get_relXVelocity()) || this.get_relX() < this.get_abs(this.get_relXVelocity())) { + this.set_relXVelocity(this.get_relXVelocity() * -1); + } + var relTextHeight = this.get_textHeightInPixels() / hello.get_height(); + if (this.get_relY() > 1 - this.get_abs(this.get_relYVelocity()) || this.get_relY() < this.get_abs(this.get_relYVelocity()) + relTextHeight) { + this.set_relYVelocity(this.get_relYVelocity() * -1); + } + this.set_relX(this.get_relX() + this.get_relXVelocity()); + this.set_relY(this.get_relY() + this.get_relYVelocity()); + } + }, randomVelocity:function () { + var tmp$0; + if (Math.random() < 0.5) + tmp$0 = 1; + else + tmp$0 = -1; + { + return 0.03 * Math.random() * tmp$0; + } + }, get_abs:function (receiver) { + var tmp$0; + if (receiver > 0) + tmp$0 = receiver; + else + tmp$0 = -receiver; + { + return tmp$0; + } + } + }); + return {HelloKotlin_0:HelloKotlin}; + } + (); + var hello = Kotlin.Namespace.create({initialize:function () { + hello.$context = getContext(); + hello.$height = getCanvas().height; + hello.$width = getCanvas().width; + }, get_context:function () { + return hello.$context; + }, get_height:function () { + return hello.$height; + }, get_width:function () { + return hello.$width; + }, renderBackground:function () { + { + hello.get_context().save(); + hello.get_context().fillStyle = '#5C7EED'; + hello.get_context().fillRect(0, 0, hello.get_width(), hello.get_height()); + hello.get_context().restore(); + } + }, main:function () { + { + var interval = 50; + var logos = Kotlin.arrayFromFun(3, function (it) { + { + return new hello.HelloKotlin_0; + } + } + ); + $(function () { + { + setInterval(function () { + { + var tmp$0; + hello.renderBackground(); + { + tmp$0 = Kotlin.arrayIterator(logos); + while (tmp$0.hasNext()) { + var logo = tmp$0.next(); + { + logo.draw(); + } + } + } + } + } + , interval); + } + } + ); + } + } + }, classes); + hello.initialize(); +} + +var args = []; +hello.main(args); diff --git a/examplesForWebDemo/src/html5/floatingText/template.html b/examplesForWebDemo/src/html5/floatingText/template.html new file mode 100644 index 00000000000..557ab5c8b6f --- /dev/null +++ b/examplesForWebDemo/src/html5/floatingText/template.html @@ -0,0 +1,30 @@ + + + + + + Canvas demo + + + + + + + + + \ No newline at end of file diff --git a/examplesForWebDemo/src/html5/floatingText/test.kt b/examplesForWebDemo/src/html5/floatingText/test.kt new file mode 100644 index 00000000000..e5bca3ea4d9 --- /dev/null +++ b/examplesForWebDemo/src/html5/floatingText/test.kt @@ -0,0 +1,91 @@ +/* + This example is just simple text floating around. If u are using chrome, there is a bug that spoil the visuals. +*/ +package hello + +import js.* +import html5.* +import jquery.* + +val context = getContext() +val height = getCanvas().height +val width = getCanvas().width + +// class representing a floating text +class HelloKotlin() { + var relX = 0.2 + 0.2 * Math.random() + var relY = 0.4 + 0.2 * Math.random() + + val absX : Double + get() = (relX * width) + val absY : Double + get() = (relY * height) + + var relXVelocity = randomVelocity() + var relYVelocity = randomVelocity() + + + val message = "Hello, Kotlin!" + val textHeightInPixels = 60 + { + context.font = "bold ${textHeightInPixels}px Georgia, serif" + } + val textWidthInPixels = context.measureText(message).width + + fun draw() { + context.save() + move() + // if you using chrome chances are good you wont see the shadow + context.shadowColor = "#000000" + context.shadowBlur = 5.0 + context.shadowOffsetX = -4.0 + context.shadowOffsetY = 4.0 + context.fillStyle = "rgb(242,160,110)" + context.fillText(message, absX, absY) + context.restore() + } + + fun move() { + val relTextWidth = textWidthInPixels / width + if (relX > (1.0 - relTextWidth - relXVelocity.abs) || relX < relXVelocity.abs) { + relXVelocity *= -1 + } + val relTextHeight = textHeightInPixels / height + if (relY > (1.0 - relYVelocity.abs) || relY < relYVelocity.abs + relTextHeight) { + relYVelocity *= -1 + } + relX += relXVelocity + relY += relYVelocity + } + + fun randomVelocity() = 0.03 * Math.random() * (if (Math.random() < 0.5) 1 else -1) + + + val Double.abs : Double + get() = if (this > 0) this else -this +} + +fun renderBackground() { + context.save() + context.fillStyle = "#5C7EED" + context.fillRect(0.0, 0.0, width, height) + context.restore() +} + +fun main() { + val interval = 50 + // we pass a literal that constructs a new HelloKotlin object + val logos = Array(3) { + HelloKotlin() + } + jq { + setInterval({ + renderBackground() + for (logo in logos) { + logo.draw() + } + }, interval) + } +} + + diff --git a/examplesForWebDemo/src/html5/interactive/interactive.js b/examplesForWebDemo/src/html5/interactive/interactive.js new file mode 100644 index 00000000000..e87a2d66315 --- /dev/null +++ b/examplesForWebDemo/src/html5/interactive/interactive.js @@ -0,0 +1,339 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function () { + var Vector = Kotlin.Class.create({initialize:function (x, y) { + this.$x = x; + this.$y = y; + }, get_x:function () { + return this.$x; + }, set_x:function (tmp$0) { + this.$x = tmp$0; + }, get_y:function () { + return this.$y; + }, set_y:function (tmp$0) { + this.$y = tmp$0; + }, plus:function (v) { + { + return interactive.v_0(this.get_x() + v.get_x(), this.get_y() + v.get_y()); + } + }, minus:function (v) { + { + return interactive.v_0(this.get_x() - v.get_x(), this.get_y() - v.get_y()); + } + }, times:function (coef) { + { + return interactive.v_0(this.get_x() * coef, this.get_y() * coef); + } + }, distanceTo:function (v) { + { + return Math.sqrt(this.minus(v).get_sqr()); + } + }, isInRect:function (topLeft, size) { + { + return this.get_x() >= topLeft.get_x() && this.get_x() <= topLeft.get_x() + size.get_x() && this.get_y() >= topLeft.get_y() && this.get_y() <= topLeft.get_y() + size.get_y(); + } + }, get_sqr:function () { + { + return this.get_x() * this.get_x() + this.get_y() * this.get_y(); + } + } + }); + var CanvasState = Kotlin.Class.create({initialize:function (canvas) { + this.$canvas = canvas; + this.$width = this.get_canvas().width; + this.$height = this.get_canvas().height; + this.$context = getContext(); + this.$valid = false; + this.$shapes = new Kotlin.ArrayList; + this.$selection = null; + this.$dragOff = new interactive.Vector_0(0, 0); + this.$interval = 1000 / 30; + this.$size = 20; + { + var tmp$4; + var tmp$3; + var tmp$2; + var tmp$1; + var tmp$0_0; + $(this.get_canvas()).mousedown((tmp$0_0 = this , function (it) { + { + var tmp$0; + tmp$0_0.set_valid(false); + tmp$0_0.set_selection(null); + var mousePos = tmp$0_0.mousePos_0(it); + { + tmp$0 = tmp$0_0.get_shapes().iterator(); + while (tmp$0.hasNext()) { + var shape = tmp$0.next(); + { + if (shape.contains(mousePos)) { + tmp$0_0.set_dragOff(mousePos.minus(shape.get_pos())); + shape.set_selected(true); + tmp$0_0.set_selection(shape); + break; + } + } + } + } + } + } + )); + $(this.get_canvas()).mousemove((tmp$1 = this , function (it) { + { + if (tmp$1.get_selection() != null) { + Kotlin.sure(tmp$1.get_selection()).set_pos(tmp$1.mousePos_0(it).minus(tmp$1.get_dragOff())); + tmp$1.set_valid(false); + } + } + } + )); + $(this.get_canvas()).mouseup((tmp$2 = this , function (it) { + { + if (tmp$2.get_selection() != null) { + Kotlin.sure(tmp$2.get_selection()).set_selected(false); + } + tmp$2.set_selection(null); + tmp$2.set_valid(false); + } + } + )); + $(this.get_canvas()).dblclick((tmp$3 = this , function (it) { + { + var redTransparentCircle = new interactive.Circle_0(tmp$3.mousePos_0(it), tmp$3.get_size(), 'rgba(200, 100, 100, 0.3)'); + tmp$3.addShape(redTransparentCircle); + tmp$3.set_valid(false); + } + } + )); + interactive.doWithPeriod(this.get_interval(), (tmp$4 = this , function () { + { + tmp$4.draw(); + } + } + )); + } + }, get_canvas:function () { + return this.$canvas; + }, get_width:function () { + return this.$width; + }, get_height:function () { + return this.$height; + }, get_context:function () { + return this.$context; + }, get_valid:function () { + return this.$valid; + }, set_valid:function (tmp$0) { + this.$valid = tmp$0; + }, get_shapes:function () { + return this.$shapes; + }, set_shapes:function (tmp$0) { + this.$shapes = tmp$0; + }, get_selection:function () { + return this.$selection; + }, set_selection:function (tmp$0) { + this.$selection = tmp$0; + }, get_dragOff:function () { + return this.$dragOff; + }, set_dragOff:function (tmp$0) { + this.$dragOff = tmp$0; + }, get_interval:function () { + return this.$interval; + }, get_size:function () { + return this.$size; + }, mousePos_0:function (e) { + { + var offset = new interactive.Vector_0(0, 0); + var element = this.get_canvas(); + while (element != null) { + var el = Kotlin.sure(element); + offset = offset.plus(new interactive.Vector_0(el.offsetLeft, el.offsetTop)); + element = el.offsetParent; + } + return (new interactive.Vector_0(e.pageX, e.pageY)).minus(offset); + } + }, addShape:function (shape) { + { + this.get_shapes().add(shape); + this.set_valid(false); + } + }, clear:function () { + { + this.get_context().fillStyle = '#FFFFFF'; + this.get_context().fillRect(0, 0, this.get_width(), this.get_height()); + this.get_context().strokeStyle = '#000000'; + this.get_context().lineWidth = 4; + this.get_context().strokeRect(0, 0, this.get_width(), this.get_height()); + } + }, draw:function () { + { + var tmp$0; + if (this.get_valid()) + return; + this.clear(); + { + tmp$0 = this.get_shapes().iterator(); + while (tmp$0.hasNext()) { + var shape = tmp$0.next(); + { + shape.draw(this); + } + } + } + this.set_valid(true); + } + } + }); + var Shape = Kotlin.Class.create({initialize:function () { + this.$selected = false; + }, draw:function (state) { + }, contains:function (mousePos) { + }, get_pos:function () { + return this.$pos; + }, set_pos:function (tmp$0) { + this.$pos = tmp$0; + }, get_selected:function () { + return this.$selected; + }, set_selected:function (tmp$0) { + this.$selected = tmp$0; + } + }); + var JB = Kotlin.Class.create(Shape, {initialize:function (pos, relSize) { + this.$pos = pos; + this.$relSize = relSize; + this.super_init(); + this.$imageSize = interactive.v_0(704, 254); + this.$canvasSize = this.get_imageSize().times(this.get_relSize()); + }, get_pos:function () { + return this.$pos; + }, set_pos:function (tmp$0) { + this.$pos = tmp$0; + }, get_relSize:function () { + return this.$relSize; + }, set_relSize:function (tmp$0) { + this.$relSize = tmp$0; + }, get_imageSize:function () { + return this.$imageSize; + }, get_canvasSize:function () { + return this.$canvasSize; + }, draw:function (state) { + { + var context = state.get_context(); + context.drawImage(getKotlinLogo(), 0, 0, this.get_imageSize().get_x(), this.get_imageSize().get_y(), this.get_pos().get_x(), this.get_pos().get_y(), this.get_canvasSize().get_x(), this.get_canvasSize().get_y()); + } + }, contains:function (mousePos) { + { + return mousePos.isInRect(this.get_pos(), this.get_canvasSize()); + } + } + }); + var Rectangle = Kotlin.Class.create(Shape, {initialize:function (pos, size) { + this.$pos = pos; + this.$size = size; + this.super_init(); + }, get_pos:function () { + return this.$pos; + }, set_pos:function (tmp$0) { + this.$pos = tmp$0; + }, get_size:function () { + return this.$size; + }, set_size:function (tmp$0) { + this.$size = tmp$0; + }, draw:function (state) { + { + var context = state.get_context(); + context.fillStyle = 'rgba(0,255,0,.6)'; + context.fillRect(this.get_pos().get_x(), this.get_pos().get_y(), this.get_size().get_x(), this.get_size().get_y()); + if (this.get_selected()) { + context.strokeStyle = '#FF0000'; + context.lineWidth = 2; + context.strokeRect(this.get_pos().get_x(), this.get_pos().get_y(), this.get_size().get_x(), this.get_size().get_y()); + } + } + }, contains:function (mousePos) { + { + return mousePos.isInRect(this.get_pos(), this.get_size()); + } + } + }); + var Circle = Kotlin.Class.create(Shape, {initialize:function (pos, radius, fillColor) { + this.$pos = pos; + this.$radius = radius; + this.$fillColor = fillColor; + this.super_init(); + }, get_pos:function () { + return this.$pos; + }, set_pos:function (tmp$0) { + this.$pos = tmp$0; + }, get_radius:function () { + return this.$radius; + }, set_radius:function (tmp$0) { + this.$radius = tmp$0; + }, get_fillColor:function () { + return this.$fillColor; + }, set_fillColor:function (tmp$0) { + this.$fillColor = tmp$0; + }, draw:function (state) { + { + var context = state.get_context(); + context.shadowColor = 'white'; + context.shadowBlur = 10; + context.fillStyle = this.get_fillColor(); + context.beginPath(); + context.arc(this.get_pos().get_x(), this.get_pos().get_y(), this.get_radius(), 0, 2 * Math.PI, false); + context.closePath(); + context.fill(); + } + }, contains:function (mousePos) { + { + return this.get_pos().distanceTo(mousePos) < this.get_radius(); + } + } + }); + return {Shape_0:Shape, JB_0:JB, Rectangle_0:Rectangle, Circle_0:Circle, CanvasState_0:CanvasState, Vector_0:Vector}; + } + (); + var interactive = Kotlin.Namespace.create({initialize:function () { + interactive.$state = new interactive.CanvasState_0(getCanvas()); + }, get_state:function () { + return interactive.$state; + }, doWithPeriod:function (period, f) { + { + setInterval(f, period); + } + }, v_0:function (x, y) { + { + return new interactive.Vector_0(x, y); + } + }, main:function () { + { + var state = new interactive.CanvasState_0(getCanvas()); + state.addShape(new interactive.JB_0(interactive.v_0(1, 1), 0.3)); + setTimeout(function () { + { + state.set_valid(false); + } + } + ); + } + } + }, classes); + interactive.initialize(); +} + +var args = []; +interactive.main(args); diff --git a/examplesForWebDemo/src/html5/interactive/jbLogo.png b/examplesForWebDemo/src/html5/interactive/jbLogo.png new file mode 100644 index 00000000000..759aa8ae05a Binary files /dev/null and b/examplesForWebDemo/src/html5/interactive/jbLogo.png differ diff --git a/examplesForWebDemo/src/html5/interactive/main.kt b/examplesForWebDemo/src/html5/interactive/main.kt new file mode 100644 index 00000000000..86eb1c1fdfc --- /dev/null +++ b/examplesForWebDemo/src/html5/interactive/main.kt @@ -0,0 +1,183 @@ +package interactive; + +import jquery.*; +import html5.*; +import java.util.ArrayList; +import js.*; +import js.Math; +import js.setInterval +import html5.getCanvas +import html5.getKotlinLogo +import jquery.jq +import js.setTimeout + +val state = CanvasState(getCanvas()); + +fun doWithPeriod(period : Int, f : ()->Unit) { + setInterval(f, period); +} + +abstract class Shape() { + abstract fun draw(state : CanvasState); + abstract fun contains(mousePos : Vector) : Boolean; + abstract var pos : Vector; + var selected : Boolean = false; +} + +class Circle(override var pos : Vector, + var radius : Double = 1.0, + var fillColor : String = "#AAAAAA") : Shape() { + + override fun draw(state : CanvasState) { + val context = state.context; + context.shadowColor = "white"; + context.shadowBlur = 10.0; + context.fillStyle = fillColor; + context.beginPath(); + context.arc(pos.x, pos.y, radius, 0.0, 2 * Math.PI, false); + context.closePath(); + context.fill(); + } + + override fun contains(mousePos : Vector) = pos.distanceTo(mousePos) < radius; +} + +class Rectangle(override var pos : Vector, + var size : Vector) : Shape() +{ + override fun draw(state : CanvasState) { + val context = state.context; + context.fillStyle = "rgba(0,255,0,.6)"; + context.fillRect(pos.x, pos.y, size.x, size.y); + if (selected) { + context.strokeStyle = "#FF0000" + context.lineWidth = 2.0; + context.strokeRect(pos.x, pos.y, size.x, size.y) + } + } + + override fun contains(mousePos : Vector) = mousePos.isInRect(pos, size); +} + +class JB(override var pos : Vector, + var relSize : Double = 0.3) : Shape() +{ + + val imageSize = v(704.0, 254.0) + val canvasSize = imageSize * relSize + + override fun draw(state : CanvasState) { + val context = state.context; + context.drawImage(getKotlinLogo(), 0.0, 0.0, imageSize.x, imageSize.y, pos.x, pos.y, canvasSize.x, canvasSize.y) + } + + override fun contains(mousePos: Vector): Boolean = mousePos.isInRect(pos, canvasSize) +} + +class CanvasState(val canvas : Canvas) { + val width = canvas.width; + val height = canvas.height; + val context = getContext(); + var valid = false; + var shapes = ArrayList(); + var selection : Shape? = null; + var dragOff = Vector(); + val interval = 1000 / 30; + val size = 20.0; + + { + jq(canvas).mousedown { + valid = false; + selection = null; + val mousePos = mousePos(it); + for (shape in shapes) { + if (mousePos in shape) { + dragOff = mousePos - shape.pos; + shape.selected = true; + selection = shape; + break; + } + } + } + + jq(canvas).mousemove { + if (selection != null) { + selection.sure().pos = mousePos(it) - dragOff; + valid = false; + } + } + + jq(canvas).mouseup { + if (selection != null) { + selection.sure().selected = false; + } + selection = null; + valid = false; + } + + jq(canvas).dblclick { + val redTransparentCircle = Circle(mousePos(it), size, "rgba(200, 100, 100, 0.3)"); + addShape(redTransparentCircle); + valid = false; + } + + doWithPeriod(interval) { + draw(); + } + } + + fun mousePos(e : MouseEvent) : Vector { + var offset = Vector(); + var element : DomElement? = canvas; + while (element != null) { + val el : DomElement = element.sure(); + offset += Vector(el.offsetLeft, el.offsetTop); + element = el.offsetParent; + } + return Vector(e.pageX, e.pageY) - offset; + } + + fun addShape(shape : Shape) { + shapes.add(shape); + valid = false; + } + + fun clear() { + context.fillStyle = "#FFFFFF" + context.fillRect(0.0, 0.0, width, height) + context.strokeStyle = "#000000" + context.lineWidth = 4.0; + context.strokeRect(0.0, 0.0, width, height) + } + + fun draw() { + if (valid) return + + clear(); + for (shape in shapes) { + shape.draw(this); + } + valid = true; + } +} + +fun v(x : Double, y : Double) = Vector(x, y); + +class Vector(var x : Double = 0.0, var y : Double = 0.0) { + fun plus(v : Vector) = v(x + v.x, y + v.y); + fun minus(v : Vector) = v(x - v.x, y - v.y); + fun times(coef : Double) = v(x * coef, y * coef); + fun distanceTo(v : Vector) = Math.sqrt((this - v).sqr); + fun isInRect(topLeft : Vector, size : Vector) = (x >= topLeft.x) && (x <= topLeft.x + size.x) && + (y >= topLeft.y) && (y <= topLeft.y + size.y) + val sqr : Double + get() = x * x + y * y; +} + +fun main() { + val state = CanvasState(getCanvas()); + state.addShape(JB(v(1.0, 1.0))); + setTimeout({ + state.valid = false + }) +} \ No newline at end of file diff --git a/examplesForWebDemo/src/html5/interactive/template.html b/examplesForWebDemo/src/html5/interactive/template.html new file mode 100644 index 00000000000..d976e3dafc2 --- /dev/null +++ b/examplesForWebDemo/src/html5/interactive/template.html @@ -0,0 +1,31 @@ + + + + + + Canvas demo + + + + + + + + + + \ No newline at end of file diff --git a/examplesForWebDemo/src/html5/interactive/template_copy.html b/examplesForWebDemo/src/html5/interactive/template_copy.html new file mode 100644 index 00000000000..d3319ca6c00 --- /dev/null +++ b/examplesForWebDemo/src/html5/interactive/template_copy.html @@ -0,0 +1,30 @@ + + + + + + Canvas demo + + + + + + + + + \ No newline at end of file diff --git a/examplesForWebDemo/src/html5/interactive/tutorial.js b/examplesForWebDemo/src/html5/interactive/tutorial.js new file mode 100644 index 00000000000..fb48f04ce7b --- /dev/null +++ b/examplesForWebDemo/src/html5/interactive/tutorial.js @@ -0,0 +1,238 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// By Simon Sarris +// www.simonsarris.com +// sarris@acm.org +// +// Last update December 2011 +// +// Free to use and distribute at will +// So long as you are nice to people, etc + +// Constructor for Shape objects to hold data for all drawn objects. +// For now they will just be defined as rectangles. +function Shape(x, y, w, h, fill) { + // This is a very simple and unsafe constructor. All we're doing is checking if the values exist. + // "x || 0" just means "if there is a value for x, use that. Otherwise use 0." + // But we aren't checking anything else! We could put "Lalala" for the value of x + this.x = x || 0; + this.y = y || 0; + this.w = w || 1; + this.h = h || 1; + this.fill = fill || '#AAAAAA'; +} + +// Draws this shape to a given context +Shape.prototype.draw = function (ctx) { + ctx.fillStyle = this.fill; + ctx.fillRect(this.x, this.y, this.w, this.h); +} + +// Determine if a point is inside the shape's bounds +Shape.prototype.contains = function (mx, my) { + // All we have to do is make sure the Mouse X,Y fall in the area between + // the shape's X and (X + Height) and its Y and (Y + Height) + return (this.x <= mx) && (this.x + this.w >= mx) && + (this.y <= my) && (this.y + this.h >= my); +} + +function CanvasState(canvas) { + // **** First some setup! **** + + this.canvas = canvas; + this.width = canvas.width; + this.height = canvas.height; + this.ctx = canvas.getContext('2d'); + // This complicates things a little but but fixes mouse co-ordinate problems + // when there's a border or padding. See getMouse for more detail +// if (document.defaultView && document.defaultView.getComputedStyle) { +// this.stylePaddingLeft = parseInt(document.defaultView.getComputedStyle(canvas, null)['paddingLeft'], 10) || 0; +// this.stylePaddingTop = parseInt(document.defaultView.getComputedStyle(canvas, null)['paddingTop'], 10) || 0; +// this.styleBorderLeft = parseInt(document.defaultView.getComputedStyle(canvas, null)['borderLeftWidth'], 10) || 0; +// this.styleBorderTop = parseInt(document.defaultView.getComputedStyle(canvas, null)['borderTopWidth'], 10) || 0; +// } + // Some pages have fixed-position bars (like the stumbleupon bar) at the top or left of the page + // They will mess up mouse coordinates and this fixes that + var html = document.body.parentNode; + this.htmlTop = html.offsetTop; + this.htmlLeft = html.offsetLeft; + + // **** Keep track of state! **** + + this.valid = false; // when set to false, the canvas will redraw everything + this.shapes = []; // the collection of things to be drawn + this.dragging = false; // Keep track of when we are dragging + // the current selected object. In the future we could turn this into an array for multiple selection + this.selection = null; + this.dragoffx = 0; // See mousedown and mousemove events for explanation + this.dragoffy = 0; + + // **** Then events! **** + + // This is an example of a closure! + // Right here "this" means the CanvasState. But we are making events on the Canvas itself, + // and when the events are fired on the canvas the variable "this" is going to mean the canvas! + // Since we still want to use this particular CanvasState in the events we have to save a reference to it. + // This is our reference! + var myState = this; + + //fixes a problem where double clicking causes text to get selected on the canvas + canvas.addEventListener('selectstart', function (e) { + e.preventDefault(); + return false; + }, false); + // Up, down, and move are for dragging + canvas.addEventListener('mousedown', function (e) { + var mouse = myState.getMouse(e); + var mx = mouse.x; + var my = mouse.y; + var shapes = myState.shapes; + var l = shapes.length; + for (var i = l - 1; i >= 0; i--) { + if (shapes[i].contains(mx, my)) { + var mySel = shapes[i]; + // Keep track of where in the object we clicked + // so we can move it smoothly (see mousemove) + myState.dragoffx = mx - mySel.x; + myState.dragoffy = my - mySel.y; + myState.dragging = true; + myState.selection = mySel; + myState.valid = false; + return; + } + } + // havent returned means we have failed to select anything. + // If there was an object selected, we deselect it + if (myState.selection) { + myState.selection = null; + myState.valid = false; // Need to clear the old selection border + } + }, true); + canvas.addEventListener('mousemove', function (e) { + if (myState.dragging) { + var mouse = myState.getMouse(e); + // We don't want to drag the object by its top-left corner, we want to drag it + // from where we clicked. Thats why we saved the offset and use it here + myState.selection.x = mouse.x - myState.dragoffx; + myState.selection.y = mouse.y - myState.dragoffy; + myState.valid = false; // Something's dragging so we must redraw + } + }, true); + canvas.addEventListener('mouseup', function (e) { + myState.dragging = false; + }, true); + // double click for making new shapes + canvas.addEventListener('dblclick', function (e) { + var mouse = myState.getMouse(e); + myState.addShape(new Shape(mouse.x - 10, mouse.y - 10, 20, 20, 'rgba(0,255,0,.6)')); + }, true); + + // **** Options! **** + + this.selectionColor = '#CC0000'; + this.selectionWidth = 2; + this.interval = 30; + setInterval(function () { + myState.draw(); + }, myState.interval); +} + +CanvasState.prototype.addShape = function (shape) { + this.shapes.push(shape); + this.valid = false; +} + +CanvasState.prototype.clear = function () { + this.ctx.clearRect(0, 0, this.width, this.height); +} + +// While draw is called as often as the INTERVAL variable demands, +// It only ever does something if the canvas gets invalidated by our code +CanvasState.prototype.draw = function () { + // if our state is invalid, redraw and validate! + if (!this.valid) { + var ctx = this.ctx; + var shapes = this.shapes; + this.clear(); + + // ** Add stuff you want drawn in the background all the time here ** + + // draw all shapes + var l = shapes.length; + for (var i = 0; i < l; i++) { + var shape = shapes[i]; + // We can skip the drawing of elements that have moved off the screen: + if (shape.x > this.width || shape.y > this.height || + shape.x + shape.w < 0 || shape.y + shape.h < 0) continue; + shapes[i].draw(ctx); + } + + // draw selection + // right now this is just a stroke along the edge of the selected Shape + if (this.selection != null) { + ctx.strokeStyle = this.selectionColor; + ctx.lineWidth = this.selectionWidth; + var mySel = this.selection; + ctx.strokeRect(mySel.x, mySel.y, mySel.w, mySel.h); + } + + // ** Add stuff you want drawn on top all the time here ** + + this.valid = true; + } +} + + +// Creates an object with x and y defined, set to the mouse position relative to the state's canvas +// If you wanna be super-correct this can be tricky, we have to worry about padding and borders +CanvasState.prototype.getMouse = function (e) { + var element = this.canvas, offsetX = 0, offsetY = 0, mx, my; + + // Compute the total offset + if (element.offsetParent !== undefined) { + do { + offsetX += element.offsetLeft; + offsetY += element.offsetTop; + } while ((element = element.offsetParent)); + } + + // Add padding and border style widths to offset + // Also add the offsets in case there's a position:fixed bar +// offsetX += this.stylePaddingLeft + this.styleBorderLeft + this.htmlLeft; + // offsetY += this.stylePaddingTop + this.styleBorderTop + this.htmlTop; + + mx = e.pageX - offsetX; + my = e.pageY - offsetY; + + // We return a simple javascript object (a hash) with x and y defined + return {x:mx, y:my}; +} + +// If you dont want to use +// You could uncomment this init() reference and place the script reference inside the body tag +init(); + +function init() { + var s = new CanvasState(getCanvas()); + s.addShape(new Shape(40, 40, 50, 50)); // The default is gray + s.addShape(new Shape(60, 140, 40, 60, 'lightskyblue')); + // Lets make some partially transparent + s.addShape(new Shape(80, 150, 60, 30, 'rgba(127, 255, 212, .5)')); + s.addShape(new Shape(125, 80, 30, 80, 'rgba(245, 222, 179, .7)')); +} + +// Now go make something amazing! \ No newline at end of file diff --git a/examplesForWebDemo/src/html5/interactive2/interactive2.js b/examplesForWebDemo/src/html5/interactive2/interactive2.js new file mode 100644 index 00000000000..93de4ed144b --- /dev/null +++ b/examplesForWebDemo/src/html5/interactive2/interactive2.js @@ -0,0 +1,475 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function () { + var Vector = Kotlin.Class.create({initialize:function (x, y) { + this.$x = x; + this.$y = y; + }, get_x:function () { + return this.$x; + }, get_y:function () { + return this.$y; + }, plus:function (v) { + { + return interactive2.v_0(this.get_x() + v.get_x(), this.get_y() + v.get_y()); + } + }, minus:function () { + { + return interactive2.v_0(-this.get_x(), -this.get_y()); + } + }, minus$0:function (v) { + { + return interactive2.v_0(this.get_x() - v.get_x(), this.get_y() - v.get_y()); + } + }, times:function (coef) { + { + return interactive2.v_0(this.get_x() * coef, this.get_y() * coef); + } + }, distanceTo:function (v) { + { + return Math.sqrt(this.minus$0(v).get_sqr()); + } + }, rotatedBy:function (theta) { + { + var sin = Math.sin(theta); + var cos = Math.cos(theta); + return interactive2.v_0(this.get_x() * cos - this.get_y() * sin, this.get_x() * sin + this.get_y() * cos); + } + }, isInRect:function (topLeft, size) { + { + return this.get_x() >= topLeft.get_x() && this.get_x() <= topLeft.get_x() + size.get_x() && this.get_y() >= topLeft.get_y() && this.get_y() <= topLeft.get_y() + size.get_y(); + } + }, get_sqr:function () { + { + return this.get_x() * this.get_x() + this.get_y() * this.get_y(); + } + }, get_normalized:function () { + { + return this.times(1 / Math.sqrt(this.get_sqr())); + } + } + }); + var RadialGradientGenerator = Kotlin.Class.create({initialize:function (context) { + this.$context = context; + this.$gradients = new Kotlin.ArrayList; + this.$current = 0; + { + this.newColorStops([ + [0, '#F59898'], + [0.5, '#F57373'], + [1, '#DB6B6B'] + ]); + this.newColorStops([ + [0.39, 'rgb(140,167,209)'], + [0.7, 'rgb(104,139,209)'], + [0.85, 'rgb(67,122,217)'] + ]); + this.newColorStops([ + [0, 'rgb(255,222,255)'], + [0.5, 'rgb(255,185,222)'], + [1, 'rgb(230,154,185)'] + ]); + this.newColorStops([ + [0, 'rgb(255,209,114)'], + [0.5, 'rgb(255,174,81)'], + [1, 'rgb(241,145,54)'] + ]); + this.newColorStops([ + [0, 'rgb(132,240,135)'], + [0.5, 'rgb(91,240,96)'], + [1, 'rgb(27,245,41)'] + ]); + this.newColorStops([ + [0, 'rgb(250,147,250)'], + [0.5, 'rgb(255,80,255)'], + [1, 'rgb(250,0,217)'] + ]); + } + }, get_context:function () { + return this.$context; + }, get_gradients:function () { + return this.$gradients; + }, get_current:function () { + return this.$current; + }, set_current:function (tmp$0) { + this.$current = tmp$0; + }, newColorStops:function (colorStops) { + { + this.get_gradients().add(colorStops); + } + }, getNext:function () { + { + var result = this.get_gradients().get(this.get_current()); + this.set_current((this.get_current() + 1) % this.get_gradients().size()); + return result; + } + } + }); + var CanvasState = Kotlin.Class.create({initialize:function (canvas) { + this.$canvas = canvas; + this.$width = this.get_canvas().width; + this.$height = this.get_canvas().height; + this.$context = getContext(); + this.$valid = false; + this.$shapes = new Kotlin.ArrayList; + this.$selection = null; + this.$dragOff = new interactive2.Vector_0(0, 0); + this.$interval = 1000 / 30; + { + var tmp$4; + var tmp$3; + var tmp$2; + var tmp$1; + var tmp$0_0; + $(this.get_canvas()).mousedown((tmp$0_0 = this , function (it) { + { + var tmp$0; + tmp$0_0.set_valid(false); + tmp$0_0.set_selection(null); + var mousePos = tmp$0_0.mousePos_0(it); + { + tmp$0 = tmp$0_0.get_shapes().iterator(); + while (tmp$0.hasNext()) { + var shape = tmp$0.next(); + { + if (shape.contains(mousePos)) { + tmp$0_0.set_dragOff(mousePos.minus$0(shape.get_pos())); + shape.set_selected(true); + tmp$0_0.set_selection(shape); + break; + } + } + } + } + } + } + )); + $(this.get_canvas()).mousemove((tmp$1 = this , function (it) { + { + if (tmp$1.get_selection() != null) { + Kotlin.sure(tmp$1.get_selection()).set_pos(tmp$1.mousePos_0(it).minus$0(tmp$1.get_dragOff())); + tmp$1.set_valid(false); + } + } + } + )); + $(this.get_canvas()).mouseup((tmp$2 = this , function (it) { + { + if (tmp$2.get_selection() != null) { + Kotlin.sure(tmp$2.get_selection()).set_selected(false); + } + tmp$2.set_selection(null); + tmp$2.set_valid(false); + } + } + )); + $(this.get_canvas()).dblclick((tmp$3 = this , function (it) { + { + var redTransparentCircle = new interactive2.Creature_0(tmp$3.mousePos_0(it), tmp$3); + tmp$3.addShape(redTransparentCircle); + tmp$3.set_valid(false); + } + } + )); + interactive2.doWithPeriod(this.get_interval(), (tmp$4 = this , function () { + { + tmp$4.draw(); + } + } + )); + } + }, get_canvas:function () { + return this.$canvas; + }, get_width:function () { + return this.$width; + }, get_height:function () { + return this.$height; + }, get_context:function () { + return this.$context; + }, get_valid:function () { + return this.$valid; + }, set_valid:function (tmp$0) { + this.$valid = tmp$0; + }, get_shapes:function () { + return this.$shapes; + }, set_shapes:function (tmp$0) { + this.$shapes = tmp$0; + }, get_selection:function () { + return this.$selection; + }, set_selection:function (tmp$0) { + this.$selection = tmp$0; + }, get_dragOff:function () { + return this.$dragOff; + }, set_dragOff:function (tmp$0) { + this.$dragOff = tmp$0; + }, get_interval:function () { + return this.$interval; + }, mousePos_0:function (e) { + { + var offset = new interactive2.Vector_0(0, 0); + var element = this.get_canvas(); + while (element != null) { + var el = Kotlin.sure(element); + offset = offset.plus(new interactive2.Vector_0(el.offsetLeft, el.offsetTop)); + element = el.offsetParent; + } + return (new interactive2.Vector_0(e.pageX, e.pageY)).minus$0(offset); + } + }, addShape:function (shape) { + { + this.get_shapes().add(shape); + this.set_valid(false); + } + }, clear:function () { + { + this.get_context().fillStyle = '#FFFFFF'; + this.get_context().fillRect(0, 0, this.get_width(), this.get_height()); + this.get_context().strokeStyle = '#000000'; + this.get_context().lineWidth = 4; + this.get_context().strokeRect(0, 0, this.get_width(), this.get_height()); + } + }, draw:function () { + { + var tmp$0; + if (this.get_valid()) + return; + this.clear(); + { + tmp$0 = this.get_shapes().iterator(); + while (tmp$0.hasNext()) { + var shape = tmp$0.next(); + { + shape.draw(this); + } + } + } + this.set_valid(true); + } + } + }); + var Shape = Kotlin.Class.create({initialize:function () { + this.$selected = false; + }, draw:function (state) { + }, contains:function (mousePos) { + }, get_pos:function () { + return this.$pos; + }, set_pos:function (tmp$0) { + this.$pos = tmp$0; + }, get_selected:function () { + return this.$selected; + }, set_selected:function (tmp$0) { + this.$selected = tmp$0; + } + }); + var Creature = Kotlin.Class.create(Shape, {initialize:function (pos, state) { + this.$pos = pos; + this.$state = state; + this.super_init(); + this.$shadowOffset = interactive2.v_0(-5, 5); + this.$colorStops = interactive2.get_gradientGenerator().getNext(); + this.$relSize = 0.05; + }, get_pos:function () { + return this.$pos; + }, set_pos:function (tmp$0) { + this.$pos = tmp$0; + }, get_state:function () { + return this.$state; + }, set_state:function (tmp$0) { + this.$state = tmp$0; + }, get_shadowOffset:function () { + return this.$shadowOffset; + }, get_colorStops:function () { + return this.$colorStops; + }, get_relSize:function () { + return this.$relSize; + }, get_radius:function () { + { + return this.get_state().get_width() * this.get_relSize(); + } + }, get_position:function () { + var tmp$0; + if (this.get_selected()) + tmp$0 = this.get_pos().minus$0(this.get_shadowOffset()); + else + tmp$0 = this.get_pos(); + { + return tmp$0; + } + }, get_directionToLogo:function () { + { + return interactive2.get_JB().get_centre().minus$0(this.get_position()).get_normalized(); + } + }, contains:function (mousePos) { + { + return this.get_pos().distanceTo(mousePos) < this.get_radius(); + } + }, fillCircle:function (receiver, position, rad) { + { + receiver.beginPath(); + receiver.arc(position.get_x(), position.get_y(), rad, 0, 2 * Math.PI, false); + receiver.closePath(); + receiver.fill(); + } + }, draw:function (state) { + { + var context = state.get_context(); + if (!this.get_selected()) { + this.drawCreature(context); + } + else { + this.drawCreatureWithShadow(context); + } + } + }, drawCreature:function (context) { + { + context.fillStyle = this.getGradient(context); + this.fillCircle(context, this.get_position(), this.get_radius()); + this.drawEye(context); + this.drawTail(context); + } + }, getGradient:function (context) { + { + var tmp$0; + var gradientCentre = this.get_position().plus(this.get_directionToLogo().times(this.get_radius() / 4)); + var gradient = context.createRadialGradient(gradientCentre.get_x(), gradientCentre.get_y(), 1, gradientCentre.get_x(), gradientCentre.get_y(), 2 * this.get_radius()); + { + tmp$0 = Kotlin.arrayIterator(this.get_colorStops()); + while (tmp$0.hasNext()) { + var colorStop = tmp$0.next(); + { + gradient.addColorStop(colorStop[0], colorStop[1]); + } + } + } + return gradient; + } + }, drawTail:function (context) { + { + var tailDirection = this.get_directionToLogo().minus(); + var tailPos = this.get_position().plus(tailDirection.times(this.get_radius()).times(0.7)); + var tailSize = this.get_radius() * 1.6; + var angle = Math.PI / 6; + var p1 = tailPos.plus(tailDirection.rotatedBy(angle).times(tailSize)); + var p2 = tailPos.plus(tailDirection.rotatedBy(-angle).times(tailSize)); + context.fillStyle = this.getGradient(context); + context.beginPath(); + context.moveTo(tailPos.get_x(), tailPos.get_y()); + context.lineTo(p1.get_x(), p1.get_y()); + var middlePoint = this.get_position().plus(tailDirection.times(this.get_radius()).times(1)); + context.quadraticCurveTo(middlePoint.get_x(), middlePoint.get_y(), p2.get_x(), p2.get_y()); + context.lineTo(tailPos.get_x(), tailPos.get_y()); + context.closePath(); + context.fill(); + } + }, drawEye:function (context) { + { + var eyePos = this.get_directionToLogo().times(this.get_radius()).times(0.6).plus(this.get_position()); + var eyeRadius = this.get_radius() / 3; + var eyeLidRadius = eyeRadius / 2; + context.fillStyle = '#FFFFFF'; + this.fillCircle(context, eyePos, eyeRadius); + context.fillStyle = '#000000'; + this.fillCircle(context, eyePos, eyeLidRadius); + } + }, drawCreatureWithShadow:function (context) { + { + context.save(); + this.setShadow(context); + context.fillStyle = this.getGradient(context); + this.fillCircle(context, this.get_position(), this.get_radius()); + context.restore(); + this.drawEye(context); + this.drawTail(context); + } + }, setShadow:function (context) { + { + context.shadowColor = 'rgba(100, 100, 100, 0.7)'; + context.shadowBlur = 5; + context.shadowOffsetX = this.get_shadowOffset().get_x(); + context.shadowOffsetY = this.get_shadowOffset().get_y(); + } + } + }); + var Logo = Kotlin.Class.create(Shape, {initialize:function (pos, relSize) { + this.$pos = pos; + this.$relSize = relSize; + this.super_init(); + this.$imageSize = interactive2.v_0(704, 254); + this.$canvasSize = this.get_imageSize().times(this.get_relSize()); + }, get_pos:function () { + return this.$pos; + }, set_pos:function (tmp$0) { + this.$pos = tmp$0; + }, get_relSize:function () { + return this.$relSize; + }, set_relSize:function (tmp$0) { + this.$relSize = tmp$0; + }, get_imageSize:function () { + return this.$imageSize; + }, get_canvasSize:function () { + return this.$canvasSize; + }, draw:function (state) { + { + var context = state.get_context(); + context.drawImage(getKotlinLogo(), 0, 0, this.get_imageSize().get_x(), this.get_imageSize().get_y(), this.get_pos().get_x(), this.get_pos().get_y(), this.get_canvasSize().get_x(), this.get_canvasSize().get_y()); + } + }, contains:function (mousePos) { + { + return mousePos.isInRect(this.get_pos(), this.get_canvasSize()); + } + }, get_centre:function () { + { + return this.get_pos().plus(this.get_canvasSize().times(0.5)); + } + } + }); + return {Shape_0:Shape, Logo_0:Logo, Creature_0:Creature, RadialGradientGenerator_0:RadialGradientGenerator, CanvasState_0:CanvasState, Vector_0:Vector}; + } + (); + var interactive2 = Kotlin.Namespace.create({initialize:function () { + interactive2.$gradientGenerator = new interactive2.RadialGradientGenerator_0(getContext()); + interactive2.$JB = new interactive2.Logo_0(interactive2.v_0(20, 20), 0.3); + }, get_gradientGenerator:function () { + return interactive2.$gradientGenerator; + }, get_JB:function () { + return interactive2.$JB; + }, doWithPeriod:function (period, f) { + { + setInterval(f, period); + } + }, v_0:function (x, y) { + { + return new interactive2.Vector_0(x, y); + } + }, main:function () { + { + var state = new interactive2.CanvasState_0(getCanvas()); + state.addShape(interactive2.get_JB()); + setTimeout(function () { + { + state.set_valid(false); + } + } + ); + } + } + }, classes); + interactive2.initialize(); +} + +var args = []; +interactive2.main(args); diff --git a/examplesForWebDemo/src/html5/interactive2/jbLogo.png b/examplesForWebDemo/src/html5/interactive2/jbLogo.png new file mode 100644 index 00000000000..759aa8ae05a Binary files /dev/null and b/examplesForWebDemo/src/html5/interactive2/jbLogo.png differ diff --git a/examplesForWebDemo/src/html5/interactive2/main.kt b/examplesForWebDemo/src/html5/interactive2/main.kt new file mode 100644 index 00000000000..e4bacc02865 --- /dev/null +++ b/examplesForWebDemo/src/html5/interactive2/main.kt @@ -0,0 +1,280 @@ +package interactive2; + +import jquery.*; +import html5.*; +import java.util.ArrayList; +import js.*; +import js.Math; +import js.setInterval +import html5.getCanvas +import html5.getKotlinLogo +import jquery.jq +import js.setTimeout + +val gradientGenerator = RadialGradientGenerator(getContext()) +val JB = Logo(v(20.0, 20.0)) + +fun doWithPeriod(period : Int, f : ()->Unit) { + setInterval(f, period); +} + +abstract class Shape() { + abstract fun draw(state : CanvasState); + abstract fun contains(mousePos : Vector) : Boolean; + abstract var pos : Vector; + var selected : Boolean = false; +} + +class Logo(override var pos : Vector, + var relSize : Double = 0.3) + : Shape() +{ + val imageSize = v(704.0, 254.0) + val canvasSize = imageSize * relSize + + override fun draw(state : CanvasState) { + val context = state.context; + context.drawImage(getKotlinLogo(), 0.0, 0.0, imageSize.x, imageSize.y, pos.x, pos.y, canvasSize.x, canvasSize.y) + } + + override fun contains(mousePos: Vector): Boolean = mousePos.isInRect(pos, canvasSize) + + val centre : Vector + get() = pos + canvasSize * 0.5 +} + +class Creature(override var pos : Vector, + var state : CanvasState) : Shape() { + + val shadowOffset = v(-5.0, 5.0) + val colorStops = gradientGenerator.getNext() + val relSize = 0.05; + val radius : Double + get() = state.width * relSize; + + val position : Vector + get() = if (selected) pos - shadowOffset else pos + + val directionToLogo : Vector + get() = (JB.centre - position).normalized + + override fun contains(mousePos : Vector) = pos.distanceTo(mousePos) < radius; + + fun Context.fillCircle(position : Vector, rad : Double) { + beginPath(); + arc(position.x, position.y, rad, 0.0, 2 * Math.PI, false); + closePath(); + fill() + } + + override fun draw(state : CanvasState) { + val context = state.context; + if (!selected) { + drawCreature(context) + } else { + drawCreatureWithShadow(context) + } + } + + fun drawCreature(context : Context) { + context.fillStyle = getGradient(context); + context.fillCircle(position, radius) + drawEye(context) + drawTail(context) + } + + fun getGradient(context : Context) : CanvasGradient { + val gradientCentre = position + directionToLogo * (radius / 4) + val gradient = context.createRadialGradient(gradientCentre.x, gradientCentre.y, 1.0, gradientCentre.x, gradientCentre.y, 2 * radius) + for (colorStop in colorStops) { + gradient.addColorStop(colorStop._1, colorStop._2) + } + return gradient; + } + + fun drawTail(context : Context) { + val tailDirection = -directionToLogo; + val tailPos = position + tailDirection * radius * 0.7 + val tailSize = radius * 1.6 + val angle = Math.PI / 6.0; + val p1 = tailPos + tailDirection.rotatedBy(angle) * tailSize + val p2 = tailPos + tailDirection.rotatedBy(-angle) * tailSize + context.fillStyle = getGradient(context) + context.beginPath() + context.moveTo(tailPos.x, tailPos.y) + context.lineTo(p1.x, p1.y) + val middlePoint = position + tailDirection * radius * 1.0 + context.quadraticCurveTo(middlePoint.x, middlePoint.y, p2.x, p2.y) + context.lineTo(tailPos.x, tailPos.y) + context.closePath() + context.fill() + } + + fun drawEye(context : Context) {; + val eyePos = directionToLogo * radius * 0.6 + position; + val eyeRadius = radius / 3; + val eyeLidRadius = eyeRadius / 2; + context.fillStyle = "#FFFFFF"; + context.fillCircle(eyePos, eyeRadius) + context.fillStyle = "#000000" + context.fillCircle(eyePos, eyeLidRadius) + } + + fun drawCreatureWithShadow(context : Context) { + context.save() + setShadow(context) + context.fillStyle = getGradient(context) + context.fillCircle(position, radius) + context.restore(); + drawEye(context) + drawTail(context) + } + + fun setShadow(context : Context) { + context.shadowColor = "rgba(100, 100, 100, 0.7)"; + context.shadowBlur = 5.0; + context.shadowOffsetX = shadowOffset.x; + context.shadowOffsetY = shadowOffset.y; + } +} + +class CanvasState(val canvas : Canvas) { + val width = canvas.width; + val height = canvas.height; + val context = getContext(); + var valid = false; + var shapes = ArrayList(); + var selection : Shape? = null; + var dragOff = Vector(); + val interval = 1000 / 30; + + { + jq(canvas).mousedown { + valid = false; + selection = null; + val mousePos = mousePos(it); + for (shape in shapes) { + if (mousePos in shape) { + dragOff = mousePos - shape.pos; + shape.selected = true; + selection = shape; + break; + } + } + } + + jq(canvas).mousemove { + if (selection != null) { + selection.sure().pos = mousePos(it) - dragOff; + valid = false; + } + } + + jq(canvas).mouseup { + if (selection != null) { + selection.sure().selected = false; + } + selection = null; + valid = false; + } + + jq(canvas).dblclick { + val redTransparentCircle = Creature(mousePos(it), this @CanvasState); + addShape(redTransparentCircle); + valid = false; + } + + doWithPeriod(interval) { + draw(); + } + } + + fun mousePos(e : MouseEvent) : Vector { + var offset = Vector(); + var element : DomElement? = canvas; + while (element != null) { + val el : DomElement = element.sure(); + offset += Vector(el.offsetLeft, el.offsetTop); + element = el.offsetParent; + } + return Vector(e.pageX, e.pageY) - offset; + } + + fun addShape(shape : Shape) { + shapes.add(shape); + valid = false; + } + + fun clear() { + context.fillStyle = "#FFFFFF" + context.fillRect(0.0, 0.0, width, height) + context.strokeStyle = "#000000" + context.lineWidth = 4.0; + context.strokeRect(0.0, 0.0, width, height) + } + + fun draw() { + if (valid) return + + clear(); + for (shape in shapes) { + shape.draw(this); + } + valid = true; + } +} + +class RadialGradientGenerator(val context : Context) { + val gradients = ArrayList>(); + var current = 0 + + fun newColorStops(vararg colorStops : #(Double, String)) { + gradients.add(colorStops) + } + + { + newColorStops(#(0.0, "#F59898"), #(0.5, "#F57373"), #(1.0, "#DB6B6B")) + newColorStops(#(0.39, "rgb(140,167,209)"), #(0.7, "rgb(104,139,209)"), #(0.85, "rgb(67,122,217)")) + newColorStops(#(0.0, "rgb(255,222,255)"), #(0.5, "rgb(255,185,222)"), #(1.0, "rgb(230,154,185)")) + newColorStops(#(0.0, "rgb(255,209,114)"), #(0.5, "rgb(255,174,81)"), #(1.0, "rgb(241,145,54)")) + newColorStops(#(0.0, "rgb(132,240,135)"), #(0.5, "rgb(91,240,96)"), #(1.0, "rgb(27,245,41)")) + newColorStops(#(0.0, "rgb(250,147,250)"), #(0.5, "rgb(255,80,255)"), #(1.0, "rgb(250,0,217)")) +} + + fun getNext() : Array<#(Double, String)> { + val result = gradients.get(current) + current = (current + 1) % gradients.size() + return result + } +} + +fun v(x : Double, y : Double) = Vector(x, y); + +class Vector(val x : Double = 0.0, val y : Double = 0.0) { + fun plus(v : Vector) = v(x + v.x, y + v.y); + fun minus() = v(-x, -y) + fun minus(v : Vector) = v(x - v.x, y - v.y) + fun times(coef : Double) = v(x * coef, y * coef) + fun distanceTo(v : Vector) = Math.sqrt((this - v).sqr) + fun rotatedBy(theta : Double) : Vector { + val sin = Math.sin(theta) + val cos = Math.cos(theta) + return v(x * cos - y * sin, x * sin + y * cos) + } + + fun isInRect(topLeft : Vector, size : Vector) = (x >= topLeft.x) && (x <= topLeft.x + size.x) && + (y >= topLeft.y) && (y <= topLeft.y + size.y) + + val sqr : Double + get() = x * x + y * y + val normalized : Vector + get() = this * (1.0 / Math.sqrt(sqr)) +} + +fun main() { + val state = CanvasState(getCanvas()); + state.addShape(JB); + setTimeout({ + state.valid = false + }) +} \ No newline at end of file diff --git a/examplesForWebDemo/src/html5/interactive2/template.html b/examplesForWebDemo/src/html5/interactive2/template.html new file mode 100644 index 00000000000..f7399d7ee00 --- /dev/null +++ b/examplesForWebDemo/src/html5/interactive2/template.html @@ -0,0 +1,31 @@ + + + + + + Canvas demo + + + + + + + + + + \ No newline at end of file diff --git a/js/AUTHORS b/js/AUTHORS new file mode 100644 index 00000000000..fea9b245e9a --- /dev/null +++ b/js/AUTHORS @@ -0,0 +1,8 @@ +# Below is a list of people and organizations that have contributed +# to the Dart project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. + +Ola Martin Bini diff --git a/js/LICENSE b/js/LICENSE new file mode 100644 index 00000000000..64ed1a49724 --- /dev/null +++ b/js/LICENSE @@ -0,0 +1,48 @@ +This license applies to all parts of Dart that are not externally +maintained libraries. The external maintained libraries used by +Dart are: + +JSCRE - in runtime/third_party/jscre +Ant - in third_party/apache_ant +Google App Engine for Java SDK - in third_party/appengine-java-sdk +args4j - in third_party/args4j +Chrome SDK - in third_party/chromesdk +Eclipse - in third_party/eclipse +gsutil = in third_party/gsutil +Guava - in third_party/guava +hamcrest - in third_party/hamcrest +Httplib2 - in third_party/httplib2 +Jetty - in third_party/jetty +JSON - in third_party/json +JUnit - in third_party/junit +Ouath - in third_party/oauth2client +Python-scss - in third_party/pyscss +Rhino - in third_party/rhino + +The libraries may have their own licenses; we recommend you read them, +as their terms may differ from the terms below. + +Copyright 2011, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/js/PATENTS b/js/PATENTS new file mode 100644 index 00000000000..69541968b91 --- /dev/null +++ b/js/PATENTS @@ -0,0 +1,23 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Dart Project. + +Google hereby grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this +section) patent license to make, have made, use, offer to sell, sell, +import, transfer, and otherwise run, modify and propagate the contents +of this implementation of Dart, where such license applies only to +those patent claims, both currently owned by Google and acquired in +the future, licensable by Google that are necessarily infringed by +this implementation of Dart. This grant does not include claims that +would be infringed only as a consequence of further modification of +this implementation. If you or your agent or exclusive licensee +institute or order or agree to the institution of patent litigation +against any entity (including a cross-claim or counterclaim in a +lawsuit) alleging that this implementation of Dart or any code +incorporated within this implementation of Dart constitutes direct or +contributory patent infringement, or inducement of patent +infringement, then any patent rights granted to you under this License +for this implementation of Dart shall terminate as of the date such +litigation is filed. diff --git a/js/js.iml b/js/js.iml new file mode 100644 index 00000000000..73bb50aea75 --- /dev/null +++ b/js/js.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/js/src/com/google/dart/compiler/InternalCompilerException.java b/js/src/com/google/dart/compiler/InternalCompilerException.java new file mode 100644 index 00000000000..5db265e920a --- /dev/null +++ b/js/src/com/google/dart/compiler/InternalCompilerException.java @@ -0,0 +1,15 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler; + +/** + * Exception thrown when the compiler encounters an unexpected internal error. + */ +public class InternalCompilerException extends RuntimeException { + + public InternalCompilerException(String message) { + super(message); + } +} diff --git a/js/src/com/google/dart/compiler/Source.java b/js/src/com/google/dart/compiler/Source.java new file mode 100644 index 00000000000..13e6e16cbdd --- /dev/null +++ b/js/src/com/google/dart/compiler/Source.java @@ -0,0 +1,44 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler; + +import java.io.IOException; +import java.io.Reader; +import java.net.URI; + +/** + * Abstract interface to a source file. + */ +public interface Source { + + /** + * Determines whether the given source exists. + */ + boolean exists(); + + /** + * Returns the last-modified timestamp for this source, using the same units as + * {@link java.util.Date#getTime()}. + */ + long getLastModified(); + + /** + * Gets the name of this source. + */ + String getName(); + + /** + * Gets a reader for the dart file's source code. The caller is responsible for closing the + * returned reader. + */ + Reader getSourceReader() throws IOException; + + /** + * Gets the identifier for this source. This is used to uniquely identify the + * source, but should not be used to obtain the source content. Use + * {@link #getSourceReader()} to obtain the source content. + */ + URI getUri(); +} diff --git a/js/src/com/google/dart/compiler/backend/js/Cloner.java b/js/src/com/google/dart/compiler/backend/js/Cloner.java new file mode 100644 index 00000000000..fa3447fe168 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/Cloner.java @@ -0,0 +1,232 @@ +// Copyright 2011, the Dart project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +package com.google.dart.compiler.backend.js; + +import com.google.dart.compiler.InternalCompilerException; +import com.google.dart.compiler.backend.js.ast.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +/** + * Implements actual cloning logic. We rely on the JsExpressions to provide + * traversal logic. The {@link #stack} field is used to accumulate + * already-cloned JsExpression instances. One gotcha that falls out of this is + * that argument lists are on the stack in reverse order, so lists should be + * constructed via inserts, rather than appends. + */ +public class Cloner extends JsVisitor { + protected final Stack stack = new Stack(); + private boolean successful = true; + + /** + * @param expression + * @return Return a clone of the expression tree + */ + public static JsExpression clone(JsExpression expression) { + Cloner c = new Cloner(); + c.accept(expression); + return c.getExpression(); + } + + @Override + public void endVisit(JsArrayAccess x, JsContext ctx) { + JsArrayAccess newExpression = new JsArrayAccess(); + newExpression.setIndexExpr(stack.pop()); + newExpression.setArrayExpr(stack.pop()); + stack.push(newExpression); + } + + @Override + public void endVisit(JsArrayLiteral x, JsContext ctx) { + JsArrayLiteral toReturn = new JsArrayLiteral(); + List expressions = toReturn.getExpressions(); + int size = x.getExpressions().size(); + while (size-- > 0) { + expressions.add(0, stack.pop()); + } + stack.push(toReturn); + } + + @Override + public void endVisit(JsBinaryOperation x, JsContext ctx) { + JsBinaryOperation toReturn = new JsBinaryOperation(x.getOperator()); + toReturn.setArg2(stack.pop()); + toReturn.setArg1(stack.pop()); + stack.push(toReturn); + } + + @Override + public void endVisit(JsBooleanLiteral x, JsContext ctx) { + stack.push(x); + } + + @Override + public void endVisit(JsConditional x, JsContext ctx) { + JsConditional toReturn = new JsConditional(); + toReturn.setElseExpression(stack.pop()); + toReturn.setThenExpression(stack.pop()); + toReturn.setTestExpression(stack.pop()); + stack.push(toReturn); + } + + /** + * The only functions that would get be visited are those being used as + * first-class objects. + */ + @Override + public void endVisit(JsFunction x, JsContext ctx) { + // Set a flag to indicate that we cannot continue, and push a null so + // we don't run out of elements on the stack. + successful = false; + stack.push(null); + } + + /** + * Cloning the invocation allows us to modify it without damaging other call + * sites. + */ + @Override + public void endVisit(JsInvocation x, JsContext ctx) { + JsInvocation toReturn = new JsInvocation(); + List params = toReturn.getArguments(); + int size = x.getArguments().size(); + while (size-- > 0) { + params.add(0, stack.pop()); + } + toReturn.setQualifier(stack.pop()); + stack.push(toReturn); + } + + /** + * Do a deep clone of a JsNameRef. Because JsNameRef chains are shared + * throughout the AST, you can't just go and change their qualifiers when + * re-writing an invocation. + */ + @Override + public void endVisit(JsNameRef x, JsContext ctx) { + JsNameRef toReturn; + JsName name = x.getName(); + if (name != null) { + toReturn = new JsNameRef(name); + } else { + toReturn = new JsNameRef(x.getIdent()); + } + + if (x.getQualifier() != null) { + toReturn.setQualifier(stack.pop()); + } + stack.push(toReturn); + } + + @Override + public void endVisit(JsNew x, JsContext ctx) { + int size = x.getArguments().size(); + List arguments = new ArrayList(size); + while (size-- > 0) { + arguments.add(0, stack.pop()); + } + JsNew toReturn = new JsNew(stack.pop()); + toReturn.getArguments().addAll(arguments); + stack.push(toReturn); + } + + @Override + public void endVisit(JsNullLiteral x, JsContext ctx) { + stack.push(x); + } + + @Override + public void endVisit(JsNumberLiteral x, JsContext ctx) { + stack.push(x); + } + + @Override + public void endVisit(JsObjectLiteral x, JsContext ctx) { + JsObjectLiteral toReturn = new JsObjectLiteral(); + List inits = toReturn.getPropertyInitializers(); + + int size = x.getPropertyInitializers().size(); + while (size-- > 0) { + /* + * JsPropertyInitializers are the only non-JsExpression objects that we + * care about, so we just go ahead and create the objects in the loop, + * rather than expecting it to be on the stack and having to perform + * narrowing casts at all stack.pop() invocations. + */ + JsPropertyInitializer newInit = new JsPropertyInitializer(); + newInit.setValueExpr(stack.pop()); + newInit.setLabelExpr(stack.pop()); + + inits.add(0, newInit); + } + stack.push(toReturn); + } + + @Override + public void endVisit(JsPostfixOperation x, JsContext ctx) { + JsPostfixOperation toReturn = new JsPostfixOperation(x.getOperator()); + toReturn.setArg(stack.pop()); + stack.push(toReturn); + } + + @Override + public void endVisit(JsPrefixOperation x, JsContext ctx) { + JsPrefixOperation toReturn = new JsPrefixOperation(x.getOperator()); + toReturn.setArg(stack.pop()); + stack.push(toReturn); + } + + @Override + public void endVisit(JsRegExp x, JsContext ctx) { + stack.push(x); + } + + @Override + public void endVisit(JsStringLiteral x, JsContext ctx) { + stack.push(x); + } + + @Override + public void endVisit(JsThisRef x, JsContext ctx) { + stack.push(new JsThisRef()); + } + + public JsExpression getExpression() { + return (successful && checkStack()) ? stack.peek() : null; + } + + private boolean checkStack() { + if (stack.size() > 1) { + throw new InternalCompilerException("Too many expressions on stack"); + } + + return stack.size() == 1; + } +} + diff --git a/js/src/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.java b/js/src/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.java new file mode 100644 index 00000000000..a15af6b44ed --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.java @@ -0,0 +1,104 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +import com.google.dart.compiler.backend.js.ast.*; + +/** + * Searches for method invocations in constructor expressions that would not + * normally be surrounded by parentheses. + */ +public class JsConstructExpressionVisitor extends JsVisitor { + + public static boolean exec(JsExpression expression) { + if (JsPrecedenceVisitor.exec(expression) < JsPrecedenceVisitor.PRECEDENCE_NEW) { + return true; + } + JsConstructExpressionVisitor visitor = new JsConstructExpressionVisitor(); + visitor.accept(expression); + return visitor.containsInvocation; + } + + private boolean containsInvocation = false; + + private JsConstructExpressionVisitor() { + } + + /** + * We only look at the array expression since the index has its own scope. + */ + @Override + public boolean visit(JsArrayAccess x, JsContext ctx) { + accept(x.getArrayExpr()); + return false; + } + + /** + * Array literals have their own scoping. + */ + @Override + public boolean visit(JsArrayLiteral x, JsContext ctx) { + return false; + } + + /** + * Functions have their own scoping. + */ + @Override + public boolean visit(JsFunction x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsInvocation x, JsContext ctx) { + containsInvocation = true; + return false; + } + + @Override + public boolean visit(JsNameRef x, JsContext ctx) { + if (!x.isLeaf()) { + accept(x.getQualifier()); + } + return false; + } + + /** + * New constructs bind to the nearest set of parentheses. + */ + @Override + public boolean visit(JsNew x, JsContext ctx) { + return false; + } + + /** + * Object literals have their own scope. + */ + @Override + public boolean visit(JsObjectLiteral x, JsContext ctx) { + return false; + } + + /** + * We only look at nodes that would not normally be surrounded by parentheses. + */ + @Override + protected T doAccept(T node) { + // Assign to Object to prevent 'inconvertible types' toJsAst errors due + // to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6548436 + // reproducible in jdk1.6.0_02. + Object o = node; + if (o instanceof JsExpression) { + JsExpression expression = (JsExpression) o; + int precedence = JsPrecedenceVisitor.exec(expression); + // Only visit expressions that won't automatically be surrounded by + // parentheses + if (precedence < JsPrecedenceVisitor.PRECEDENCE_NEW) { + return node; + } + } + return super.doAccept(node); + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/JsFirstExpressionVisitor.java b/js/src/com/google/dart/compiler/backend/js/JsFirstExpressionVisitor.java new file mode 100644 index 00000000000..0fdb8a5032b --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsFirstExpressionVisitor.java @@ -0,0 +1,119 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +import com.google.dart.compiler.backend.js.ast.*; + +/** + * Determines if an expression statement needs to be surrounded by parentheses. + * + * The statement or the left-most expression needs to be surrounded by + * parentheses if the left-most expression is an object literal or a function + * object. Function declarations do not need parentheses. + * + * For example the following require parentheses:
+ *
    + *
  • { key : 'value'}
  • + *
  • { key : 'value'}.key
  • + *
  • function () {return 1;}()
  • + *
  • function () {return 1;}.prototype
  • + *
+ * + * The following do not require parentheses:
+ *
    + *
  • var x = { key : 'value'}
  • + *
  • "string" + { key : 'value'}.key
  • + *
  • function func() {}
  • + *
  • function() {}
  • + *
+ */ +public class JsFirstExpressionVisitor extends JsVisitor { + + public static boolean exec(JsExprStmt statement) { + JsFirstExpressionVisitor visitor = new JsFirstExpressionVisitor(); + JsExpression expression = statement.getExpression(); + // Pure function declarations do not need parentheses + if (expression instanceof JsFunction) { + return false; + } + visitor.accept(statement.getExpression()); + return visitor.needsParentheses; + } + + private boolean needsParentheses = false; + + private JsFirstExpressionVisitor() { + } + + @Override + public boolean visit(JsArrayAccess x, JsContext ctx) { + accept(x.getArrayExpr()); + return false; + } + + @Override + public boolean visit(JsArrayLiteral x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsBinaryOperation x, JsContext ctx) { + accept(x.getArg1()); + return false; + } + + @Override + public boolean visit(JsConditional x, JsContext ctx) { + accept(x.getTestExpression()); + return false; + } + + @Override + public boolean visit(JsFunction x, JsContext ctx) { + needsParentheses = true; + return false; + } + + @Override + public boolean visit(JsInvocation x, JsContext ctx) { + accept(x.getQualifier()); + return false; + } + + @Override + public boolean visit(JsNameRef x, JsContext ctx) { + if (!x.isLeaf()) { + accept(x.getQualifier()); + } + return false; + } + + @Override + public boolean visit(JsNew x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsObjectLiteral x, JsContext ctx) { + needsParentheses = true; + return false; + } + + @Override + public boolean visit(JsPostfixOperation x, JsContext ctx) { + accept(x.getArg()); + return false; + } + + @Override + public boolean visit(JsPrefixOperation x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsRegExp x, JsContext ctx) { + return false; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/JsNamer.java b/js/src/com/google/dart/compiler/backend/js/JsNamer.java new file mode 100644 index 00000000000..0c49ad05750 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsNamer.java @@ -0,0 +1,23 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +import com.google.dart.compiler.backend.js.ast.JsProgram; + +/** + * A namer runs through a program and renames the short names of JsNames. + * Namers must assign short names that don't clash and that are valid + * JS-identifiers. Nested JsScopes must not shadow JsNames from outer + * scopes. + * If a JsName is marked as non-obfuscatable then it must retain its short + * name. + */ +public interface JsNamer { + /** + * 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/js/src/com/google/dart/compiler/backend/js/JsNormalizer.java b/js/src/com/google/dart/compiler/backend/js/JsNormalizer.java new file mode 100644 index 00000000000..04c5530cd42 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsNormalizer.java @@ -0,0 +1,103 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +import com.google.dart.compiler.backend.js.ast.*; + +/** + * Fixes any semantic errors introduced by JS AST gen. + * + *
    + *
  • Creating clinit calls can put comma expressions as lvalues; the modifying + * operation must be moved inside the comma expression to the last argument.
  • + *
+ */ +public class JsNormalizer { + + /** + * Resolves any unresolved JsNameRefs. + */ + private static class JsNormalizing extends JsModVisitor { + + @Override + public void endVisit(JsBinaryOperation x, JsContext ctx) { + maybeShuffleModifyingBinary(x, ctx); + } + + @Override + public void endVisit(JsPostfixOperation x, JsContext ctx) { + maybeShuffleModifyingUnary(x, ctx); + } + + @Override + public void endVisit(JsPrefixOperation x, JsContext ctx) { + maybeShuffleModifyingUnary(x, ctx); + } + + /** + * Due to the way clinits are constructed, you can end up with a comma + * operation as the argument to a modifying operation, which is illegal. + * Juggle things to put the operator inside of the comma expression. + */ + private void maybeShuffleModifyingBinary(JsBinaryOperation x, JsContext ctx) { + JsBinaryOperator myOp = x.getOperator(); + JsExpression lhs = x.getArg1(); + + if (myOp.isAssignment() && (lhs instanceof JsBinaryOperation)) { + // Find the rightmost comma operation + JsBinaryOperation curLhs = (JsBinaryOperation) lhs; + assert (curLhs.getOperator() == JsBinaryOperator.COMMA); + while (curLhs.getArg2() instanceof JsBinaryOperation) { + curLhs = (JsBinaryOperation) curLhs.getArg2(); + assert (curLhs.getOperator() == JsBinaryOperator.COMMA); + } + // curLhs is now the rightmost comma operation; slide our operation in + x.setArg1(curLhs.getArg2()); + curLhs.setArg2(x); + // replace myself with the comma expression + ctx.replaceMe(lhs); + } + } + + /** + * Due to the way clinits are constructed, you can end up with a comma + * operation as the argument to a modifying operation, which is illegal. + * Juggle things to put the operator inside of the comma expression. + */ + private void maybeShuffleModifyingUnary(JsUnaryOperation x, JsContext ctx) { + JsUnaryOperator myOp = x.getOperator(); + JsExpression arg = x.getArg(); + if (myOp.isModifying() && (arg instanceof JsBinaryOperation)) { + // Find the rightmost comma operation + JsBinaryOperation curArg = (JsBinaryOperation) arg; + assert (curArg.getOperator() == JsBinaryOperator.COMMA); + while (curArg.getArg2() instanceof JsBinaryOperation) { + curArg = (JsBinaryOperation) curArg.getArg2(); + assert (curArg.getOperator() == JsBinaryOperator.COMMA); + } + // curArg is now the rightmost comma operation; slide our operation in + x.setArg(curArg.getArg2()); + curArg.setArg2(x); + // replace myself with the comma expression + ctx.replaceMe(arg); + } + } + } + + public static void exec(JsProgram program) { + new JsNormalizer(program).execImpl(); + } + + private final JsProgram program; + + private JsNormalizer(JsProgram program) { + this.program = program; + } + + private void execImpl() { + JsNormalizing normalizer = new JsNormalizing(); + normalizer.accept(program); + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/JsParserException.java b/js/src/com/google/dart/compiler/backend/js/JsParserException.java new file mode 100644 index 00000000000..79b53c1d69e --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsParserException.java @@ -0,0 +1,92 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +/** + * Indicates inability to parse JavaScript source. + */ +public class JsParserException extends Exception { + + /** + * Represents the location of a parser exception. + */ + public static class SourceDetail { + private final String fileName; + private final int line; + private final int lineOffset; + private final String lineSource; + + public SourceDetail(int line, String lineSource, int lineOffset, String fileName) { + this.line = line; + this.lineSource = lineSource; + this.lineOffset = lineOffset; + this.fileName = fileName; + } + + public String getFileName() { + return fileName; + } + + public int getLine() { + return line; + } + + public int getLineOffset() { + return lineOffset; + } + + public String getLineSource() { + return lineSource; + } + } + + private static String createMessageWithDetail(String msg, SourceDetail sourceDetail) { + if (sourceDetail == null) { + return msg; + } + StringBuffer sb = new StringBuffer(); + sb.append(sourceDetail.getFileName()); + sb.append('('); + sb.append(sourceDetail.getLine()); + sb.append(')'); + sb.append(": "); + sb.append(msg); + if (sourceDetail.getLineSource() != null) { + sb.append("\n> "); + sb.append(sourceDetail.getLineSource()); + sb.append("\n> "); + for (int i = 0, n = sourceDetail.getLineOffset(); i < n; ++i) { + sb.append('-'); + } + sb.append('^'); + } + return sb.toString(); + } + + private final SourceDetail sourceDetail; + + public JsParserException(String msg) { + this(msg, null); + } + + public JsParserException(String msg, int line, String lineSource, int lineOffset, String fileName) { + this(msg, new SourceDetail(line, lineSource, lineOffset, fileName)); + } + + public JsParserException(String msg, SourceDetail sourceDetail) { + super(createMessageWithDetail(msg, sourceDetail)); + this.sourceDetail = sourceDetail; + } + + /** + * Provides additional source detail in some cases. + * + * @return additional detail regarding the error, or null if no + * additional detail is available + */ + public SourceDetail getSourceDetail() { + return sourceDetail; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/JsPrecedenceVisitor.java b/js/src/com/google/dart/compiler/backend/js/JsPrecedenceVisitor.java new file mode 100644 index 00000000000..c3a58b64e22 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsPrecedenceVisitor.java @@ -0,0 +1,274 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +import com.google.dart.compiler.backend.js.ast.*; + +/** + * Precedence indices from "JavaScript - The Definitive Guide" 4th Edition (page + * 57) + * + * Precedence 17 is for indivisible primaries that either don't have children, + * or provide their own delimiters. + * + * Precedence 16 is for really important things that have their own AST classes. + * + * Precedence 15 is for the new construct. + * + * Precedence 14 is for unary operators. + * + * Precedences 12 through 4 are for non-assigning binary operators. + * + * Precedence 3 is for the tertiary conditional. + * + * Precedence 2 is for assignments. + * + * Precedence 1 is for comma operations. + */ +class JsPrecedenceVisitor extends JsVisitor { + + static final int PRECEDENCE_NEW = 15; + + public static int exec(JsExpression expression) { + JsPrecedenceVisitor visitor = new JsPrecedenceVisitor(); + visitor.accept(expression); + if (visitor.answer < 0) { + throw new RuntimeException("Precedence must be >= 0!"); + } + return visitor.answer; + } + + private int answer = -1; + + private JsPrecedenceVisitor() { + } + + @Override + public boolean visit(JsArrayAccess x, JsContext ctx) { + answer = 16; + return false; + } + + @Override + public boolean visit(JsArrayLiteral x, JsContext ctx) { + answer = 17; // primary + return false; + } + + @Override + public boolean visit(JsBinaryOperation x, JsContext ctx) { + answer = x.getOperator().getPrecedence(); + return false; + } + + @Override + public boolean visit(JsBlock x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsBooleanLiteral x, JsContext ctx) { + answer = 17; // primary + return false; + } + + @Override + public boolean visit(JsBreak x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsCase x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsCatch x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsConditional x, JsContext ctx) { + answer = 3; + return false; + } + + @Override + public boolean visit(JsContinue x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsDebugger x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsDefault x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsDoWhile x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsEmpty x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsExprStmt x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsFor x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsForIn x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsFunction x, JsContext ctx) { + answer = 17; // primary + return false; + } + + @Override + public boolean visit(JsIf x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsInvocation x, JsContext ctx) { + answer = 16; + return false; + } + + @Override + public boolean visit(JsLabel x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsNameRef x, JsContext ctx) { + if (x.isLeaf()) { + answer = 17; // primary + } else { + answer = 16; // property access + } + return false; + } + + @Override + public boolean visit(JsNew x, JsContext ctx) { + answer = PRECEDENCE_NEW; + return false; + } + + @Override + public boolean visit(JsNullLiteral x, JsContext ctx) { + answer = 17; // primary + return false; + } + + @Override + public boolean visit(JsNumberLiteral x, JsContext ctx) { + answer = 17; // primary + return false; + } + + @Override + public boolean visit(JsObjectLiteral x, JsContext ctx) { + answer = 17; // primary + return false; + } + + @Override + public boolean visit(JsParameter x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsPostfixOperation x, JsContext ctx) { + answer = x.getOperator().getPrecedence(); + return false; + } + + @Override + public boolean visit(JsPrefixOperation x, JsContext ctx) { + answer = x.getOperator().getPrecedence(); + return false; + } + + @Override + public boolean visit(JsProgram x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsPropertyInitializer x, JsContext ctx) { + answer = 17; // primary + return false; + } + + @Override + public boolean visit(JsRegExp x, JsContext ctx) { + answer = 17; // primary + return false; + } + + @Override + public boolean visit(JsReturn x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsStringLiteral x, JsContext ctx) { + answer = 17; // primary + return false; + } + + @Override + public boolean visit(JsSwitch x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsThisRef x, JsContext ctx) { + answer = 17; // primary + return false; + } + + @Override + public boolean visit(JsThrow x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsTry x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsVars.JsVar x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsVars x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } + + @Override + public boolean visit(JsWhile x, JsContext ctx) { + throw new RuntimeException("Only expressions have precedence."); + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/JsPrettyNamer.java b/js/src/com/google/dart/compiler/backend/js/JsPrettyNamer.java new file mode 100644 index 00000000000..2c61e01f6b3 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsPrettyNamer.java @@ -0,0 +1,122 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +import com.google.dart.compiler.backend.js.ast.JsName; +import com.google.dart.compiler.backend.js.ast.JsProgram; +import com.google.dart.compiler.backend.js.ast.JsRootScope; +import com.google.dart.compiler.backend.js.ast.JsScope; + +import java.util.*; + +/** + * A namer that uses short, readable idents to maximize reability. + */ +public class JsPrettyNamer implements JsNamer { + + public JsPrettyNamer() { + this.program = null; + } + + @Override + public void exec(JsProgram program) { + new JsPrettyNamer(program).execImpl(); + } + + /** + * Communicates to a parent scope all the idents used by all child scopes. + */ + private Set childIdents = null; + + private final JsProgram program; + + /** + * A map containing the next integer to try as an identifier suffix for a + * given JsScope. + */ + private IdentityHashMap> startIdentForScope = + new IdentityHashMap>(); + + protected JsPrettyNamer(JsProgram program) { + this.program = program; + } + + private void execImpl() { + visit(program.getRootScope()); + } + + private boolean isLegal(JsScope scope, Set childIdents, String newIdent) { + if (JsReservedIdentifiers.isKeyword(newIdent)) { + return false; + } + if (childIdents.contains(newIdent)) { + // one of my children already claimed this ident + return false; + } + /* + * Never obfuscate a name into an identifier that conflicts with an existing + * unobfuscatable name! It's okay if it conflicts with an existing + * obfuscatable name; that name will get obfuscated out of the way. + */ + return (scope.findExistingUnobfuscatableName(newIdent) == null); + } + + private void visit(JsScope scope) { + HashMap startIdent = startIdentForScope.get(scope); + if (startIdent == null) { + startIdent = new HashMap(); + startIdentForScope.put(scope, startIdent); + } + + // Save off the childIdents which is currently being computed for my parent. + Set myChildIdents = childIdents; + + /* + * Visit my children first. Reset childIdents so that my children will get a + * clean slate: I do not communicate to my children. + */ + childIdents = new HashSet(); + List children = scope.getChildren(); + for (Iterator it = children.iterator(); it.hasNext();) { + visit(it.next()); + } + + JsRootScope rootScope = program.getRootScope(); + if (scope == rootScope) { + return; + } + + // Visit all my idents. + for (Iterator it = scope.getAllNames(); it.hasNext();) { + JsName name = it.next(); + if (!name.isObfuscatable()) { + // Unobfuscatable names become themselves. + name.setShortIdent(name.getIdent()); + continue; + } + + String newIdent = name.getShortIdent(); + if (!isLegal(scope, childIdents, newIdent)) { + String checkIdent; + + // Start searching using a suffix hint stored in the scope. + // We still do a search in case there is a collision with + // a user-provided identifier + Integer s = startIdent.get(newIdent); + int suffix = (s == null) ? 0 : s.intValue(); + do { + checkIdent = newIdent + "_" + suffix++; + } while (!isLegal(scope, childIdents, checkIdent)); + startIdent.put(newIdent, suffix); + name.setShortIdent(checkIdent); + } else { + // nothing to do; the short name is already good + } + childIdents.add(name.getShortIdent()); + } + myChildIdents.addAll(childIdents); + childIdents = myChildIdents; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/JsRequiresSemiVisitor.java b/js/src/com/google/dart/compiler/backend/js/JsRequiresSemiVisitor.java new file mode 100644 index 00000000000..f4095c5c822 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsRequiresSemiVisitor.java @@ -0,0 +1,140 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +import com.google.dart.compiler.backend.js.ast.*; + +/** + * Determines if a statement at the end of a block requires a semicolon. + * + * For example, the following statements require semicolons:
+ *
    + *
  • if (cond);
  • + *
  • while (cond);
  • + *
+ * + * The following do not require semicolons:
+ *
    + *
  • return 1
  • + *
  • do {} while(true)
  • + *
+ */ +public class JsRequiresSemiVisitor extends JsVisitor { + + public static boolean exec(JsStatement lastStatement) { + JsRequiresSemiVisitor visitor = new JsRequiresSemiVisitor(); + visitor.accept(lastStatement); + return visitor.needsSemicolon; + } + + private boolean needsSemicolon = false; + + private JsRequiresSemiVisitor() { + } + + @Override + public boolean visit(JsBlock x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsBreak x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsDebugger x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsDoWhile x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsEmpty x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsExprStmt x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsFor x, JsContext ctx) { + if (x.getBody() instanceof JsEmpty) { + needsSemicolon = true; + } + return false; + } + + @Override + public boolean visit(JsForIn x, JsContext ctx) { + if (x.getBody() instanceof JsEmpty) { + needsSemicolon = true; + } + return false; + } + + @Override + public boolean visit(JsIf x, JsContext ctx) { + JsStatement thenStmt = x.getThenStmt(); + JsStatement elseStmt = x.getElseStmt(); + JsStatement toCheck = thenStmt; + if (elseStmt != null) { + toCheck = elseStmt; + } + if (toCheck instanceof JsEmpty) { + needsSemicolon = true; + } else { + // Must recurse to determine last statement (possible if-else chain). + accept(toCheck); + } + return false; + } + + @Override + public boolean visit(JsLabel x, JsContext ctx) { + if (x.getStmt() instanceof JsEmpty) { + needsSemicolon = true; + } + return false; + } + + @Override + public boolean visit(JsReturn x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsSwitch x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsThrow x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsTry x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsVars x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsWhile x, JsContext ctx) { + if (x.getBody() instanceof JsEmpty) { + needsSemicolon = true; + } + return false; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/JsReservedIdentifiers.java b/js/src/com/google/dart/compiler/backend/js/JsReservedIdentifiers.java new file mode 100644 index 00000000000..56ae5428a3d --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsReservedIdentifiers.java @@ -0,0 +1,223 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +import java.util.HashSet; +import java.util.Set; + +/** + * Determines whether or not a particular string is a JavaScript keyword or not. + */ +public class JsReservedIdentifiers { + + private static Set javaScriptKeywords; + private static Set reservedGlobalSymbols; + private static Set reservedPropertySymbols; + + static { + javaScriptKeywords = new HashSet(); + reservedGlobalSymbols = new HashSet(); + reservedPropertySymbols = new HashSet(); + initJavaScriptKeywords(); + initReservedGlobalSymbols(); + initReservedPropertySymbols(); + } + + public static boolean isKeyword(String s) { + return javaScriptKeywords.contains(s); + } + + private static void initJavaScriptKeywords() { + String[] keywords = new String[] { + // These are current keywords + "break", "delete", "function", "return", "typeof", "case", "do", "if", "switch", "var", + "catch", "else", "in", "this", "void", "continue", "false", "instanceof", "throw", + "while", "debugger", "finally", "new", "true", "with", "default", "for", + "null", "try", + + // These are future keywords + "abstract", "double", "goto", "native", "static", "boolean", "enum", "implements", + "package", "super", "byte", "export", "import", "private", "synchronized", "char", + "extends", "int", "protected", "throws", "class", "final", "interface", "public", + "transient", "const", "float", "long", "short", "volatile" + }; + + for (int i = 0; i < keywords.length; i++) { + javaScriptKeywords.add(keywords[i]); + } + } + + /** + * @return a set containing all known reserved global identifiers. This set must not be modified. + */ + public static Set getReservedGlobalSymbols() { + return reservedGlobalSymbols; + } + + /** + * Returns true if the string s can not be used as a global identifier. The check includes + * JavaScript keywords (as they must not be used either). + * @param s + * @return true if the given String must not be used as a global identifier. + */ + public static boolean isReservedGlobalSymbol(String s) { + return isKeyword(s) || reservedGlobalSymbols.contains(s); + } + + private static void initReservedGlobalSymbols() { + // Section references are from Ecma-262 + // (http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf) + String[] commonBuiltins = new String[] { + // 15.1.1 Value Properties of the Global Object + "NaN", "Infinity", "undefined", + + // 15.1.2 Function Properties of the Global Object + "eval", "parseInt", "parseFloat", "isNan", "isFinite", + + // 15.1.3 URI Handling Function Properties + "decodeURI", "decodeURIComponent", + "encodeURI", + "encodeURIComponent", + + // 15.1.4 Constructor Properties of the Global Object + "Object", "Function", "Array", "String", "Boolean", "Number", "Date", + "RegExp", "Error", "EvalError", "RangeError", "ReferenceError", + "SyntaxError", "TypeError", "URIError", + + // 15.1.5 Other Properties of the Global Object + "Math", + + // 10.1.6 Activation Object + "arguments", + + // B.2 Additional Properties (non-normative) + "escape", "unescape", + + // Window props (https://developer.mozilla.org/en/DOM/window) + "applicationCache", "closed", "Components", "content", "controllers", + "crypto", "defaultStatus", "dialogArguments", "directories", + "document", "frameElement", "frames", "fullScreen", "globalStorage", + "history", "innerHeight", "innerWidth", "length", + "location", "locationbar", "localStorage", "menubar", + "mozInnerScreenX", "mozInnerScreenY", "mozScreenPixelsPerCssPixel", + "name", "navigator", "opener", "outerHeight", "outerWidth", + "pageXOffset", "pageYOffset", "parent", "personalbar", "pkcs11", + "returnValue", "screen", "scrollbars", "scrollMaxX", "scrollMaxY", + "self", "sessionStorage", "sidebar", "status", "statusbar", "toolbar", + "top", "window", + + // Window methods (https://developer.mozilla.org/en/DOM/window) + "alert", "addEventListener", "atob", "back", "blur", "btoa", + "captureEvents", "clearInterval", "clearTimeout", "close", "confirm", + "disableExternalCapture", "dispatchEvent", "dump", + "enableExternalCapture", "escape", "find", "focus", "forward", + "GeckoActiveXObject", "getAttention", "getAttentionWithCycleCount", + "getComputedStyle", "getSelection", "home", "maximize", "minimize", + "moveBy", "moveTo", "open", "openDialog", "postMessage", "print", + "prompt", "QueryInterface", "releaseEvents", "removeEventListener", + "resizeBy", "resizeTo", "restore", "routeEvent", "scroll", "scrollBy", + "scrollByLines", "scrollByPages", "scrollTo", "setInterval", + "setResizeable", "setTimeout", "showModalDialog", "sizeToContent", + "stop", "uuescape", "updateCommands", "XPCNativeWrapper", + "XPCSafeJSOjbectWrapper", + + // Mozilla Window event handlers, same cite + "onabort", "onbeforeunload", "onchange", "onclick", "onclose", + "oncontextmenu", "ondragdrop", "onerror", "onfocus", "onhashchange", + "onkeydown", "onkeypress", "onkeyup", "onload", "onmousedown", + "onmousemove", "onmouseout", "onmouseover", "onmouseup", + "onmozorientation", "onpaint", "onreset", "onresize", "onscroll", + "onselect", "onsubmit", "onunload", + + // Safari Web Content Guide + // http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/SafariWebContent.pdf + // WebKit Window member data, from WebKit DOM Reference + // (http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/WebKitDOMRef/DOMWindow_idl/Classes/DOMWindow/index.html) + // TODO(fredsa) Many, many more functions and member data to add + "ontouchcancel", "ontouchend", "ontouchmove", "ontouchstart", + "ongesturestart", "ongesturechange", "ongestureend", + + // extra window methods + "uneval", + + // keywords https://developer.mozilla.org/en/New_in_JavaScript_1.7, + // https://developer.mozilla.org/en/New_in_JavaScript_1.8.1 + "getPrototypeOf", "let", "yield", + + // "future reserved words" + "abstract", "int", "short", "boolean", "interface", "static", "byte", + "long", "char", "final", "native", "synchronized", "float", "package", + "throws", "goto", "private", "transient", "implements", "protected", + "volatile", "double", "public", + + // IE methods + // (http://msdn.microsoft.com/en-us/library/ms535873(VS.85).aspx#) + "attachEvent", "clientInformation", "clipboardData", "createPopup", + "dialogHeight", "dialogLeft", "dialogTop", "dialogWidth", + "onafterprint", "onbeforedeactivate", "onbeforeprint", + "oncontrolselect", "ondeactivate", "onhelp", "onresizeend", + + // Common browser-defined identifiers not defined in ECMAScript + "event", "external", "Debug", "Enumerator", "Global", "Image", + "ActiveXObject", "VBArray", "Components", + + // Functions commonly defined on Object + "toString", "getClass", "constructor", "prototype", "valueOf", + + // Client-side JavaScript identifiers, which are needed for linkers + // that don't ensure GWT's window != $wnd, document != $doc, etc. + // Taken from the Rhino book, pg 715 + "Anchor", "Applet", "Attr", "Canvas", "CanvasGradient", + "CanvasPattern", "CanvasRenderingContext2D", "CDATASection", + "CharacterData", "Comment", "CSS2Properties", "CSSRule", + "CSSStyleSheet", "Document", "DocumentFragment", "DocumentType", + "DOMException", "DOMImplementation", "DOMParser", "Element", "Event", + "ExternalInterface", "FlashPlayer", "Form", "Frame", "History", + "HTMLCollection", "HTMLDocument", "HTMLElement", "IFrame", "Image", + "Input", "JSObject", "KeyEvent", "Link", "Location", "MimeType", + "MouseEvent", "Navigator", "Node", "NodeList", "Option", "Plugin", + "ProcessingInstruction", "Range", "RangeException", "Screen", "Select", + "Table", "TableCell", "TableRow", "TableSelection", "Text", "TextArea", + "UIEvent", "Window", "XMLHttpRequest", "XMLSerializer", + "XPathException", "XPathResult", "XSLTProcessor", + + // These keywords trigger the loading of the java-plugin. For the + // next-generation plugin, this results in starting a new Java process. + "java", "Packages", "netscape", "sun", "JavaObject", "JavaClass", + "JavaArray", "JavaMember", + + // GWT-defined identifiers + "$wnd", "$doc", "$entry", "$moduleName", "$moduleBase", "$gwt_version", "$sessionId", + + // Identifiers used by JsStackEmulator; later set to obfuscatable + "$stack", "$stackDepth", "$location", + + // TODO: prove why this is necessary or remove it + "call" + }; + for (int i = 0; i < commonBuiltins.length; i++) { + reservedGlobalSymbols.add(commonBuiltins[i]); + } + } + + /** + * Returns true if the given string can not be used as property symbol. The check excludes + * keywords as JavaScript allow keywords as properties. + * @param s + * @return true if the given string must not be used as a property. + */ + public static boolean isReservedPropertySymbol(String s) { + return reservedPropertySymbols.contains(s); + } + + private static void initReservedPropertySymbols() { + // TODO(floitsch): fill in reserved property symbols. + reservedPropertySymbols.add("__PROTO__"); + reservedPropertySymbols.add("prototype"); + } + + private JsReservedIdentifiers() { + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/JsSourceGenerationVisitor.java b/js/src/com/google/dart/compiler/backend/js/JsSourceGenerationVisitor.java new file mode 100644 index 00000000000..3a2689f65da --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsSourceGenerationVisitor.java @@ -0,0 +1,39 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +import com.google.dart.compiler.util.TextOutput; +import com.google.dart.compiler.backend.js.ast.JsContext; +import com.google.dart.compiler.backend.js.ast.JsProgramFragment; +import com.google.dart.compiler.backend.js.ast.JsBlock; +import com.google.dart.compiler.backend.js.ast.JsProgram; + +/** + * Generates JavaScript source from an AST. + */ +public class JsSourceGenerationVisitor extends JsToStringGenerationVisitor { + + public JsSourceGenerationVisitor(TextOutput out) { + super(out); + } + + @Override + public boolean visit(JsProgram x, JsContext ctx) { + // Descend naturally. + return true; + } + + @Override + public boolean visit(JsProgramFragment x, JsContext ctx) { + // Descend naturally. + return true; + } + + @Override + public boolean visit(JsBlock x, JsContext ctx) { + printJsBlock(x, false, true); + return false; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/JsToStringGenerationVisitor.java b/js/src/com/google/dart/compiler/backend/js/JsToStringGenerationVisitor.java new file mode 100644 index 00000000000..a078eca30ac --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/JsToStringGenerationVisitor.java @@ -0,0 +1,1331 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.TextOutput; + +import java.util.*; +import java.util.regex.Pattern; + +//import com.google.debugging.sourcemap.FilePosition; + +/** + * Produces text output from a JavaScript AST. + */ +public class JsToStringGenerationVisitor extends JsVisitor { + + private static final char[] CHARS_BREAK = "break".toCharArray(); + private static final char[] CHARS_CASE = "case".toCharArray(); + private static final char[] CHARS_CATCH = "catch".toCharArray(); + private static final char[] CHARS_CONTINUE = "continue".toCharArray(); + private static final char[] CHARS_DEBUGGER = "debugger".toCharArray(); + private static final char[] CHARS_DEFAULT = "default".toCharArray(); + private static final char[] CHARS_DO = "do".toCharArray(); + private static final char[] CHARS_ELSE = "else".toCharArray(); + private static final char[] CHARS_FALSE = "false".toCharArray(); + private static final char[] CHARS_FINALLY = "finally".toCharArray(); + private static final char[] CHARS_FOR = "for".toCharArray(); + private static final char[] CHARS_FUNCTION = "function".toCharArray(); + private static final char[] CHARS_IF = "if".toCharArray(); + private static final char[] CHARS_IN = "in".toCharArray(); + private static final char[] CHARS_NEW = "new".toCharArray(); + private static final char[] CHARS_NULL = "null".toCharArray(); + private static final char[] CHARS_RETURN = "return".toCharArray(); + private static final char[] CHARS_SWITCH = "switch".toCharArray(); + private static final char[] CHARS_THIS = "this".toCharArray(); + private static final char[] CHARS_THROW = "throw".toCharArray(); + private static final char[] CHARS_TRUE = "true".toCharArray(); + private static final char[] CHARS_TRY = "try".toCharArray(); + private static final char[] CHARS_VAR = "var".toCharArray(); + private static final char[] CHARS_WHILE = "while".toCharArray(); + private static final char[] HEX_DIGITS = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + + /** + * How many lines of code to print inside of a JsBlock when printing terse. + */ + private static final int JSBLOCK_LINES_TO_PRINT = 3; + + /** + * A variable name is valid if it contains only letters, numbers, _, $ and + * does not begin with a number. There are actually other valid variable + * names, such as ones that contain escaped Unicode characters, but we + * surround those names with quotes in property initializers to be safe. + */ + private static final Pattern VALID_NAME_PATTERN = Pattern.compile("[a-zA-Z_$][\\w$]*"); + + public static String javaScriptString(String value) { + return javaScriptString(value, false); + } + + /** + * Generate JavaScript code that evaluates to the supplied string. Adapted + * from + * . The difference is that we quote with either " or ' depending on + * which one is used less inside the string. + */ + public static String javaScriptString(String value, boolean forceDoubleQuote) { + char[] chars = value.toCharArray(); + final int n = chars.length; + int quoteCount = 0; + int aposCount = 0; + for (int i = 0; i < n; ++i) { + switch (chars[i]) { + case '"': + ++quoteCount; + break; + case '\'': + ++aposCount; + break; + } + } + + StringBuffer result = new StringBuffer(value.length() + 16); + + char quoteChar = (quoteCount < aposCount || forceDoubleQuote) ? '"' : '\''; + result.append(quoteChar); + + for (int i = 0; i < n; ++i) { + char c = chars[i]; + + if (' ' <= c && c <= '~' && c != quoteChar && c != '\\') { + // an ordinary print character (like C isprint()) + result.append(c); + continue; + } + + int escape = -1; + switch (c) { + case '\b': + escape = 'b'; + break; + case '\f': + escape = 'f'; + break; + case '\n': + escape = 'n'; + break; + case '\r': + escape = 'r'; + break; + case '\t': + escape = 't'; + break; + case '"': + escape = '"'; + break; // only reach here if == quoteChar + case '\'': + escape = '\''; + break; // only reach here if == quoteChar + case '\\': + escape = '\\'; + break; + } + + if (escape >= 0) { + // an \escaped sort of character + result.append('\\'); + result.append((char) escape); + } else { + /* + * Emit characters from 0 to 31 that don't have a single character + * escape sequence in octal where possible. This saves one or two + * characters compared to the hexadecimal format '\xXX'. + * + * These short octal sequences may only be used at the end of the string + * or where the following character is a non-digit. Otherwise, the + * following character would be incorrectly interpreted as belonging to + * the sequence. + */ + if (c < ' ' && (i == n - 1 || chars[i + 1] < '0' || chars[i + 1] > '9')) { + result.append('\\'); + if (c > 0x7) { + result.append((char) ('0' + (0x7 & (c >> 3)))); + } + result.append((char) ('0' + (0x7 & c))); + } else { + int hexSize; + if (c < 256) { + // 2-digit hex + result.append("\\x"); + hexSize = 2; + } else { + // Unicode. + result.append("\\u"); + hexSize = 4; + } + // append hexadecimal form of ch left-padded with 0 + for (int shift = (hexSize - 1) * 4; shift >= 0; shift -= 4) { + int digit = 0xf & (c >> shift); + result.append(HEX_DIGITS[digit]); + } + } + } + } + result.append(quoteChar); + escapeClosingTags(result); + String resultString = result.toString(); + return resultString; + } + + /** + * Escapes any closing XML tags embedded in str, which could + * potentially cause a parse failure in a browser, for example, embedding a + * closing <script> tag. + * + * @param str an unescaped literal; May be null + */ + private static void escapeClosingTags(StringBuffer str) { + if (str == null) { + return; + } + + int index = 0; + + while ((index = str.indexOf(" globalBlocks = new HashSet(); + private final TextOutput p; + private ArrayList statementEnds = new ArrayList(); + private ArrayList statementStarts = new ArrayList(); + private boolean buildMappings; + //private List mappings = Lists.newArrayList(); + + public JsToStringGenerationVisitor(TextOutput out) { + this.p = out; + } + + /** + * @param generate Whether to translate the source map. + */ + public void generateSourceMap(boolean generate) { + this.buildMappings = generate; + } + +// public void writeSourceMap(Appendable out, String name) throws IOException { +// GenerateSourceMap generator = new GenerateSourceMap(); +// for (SourceMapping m : mappings) { +// generator.addMapping(m.getNode(), m.getStart(), m.getEnd()); +// } +// generator.appendTo(out, name); +// } + + @Override + public void doTraverse(JsVisitable x, JsContext ctx) { + //SourceMapping m = null; + // TODO(johnlenz): filter out uninteresting node types + if (buildMappings) { + // m = new SourceMapping((HasSourceInfo) x, new FilePosition(p.getLine(), p.getColumn())); + // mappings.add(m); + } + + super.doTraverse(x, ctx); + + if (buildMappings) { + // m.setEnd(new FilePosition(p.getLine(), p.getColumn())); + } + } + + @Override + public boolean visit(JsArrayAccess x, JsContext ctx) { + JsExpression arrayExpr = x.getArrayExpr(); + _parenPush(x, arrayExpr, false); + accept(arrayExpr); + _parenPop(x, arrayExpr, false); + _lsquare(); + accept(x.getIndexExpr()); + _rsquare(); + return false; + } + + @Override + public boolean visit(JsArrayLiteral x, JsContext ctx) { + _lsquare(); + boolean sep = false; + for (Object element : x.getExpressions()) { + JsExpression arg = (JsExpression) element; + sep = _sepCommaOptSpace(sep); + _parenPushIfCommaExpr(arg); + accept(arg); + _parenPopIfCommaExpr(arg); + } + _rsquare(); + return false; + } + + @Override + public boolean visit(JsBinaryOperation x, JsContext ctx) { + JsBinaryOperator op = x.getOperator(); + JsExpression arg1 = x.getArg1(); + _parenPush(x, arg1, !op.isLeftAssociative()); + accept(arg1); + if (op.isKeyword()) { + _parenPopOrSpace(x, arg1, !op.isLeftAssociative()); + } else { + _parenPop(x, arg1, !op.isLeftAssociative()); + _spaceOpt(); + } + p.print(op.getSymbol()); + JsExpression arg2 = x.getArg2(); + if (_spaceCalc(op, arg2)) { + _parenPushOrSpace(x, arg2, op.isLeftAssociative()); + } else { + _spaceOpt(); + _parenPush(x, arg2, op.isLeftAssociative()); + } + accept(arg2); + _parenPop(x, arg2, op.isLeftAssociative()); + return false; + } + + @Override + public boolean visit(JsBlock x, JsContext ctx) { + printJsBlock(x, true, true); + return false; + } + + @Override + public boolean visit(JsBooleanLiteral x, JsContext ctx) { + if (x.getValue()) { + _true(); + } else { + _false(); + } + return false; + } + + @Override + public boolean visit(JsBreak x, JsContext ctx) { + _break(); + + JsNameRef label = x.getLabel(); + if (label != null) { + _space(); + _nameRef(label); + } + + return false; + } + + @Override + public boolean visit(JsCase x, JsContext ctx) { + _case(); + _space(); + accept(x.getCaseExpr()); + _colon(); + _newlineOpt(); + + indent(); + for (Object element : x.getStmts()) { + JsStatement stmt = (JsStatement) element; + needSemi = true; + accept(stmt); + if (needSemi) { + _semi(); + } + _newlineOpt(); + } + outdent(); + needSemi = false; + return false; + } + + @Override + public boolean visit(JsCatch x, JsContext ctx) { + _spaceOpt(); + _catch(); + _spaceOpt(); + _lparen(); + _nameDef(x.getParameter().getName()); + + // Optional catch condition. + // + JsExpression catchCond = x.getCondition(); + if (catchCond != null) { + _space(); + _if(); + _space(); + accept(catchCond); + } + + _rparen(); + _spaceOpt(); + accept(x.getBody()); + + return false; + } + + @Override + public boolean visit(JsConditional x, JsContext ctx) { + // Associativity: for the then and else branches, it is safe to insert + // another + // ternary expression, but if the test expression is a ternary, it should + // get parentheses around it. + { + JsExpression testExpression = x.getTestExpression(); + _parenPush(x, testExpression, true); + accept(testExpression); + _parenPop(x, testExpression, true); + } + _questionMark(); + { + JsExpression thenExpression = x.getThenExpression(); + _parenPush(x, thenExpression, false); + accept(thenExpression); + _parenPop(x, thenExpression, false); + } + _colon(); + { + JsExpression elseExpression = x.getElseExpression(); + _parenPush(x, elseExpression, false); + accept(elseExpression); + _parenPop(x, elseExpression, false); + } + return false; + } + + @Override + public boolean visit(JsContinue x, JsContext ctx) { + _continue(); + + JsNameRef label = x.getLabel(); + if (label != null) { + _space(); + _nameRef(label); + } + + return false; + } + + @Override + public boolean visit(JsDebugger x, JsContext ctx) { + _debugger(); + return false; + } + + @Override + public boolean visit(JsDefault x, JsContext ctx) { + _default(); + _colon(); + + indent(); + for (Object element : x.getStmts()) { + JsStatement stmt = (JsStatement) element; + needSemi = true; + accept(stmt); + if (needSemi) { + _semi(); + } + _newlineOpt(); + } + outdent(); + needSemi = false; + return false; + } + + @Override + public boolean visit(JsDoWhile x, JsContext ctx) { + _do(); + _nestedPush(x.getBody(), true); + accept(x.getBody()); + _nestedPop(x.getBody()); + if (needSemi) { + _semi(); + _newlineOpt(); + } else { + _spaceOpt(); + needSemi = true; + } + _while(); + _spaceOpt(); + _lparen(); + accept(x.getCondition()); + _rparen(); + return false; + } + + @Override + public boolean visit(JsEmpty x, JsContext ctx) { + return false; + } + + @Override + public boolean visit(JsExprStmt x, JsContext ctx) { + boolean surroundWithParentheses = JsFirstExpressionVisitor.exec(x); + if (surroundWithParentheses) { + _lparen(); + } + JsExpression expr = x.getExpression(); + accept(expr); + if (surroundWithParentheses) { + _rparen(); + } + return false; + } + + @Override + public boolean visit(JsFor x, JsContext ctx) { + _for(); + _spaceOpt(); + _lparen(); + + // The init expressions or var decl. + // + if (x.getInitExpr() != null) { + accept(x.getInitExpr()); + } else if (x.getInitVars() != null) { + accept(x.getInitVars()); + } + + _semi(); + + // The loop test. + // + if (x.getCondition() != null) { + _spaceOpt(); + accept(x.getCondition()); + } + + _semi(); + + // The incr expression. + // + if (x.getIncrExpr() != null) { + _spaceOpt(); + accept(x.getIncrExpr()); + } + + _rparen(); + _nestedPush(x.getBody(), false); + accept(x.getBody()); + _nestedPop(x.getBody()); + return false; + } + + @Override + public boolean visit(JsForIn x, JsContext ctx) { + _for(); + _spaceOpt(); + _lparen(); + + if (x.getIterVarName() != null) { + _var(); + _space(); + _nameDef(x.getIterVarName()); + + if (x.getIterExpr() != null) { + _spaceOpt(); + _assignment(); + _spaceOpt(); + accept(x.getIterExpr()); + } + } else { + // Just a name ref. + // + accept(x.getIterExpr()); + } + + _space(); + _in(); + _space(); + accept(x.getObjExpr()); + + _rparen(); + _nestedPush(x.getBody(), false); + accept(x.getBody()); + _nestedPop(x.getBody()); + return false; + } + + // function foo(a, b) { + // stmts... + // } + // + @Override + public boolean visit(JsFunction x, JsContext ctx) { + _function(); + + // Functions can be anonymous. + // + if (x.getName() != null) { + _space(); + _nameOf(x); + } + + _lparen(); + boolean sep = false; + for (Object element : x.getParameters()) { + JsParameter param = (JsParameter) element; + sep = _sepCommaOptSpace(sep); + accept(param); + } + _rparen(); + + accept(x.getBody()); + needSemi = true; + return false; + } + + @Override + public boolean visit(JsIf x, JsContext ctx) { + _if(); + _spaceOpt(); + _lparen(); + accept(x.getIfExpr()); + _rparen(); + JsStatement thenStmt = x.getThenStmt(); + _nestedPush(thenStmt, false); + accept(thenStmt); + _nestedPop(thenStmt); + JsStatement elseStmt = x.getElseStmt(); + if (elseStmt != null) { + if (needSemi) { + _semi(); + _newlineOpt(); + } else { + _spaceOpt(); + needSemi = true; + } + _else(); + boolean elseIf = elseStmt instanceof JsIf; + if (!elseIf) { + _nestedPush(elseStmt, true); + } else { + _space(); + } + accept(elseStmt); + if (!elseIf) { + _nestedPop(elseStmt); + } + } + return false; + } + + @Override + public boolean visit(JsInvocation x, JsContext ctx) { + JsExpression qualifier = x.getQualifier(); + _parenPush(x, qualifier, false); + accept(qualifier); + _parenPop(x, qualifier, false); + + _lparen(); + boolean sep = false; + for (Object element : x.getArguments()) { + JsExpression arg = (JsExpression) element; + sep = _sepCommaOptSpace(sep); + _parenPushIfCommaExpr(arg); + accept(arg); + _parenPopIfCommaExpr(arg); + } + _rparen(); + return false; + } + + @Override + public boolean visit(JsLabel x, JsContext ctx) { + _nameOf(x); + _colon(); + _spaceOpt(); + accept(x.getStmt()); + return false; + } + + @Override + public boolean visit(JsNameRef x, JsContext ctx) { + JsExpression q = x.getQualifier(); + if (q != null) { + _parenPush(x, q, false); + if (q instanceof JsNumberLiteral) { + /** + * Fix for Issue #3796. "42.foo" is not allowed, but "(42).foo" is. + */ + _lparen(); + } + accept(q); + if (q instanceof JsNumberLiteral) { + _rparen(); + } + _parenPop(x, q, false); + _dot(); + } + _nameRef(x); + return false; + } + + @Override + public boolean visit(JsNew x, JsContext ctx) { + _new(); + _space(); + + JsExpression ctorExpr = x.getConstructorExpression(); + boolean needsParens = JsConstructExpressionVisitor.exec(ctorExpr); + if (needsParens) { + _lparen(); + } + accept(ctorExpr); + if (needsParens) { + _rparen(); + } + + /* + * If a constructor call has no arguments, it may simply be replaced with + * "new Constructor" with no parentheses. + */ + List args = x.getArguments(); + if (args.size() > 0) { + _lparen(); + boolean sep = false; + for (JsExpression arg : args) { + sep = _sepCommaOptSpace(sep); + _parenPushIfCommaExpr(arg); + accept(arg); + _parenPopIfCommaExpr(arg); + } + _rparen(); + } + + return false; + } + + @Override + public boolean visit(JsNullLiteral x, JsContext ctx) { + _null(); + return false; + } + + @Override + public boolean visit(JsNumberLiteral x, JsContext ctx) { + double dvalue = x.getValue(); + long lvalue = (long) dvalue; + if (lvalue == dvalue) { + p.print(Long.toString(lvalue)); + } else { + p.print(Double.toString(dvalue)); + } + return false; + } + + @Override + public boolean visit(JsObjectLiteral x, JsContext ctx) { + _lbrace(); + boolean sep = false; + for (Object element : x.getPropertyInitializers()) { + sep = _sepCommaOptSpace(sep); + JsPropertyInitializer propInit = (JsPropertyInitializer) element; + printLabel : { + JsExpression labelExpr = propInit.getLabelExpr(); + // labels can be either string, integral, or decimal literals + if (labelExpr instanceof JsStringLiteral) { + String propName = ((JsStringLiteral) labelExpr).getValue(); + if (VALID_NAME_PATTERN.matcher(propName).matches() + && !JsReservedIdentifiers.isKeyword(propName)) { + p.print(propName); + break printLabel; + } + } + accept(labelExpr); + } + _colon(); + JsExpression valueExpr = propInit.getValueExpr(); + _parenPushIfCommaExpr(valueExpr); + accept(valueExpr); + _parenPopIfCommaExpr(valueExpr); + } + _rbrace(); + return false; + } + + @Override + public boolean visit(JsParameter x, JsContext ctx) { + _nameOf(x); + return false; + } + + @Override + public boolean visit(JsPostfixOperation x, JsContext ctx) { + JsUnaryOperator op = x.getOperator(); + JsExpression arg = x.getArg(); + // unary operators always associate correctly (I think) + _parenPush(x, arg, false); + accept(arg); + _parenPop(x, arg, false); + p.print(op.getSymbol()); + return false; + } + + @Override + public boolean visit(JsPrefixOperation x, JsContext ctx) { + JsUnaryOperator op = x.getOperator(); + p.print(op.getSymbol()); + JsExpression arg = x.getArg(); + if (_spaceCalc(op, arg)) { + _space(); + } + // unary operators always associate correctly (I think) + _parenPush(x, arg, false); + accept(arg); + _parenPop(x, arg, false); + return false; + } + + @Override + public boolean visit(JsProgram x, JsContext ctx) { + p.print(""); + return false; + } + + @Override + public boolean visit(JsProgramFragment x, JsContext ctx) { + p.print(""); + return false; + } + + @Override + public boolean visit(JsPropertyInitializer x, JsContext ctx) { + // Since there are separators, we actually print the property init + // in visit(JsObjectLiteral). + // + return false; + } + + @Override + public boolean visit(JsRegExp x, JsContext ctx) { + _slash(); + p.print(x.getPattern()); + _slash(); + String flags = x.getFlags(); + if (flags != null) { + p.print(flags); + } + return false; + } + + @Override + public boolean visit(JsReturn x, JsContext ctx) { + _return(); + JsExpression expr = x.getExpr(); + if (expr != null) { + _space(); + accept(expr); + } + return false; + } + + @Override + public boolean visit(JsStringLiteral x, JsContext ctx) { + printStringLiteral(x.getValue()); + return false; + } + + @Override + public boolean visit(JsSwitch x, JsContext ctx) { + _switch(); + _spaceOpt(); + _lparen(); + accept(x.getExpr()); + _rparen(); + _spaceOpt(); + _blockOpen(); + acceptList(x.getCases()); + _blockClose(); + return false; + } + + @Override + public boolean visit(JsThisRef x, JsContext ctx) { + _this(); + return false; + } + + @Override + public boolean visit(JsThrow x, JsContext ctx) { + _throw(); + _space(); + accept(x.getExpr()); + return false; + } + + @Override + public boolean visit(JsTry x, JsContext ctx) { + _try(); + _spaceOpt(); + accept(x.getTryBlock()); + + acceptList(x.getCatches()); + + JsBlock finallyBlock = x.getFinallyBlock(); + if (finallyBlock != null) { + _spaceOpt(); + _finally(); + _spaceOpt(); + accept(finallyBlock); + } + + return false; + } + + @Override + public boolean visit(JsVars.JsVar x, JsContext ctx) { + _nameOf(x); + JsExpression initExpr = x.getInitExpr(); + if (initExpr != null) { + _spaceOpt(); + _assignment(); + _spaceOpt(); + _parenPushIfCommaExpr(initExpr); + accept(initExpr); + _parenPopIfCommaExpr(initExpr); + } + return false; + } + + @Override + public boolean visit(JsVars x, JsContext ctx) { + _var(); + _space(); + boolean sep = false; + for (JsVars.JsVar var : x) { + sep = _sepCommaOptSpace(sep); + accept(var); + } + return false; + } + + @Override + public boolean visit(JsWhile x, JsContext ctx) { + _while(); + _spaceOpt(); + _lparen(); + accept(x.getCondition()); + _rparen(); + _nestedPush(x.getBody(), false); + accept(x.getBody()); + _nestedPop(x.getBody()); + return false; + } + + // CHECKSTYLE_NAMING_OFF + protected void _newline() { + p.newline(); + } + + protected void _newlineOpt() { + p.newlineOpt(); + } + + protected void printJsBlock(JsBlock x, boolean truncate, boolean finalNewline) { + boolean needBraces = !x.isGlobalBlock(); + + if (needBraces) { + // Open braces. + // + _blockOpen(); + } + + int count = 0; + for (Iterator iter = x.getStatements().iterator(); iter.hasNext(); ++count) { + boolean isGlobal = x.isGlobalBlock() || globalBlocks.contains(x); + + if (truncate && count > JSBLOCK_LINES_TO_PRINT) { + p.print("[...]"); + _newlineOpt(); + break; + } + JsStatement stmt = iter.next(); + needSemi = true; + boolean shouldRecordPositions = isGlobal && !(stmt instanceof JsBlock); + boolean stmtIsGlobalBlock = false; + if (isGlobal) { + if (stmt instanceof JsBlock) { + // A block inside a global block is still considered global + stmtIsGlobalBlock = true; + globalBlocks.add((JsBlock) stmt); + } + } + if (shouldRecordPositions) { + statementStarts.add(p.getPosition()); + } + accept(stmt); + if (stmtIsGlobalBlock) { + globalBlocks.remove(stmt); + } + if (needSemi) { + /* + * Special treatment of function decls: If they are the only item in a + * statement (i.e. not part of an assignment operation), just give them + * a newline instead of a semi. + */ + boolean functionStmt = + stmt instanceof JsExprStmt && ((JsExprStmt) stmt).getExpression() instanceof JsFunction; + /* + * Special treatment of the last statement in a block: only a few + * statements at the end of a block require semicolons. + */ + boolean lastStatement = !iter.hasNext() && needBraces && !JsRequiresSemiVisitor.exec(stmt); + if (functionStmt) { + if (lastStatement) { + _newlineOpt(); + } else { + _newline(); + } + } else { + if (lastStatement) { + _semiOpt(); + } else { + _semi(); + } + _newlineOpt(); + } + } + if (shouldRecordPositions) { + assert (statementStarts.size() == statementEnds.size() + 1); + statementEnds.add(p.getPosition()); + } + } + + if (needBraces) { + // _blockClose() modified + p.indentOut(); + p.print('}'); + if (finalNewline) { + _newlineOpt(); + } + } + needSemi = false; + } + + private void _assignment() { + p.print('='); + } + + private void _blockClose() { + p.indentOut(); + p.print('}'); + _newlineOpt(); + } + + private void _blockOpen() { + p.print('{'); + p.indentIn(); + _newlineOpt(); + } + + private void _break() { + p.print(CHARS_BREAK); + } + + private void _case() { + p.print(CHARS_CASE); + } + + private void _catch() { + p.print(CHARS_CATCH); + } + + private void _colon() { + p.print(':'); + } + + private void _continue() { + p.print(CHARS_CONTINUE); + } + + private void _debugger() { + p.print(CHARS_DEBUGGER); + } + + private void _default() { + p.print(CHARS_DEFAULT); + } + + private void _do() { + p.print(CHARS_DO); + } + + private void _dot() { + p.print('.'); + } + + private void _else() { + p.print(CHARS_ELSE); + } + + private void _false() { + p.print(CHARS_FALSE); + } + + private void _finally() { + p.print(CHARS_FINALLY); + } + + private void _for() { + p.print(CHARS_FOR); + } + + private void _function() { + p.print(CHARS_FUNCTION); + } + + private void _if() { + p.print(CHARS_IF); + } + + private void _in() { + p.print(CHARS_IN); + } + + private void _lbrace() { + p.print('{'); + } + + private void _lparen() { + p.print('('); + } + + private void _lsquare() { + p.print('['); + } + + private void _nameDef(JsName name) { + p.print(name.getShortIdent()); + } + + private void _nameOf(HasName hasName) { + _nameDef(hasName.getName()); + } + + private void _nameRef(JsNameRef nameRef) { + p.print(nameRef.getShortIdent()); + } + + private boolean _nestedPop(JsStatement statement) { + boolean pop = !(statement instanceof JsBlock); + if (pop) { + p.indentOut(); + } + return pop; + } + + private boolean _nestedPush(JsStatement statement, boolean needSpace) { + boolean push = !(statement instanceof JsBlock); + if (push) { + if (needSpace) { + _space(); + } + p.indentIn(); + _newlineOpt(); + } else { + _spaceOpt(); + } + return push; + } + + private void _new() { + p.print(CHARS_NEW); + } + + private void _null() { + p.print(CHARS_NULL); + } + + private boolean _parenCalc(JsExpression parent, JsExpression child, boolean wrongAssoc) { + int parentPrec = JsPrecedenceVisitor.exec(parent); + int childPrec = JsPrecedenceVisitor.exec(child); + return (parentPrec > childPrec || (parentPrec == childPrec && wrongAssoc)); + } + + private boolean _parenPop(JsExpression parent, JsExpression child, boolean wrongAssoc) { + boolean doPop = _parenCalc(parent, child, wrongAssoc); + if (doPop) { + _rparen(); + } + return doPop; + } + + private boolean _parenPopIfCommaExpr(JsExpression x) { + boolean doPop = + x instanceof JsBinaryOperation + && ((JsBinaryOperation) x).getOperator() == JsBinaryOperator.COMMA; + if (doPop) { + _rparen(); + } + return doPop; + } + + private boolean _parenPopOrSpace(JsExpression parent, JsExpression child, boolean wrongAssoc) { + boolean doPop = _parenCalc(parent, child, wrongAssoc); + if (doPop) { + _rparen(); + } else { + _space(); + } + return doPop; + } + + private boolean _parenPush(JsExpression parent, JsExpression child, boolean wrongAssoc) { + boolean doPush = _parenCalc(parent, child, wrongAssoc); + if (doPush) { + _lparen(); + } + return doPush; + } + + private boolean _parenPushIfCommaExpr(JsExpression x) { + boolean doPush = + x instanceof JsBinaryOperation + && ((JsBinaryOperation) x).getOperator() == JsBinaryOperator.COMMA; + if (doPush) { + _lparen(); + } + return doPush; + } + + private boolean _parenPushOrSpace(JsExpression parent, JsExpression child, boolean wrongAssoc) { + boolean doPush = _parenCalc(parent, child, wrongAssoc); + if (doPush) { + _lparen(); + } else { + _space(); + } + return doPush; + } + + private void _questionMark() { + p.print('?'); + } + + private void _rbrace() { + p.print('}'); + } + + private void _return() { + p.print(CHARS_RETURN); + } + + private void _rparen() { + p.print(')'); + } + + private void _rsquare() { + p.print(']'); + } + + private void _semi() { + p.print(';'); + } + + private void _semiOpt() { + p.printOpt(';'); + } + + private boolean _sepCommaOptSpace(boolean sep) { + if (sep) { + p.print(','); + _spaceOpt(); + } + return true; + } + + private void _slash() { + p.print('/'); + } + + private void _space() { + p.print(' '); + } + + /** + * Decide whether, if op is printed followed by arg, + * there needs to be a space between the operator and expression. + * + * @return true if a space needs to be printed + */ + private boolean _spaceCalc(JsOperator op, JsExpression arg) { + if (op.isKeyword()) { + return true; + } + if (arg instanceof JsBinaryOperation) { + JsBinaryOperation binary = (JsBinaryOperation) arg; + /* + * If the binary operation has a higher precedence than op, then it won't + * be parenthesized, so check the first argument of the binary operation. + */ + if (binary.getOperator().getPrecedence() > op.getPrecedence()) { + return _spaceCalc(op, binary.getArg1()); + } + return false; + } + if (arg instanceof JsPrefixOperation) { + JsOperator op2 = ((JsPrefixOperation) arg).getOperator(); + return (op == JsBinaryOperator.SUB || op == JsUnaryOperator.NEG) + && (op2 == JsUnaryOperator.DEC || op2 == JsUnaryOperator.NEG) + || (op == JsBinaryOperator.ADD && op2 == JsUnaryOperator.INC); + } + if (arg instanceof JsNumberLiteral) { + JsNumberLiteral literal = (JsNumberLiteral) arg; + return (op == JsBinaryOperator.SUB || op == JsUnaryOperator.NEG) && (literal.getValue() < 0); + } + return false; + } + + private void _spaceOpt() { + p.printOpt(' '); + } + + private void _switch() { + p.print(CHARS_SWITCH); + } + + private void _this() { + p.print(CHARS_THIS); + } + + private void _throw() { + p.print(CHARS_THROW); + } + + private void _true() { + p.print(CHARS_TRUE); + } + + private void _try() { + p.print(CHARS_TRY); + } + + private void _var() { + p.print(CHARS_VAR); + } + + private void _while() { + p.print(CHARS_WHILE); + } + + // CHECKSTYLE_NAMING_ON + + private void indent() { + p.indentIn(); + } + + private void outdent() { + p.indentOut(); + } + + private void printStringLiteral(String value) { + String resultString = javaScriptString(value); + p.print(resultString); + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/UncheckedJsParserException.java b/js/src/com/google/dart/compiler/backend/js/UncheckedJsParserException.java new file mode 100644 index 00000000000..c2db8120537 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/UncheckedJsParserException.java @@ -0,0 +1,21 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js; + +/** + * An unchecked wrapper exception to interop with Rhino. + */ +class UncheckedJsParserException extends RuntimeException { + + private final JsParserException parserException; + + public UncheckedJsParserException(JsParserException parserException) { + this.parserException = parserException; + } + + public JsParserException getParserException() { + return parserException; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/CanBooleanEval.java b/js/src/com/google/dart/compiler/backend/js/ast/CanBooleanEval.java new file mode 100644 index 00000000000..8f4364d94f2 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/CanBooleanEval.java @@ -0,0 +1,15 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * An interface that describes the boolean evaluation of an expression. + */ +public interface CanBooleanEval { + + boolean isBooleanFalse(); + + boolean isBooleanTrue(); +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/HasArguments.java b/js/src/com/google/dart/compiler/backend/js/ast/HasArguments.java new file mode 100644 index 00000000000..5a47c567606 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/HasArguments.java @@ -0,0 +1,14 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.List; + +/** + * Implemented by JavaScript objects that accept arguments. + */ +public interface HasArguments { + List getArguments(); +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/HasCondition.java b/js/src/com/google/dart/compiler/backend/js/ast/HasCondition.java new file mode 100644 index 00000000000..082f4e15eb3 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/HasCondition.java @@ -0,0 +1,15 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Implemented by JavaScript objects with conditional execution. + */ +public interface HasCondition { + + JsExpression getCondition(); + + void setCondition(JsExpression condition); +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/HasName.java b/js/src/com/google/dart/compiler/backend/js/ast/HasName.java new file mode 100644 index 00000000000..8daed3769f4 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/HasName.java @@ -0,0 +1,12 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Implemented by JavaScript objects that have a name. + */ +public interface HasName { + JsName getName(); +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsArrayAccess.java b/js/src/com/google/dart/compiler/backend/js/ast/JsArrayAccess.java new file mode 100644 index 00000000000..46df5108086 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsArrayAccess.java @@ -0,0 +1,68 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a javascript expression for array access. + */ +public final class JsArrayAccess extends JsExpression { + + private JsExpression arrayExpr; + private JsExpression indexExpr; + + public JsArrayAccess() { + super(); + } + + public JsArrayAccess(JsExpression arrayExpr, JsExpression indexExpr) { + this.arrayExpr = arrayExpr; + this.indexExpr = indexExpr; + } + + public JsExpression getArrayExpr() { + return arrayExpr; + } + + public JsExpression getIndexExpr() { + return indexExpr; + } + + @Override + public boolean hasSideEffects() { + return arrayExpr.hasSideEffects() || indexExpr.hasSideEffects(); + } + + @Override + public boolean isDefinitelyNotNull() { + return false; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + public void setArrayExpr(JsExpression arrayExpr) { + this.arrayExpr = arrayExpr; + } + + public void setIndexExpr(JsExpression indexExpr) { + this.indexExpr = indexExpr; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + arrayExpr = v.accept(arrayExpr); + indexExpr = v.accept(indexExpr); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.ARRAY_ACCESS; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsArrayLiteral.java b/js/src/com/google/dart/compiler/backend/js/ast/JsArrayLiteral.java new file mode 100644 index 00000000000..8cb9f7e6d52 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsArrayLiteral.java @@ -0,0 +1,67 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a JavaScript expression for array literals. + */ +public final class JsArrayLiteral extends JsLiteral { + + private final List exprs = new ArrayList(); + + public JsArrayLiteral() { + super(); + } + + public List getExpressions() { + return exprs; + } + + @Override + public boolean hasSideEffects() { + for (JsExpression expr : exprs) { + if (expr.hasSideEffects()) { + return true; + } + } + return false; + } + + @Override + public boolean isBooleanFalse() { + return false; + } + + @Override + public boolean isBooleanTrue() { + return true; + } + + @Override + public boolean isDefinitelyNotNull() { + return true; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + v.acceptWithInsertRemove(exprs); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.ARRAY; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsBinaryOperation.java b/js/src/com/google/dart/compiler/backend/js/ast/JsBinaryOperation.java new file mode 100644 index 00000000000..b09d50c1d05 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsBinaryOperation.java @@ -0,0 +1,107 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript binary operation. + */ +public final class JsBinaryOperation extends JsExpression { + + private JsExpression arg1; + private JsExpression arg2; + private final JsBinaryOperator op; + + public JsBinaryOperation(JsBinaryOperator op) { + this(op, null, null); + } + + public JsBinaryOperation(JsBinaryOperator op, JsExpression arg1, JsExpression arg2) { + this.op = op; + this.arg1 = arg1; + this.arg2 = arg2; + } + + public JsExpression getArg1() { + return arg1; + } + + public JsExpression getArg2() { + return arg2; + } + + public JsBinaryOperator getOperator() { + return op; + } + + @Override + public boolean hasSideEffects() { + return op.isAssignment() || arg1.hasSideEffects() || arg2.hasSideEffects(); + } + + @Override + public boolean isDefinitelyNotNull() { + // Precarious coding, but none of these can have null results. + if (op.getPrecedence() > 5) { + return true; + } + if (op == JsBinaryOperator.OR) { + if (arg1 instanceof CanBooleanEval) { + if (((CanBooleanEval) arg1).isBooleanTrue()) { + assert arg1.isDefinitelyNotNull(); + return true; + } + } + } + // AND and OR can return nulls + if (op.isAssignment()) { + if (op == JsBinaryOperator.ASG) { + return arg2.isDefinitelyNotNull(); + } else { + // All other ASG's are math ops. + return true; + } + } + + if (op == JsBinaryOperator.COMMA) { + return arg2.isDefinitelyNotNull(); + } + + return false; + } + + @Override + public boolean isDefinitelyNull() { + if (op == JsBinaryOperator.AND) { + return arg1.isDefinitelyNull(); + } + return false; + } + + public void setArg1(JsExpression arg1) { + this.arg1 = arg1; + } + + public void setArg2(JsExpression arg2) { + this.arg2 = arg2; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + if (op.isAssignment()) { + arg1 = v.acceptLvalue(arg1); + } else { + arg1 = v.accept(arg1); + } + arg2 = v.accept(arg2); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.BINARY_OP; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsBinaryOperator.java b/js/src/com/google/dart/compiler/backend/js/ast/JsBinaryOperator.java new file mode 100644 index 00000000000..b54647f3a46 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsBinaryOperator.java @@ -0,0 +1,120 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents the operator in a JavaScript binary operation. + */ +public enum JsBinaryOperator implements JsOperator { + + /* + * Precedence indices from "JavaScript - The Definitive Guide" 4th Edition + * (page 57) + * + * + * Precedence 15 is for really important things that have their own AST + * classes. + * + * Precedence 14 is for unary operators. + */ + + MUL("*", 13, LEFT | INFIX), DIV("/", 13, LEFT | INFIX), MOD("%", 13, LEFT + | INFIX), + + ADD("+", 12, LEFT | INFIX), SUB("-", 12, LEFT | INFIX), + + SHL("<<", 11, LEFT | INFIX), SHR(">>", 11, LEFT | INFIX), SHRU(">>>", 11, + LEFT | INFIX), + + LT("<", 10, LEFT | INFIX), LTE("<=", 10, LEFT | INFIX), GT(">", 10, LEFT + | INFIX), GTE(">=", 10, LEFT | INFIX), INSTANCEOF("instanceof", 10, LEFT + | INFIX), INOP("in", 10, LEFT | INFIX), + + EQ("==", 9, LEFT | INFIX), NEQ("!=", 9, LEFT | INFIX), REF_EQ("===", 9, LEFT + | INFIX), REF_NEQ("!==", 9, LEFT | INFIX), + + BIT_AND("&", 8, LEFT | INFIX), + + BIT_XOR("^", 7, LEFT | INFIX), + + BIT_OR("|", 6, LEFT | INFIX), + + AND("&&", 5, LEFT | INFIX), + + OR("||", 4, LEFT | INFIX), + + // Precedence 3 is for the condition operator. + + // These assignment operators are right-associative. + ASG("=", 2, INFIX), ASG_ADD("+=", 2, INFIX), ASG_SUB("-=", 2, INFIX), ASG_MUL( + "*=", 2, INFIX), ASG_DIV("/=", 2, INFIX), ASG_MOD("%=", 2, INFIX), ASG_SHL( + "<<=", 2, INFIX), ASG_SHR(">>=", 2, INFIX), ASG_SHRU(">>>=", 2, INFIX), ASG_BIT_AND( + "&=", 2, INFIX), ASG_BIT_OR("|=", 2, INFIX), ASG_BIT_XOR("^=", 2, INFIX), + + COMMA(",", 1, LEFT | INFIX); + + private final int mask; + private final int precedence; + private final String symbol; + + private JsBinaryOperator(String symbol, int precedence, int mask) { + this.symbol = symbol; + this.precedence = precedence; + this.mask = mask; + } + + @Override + public int getPrecedence() { + return precedence; + } + + @Override + public String getSymbol() { + return symbol; + } + + public boolean isAssignment() { + /* + * Beware, flaky! Maybe I should have added Yet Another Field to + * BinaryOperator? + */ + return (getPrecedence() == ASG.getPrecedence()); + } + + @Override + public boolean isKeyword() { + return this == INSTANCEOF || this == INOP; + } + + @Override + public boolean isLeftAssociative() { + return (mask & LEFT) != 0; + } + + @Override + public boolean isPrecedenceLessThan(JsOperator other) { + return precedence < other.getPrecedence(); + } + + @Override + public boolean isValidInfix() { + return (mask & INFIX) != 0; + } + + @Override + public boolean isValidPostfix() { + return (mask & POSTFIX) != 0; + } + + @Override + public boolean isValidPrefix() { + return (mask & PREFIX) != 0; + } + + @Override + public String toString() { + return symbol; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsBlock.java b/js/src/com/google/dart/compiler/backend/js/ast/JsBlock.java new file mode 100644 index 00000000000..fca607c4eb4 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsBlock.java @@ -0,0 +1,60 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.LinkedList; +import java.util.List; + +/** + * Represents a JavaScript block statement. + */ +public class JsBlock extends JsStatement { + + private final LinkedList stmts = new LinkedList(); + + public JsBlock() { + } + + public JsBlock(JsStatement stmt) { + stmts.add(stmt); + } + + public List getStatements() { + return stmts; + } + + public void addStatement(JsStatement statement) { + assert statement != null; + stmts.add(statement); + } + + public boolean isGlobalBlock() { + return false; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + v.acceptWithInsertRemove(stmts); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.BLOCK; + } + + /*Pavel Talanov*/ + public void addVarDeclaration(JsVars vars) { + stmts.offerFirst(vars); + } + + public void setStatements(List statements) { + assert this.stmts.isEmpty() : "Already contains statements."; + this.stmts.addAll(statements); + } + +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsBooleanLiteral.java b/js/src/com/google/dart/compiler/backend/js/ast/JsBooleanLiteral.java new file mode 100644 index 00000000000..12238ddbb02 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsBooleanLiteral.java @@ -0,0 +1,53 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript literal boolean expression. + */ +public final class JsBooleanLiteral extends JsValueLiteral { + + private final boolean value; + + // Should be interned by JsProgram + JsBooleanLiteral(boolean value) { + this.value = value; + } + + public boolean getValue() { + return value; + } + + @Override + public boolean isBooleanFalse() { + return value == false; + } + + @Override + public boolean isBooleanTrue() { + return value == true; + } + + @Override + public boolean isDefinitelyNotNull() { + return true; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + v.visit(this, ctx); + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.BOOLEAN; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsBreak.java b/js/src/com/google/dart/compiler/backend/js/ast/JsBreak.java new file mode 100644 index 00000000000..363f294df78 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsBreak.java @@ -0,0 +1,46 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents the JavaScript break statement. + */ +public final class JsBreak extends JsStatement { + + private final JsNameRef label; + + public JsBreak() { + this(null); + } + + public JsBreak(JsNameRef label) { + super(); + this.label = label; + } + + public JsNameRef getLabel() { + return label; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + if (label != null) { + v.accept(label); + } + } + v.endVisit(this, ctx); + } + + @Override + public boolean unconditionalControlBreak() { + return true; + } + + @Override + public NodeKind getKind() { + return NodeKind.BREAK; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsCase.java b/js/src/com/google/dart/compiler/backend/js/ast/JsCase.java new file mode 100644 index 00000000000..43d2fc41230 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsCase.java @@ -0,0 +1,39 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents the JavaScript case statement. + */ +public final class JsCase extends JsSwitchMember { + + private JsExpression caseExpr; + + public JsCase() { + super(); + } + + public JsExpression getCaseExpr() { + return caseExpr; + } + + public void setCaseExpr(JsExpression caseExpr) { + this.caseExpr = caseExpr; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + caseExpr = v.accept(caseExpr); + v.acceptWithInsertRemove(stmts); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.CASE; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsCatch.java b/js/src/com/google/dart/compiler/backend/js/ast/JsCatch.java new file mode 100644 index 00000000000..f992545b944 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsCatch.java @@ -0,0 +1,66 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript catch clause. + */ +public class JsCatch extends JsNode implements HasCondition { + + protected final JsCatchScope scope; + private JsBlock body; + private JsExpression condition; + private JsParameter param; + + public JsCatch(JsScope parent, String ident) { + super(); + assert (parent != null); + scope = new JsCatchScope(parent, ident); + param = new JsParameter(scope.findExistingName(ident)); + } + + public JsBlock getBody() { + return body; + } + + @Override + public JsExpression getCondition() { + return condition; + } + + public JsParameter getParameter() { + return param; + } + + public JsScope getScope() { + return scope; + } + + public void setBody(JsBlock body) { + this.body = body; + } + + @Override + public void setCondition(JsExpression condition) { + this.condition = condition; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + param = v.accept(param); + if (condition != null) { + condition = v.accept(condition); + } + body = v.accept(body); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.CATCH; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsCatchScope.java b/js/src/com/google/dart/compiler/backend/js/ast/JsCatchScope.java new file mode 100644 index 00000000000..5e5a2f2f577 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsCatchScope.java @@ -0,0 +1,75 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.Iterator; +import java.util.NoSuchElementException; + +/** + * A special scope used only for catch blocks. It only holds a single symbol: + * the catch argument's name. + */ +public class JsCatchScope extends JsScope { + + private final JsName name; + + public JsCatchScope(JsScope parent, String ident) { + super(parent, "Catch scope"); + this.name = new JsName(this, ident, ident, ident); + } + + @Override + public JsName declareName(String ident) { + // Declare into parent scope! + return getParent().declareName(ident); + } + + @Override + public JsName declareName(String ident, String shortIdent) { + // Declare into parent scope! + return getParent().declareName(ident, shortIdent); + } + + @Override + public Iterator getAllNames() { + return new Iterator() { + private boolean didIterate = false; + + @Override + public boolean hasNext() { + return !didIterate; + } + + @Override + public JsName next() { + if (didIterate) { + throw new NoSuchElementException(); + } + didIterate = true; + return name; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + }; + } + + @Override + protected JsName doCreateName(String ident, String shortIdent, String originalName) { + throw new UnsupportedOperationException("Cannot create a name in a catch scope"); + } + + @Override + public JsName findExistingNameNoRecurse(String ident) { + if (name.getIdent().equals(ident)) { + return name; + } else { + return null; + } + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsConditional.java b/js/src/com/google/dart/compiler/backend/js/ast/JsConditional.java new file mode 100644 index 00000000000..b1171bac2c0 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsConditional.java @@ -0,0 +1,78 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript conditional expression. + */ +public final class JsConditional extends JsExpression { + + private JsExpression elseExpr; + private JsExpression testExpr; + private JsExpression thenExpr; + + public JsConditional() { + } + + public JsConditional(JsExpression testExpr, JsExpression thenExpr, JsExpression elseExpr) { + this.testExpr = testExpr; + this.thenExpr = thenExpr; + this.elseExpr = elseExpr; + } + + public JsExpression getElseExpression() { + return elseExpr; + } + + public JsExpression getTestExpression() { + return testExpr; + } + + public JsExpression getThenExpression() { + return thenExpr; + } + + @Override + public boolean hasSideEffects() { + return testExpr.hasSideEffects() || thenExpr.hasSideEffects() || elseExpr.hasSideEffects(); + } + + @Override + public boolean isDefinitelyNotNull() { + return thenExpr.isDefinitelyNotNull() && elseExpr.isDefinitelyNotNull(); + } + + @Override + public boolean isDefinitelyNull() { + return thenExpr.isDefinitelyNull() && elseExpr.isDefinitelyNull(); + } + + public void setElseExpression(JsExpression elseExpr) { + this.elseExpr = elseExpr; + } + + public void setTestExpression(JsExpression testExpr) { + this.testExpr = testExpr; + } + + public void setThenExpression(JsExpression thenExpr) { + this.thenExpr = thenExpr; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + testExpr = v.accept(testExpr); + thenExpr = v.accept(thenExpr); + elseExpr = v.accept(elseExpr); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.CONDITIONAL; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsContext.java b/js/src/com/google/dart/compiler/backend/js/ast/JsContext.java new file mode 100644 index 00000000000..ddb170052d3 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsContext.java @@ -0,0 +1,27 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * The context in which a JsNode visitation occurs. This represents the set of + * possible operations a JsVisitor subclass can perform on the currently visited + * node. + */ +public interface JsContext { + + boolean canInsert(); + + boolean canRemove(); + + void insertAfter(JsVisitable node); + + void insertBefore(JsVisitable node); + + boolean isLvalue(); + + void removeMe(); + + void replaceMe(JsVisitable node); +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsContinue.java b/js/src/com/google/dart/compiler/backend/js/ast/JsContinue.java new file mode 100644 index 00000000000..d761815fe76 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsContinue.java @@ -0,0 +1,46 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents the JavaScript continue statement. + */ +public final class JsContinue extends JsStatement { + + private final JsNameRef label; + + public JsContinue() { + this(null); + } + + public JsContinue(JsNameRef label) { + super(); + this.label = label; + } + + public JsNameRef getLabel() { + return label; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + if (label != null) { + v.accept(label); + } + } + v.endVisit(this, ctx); + } + + @Override + public boolean unconditionalControlBreak() { + return true; + } + + @Override + public NodeKind getKind() { + return NodeKind.CONTINUE; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsDebugger.java b/js/src/com/google/dart/compiler/backend/js/ast/JsDebugger.java new file mode 100644 index 00000000000..34cfae43f48 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsDebugger.java @@ -0,0 +1,25 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript debugger statement. + */ +public class JsDebugger extends JsStatement { + + public JsDebugger() { + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + v.visit(this, ctx); + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.DEBUGGER; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsDefault.java b/js/src/com/google/dart/compiler/backend/js/ast/JsDefault.java new file mode 100644 index 00000000000..a76987a8e5d --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsDefault.java @@ -0,0 +1,28 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents the default option in a JavaScript swtich statement. + */ +public final class JsDefault extends JsSwitchMember { + + public JsDefault() { + super(); + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + v.acceptWithInsertRemove(stmts); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.DEFAULT; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsDoWhile.java b/js/src/com/google/dart/compiler/backend/js/ast/JsDoWhile.java new file mode 100644 index 00000000000..1dd4a47e8d4 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsDoWhile.java @@ -0,0 +1,54 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript do..while statement. + */ +public class JsDoWhile extends JsStatement { + + private JsStatement body; + private JsExpression condition; + + public JsDoWhile() { + super(); + } + + public JsDoWhile(JsExpression condition, JsStatement body) { + super(); + this.condition = condition; + this.body = body; + } + + public JsStatement getBody() { + return body; + } + + public JsExpression getCondition() { + return condition; + } + + public void setBody(JsStatement body) { + this.body = body; + } + + public void setCondition(JsExpression condition) { + this.condition = condition; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + body = v.accept(body); + condition = v.accept(condition); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.DO; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsEmpty.java b/js/src/com/google/dart/compiler/backend/js/ast/JsEmpty.java new file mode 100644 index 00000000000..c2ac99e3ac0 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsEmpty.java @@ -0,0 +1,26 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents an empty statement in JavaScript. + */ +public class JsEmpty extends JsStatement { + + // Interned by JsProgram + JsEmpty() { + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + v.visit(this, ctx); + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.EMPTY; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsExprStmt.java b/js/src/com/google/dart/compiler/backend/js/ast/JsExprStmt.java new file mode 100644 index 00000000000..5b9fc1218c3 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsExprStmt.java @@ -0,0 +1,36 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript expression statement. + */ +public final class JsExprStmt extends JsStatement { + + private JsExpression expr; + + public JsExprStmt(JsExpression expr) { + super(); + this.expr = expr; + this.setSourceInfo(expr); + } + + public JsExpression getExpression() { + return expr; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + expr = v.accept(expr); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.EXPR_STMT; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsExpression.java b/js/src/com/google/dart/compiler/backend/js/ast/JsExpression.java new file mode 100644 index 00000000000..43545ec98dc --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsExpression.java @@ -0,0 +1,52 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import com.google.dart.compiler.common.SourceInfo; + +/** + * An abstract base class for all JavaScript expressions. + */ +public abstract class JsExpression extends JsNode { + + protected JsExpression() { + } + + /** + * Determines whether the expression can cause side effects. + */ + public abstract boolean hasSideEffects(); + + /** + * True if the target expression is definitely not null. + */ + public abstract boolean isDefinitelyNotNull(); + + /** + * True if the target expression is definitely null. + */ + public abstract boolean isDefinitelyNull(); + + /** + * Determines whether or not this expression is a leaf, such as a + * {@link JsNameRef}, {@link JsBooleanLiteral}, and so on. Leaf expressions + * never need to be parenthesized. + */ + public boolean isLeaf() { + // Conservatively say that it isn't a leaf. + // Individual subclasses can speak for themselves if they are a leaf. + return false; + } + + public JsExprStmt makeStmt() { + return new JsExprStmt(this); + } + + @Override + public JsExpression setSourceRef(SourceInfo info) { + super.setSourceRef(info); + return this; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsFor.java b/js/src/com/google/dart/compiler/backend/js/ast/JsFor.java new file mode 100644 index 00000000000..b980d4be1a2 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsFor.java @@ -0,0 +1,105 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import com.google.dart.compiler.common.SourceInfo; + +/** + * A for statement. If specified at all, the initializer part is + * either a declaration of one or more variables, in which case + * {@link #getInitVars()} is used, or an expression, in which case + * {@link #getInitExpr()} is used. In the latter case, the comma operator is + * often used to create a compound expression. + * + *

+ * Note that any of the parts of the for loop header can be + * null, although the body will never be null. + */ +public class JsFor extends JsStatement { + + private JsStatement body; + private JsExpression condition; + private JsExpression incrExpr; + private JsExpression initExpr; + private JsVars initVars; + + public JsFor() { + super(); + } + + public JsStatement getBody() { + return body; + } + + public JsExpression getCondition() { + return condition; + } + + public JsExpression getIncrExpr() { + return incrExpr; + } + + public JsExpression getInitExpr() { + return initExpr; + } + + public JsVars getInitVars() { + return initVars; + } + + public void setBody(JsStatement body) { + this.body = body; + } + + public void setCondition(JsExpression condition) { + this.condition = condition; + } + + public void setIncrExpr(JsExpression incrExpr) { + this.incrExpr = incrExpr; + } + + public void setInitExpr(JsExpression initExpr) { + this.initExpr = initExpr; + } + + public void setInitVars(JsVars initVars) { + this.initVars = initVars; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + assert (!(initExpr != null && initVars != null)); + + if (initExpr != null) { + initExpr = v.accept(initExpr); + } else if (initVars != null) { + initVars = v.accept(initVars); + } + + if (condition != null) { + condition = v.accept(condition); + } + + if (incrExpr != null) { + incrExpr = v.accept(incrExpr); + } + body = v.accept(body); + } + v.endVisit(this, ctx); + } + + @Override + public JsFor setSourceRef(SourceInfo info) { + super.setSourceRef(info); + return this; + } + + @Override + public NodeKind getKind() { + return NodeKind.FOR; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsForIn.java b/js/src/com/google/dart/compiler/backend/js/ast/JsForIn.java new file mode 100644 index 00000000000..646e349885c --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsForIn.java @@ -0,0 +1,71 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript for..in statement. + */ +public class JsForIn extends JsStatement { + + private JsStatement body; + private JsExpression iterExpr; + private JsExpression objExpr; + + // Optional: the name of a new iterator variable to introduce + private final JsName iterVarName; + + public JsForIn() { + this(null); + } + + public JsForIn(JsName iterVarName) { + this.iterVarName = iterVarName; + } + + public JsStatement getBody() { + return body; + } + + public JsExpression getIterExpr() { + return iterExpr; + } + + public JsName getIterVarName() { + return iterVarName; + } + + public JsExpression getObjExpr() { + return objExpr; + } + + public void setBody(JsStatement body) { + this.body = body; + } + + public void setIterExpr(JsExpression iterExpr) { + this.iterExpr = iterExpr; + } + + public void setObjExpr(JsExpression objExpr) { + this.objExpr = objExpr; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + if (iterExpr != null) { + iterExpr = v.acceptLvalue(iterExpr); + } + objExpr = v.accept(objExpr); + body = v.accept(body); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.FOR_IN; + } +} \ No newline at end of file diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsFunction.java b/js/src/com/google/dart/compiler/backend/js/ast/JsFunction.java new file mode 100644 index 00000000000..f2c7d258791 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsFunction.java @@ -0,0 +1,238 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import com.google.dart.compiler.common.SourceInfo; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a JavaScript function expression. + */ +public final class JsFunction extends JsLiteral implements HasName { + + private static void trace(String title, String code) { + System.out.println("---------------------------"); + System.out.println(title + ":"); + System.out.println("---------------------------"); + System.out.println(code); + } + + protected JsBlock body; + protected final List params = new ArrayList(); + protected final JsScope scope; + private boolean artificiallyRescued; + private boolean executeOnce; + private boolean fromDart; + private JsFunction impliedExecute; + private JsName name; + private boolean trace = false; + private boolean traceFirst = true; + private boolean hoisted = false; + private boolean constructor = false; + + /** + * Creates an anonymous function. + */ + public JsFunction(JsScope parent) { + this(parent, null, false); + } + + /** + * Creates a function that is not derived from Dart source. + */ + public JsFunction(JsScope parent, JsName name) { + this(parent, name, false); + } + + /** + * Creates a named function, possibly derived from Dart source. + */ + public JsFunction(JsScope parent, JsName name, boolean fromDart) { + assert (parent != null); + this.fromDart = fromDart; + setName(name); + String scopeName = (name == null) ? "" : name.getIdent(); + scopeName = "function " + scopeName; + this.scope = new JsScope(parent, scopeName); + } + + public JsBlock getBody() { + return body; + } + + /** + * If true, this indicates that only the first invocation of the function will + * have any effects. Subsequent invocations may be considered to be no-op + * calls whose return value is ignored. + */ + public boolean getExecuteOnce() { + return executeOnce; + } + + public JsFunction getImpliedExecute() { + return impliedExecute; + } + + @Override + public JsName getName() { + return name; + } + + public void setParameters(List params) { + this.params.clear(); + this.params.addAll(params); + } + + public List getParameters() { + return params; + } + + public JsScope getScope() { + return scope; + } + + @Override + public boolean hasSideEffects() { + // If there's a name, the name is assigned to. + return name != null; + } + + public boolean isArtificiallyRescued() { + return artificiallyRescued; + } + + @Override + public boolean isBooleanFalse() { + return false; + } + + @Override + public boolean isBooleanTrue() { + return true; + } + + @Override + public boolean isDefinitelyNotNull() { + return true; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + public boolean isFromDart() { + return fromDart; + } + + public void setArtificiallyRescued(boolean rescued) { + this.artificiallyRescued = rescued; + } + + public void setBody(JsBlock body) { + this.body = body; + } + + public void setExecuteOnce(boolean executeOnce) { + this.executeOnce = executeOnce; + } + + public void setFromDart(boolean fromDart) { + this.fromDart = fromDart; + } + + public void setImpliedExecute(JsFunction impliedExecute) { + this.impliedExecute = impliedExecute; + } + + public void setName(JsName name) { + this.name = name; + if (name != null) { + if (isFromDart()) { + name.setStaticRef(this); + } + } + } + + public void setTrace() { + this.trace = true; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + String before = null; + if (trace && v instanceof JsModVisitor) { + before = this.toSource(); + if (traceFirst) { + traceFirst = false; + trace("SCRIPT INITIAL", before); + } + } + if (v.visit(this, ctx)) { + v.acceptWithInsertRemove(params); + body = v.accept(body); + } + v.endVisit(this, ctx); + if (trace && v instanceof JsModVisitor) { + String after = this.toSource(); + if (!after.equals(before)) { + String title = v.getClass().getSimpleName(); + trace(title, after); + } + } + } + + public void setHoisted() { + hoisted = true; + } + + /** + * Whether the function has been hoisted + */ + public boolean isHoisted() { + return hoisted; + } + + /** + * Rebase the function to a new scope. + * + * @param newScopeParent The scope to add the function to. + */ + public void rebaseScope(JsScope newScopeParent) { + this.scope.rebase(newScopeParent); + } + + @Override + public JsFunction setSourceRef(SourceInfo info) { + super.setSourceRef(info); + return this; + } + + public boolean isConstructor() { + return this.constructor; + } + + public boolean setIsConstructor(boolean constructor) { + return this.constructor = constructor; + } + + @Override + public NodeKind getKind() { + return NodeKind.FUNCTION; + } + + // Pavel Talanov + // dummy parameter to distinguish from other constructors + private JsFunction(Void dummy, JsScope functionScope) { + this.fromDart = false; + this.scope = functionScope; + } + + public static JsFunction getAnonymousFunctionWithScope(JsScope scope) { + return new JsFunction(null, scope); + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsGlobalBlock.java b/js/src/com/google/dart/compiler/backend/js/ast/JsGlobalBlock.java new file mode 100644 index 00000000000..9a14004e14c --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsGlobalBlock.java @@ -0,0 +1,19 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represnts a JavaScript block in the global scope. + */ +public class JsGlobalBlock extends JsBlock { + + public JsGlobalBlock() { + } + + @Override + public boolean isGlobalBlock() { + return true; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsIf.java b/js/src/com/google/dart/compiler/backend/js/ast/JsIf.java new file mode 100644 index 00000000000..478538235ab --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsIf.java @@ -0,0 +1,65 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript if statement. + */ +public final class JsIf extends JsStatement { + + private JsExpression ifExpr; + private JsStatement thenStmt; + private JsStatement elseStmt; + + public JsIf() { + } + + public JsIf(JsExpression ifExpr, JsStatement thenStmt, JsStatement elseStmt) { + this.ifExpr = ifExpr; + this.thenStmt = thenStmt; + this.elseStmt = elseStmt; + } + + public JsStatement getElseStmt() { + return elseStmt; + } + + public JsExpression getIfExpr() { + return ifExpr; + } + + public JsStatement getThenStmt() { + return thenStmt; + } + + public void setElseStmt(JsStatement elseStmt) { + this.elseStmt = elseStmt; + } + + public void setIfExpr(JsExpression ifExpr) { + this.ifExpr = ifExpr; + } + + public void setThenStmt(JsStatement thenStmt) { + this.thenStmt = thenStmt; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + ifExpr = v.accept(ifExpr); + thenStmt = v.accept(thenStmt); + if (elseStmt != null) { + elseStmt = v.accept(elseStmt); + } + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.IF; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsInvocation.java b/js/src/com/google/dart/compiler/backend/js/ast/JsInvocation.java new file mode 100644 index 00000000000..777c33730d0 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsInvocation.java @@ -0,0 +1,73 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Represents a JavaScript invocation. + */ +public final class JsInvocation extends JsExpression implements HasArguments { + + private final List args = new ArrayList(); + private JsExpression qualifier; + + public JsInvocation() { + } + + @Override + public List getArguments() { + return args; + } + + public JsExpression getQualifier() { + return qualifier; + } + + @Override + public boolean hasSideEffects() { + return true; + } + + @Override + public boolean isDefinitelyNotNull() { + return false; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + public void setQualifier(JsExpression qualifier) { + this.qualifier = qualifier; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + qualifier = v.accept(qualifier); + v.acceptList(args); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.INVOKE; + } + + // Pavel Talanov + public void setArguments(List arguments) { + assert this.args.isEmpty() : "Arguments already set."; + this.args.addAll(arguments); + } + + public void setArguments(JsExpression... arguments) { + setArguments(Arrays.asList(arguments)); + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsLabel.java b/js/src/com/google/dart/compiler/backend/js/ast/JsLabel.java new file mode 100644 index 00000000000..7d026c3a6de --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsLabel.java @@ -0,0 +1,45 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript label statement. + */ +public class JsLabel extends JsStatement implements HasName { + + private final JsName label; + + private JsStatement stmt; + + public JsLabel(JsName label) { + this.label = label; + } + + @Override + public JsName getName() { + return label; + } + + public JsStatement getStmt() { + return stmt; + } + + public void setStmt(JsStatement stmt) { + this.stmt = stmt; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + stmt = v.accept(stmt); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.LABEL; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsLiteral.java b/js/src/com/google/dart/compiler/backend/js/ast/JsLiteral.java new file mode 100644 index 00000000000..c87ae0c8af1 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsLiteral.java @@ -0,0 +1,14 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript string literal expression. + */ +public abstract class JsLiteral extends JsExpression implements CanBooleanEval { + + protected JsLiteral() { + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsModVisitor.java b/js/src/com/google/dart/compiler/backend/js/ast/JsModVisitor.java new file mode 100644 index 00000000000..ef6e75ce994 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsModVisitor.java @@ -0,0 +1,189 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import com.google.dart.compiler.util.Hack; + +import java.util.List; + +/** + * A visitor for iterating through and modifying an AST. + */ +public class JsModVisitor extends JsVisitor { + + private class ListContext implements JsContext { + + private List collection; + private int index; + private boolean removed; + private boolean replaced; + + @Override + public boolean canInsert() { + return true; + } + + @Override + public boolean canRemove() { + return true; + } + + @Override + public void insertAfter(JsVisitable node) { + checkRemoved(); + collection.add(index + 1, Hack.cast(node)); + didChange = true; + } + + @Override + public void insertBefore(JsVisitable node) { + checkRemoved(); + collection.add(index++, Hack.cast(node)); + didChange = true; + } + + @Override + public boolean isLvalue() { + return false; + } + + @Override + public void removeMe() { + checkState(); + collection.remove(index--); + didChange = removed = true; + } + + @Override + public void replaceMe(JsVisitable node) { + checkState(); + checkReplacement(collection.get(index), node); + collection.set(index, Hack.cast(node)); + didChange = replaced = true; + } + + protected void traverse(List collection) { + this.collection = collection; + for (index = 0; index < collection.size(); ++index) { + removed = replaced = false; + doTraverse(collection.get(index), this); + } + } + + private void checkRemoved() { + if (removed) { + throw new RuntimeException("Node was already removed"); + } + } + + private void checkState() { + checkRemoved(); + if (replaced) { + throw new RuntimeException("Node was already replaced"); + } + } + } + + private class LvalueContext extends NodeContext { + @Override + public boolean isLvalue() { + return true; + } + } + + private class NodeContext implements JsContext { + private T node; + private boolean replaced; + + @Override + public boolean canInsert() { + return false; + } + + @Override + public boolean canRemove() { + return false; + } + + @Override + public void insertAfter(JsVisitable node) { + throw new UnsupportedOperationException(); + } + + @Override + public void insertBefore(JsVisitable node) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isLvalue() { + return false; + } + + @Override + public void removeMe() { + throw new UnsupportedOperationException(); + } + + @Override + public void replaceMe(JsVisitable node) { + if (replaced) { + throw new RuntimeException("Node was already replaced"); + } + checkReplacement(this.node, node); + this.node = Hack.cast(node); + didChange = replaced = true; + } + + protected T traverse(T node) { + this.node = node; + replaced = false; + doTraverse(node, this); + return this.node; + } + } + + protected static void checkReplacement(T origNode, T newNode) { + if (newNode == null) { + throw new RuntimeException("Cannot replace with null"); + } + if (newNode == origNode) { + throw new RuntimeException("The replacement is the same as the original"); + } + } + + protected boolean didChange = false; + + @Override + public boolean didChange() { + return didChange; + } + + @Override + protected T doAccept(T node) { + return new NodeContext().traverse(node); + } + + @Override + protected void doAcceptList(List collection) { + NodeContext ctx = new NodeContext(); + for (int i = 0, c = collection.size(); i < c; ++i) { + ctx.traverse(collection.get(i)); + if (ctx.replaced) { + collection.set(i, ctx.node); + } + } + } + + @Override + protected JsExpression doAcceptLvalue(JsExpression expr) { + return new LvalueContext().traverse(expr); + } + + @Override + protected void doAcceptWithInsertRemove(List collection) { + new ListContext().traverse(collection); + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsName.java b/js/src/com/google/dart/compiler/backend/js/ast/JsName.java new file mode 100644 index 00000000000..ccc1322338a --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsName.java @@ -0,0 +1,102 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.io.Serializable; + +/** + * An abstract base class for named JavaScript objects. + */ +public class JsName implements Serializable { + private final JsScope enclosing; + private final String ident; + private boolean isObfuscatable; + private String shortIdent; + private String originalName; + + /** + * A back-reference to the JsNode that the JsName refers to. + */ + private JsNode staticRef; + + /** + * @param ident the unmangled ident to use for this name + */ +JsName(JsScope enclosing, String ident, String shortIdent, String originalName) { + this.enclosing = enclosing; + this.ident = ident; + this.shortIdent = shortIdent; + if (originalName != null) { + this.originalName = originalName; + } + this.isObfuscatable = true; + } + + public JsScope getEnclosing() { + return enclosing; + } + + public String getIdent() { + return ident; + } + + public String getShortIdent() { + return shortIdent; + } + + public String getOriginalName() { + return originalName; + } + + public JsNode getStaticRef() { + return staticRef; + } + + public boolean isObfuscatable() { + return isObfuscatable; + } + + public JsNameRef makeRef() { + return new JsNameRef(this); + } + + public void setObfuscatable(boolean isObfuscatable) { + this.isObfuscatable = isObfuscatable; + } + + public void setShortIdent(String shortIdent) { + this.shortIdent = shortIdent; + } + + /** + * Should never be called except on immutable stuff. + */ + public void setStaticRef(JsNode node) { + this.staticRef = node; + } + + @Override + public String toString() { + return ident; + } + + @Override + public int hashCode() { + return ident.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof JsName)) { + return false; + } + JsName other = (JsName) obj; + return ident.equals(other.ident) && enclosing == other.enclosing; + } + +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java b/js/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java new file mode 100644 index 00000000000..dc26c8fa61a --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java @@ -0,0 +1,113 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript expression that references a name. + */ +public final class JsNameRef extends JsExpression implements CanBooleanEval, HasName { + + private String ident; + private JsName name; + private JsExpression qualifier; + + public JsNameRef(JsName name) { + this.name = name; + } + + public JsNameRef(String ident) { + this.ident = ident; + } + + public String getIdent() { + return (name == null) ? ident : name.getIdent(); + } + + @Override + public JsName getName() { + return name; + } + + public JsExpression getQualifier() { + return qualifier; + } + + public String getShortIdent() { + return (name == null) ? ident : name.getShortIdent(); + } + + @Override + public boolean hasSideEffects() { + if (qualifier == null) { + return false; + } + if (!qualifier.isDefinitelyNotNull()) { + // Could trigger NPE. + return true; + } + return qualifier.hasSideEffects(); + } + + @Override + public boolean isBooleanFalse() { + return isDefinitelyNull(); + } + + @Override + public boolean isBooleanTrue() { + return false; + } + + @Override + public boolean isDefinitelyNotNull() { + // TODO: look for single-assignment of stuff from Java? + return false; + } + + @Override + public boolean isDefinitelyNull() { + if (name != null) { + return (name.getEnclosing().getProgram().getUndefinedLiteral().getName() == name); + } + return false; + } + + @Override + public boolean isLeaf() { + if (qualifier == null) { + return true; + } else { + return false; + } + } + + public boolean isResolved() { + return name != null; + } + + public void resolve(JsName name) { + this.name = name; + this.ident = null; + } + + public void setQualifier(JsExpression qualifier) { + this.qualifier = qualifier; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + if (qualifier != null) { + qualifier = v.accept(qualifier); + } + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.NAME_REF; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsNew.java b/js/src/com/google/dart/compiler/backend/js/ast/JsNew.java new file mode 100644 index 00000000000..68fc366684d --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsNew.java @@ -0,0 +1,66 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents the JavaScript new expression. + */ +public final class JsNew extends JsExpression implements HasArguments { + + private final List args = new ArrayList(); + private JsExpression ctorExpr; + + public JsNew(JsExpression ctorExpr) { + this.ctorExpr = ctorExpr; + } + + @Override + public List getArguments() { + return args; + } + + public void setArguments(List arguments) { + args.clear(); + args.addAll(arguments); + } + + public JsExpression getConstructorExpression() { + return ctorExpr; + } + + @Override + public boolean hasSideEffects() { + return true; + } + + @Override + public boolean isDefinitelyNotNull() { + // Sadly, in JS it can be! + // TODO: analysis could probably determine most instances cannot be null. + return false; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + ctorExpr = v.accept(ctorExpr); + v.acceptList(args); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.NEW; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsNode.java b/js/src/com/google/dart/compiler/backend/js/ast/JsNode.java new file mode 100644 index 00000000000..0d4b7aaa714 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsNode.java @@ -0,0 +1,50 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +package com.google.dart.compiler.backend.js.ast; + +import com.google.dart.compiler.backend.js.JsSourceGenerationVisitor; +import com.google.dart.compiler.backend.js.JsToStringGenerationVisitor; +import com.google.dart.compiler.common.AbstractNode; +import com.google.dart.compiler.common.SourceInfo; +import com.google.dart.compiler.util.DefaultTextOutput; + +/** + * Base class for all JS AST elements. + */ +public abstract class JsNode extends AbstractNode implements JsVisitable { + + protected JsNode() { + } + + // Causes source generation to delegate to the one visitor + public final String toSource() { + DefaultTextOutput out = new DefaultTextOutput(false); + JsSourceGenerationVisitor v = new JsSourceGenerationVisitor(out); + v.accept(this); + return out.toString(); + } + + // Causes source generation to delegate to the one visitor + @Override + public final String toString() { + DefaultTextOutput out = new DefaultTextOutput(false); + JsToStringGenerationVisitor v = new JsToStringGenerationVisitor(out); + v.accept(this); + return out.toString(); + } + + @Override + public SourceInfo getSourceInfo() { + return this; + } + + public JsNode setSourceRef(SourceInfo info) { + if (info != null) { + this.setSourceInfo(info); + } + return this; + } + + public abstract NodeKind getKind(); +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsNullLiteral.java b/js/src/com/google/dart/compiler/backend/js/ast/JsNullLiteral.java new file mode 100644 index 00000000000..506b2e3f330 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsNullLiteral.java @@ -0,0 +1,46 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript null literal. + */ +public final class JsNullLiteral extends JsValueLiteral { + + // Should only be instantiated in JsProgram + JsNullLiteral() { + } + + @Override + public boolean isBooleanFalse() { + return true; + } + + @Override + public boolean isBooleanTrue() { + return false; + } + + @Override + public boolean isDefinitelyNotNull() { + return false; + } + + @Override + public boolean isDefinitelyNull() { + return true; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + v.visit(this, ctx); + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.NULL; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsNumberLiteral.java b/js/src/com/google/dart/compiler/backend/js/ast/JsNumberLiteral.java new file mode 100644 index 00000000000..726c6b0ed27 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsNumberLiteral.java @@ -0,0 +1,53 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Represents a JavaScript literal decimal expression. + */ +public final class JsNumberLiteral extends JsValueLiteral { + + private final double value; + + // Should be interned by JsProgram + JsNumberLiteral(double value) { + this.value = value; + } + + public double getValue() { + return value; + } + + @Override + public boolean isBooleanFalse() { + return value == 0.0; + } + + @Override + public boolean isBooleanTrue() { + return value != 0.0; + } + + @Override + public boolean isDefinitelyNotNull() { + return true; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + v.visit(this, ctx); + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.NUMBER; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsObjectLiteral.java b/js/src/com/google/dart/compiler/backend/js/ast/JsObjectLiteral.java new file mode 100644 index 00000000000..749ed473c21 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsObjectLiteral.java @@ -0,0 +1,72 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.ArrayList; +import java.util.List; + +/** + * A JavaScript object literal. + */ +public final class JsObjectLiteral extends JsLiteral { + + private final List props; + + public JsObjectLiteral() { + props = new ArrayList(); + } + + public JsObjectLiteral(List props) { + assert props != null; + this.props = props; + } + + public List getPropertyInitializers() { + return props; + } + + @Override + public boolean hasSideEffects() { + for (JsPropertyInitializer prop : props) { + if (prop.hasSideEffects()) { + return true; + } + } + return false; + } + + @Override + public boolean isBooleanFalse() { + return false; + } + + @Override + public boolean isBooleanTrue() { + return true; + } + + @Override + public boolean isDefinitelyNotNull() { + return true; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + v.acceptWithInsertRemove(props); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.OBJECT; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsOperator.java b/js/src/com/google/dart/compiler/backend/js/ast/JsOperator.java new file mode 100644 index 00000000000..e4440cbe9ab --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsOperator.java @@ -0,0 +1,32 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript operator. + */ +public interface JsOperator { + + int INFIX = 0x02; + int LEFT = 0x01; + int POSTFIX = 0x04; + int PREFIX = 0x08; + + int getPrecedence(); + + String getSymbol(); + + boolean isKeyword(); + + boolean isLeftAssociative(); + + boolean isPrecedenceLessThan(JsOperator other); + + boolean isValidInfix(); + + boolean isValidPostfix(); + + boolean isValidPrefix(); +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsParameter.java b/js/src/com/google/dart/compiler/backend/js/ast/JsParameter.java new file mode 100644 index 00000000000..17581ce4084 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsParameter.java @@ -0,0 +1,34 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript parameter. + */ +public final class JsParameter extends JsNode implements HasName { + + private final JsName name; + + public JsParameter(JsName name) { + this.name = name; + name.setStaticRef(this); + } + + @Override + public JsName getName() { + return name; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + v.visit(this, ctx); + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.PARAMETER; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsPostfixOperation.java b/js/src/com/google/dart/compiler/backend/js/ast/JsPostfixOperation.java new file mode 100644 index 00000000000..a33536f6c0d --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsPostfixOperation.java @@ -0,0 +1,42 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript postfix operation. + */ +public final class JsPostfixOperation extends JsUnaryOperation { + + public JsPostfixOperation(JsUnaryOperator op) { + this(op, null); + } + + public JsPostfixOperation(JsUnaryOperator op, JsExpression arg) { + super(op, arg); + } + + @Override + public boolean isDefinitelyNotNull() { + return true; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + super.traverse(v, ctx); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.POSTFIX_OP; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.java b/js/src/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.java new file mode 100644 index 00000000000..8ce12c7bacd --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.java @@ -0,0 +1,69 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript prefix operation. + */ +public final class JsPrefixOperation extends JsUnaryOperation implements CanBooleanEval { + + public JsPrefixOperation(JsUnaryOperator op) { + this(op, null); + } + + public JsPrefixOperation(JsUnaryOperator op, JsExpression arg) { + super(op, arg); + } + + @Override + public boolean isBooleanFalse() { + if (getOperator() == JsUnaryOperator.VOID) { + return true; + } + if (getOperator() == JsUnaryOperator.NOT && getArg() instanceof CanBooleanEval) { + CanBooleanEval eval = (CanBooleanEval) getArg(); + return eval.isBooleanTrue(); + } + return false; + } + + @Override + public boolean isBooleanTrue() { + if (getOperator() == JsUnaryOperator.NOT && getArg() instanceof CanBooleanEval) { + CanBooleanEval eval = (CanBooleanEval) getArg(); + return eval.isBooleanFalse(); + } + if (getOperator() == JsUnaryOperator.TYPEOF) { + return true; + } + return false; + } + + @Override + public boolean isDefinitelyNotNull() { + if (getOperator() == JsUnaryOperator.TYPEOF) { + return true; + } + return getOperator() != JsUnaryOperator.VOID; + } + + @Override + public boolean isDefinitelyNull() { + return getOperator() == JsUnaryOperator.VOID; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + super.traverse(v, ctx); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.PREFIX_OP; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsProgram.java b/js/src/com/google/dart/compiler/backend/js/ast/JsProgram.java new file mode 100644 index 00000000000..c8e4310ba9b --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsProgram.java @@ -0,0 +1,174 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.HashMap; +import java.util.Map; + +/** + * A JavaScript program. + */ +public final class JsProgram extends JsNode { + + private final JsStatement debuggerStmt; + private final JsEmpty emptyStmt; + private final JsBooleanLiteral falseLiteral; + private JsProgramFragment[] fragments; + private final Map indexedFunctions = new HashMap(); + private final JsNullLiteral nullLiteral; + private final Map numberLiteralMap = + new HashMap(); + private final JsScope objectScope; + private final JsRootScope rootScope; + private final Map stringLiteralMap = + new HashMap(); + private final JsScope topScope; + private final JsBooleanLiteral trueLiteral; + + /** + * Constructs a JavaScript program object. + */ + public JsProgram(String unitId) { + rootScope = new JsRootScope(this); + topScope = new JsScope(rootScope, "Global", unitId); + objectScope = new JsScope(rootScope, "Object"); + setFragmentCount(1); + + debuggerStmt = new JsDebugger(); + emptyStmt = new JsEmpty(); + falseLiteral = new JsBooleanLiteral(false); + nullLiteral = new JsNullLiteral(); + trueLiteral = new JsBooleanLiteral(true); + } + + public JsBooleanLiteral getBooleanLiteral(boolean truth) { + if (truth) { + return getTrueLiteral(); + } + return getFalseLiteral(); + } + + /** + * Gets the {@link JsStatement} to use whenever parsed source include a + * debugger statement. + */ + public JsStatement getDebuggerStmt() { + return debuggerStmt; + } + + public JsEmpty getEmptyStmt() { + return emptyStmt; + } + + public JsBooleanLiteral getFalseLiteral() { + return falseLiteral; + } + + public JsBlock getFragmentBlock(int fragment) { + if (fragment < 0 || fragment >= fragments.length) { + throw new IllegalArgumentException("Invalid fragment: " + fragment); + } + return fragments[fragment].getGlobalBlock(); + } + + public int getFragmentCount() { + return this.fragments.length; + } + + /** + * Gets the one and only global block. + */ + public JsBlock getGlobalBlock() { + return getFragmentBlock(0); + } + + public JsFunction getIndexedFunction(String name) { + return indexedFunctions.get(name); + } + + public JsNullLiteral getNullLiteral() { + return nullLiteral; + } + + public JsNumberLiteral getNumberLiteral(double value) { + JsNumberLiteral lit = numberLiteralMap.get(value); + if (lit == null) { + lit = new JsNumberLiteral(value); + numberLiteralMap.put(value, lit); + } + + return lit; + } + + public JsScope getObjectScope() { + return objectScope; + } + + /** + * Gets the quasi-mythical root scope. This is not the same as the top scope; + * all unresolvable identifiers wind up here, because they are considered + * external to the program. + */ + public JsRootScope getRootScope() { + return rootScope; + } + + /** + * Gets the top level scope. This is the scope of all the statements in the + * main program. + */ + public JsScope getScope() { + return topScope; + } + + /** + * Creates or retrieves a JsStringLiteral from an interned object pool. + */ + public JsStringLiteral getStringLiteral(String value) { + JsStringLiteral lit = stringLiteralMap.get(value); + if (lit == null) { + lit = new JsStringLiteral(value); + stringLiteralMap.put(value, lit); + } + return lit; + } + + public JsBooleanLiteral getTrueLiteral() { + return trueLiteral; + } + + public JsNameRef getUndefinedLiteral() { + return new JsNameRef("$Dart$Null"); + } + + public void setFragmentCount(int fragments) { + this.fragments = new JsProgramFragment[fragments]; + for (int i = 0; i < fragments; i++) { + this.fragments[i] = new JsProgramFragment(); + } + } + + public void setIndexedFunctions(Map indexedFunctions) { + this.indexedFunctions.clear(); + this.indexedFunctions.putAll(indexedFunctions); + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + for (JsProgramFragment fragment : fragments) { + v.accept(fragment); + } + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.PROGRAM; + } + + +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsProgramFragment.java b/js/src/com/google/dart/compiler/backend/js/ast/JsProgramFragment.java new file mode 100644 index 00000000000..3c6859e2150 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsProgramFragment.java @@ -0,0 +1,34 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * One independently loadable fragment of a {@link JsProgram}. + */ +public class JsProgramFragment extends JsNode { + + private final JsGlobalBlock globalBlock; + + public JsProgramFragment() { + this.globalBlock = new JsGlobalBlock(); + } + + public JsBlock getGlobalBlock() { + return globalBlock; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + v.accept(globalBlock); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.PROGRAM_FRAGMENT; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java b/js/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java new file mode 100644 index 00000000000..d68d8d01af4 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java @@ -0,0 +1,56 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Used in object literals to specify property values by name. + */ +public class JsPropertyInitializer extends JsNode { + + private JsExpression labelExpr; + private JsExpression valueExpr; + + public JsPropertyInitializer() { + } + + public JsPropertyInitializer(JsExpression labelExpr, JsExpression valueExpr) { + this.labelExpr = labelExpr; + this.valueExpr = valueExpr; + } + + public JsExpression getLabelExpr() { + return labelExpr; + } + + public JsExpression getValueExpr() { + return valueExpr; + } + + public boolean hasSideEffects() { + return labelExpr.hasSideEffects() || valueExpr.hasSideEffects(); + } + + public void setLabelExpr(JsExpression labelExpr) { + this.labelExpr = labelExpr; + } + + public void setValueExpr(JsExpression valueExpr) { + this.valueExpr = valueExpr; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + labelExpr = v.accept(labelExpr); + valueExpr = v.accept(valueExpr); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.PROPERTY_INIT; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsRegExp.java b/js/src/com/google/dart/compiler/backend/js/ast/JsRegExp.java new file mode 100644 index 00000000000..158c7a5e092 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsRegExp.java @@ -0,0 +1,64 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript regular expression. + */ +public final class JsRegExp extends JsValueLiteral { + + private String flags; + private String pattern; + + public JsRegExp() { + } + + public String getFlags() { + return flags; + } + + public String getPattern() { + return pattern; + } + + @Override + public boolean isBooleanFalse() { + return false; + } + + @Override + public boolean isBooleanTrue() { + return true; + } + + @Override + public boolean isDefinitelyNotNull() { + return true; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + public void setFlags(String suffix) { + this.flags = suffix; + } + + public void setPattern(String re) { + this.pattern = re; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + v.visit(this, ctx); + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.REGEXP; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsReturn.java b/js/src/com/google/dart/compiler/backend/js/ast/JsReturn.java new file mode 100644 index 00000000000..16d90e4b353 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsReturn.java @@ -0,0 +1,48 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript return statement. + */ +public final class JsReturn extends JsStatement { + + private JsExpression expr; + + public JsReturn() { + } + + public JsReturn(JsExpression expr) { + this.expr = expr; + } + + public JsExpression getExpr() { + return expr; + } + + public void setExpr(JsExpression expr) { + this.expr = expr; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + if (expr != null) { + expr = v.accept(expr); + } + } + v.endVisit(this, ctx); + } + + @Override + public boolean unconditionalControlBreak() { + return true; + } + + @Override + public NodeKind getKind() { + return NodeKind.RETURN; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsRootScope.java b/js/src/com/google/dart/compiler/backend/js/ast/JsRootScope.java new file mode 100644 index 00000000000..33b71f26222 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsRootScope.java @@ -0,0 +1,50 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import com.google.dart.compiler.backend.js.JsReservedIdentifiers; + +/** + * The root scope is the parent of every scope. All identifiers in this scope + * are not obfuscatable. This scope is prefilled with reserved global + * JavaScript symbols. + */ +public final class JsRootScope extends JsScope { + + private final JsProgram program; + + public JsRootScope(JsProgram program) { + super("Root"); + this.program = program; + } + + @Override + public JsProgram getProgram() { + return program; + } + + @Override + protected JsName doCreateName(String ident, String shortIdent, String originalName) { + JsName name = super.doCreateName(ident, shortIdent, originalName); + name.setObfuscatable(false); + return name; + } + + @Override + public JsName findExistingNameNoRecurse(String ident) { + JsName name = super.findExistingNameNoRecurse(ident); + if (name == null) { + if (JsReservedIdentifiers.getReservedGlobalSymbols().contains(ident)) { + /* + * Lazily add JsNames for reserved identifiers. Since a JsName for a reserved global symbol + * must report a legitimate enclosing scope, we can't simply have a shared set of symbol + * names. + */ + name = doCreateName(ident, ident, ident); + } + } + return name; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsScope.java b/js/src/com/google/dart/compiler/backend/js/ast/JsScope.java new file mode 100644 index 00000000000..0a4053960b8 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsScope.java @@ -0,0 +1,308 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import com.google.dart.compiler.util.Lists; +import com.google.dart.compiler.util.Maps; + +import java.io.Serializable; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * A scope is a factory for creating and allocating + * {@link JsName}s. A JavaScript AST is + * built in terms of abstract name objects without worrying about obfuscation, + * keyword/identifier blacklisting, and so on. + *

+ *

+ *

+ * Scopes are associated with + * {@link JsFunction}s, but the two are + * not equivalent. Functions have scopes, but a scope does not + * necessarily have an associated Function. Examples of this include the + * {@link JsRootScope} and synthetic + * scopes that might be created by a client. + *

+ *

+ *

+ * Scopes can have parents to provide constraints when allocating actual + * identifiers for names. Specifically, names in child scopes are chosen such + * that they do not conflict with names in their parent scopes. The ultimate + * parent is usually the global scope (see + * {@link JsProgram#getRootScope()}), + * but parentless scopes are useful for managing names that are always accessed + * with a qualifier and could therefore never be confused with the global scope + * hierarchy. + */ +public class JsScope implements Serializable { + + private List children = Collections.emptyList(); + private final String description; + private Map names = Collections.emptyMap(); + private JsScope parent; + protected int tempIndex = 0; + private final String scopeId; + + /* + * Create a scope with parent. + */ + public JsScope(JsScope parent, String description) { + this(parent, description, null); + } + + /** + * Create a scope with parent. + */ + public JsScope(JsScope parent, String description, String scopeId) { + assert (parent != null); + this.scopeId = scopeId; + this.description = description; + this.parent = parent; + parent.children = Lists.add(parent.children, this); + } + + /** + * Rebase the function to a new scope. + * + * @param newParent The scope to add the function to. + */ + public void rebase(JsScope newParent) { + detachFromParent(); + parent = newParent; + parent.children = Lists.add(parent.children, this); + } + + /** + * Rebase the function's children to a new scope. + * + * @param newParent + */ + public void rebaseChildScopes(JsScope newParent) { + if (newParent == this) { + return; + } + parent.children = Lists.addAll(parent.children, children); + for (JsScope child : children) { + child.parent = newParent; + } + children = Collections.emptyList(); + } + + /** + * Subclasses can detach and become parentless. + */ + protected void detachFromParent() { + JsScope oldParent = parent; + + oldParent.children = Lists.remove( + parent.children, oldParent.children.indexOf(this)); + + parent = null; + } + + /** + * Subclasses can be parentless. + */ + protected JsScope(String description) { + this.description = description; + this.parent = null; + this.scopeId = null; + } + + /** + * Gets a name object associated with the specified ident in this scope, + * creating it if necessary.
+ * If the JsName does not exist yet, a new JsName is created. The ident, + * short name, and original name of the newly created JsName are equal to + * the given ident. + * + * @param ident An identifier that is unique within this scope. + */ + public JsName declareName(String ident) { + JsName name = findExistingNameNoRecurse(ident); + if (name != null) { + return name; + } + return doCreateName(ident, ident, ident); + } + + /** + * Creates a new variable with an unique ident in this scope. + * The generated JsName is guaranteed to have an identifier (but not short + * name) that does not clash with any existing variables in the scope. + * Future declarations of variables might however clash with the temporary + * (unless they use this function). + */ + public JsName declareFreshName(String shortName) { + String ident = shortName; + int counter = 0; + while (findExistingNameNoRecurse(ident) != null) { + ident = shortName + "_" + counter++; + } + return doCreateName(ident, shortName, shortName); + } + + String getNextTempName() { + // TODO(ngeoffray): Decide on a convention for temporary variables + // introduced by the compiler. + return "tmp$" + (scopeId != null ? scopeId + "$" : "") + tempIndex++; + } + + /** + * Creates a temporary variable with an unique name in this scope. + * The generated temporary is guaranteed to have an identifier (but not short + * name) that does not clash with any existing variables in the scope. + * Future declarations of variables might however clash with the temporary. + */ + public JsName declareTemporary() { + return declareFreshName(getNextTempName()); + } + + /** + * Gets a name object associated with the specified ident in this scope, + * creating it if necessary.
+ * If the JsName does not exist yet, a new JsName is created with the given + * ident, short name and original name. + * + * @param ident An identifier that is unique within this scope. + * @param shortIdent A "pretty" name that does not have to be unique. + * @throws IllegalArgumentException if ident already exists in this scope but + * the requested short name does not match the existing short name. + */ + public JsName declareName(String ident, String shortIdent) { + return declareName(ident, shortIdent, ident); + } + + /** + * Gets a name object associated with the specified ident in this scope, + * creating it if necessary.
+ * If the JsName does not exist yet, a new JsName is created. The original + * name stored in the JsName is equal to the (unmangled) specified originalName. + * + * @param ident An identifier that is unique within this scope. + * @param shortIdent A "pretty" name that does not have to be unique. + * @param originalName The original name in the source. + * @throws IllegalArgumentException if ident already exists in this scope but + * the requested short name does not match the existing short name, + * or the original name does not match the existing original name. + */ + public JsName declareName(String ident, String shortIdent, String originalName) { + JsName name = findExistingNameNoRecurse(ident); + if (name != null) { + if (!name.getShortIdent().equals(shortIdent) + || !nullableEquals(name.getOriginalName(), originalName)) { + throw new IllegalArgumentException("Requested short name " + shortIdent + + " conflicts with preexisting short name " + name.getShortIdent() + " for identifier " + + ident); + } + return name; + } + return doCreateName(ident, shortIdent, originalName); + } + + boolean nullableEquals(String s1, String s2) { + return (s1 == null) ? (s2 == null) : s1.equals(s2); + } + + /** + * Attempts to find the name object for the specified ident, searching in this + * scope, and if not found, in the parent scopes. + * + * @return null if the identifier has no associated name + */ + public final JsName findExistingName(String ident) { + JsName name = findExistingNameNoRecurse(ident); + if (name == null && parent != null) { + return parent.findExistingName(ident); + } + return name; + } + + /** + * Attempts to find an unobfuscatable name object for the specified ident, + * searching in this scope, and if not found, in the parent scopes. + * + * @return null if the identifier has no associated name + */ + public final JsName findExistingUnobfuscatableName(String ident) { + JsName name = findExistingNameNoRecurse(ident); + if (name != null && name.isObfuscatable()) { + name = null; + } + if (name == null && parent != null) { + return parent.findExistingUnobfuscatableName(ident); + } + return name; + } + + /** + * Returns an iterator for all the names defined by this scope. + */ + public Iterator getAllNames() { + return names.values().iterator(); + } + + /** + * Returns a list of this scope's child scopes. + */ + public final List getChildren() { + return children; + } + + /** + * Returns the parent scope of this scope, or null if this is the + * root scope. + */ + public final JsScope getParent() { + return parent; + } + + /** + * Returns the associated program. + */ + public JsProgram getProgram() { + assert (parent != null) : "Subclasses must override getProgram() if they do not set a parent"; + return parent.getProgram(); + } + + @Override + public final String toString() { + if (parent != null) { + return description + "->" + parent; + } else { + return description; + } + } + + /** + * Creates a new name in this scope. + */ + protected JsName doCreateName(String ident, String shortIdent, String originalName) { + JsName name = new JsName(this, ident, shortIdent, originalName); + names = Maps.putOrdered(names, ident, name); + return name; + } + + /** + * Attempts to find the name object for the specified ident, searching in this + * scope only. + * + * @return null if the identifier has no associated name + */ + public JsName findExistingNameNoRecurse(String ident) { + return names.get(ident); + } + + /** + * + * Checks whether this scope owns this name. + */ + public boolean ownsName(JsName name) { + return names.containsValue(name); + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsStatement.java b/js/src/com/google/dart/compiler/backend/js/ast/JsStatement.java new file mode 100644 index 00000000000..82d37ca1185 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsStatement.java @@ -0,0 +1,22 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Abstract base class for JavaScript statement objects. + */ +public abstract class JsStatement extends JsNode { + + protected JsStatement() { + } + + /** + * Returns true if this statement definitely causes an abrupt change in flow + * control. + */ + public boolean unconditionalControlBreak() { + return false; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsStringLiteral.java b/js/src/com/google/dart/compiler/backend/js/ast/JsStringLiteral.java new file mode 100644 index 00000000000..77e60c9b89a --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsStringLiteral.java @@ -0,0 +1,53 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript string literal expression. + */ +public final class JsStringLiteral extends JsValueLiteral { + + private final String value; + + // These only get created by JsProgram so that they can be interned. + JsStringLiteral(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public boolean isBooleanFalse() { + return value.length() == 0; + } + + @Override + public boolean isBooleanTrue() { + return value.length() != 0; + } + + @Override + public boolean isDefinitelyNotNull() { + return true; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + v.visit(this, ctx); + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.STRING; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsSwitch.java b/js/src/com/google/dart/compiler/backend/js/ast/JsSwitch.java new file mode 100644 index 00000000000..5a49624af42 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsSwitch.java @@ -0,0 +1,47 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.ArrayList; +import java.util.List; + +/** + * A JavaScript switch statement. + */ +public class JsSwitch extends JsStatement { + + private final List cases = new ArrayList(); + private JsExpression expr; + + public JsSwitch() { + super(); + } + + public List getCases() { + return cases; + } + + public JsExpression getExpr() { + return expr; + } + + public void setExpr(JsExpression expr) { + this.expr = expr; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + expr = v.accept(expr); + v.acceptWithInsertRemove(cases); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.SWITCH; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsSwitchMember.java b/js/src/com/google/dart/compiler/backend/js/ast/JsSwitchMember.java new file mode 100644 index 00000000000..0a748f60078 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsSwitchMember.java @@ -0,0 +1,24 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.ArrayList; +import java.util.List; + +/** + * A member/case in a JavaScript switch object. + */ +public abstract class JsSwitchMember extends JsNode { + + protected final List stmts = new ArrayList(); + + protected JsSwitchMember() { + super(); + } + + public List getStmts() { + return stmts; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsThisRef.java b/js/src/com/google/dart/compiler/backend/js/ast/JsThisRef.java new file mode 100644 index 00000000000..9adb6459488 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsThisRef.java @@ -0,0 +1,51 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript this reference. + */ +public final class JsThisRef extends JsValueLiteral { + + public JsThisRef() { + super(); + } + + @Override + public boolean isBooleanFalse() { + return false; + } + + @Override + public boolean isBooleanTrue() { + return true; + } + + @Override + public boolean isDefinitelyNotNull() { + /* + * You'd think that you could get a null this via function.call/apply, but + * in fact you can't: they just make this be the window object instead. So + * it really can't ever be null. + */ + return true; + } + + @Override + public boolean isDefinitelyNull() { + return false; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + v.visit(this, ctx); + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.THIS; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsThrow.java b/js/src/com/google/dart/compiler/backend/js/ast/JsThrow.java new file mode 100644 index 00000000000..4616418fb6b --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsThrow.java @@ -0,0 +1,48 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript throw statement. + */ +public class JsThrow extends JsStatement { + + private JsExpression expr; + + public JsThrow() { + super(); + } + + public JsThrow(JsExpression expr) { + super(); + this.expr = expr; + } + + public JsExpression getExpr() { + return expr; + } + + public void setExpr(JsExpression expr) { + this.expr = expr; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + expr = v.accept(expr); + } + v.endVisit(this, ctx); + } + + @Override + public boolean unconditionalControlBreak() { + return true; + } + + @Override + public NodeKind getKind() { + return NodeKind.THROW; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsTry.java b/js/src/com/google/dart/compiler/backend/js/ast/JsTry.java new file mode 100644 index 00000000000..61357bcd406 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsTry.java @@ -0,0 +1,59 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.ArrayList; +import java.util.List; + +/** + * A JavaScript try statement. + */ +public class JsTry extends JsStatement { + + private final List catches = new ArrayList(); + private JsBlock finallyBlock; + private JsBlock tryBlock; + + public JsTry() { + super(); + } + + public List getCatches() { + return catches; + } + + public JsBlock getFinallyBlock() { + return finallyBlock; + } + + public JsBlock getTryBlock() { + return tryBlock; + } + + public void setFinallyBlock(JsBlock block) { + this.finallyBlock = block; + } + + public void setTryBlock(JsBlock block) { + tryBlock = block; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + tryBlock = v.accept(tryBlock); + v.acceptWithInsertRemove(catches); + if (finallyBlock != null) { + finallyBlock = v.accept(finallyBlock); + } + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.TRY; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsUnaryOperation.java b/js/src/com/google/dart/compiler/backend/js/ast/JsUnaryOperation.java new file mode 100644 index 00000000000..00f103f35c9 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsUnaryOperation.java @@ -0,0 +1,53 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript prefix or postfix operation. + */ +public abstract class JsUnaryOperation extends JsExpression { + + private JsExpression arg; + + private final JsUnaryOperator op; + + public JsUnaryOperation(JsUnaryOperator op) { + this(op, null); + } + + public JsUnaryOperation(JsUnaryOperator op, JsExpression arg) { + super(); + this.op = op; + this.arg = arg; + } + + public JsExpression getArg() { + return arg; + } + + public JsUnaryOperator getOperator() { + return op; + } + + @Override + public final boolean hasSideEffects() { + return op.isModifying() || arg.hasSideEffects(); + } + + public void setArg(JsExpression arg) { + this.arg = arg; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (op.isModifying()) { + // The delete operator is practically like an assignment of undefined, so + // for practical purposes we're treating it as an lvalue. + arg = v.acceptLvalue(arg); + } else { + arg = v.accept(arg); + } + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsUnaryOperator.java b/js/src/com/google/dart/compiler/backend/js/ast/JsUnaryOperator.java new file mode 100644 index 00000000000..2b854d8313e --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsUnaryOperator.java @@ -0,0 +1,78 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript unary operator. + */ +public enum JsUnaryOperator implements JsOperator { + + /* + * Precedence indices from "JavaScript - The Definitive Guide" 4th Edition + * (page 57) + */ + BIT_NOT("~", 14, PREFIX), DEC("--", 14, POSTFIX | PREFIX), DELETE("delete", 14, PREFIX), INC( + "++", 14, POSTFIX | PREFIX), NEG("-", 14, PREFIX), POS("+", 14, PREFIX), + NOT("!", 14, PREFIX), TYPEOF("typeof", 14, PREFIX), VOID("void", 14, PREFIX); + + private final int mask; + private final int precedence; + private final String symbol; + + private JsUnaryOperator(String symbol, int precedence, int mask) { + this.symbol = symbol; + this.precedence = precedence; + this.mask = mask; + } + + @Override + public int getPrecedence() { + return precedence; + } + + @Override + public String getSymbol() { + return symbol; + } + + @Override + public boolean isKeyword() { + return this == DELETE || this == TYPEOF || this == VOID; + } + + @Override + public boolean isLeftAssociative() { + return (mask & LEFT) != 0; + } + + public boolean isModifying() { + return this == DEC || this == INC || this == DELETE; + } + + @Override + public boolean isPrecedenceLessThan(JsOperator other) { + return precedence < other.getPrecedence(); + } + + @Override + public boolean isValidInfix() { + return (mask & INFIX) != 0; + } + + @Override + public boolean isValidPostfix() { + return (mask & POSTFIX) != 0; + } + + @Override + public boolean isValidPrefix() { + return (mask & PREFIX) != 0; + } + + @Override + public String toString() { + return symbol; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsValueLiteral.java b/js/src/com/google/dart/compiler/backend/js/ast/JsValueLiteral.java new file mode 100644 index 00000000000..f23ab5dbce4 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsValueLiteral.java @@ -0,0 +1,24 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript string literal expression. + */ +public abstract class JsValueLiteral extends JsLiteral { + + protected JsValueLiteral() { + } + + @Override + public final boolean hasSideEffects() { + return false; + } + + @Override + public final boolean isLeaf() { + return true; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsVars.java b/js/src/com/google/dart/compiler/backend/js/ast/JsVars.java new file mode 100644 index 00000000000..aaf629259aa --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsVars.java @@ -0,0 +1,109 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import com.google.dart.compiler.common.SourceInfo; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * A JavaScript var statement. + */ +public class JsVars extends JsStatement implements Iterable { + + /** + * A var declared using the JavaScript var statement. + */ + public static class JsVar extends JsNode implements HasName { + + private final JsName name; + private JsExpression initExpr; + + public JsVar(JsName name) { + this.name = name; + } + + public JsVar(JsName name, JsExpression initExpr) { + this.name = name; + this.initExpr = initExpr; + } + + public JsExpression getInitExpr() { + return initExpr; + } + + @Override + public JsName getName() { + return name; + } + + public void setInitExpr(JsExpression initExpr) { + this.initExpr = initExpr; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + if (initExpr != null) { + initExpr = v.accept(initExpr); + } + } + v.endVisit(this, ctx); + } + + @Override + public JsVar setSourceRef(SourceInfo info) { + super.setSourceRef(info); + return this; + } + + @Override + public NodeKind getKind() { + return NodeKind.VAR; + } + } + + private final List vars = new ArrayList(); + + public JsVars() { + } + + public void add(JsVar var) { + vars.add(var); + } + + public int getNumVars() { + return vars.size(); + } + + public void insert(JsVar var) { + vars.add(var); + } + + public boolean isEmpty() { + return vars.isEmpty(); + } + + // Iterator returns JsVar objects + @Override + public Iterator iterator() { + return vars.iterator(); + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + v.acceptWithInsertRemove(vars); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.VARS; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsVisitable.java b/js/src/com/google/dart/compiler/backend/js/ast/JsVisitable.java new file mode 100644 index 00000000000..626648af8ae --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsVisitable.java @@ -0,0 +1,19 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * Abstracts the idea that a class can be traversed. + */ +public interface JsVisitable { + + /** + * Causes this object to have the visitor visit itself and its children. + * + * @param visitor the visitor that should traverse this node + * @param ctx the context of an existing traversal + */ + void traverse(JsVisitor visitor, JsContext ctx); +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsVisitor.java b/js/src/com/google/dart/compiler/backend/js/ast/JsVisitor.java new file mode 100644 index 00000000000..5b9cd983d08 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsVisitor.java @@ -0,0 +1,430 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +import java.util.List; + +/** + * Implemented by nodes that will visit child nodes. + */ +@SuppressWarnings("unused") +public class JsVisitor { + + protected static final JsContext LVALUE_CONTEXT = new JsContext() { + + @Override + public boolean canInsert() { + return false; + } + + @Override + public boolean canRemove() { + return false; + } + + @Override + public void insertAfter(JsVisitable node) { + throw new UnsupportedOperationException(); + } + + @Override + public void insertBefore(JsVisitable node) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isLvalue() { + return true; + } + + @Override + public void removeMe() { + throw new UnsupportedOperationException(); + } + + @Override + public void replaceMe(JsVisitable node) { + throw new UnsupportedOperationException(); + } + }; + + protected static final JsContext UNMODIFIABLE_CONTEXT = new JsContext() { + + @Override + public boolean canInsert() { + return false; + } + + @Override + public boolean canRemove() { + return false; + } + + @Override + public void insertAfter(JsVisitable node) { + throw new UnsupportedOperationException(); + } + + @Override + public void insertBefore(JsVisitable node) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isLvalue() { + return false; + } + + @Override + public void removeMe() { + throw new UnsupportedOperationException(); + } + + @Override + public void replaceMe(JsVisitable node) { + throw new UnsupportedOperationException(); + } + }; + + public final T accept(T node) { + return this.doAccept(node); + } + + public final void acceptList(List collection) { + doAcceptList(collection); + } + + public JsExpression acceptLvalue(JsExpression expr) { + return doAcceptLvalue(expr); + } + + public final void acceptWithInsertRemove(List collection) { + doAcceptWithInsertRemove(collection); + } + + public boolean didChange() { + throw new UnsupportedOperationException(); + } + + public void endVisit(JsArrayAccess x, JsContext ctx) { + } + + public void endVisit(JsArrayLiteral x, JsContext ctx) { + } + + public void endVisit(JsBinaryOperation x, JsContext ctx) { + } + + public void endVisit(JsBlock x, JsContext ctx) { + } + + public void endVisit(JsBooleanLiteral x, JsContext ctx) { + } + + public void endVisit(JsBreak x, JsContext ctx) { + } + + public void endVisit(JsCase x, JsContext ctx) { + } + + public void endVisit(JsCatch x, JsContext ctx) { + } + + public void endVisit(JsConditional x, JsContext ctx) { + } + + public void endVisit(JsContinue x, JsContext ctx) { + } + + public void endVisit(JsDebugger x, JsContext ctx) { + } + + public void endVisit(JsDefault x, JsContext ctx) { + } + + public void endVisit(JsDoWhile x, JsContext ctx) { + } + + public void endVisit(JsEmpty x, JsContext ctx) { + } + + public void endVisit(JsExprStmt x, JsContext ctx) { + } + + public void endVisit(JsFor x, JsContext ctx) { + } + + public void endVisit(JsForIn x, JsContext ctx) { + } + + public void endVisit(JsFunction x, JsContext ctx) { + } + + public void endVisit(JsIf x, JsContext ctx) { + } + + public void endVisit(JsInvocation x, JsContext ctx) { + } + + public void endVisit(JsLabel x, JsContext ctx) { + } + + public void endVisit(JsNameRef x, JsContext ctx) { + } + + public void endVisit(JsNew x, JsContext ctx) { + } + + public void endVisit(JsNullLiteral x, JsContext ctx) { + } + + public void endVisit(JsNumberLiteral x, JsContext ctx) { + } + + public void endVisit(JsObjectLiteral x, JsContext ctx) { + } + + public void endVisit(JsParameter x, JsContext ctx) { + } + + public void endVisit(JsPostfixOperation x, JsContext ctx) { + } + + public void endVisit(JsPrefixOperation x, JsContext ctx) { + } + + public void endVisit(JsProgram x, JsContext ctx) { + } + + public void endVisit(JsProgramFragment x, JsContext ctx) { + } + + public void endVisit(JsPropertyInitializer x, JsContext ctx) { + } + + public void endVisit(JsRegExp x, JsContext ctx) { + } + + public void endVisit(JsReturn x, JsContext ctx) { + } + + public void endVisit(JsStringLiteral x, JsContext ctx) { + } + + public void endVisit(JsSwitch x, JsContext ctx) { + } + + public void endVisit(JsThisRef x, JsContext ctx) { + } + + public void endVisit(JsThrow x, JsContext ctx) { + } + + public void endVisit(JsTry x, JsContext ctx) { + } + + public void endVisit(JsVars.JsVar x, JsContext ctx) { + } + + public void endVisit(JsVars x, JsContext ctx) { + } + + public void endVisit(JsWhile x, JsContext ctx) { + } + + public boolean visit(JsArrayAccess x, JsContext ctx) { + return true; + } + + public boolean visit(JsArrayLiteral x, JsContext ctx) { + return true; + } + + public boolean visit(JsBinaryOperation x, JsContext ctx) { + return true; + } + + public boolean visit(JsBlock x, JsContext ctx) { + return true; + } + + public boolean visit(JsBooleanLiteral x, JsContext ctx) { + return true; + } + + public boolean visit(JsBreak x, JsContext ctx) { + return true; + } + + public boolean visit(JsCase x, JsContext ctx) { + return true; + } + + public boolean visit(JsCatch x, JsContext ctx) { + return true; + } + + public boolean visit(JsConditional x, JsContext ctx) { + return true; + } + + public boolean visit(JsContinue x, JsContext ctx) { + return true; + } + + public boolean visit(JsDebugger x, JsContext ctx) { + return true; + } + + public boolean visit(JsDefault x, JsContext ctx) { + return true; + } + + public boolean visit(JsDoWhile x, JsContext ctx) { + return true; + } + + public boolean visit(JsEmpty x, JsContext ctx) { + return true; + } + + public boolean visit(JsExprStmt x, JsContext ctx) { + return true; + } + + public boolean visit(JsFor x, JsContext ctx) { + return true; + } + + public boolean visit(JsForIn x, JsContext ctx) { + return true; + } + + public boolean visit(JsFunction x, JsContext ctx) { + return true; + } + + public boolean visit(JsIf x, JsContext ctx) { + return true; + } + + public boolean visit(JsInvocation x, JsContext ctx) { + return true; + } + + public boolean visit(JsLabel x, JsContext ctx) { + return true; + } + + public boolean visit(JsNameRef x, JsContext ctx) { + return true; + } + + public boolean visit(JsNew x, JsContext ctx) { + return true; + } + + public boolean visit(JsNullLiteral x, JsContext ctx) { + return true; + } + + public boolean visit(JsNumberLiteral x, JsContext ctx) { + return true; + } + + public boolean visit(JsObjectLiteral x, JsContext ctx) { + return true; + } + + public boolean visit(JsParameter x, JsContext ctx) { + return true; + } + + public boolean visit(JsPostfixOperation x, JsContext ctx) { + return true; + } + + public boolean visit(JsPrefixOperation x, JsContext ctx) { + return true; + } + + public boolean visit(JsProgram x, JsContext ctx) { + return true; + } + + public boolean visit(JsProgramFragment x, JsContext ctx) { + return true; + } + + public boolean visit(JsPropertyInitializer x, JsContext ctx) { + return true; + } + + public boolean visit(JsRegExp x, JsContext ctx) { + return true; + } + + public boolean visit(JsReturn x, JsContext ctx) { + return true; + } + + public boolean visit(JsStringLiteral x, JsContext ctx) { + return true; + } + + public boolean visit(JsSwitch x, JsContext ctx) { + return true; + } + + public boolean visit(JsThisRef x, JsContext ctx) { + return true; + } + + public boolean visit(JsThrow x, JsContext ctx) { + return true; + } + + public boolean visit(JsTry x, JsContext ctx) { + return true; + } + + public boolean visit(JsVars.JsVar x, JsContext ctx) { + return true; + } + + public boolean visit(JsVars x, JsContext ctx) { + return true; + } + + public boolean visit(JsWhile x, JsContext ctx) { + return true; + } + + protected T doAccept(T node) { + doTraverse(node, UNMODIFIABLE_CONTEXT); + return node; + } + + protected void doAcceptList(List collection) { + for (T node : collection) { + doTraverse(node, UNMODIFIABLE_CONTEXT); + } + } + + protected JsExpression doAcceptLvalue(JsExpression expr) { + doTraverse(expr, LVALUE_CONTEXT); + return expr; + } + + protected void doAcceptWithInsertRemove(List collection) { + for (T node : collection) { + doTraverse(node, UNMODIFIABLE_CONTEXT); + } + } + + protected void doTraverse(JsVisitable node, JsContext ctx) { + node.traverse(this, ctx); + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/JsWhile.java b/js/src/com/google/dart/compiler/backend/js/ast/JsWhile.java new file mode 100644 index 00000000000..c40203bc1f1 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/JsWhile.java @@ -0,0 +1,52 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +/** + * A JavaScript while statement. + */ +public class JsWhile extends JsStatement { + + private JsStatement body; + private JsExpression condition; + + public JsWhile() { + } + + public JsWhile(JsExpression condition, JsStatement body) { + this.condition = condition; + this.body = body; + } + + public JsStatement getBody() { + return body; + } + + public JsExpression getCondition() { + return condition; + } + + public void setBody(JsStatement body) { + this.body = body; + } + + public void setCondition(JsExpression condition) { + this.condition = condition; + } + + @Override + public void traverse(JsVisitor v, JsContext ctx) { + if (v.visit(this, ctx)) { + condition = v.accept(condition); + body = v.accept(body); + } + v.endVisit(this, ctx); + } + + @Override + public NodeKind getKind() { + return NodeKind.WHILE; + } +} diff --git a/js/src/com/google/dart/compiler/backend/js/ast/NodeKind.java b/js/src/com/google/dart/compiler/backend/js/ast/NodeKind.java new file mode 100644 index 00000000000..614e4bb3bd9 --- /dev/null +++ b/js/src/com/google/dart/compiler/backend/js/ast/NodeKind.java @@ -0,0 +1,50 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.backend.js.ast; + +public enum NodeKind { + ARRAY_ACCESS, + ARRAY, + BINARY_OP, + BLOCK, + BOOLEAN, + BREAK, + CASE, + CATCH, + CONDITIONAL, + CONTINUE, + DEBUGGER, + DEFAULT, + DO, + EMPTY, + EXPR_STMT, + FOR, + FOR_IN, + FUNCTION, + IF, + INVOKE, + LABEL, + NAME_REF, + NEW, + NULL, + NUMBER, + OBJECT, + PARAMETER, + POSTFIX_OP, + PREFIX_OP, + PROGRAM, + PROGRAM_FRAGMENT, + PROPERTY_INIT, + REGEXP, + RETURN, + STRING, + SWITCH, + THIS, + THROW, + TRY, + VARS, + VAR, + WHILE +} diff --git a/js/src/com/google/dart/compiler/common/AbstractNode.java b/js/src/com/google/dart/compiler/common/AbstractNode.java new file mode 100644 index 00000000000..5b70197dd13 --- /dev/null +++ b/js/src/com/google/dart/compiler/common/AbstractNode.java @@ -0,0 +1,81 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.common; + +import com.google.dart.compiler.Source; + +/** + * Abstract base class for nodes that carry source information. + */ +public class AbstractNode implements SourceInfo, HasSourceInfo { + + // TODO(johnlenz): All this source location data is wasteful. + // Move it into a com.google.dart.compiler.backend.common object, that can be shared between the ASTs + // or something. + protected Source source = null; + protected int sourceLine = -1; + protected int sourceColumn = -1; + protected int sourceStart = -1; + protected int sourceLength = -1; + + @Override + public Source getSource() { + return source; + } + + @Override + public int getSourceLine() { + return sourceLine; + } + + @Override + public int getSourceColumn() { + return sourceColumn; + } + + @Override + public int getSourceStart() { + return sourceStart; + } + + @Override + public int getSourceLength() { + return sourceLength; + } + + @Override + public SourceInfo getSourceInfo() { + return this; + } + + @Override + public void setSourceInfo(SourceInfo info) { + source = info.getSource(); + sourceStart = info.getSourceStart(); + sourceLength = info.getSourceLength(); + sourceLine = info.getSourceLine(); + sourceColumn = info.getSourceColumn(); + } + + @Override + public final void setSourceLocation( + Source source, int line, int column, int startPosition, int length) { + assert (startPosition != -1 && length >= 0 + || startPosition == -1 && length == 0); + this.source = source; + this.sourceLine = line; + this.sourceColumn = column; + this.sourceStart = startPosition; + this.sourceLength = length; + } + + public final void setSourceRange(int startPosition, int length) { + assert (startPosition != -1 && length >= 0 + || startPosition == -1 && length == 0); + this.sourceStart = startPosition; + this.sourceLength = length; + } + +} diff --git a/js/src/com/google/dart/compiler/common/HasSourceInfo.java b/js/src/com/google/dart/compiler/common/HasSourceInfo.java new file mode 100644 index 00000000000..bda3da94996 --- /dev/null +++ b/js/src/com/google/dart/compiler/common/HasSourceInfo.java @@ -0,0 +1,55 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.common; + +import com.google.dart.compiler.Source; + +/** + * Abstract view of a class that has source info. + */ +public interface HasSourceInfo { + + /** + * Return the source info associated with this object. + */ + SourceInfo getSourceInfo(); + + /** + * Set the source info associated with this object. May only be called once. + * @param info + */ + void setSourceInfo(SourceInfo info); + + /** + * Sets the source range of the original source file where the source fragment + * corresponding to this node was found. + * + *

+ * Each node in the subtree (other than the contrived nodes) carries source + * range(s) information relating back to positions in the given source (the + * given source itself is not remembered with the AST). The source range + * usually begins at the first character of the first token corresponding to + * the node; leading whitespace and comments are not included. The + * source range usually extends through the last character of the last token + * corresponding to the node; trailing whitespace and comments are not + * included. There are a handful of exceptions (including the various body + * declarations). Source ranges nest properly: the source range for a child is + * always within the source range of its parent, and the source ranges of + * sibling nodes never overlap. + * + * @param source the associated source + * @param line the 1-based line index, or -1, if no source + * location is available + * @param column the 1-based column index, or -1, if no source + * location is available + * @param startPosition a 0-based character index, or -1, if no + * source location is available + * @param length a (possibly 0) length, or -1, if no source + * location is available + * @see SourceInfo#getSourceStart() + * @see SourceInfo#getSourceLength() + */ + void setSourceLocation(Source source, int line, int column, int startPosition, int length); +} diff --git a/js/src/com/google/dart/compiler/common/Name.java b/js/src/com/google/dart/compiler/common/Name.java new file mode 100644 index 00000000000..4697b491d96 --- /dev/null +++ b/js/src/com/google/dart/compiler/common/Name.java @@ -0,0 +1,121 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.common; + +import java.io.*; +import java.nio.charset.Charset; + +/** + * Instead of Strings, we use GlobalNames to abstract the underlying representation. + * + *

    + *
  • 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 + * to parse byte[]. + */ +public final class Name implements Serializable { + + /** + * The encoding this class uses when converting between chars and bytes. + */ + public static final Charset CHARSET = Charset.forName("UTF-8"); + + private static final NameFactory factory = new NameFactory(); + + private static final long serialVersionUID = 0L; + + /** + * Return the Name corresponding to the data. An internal reference to + * data is kept for efficiency, do NOT mutate data after calling + * this method. + */ + public static Name of(char[] data) { + return factory.of(data); + } + + /** + * Return the Name corresponding to the data. An internal copy of the data is + * made. + */ + public static Name of(char[] data, int offset, int length) { + return factory.of(data, offset, length); + } + + static int computeHashCode(char[] data, int offset, int length) { + // Effective Java Item 9. + int result = 89; + for (int i = offset, end = offset + length; i < end; ++i) { + result *= 31; + result += data[i]; + } + return result; + } + + final char[] data; + + private final transient int hashCode; + + Name(char[] data, int hashCode) { + this.data = data; + this.hashCode = hashCode; + } + + /** + * Always compares based on identity. + */ + @Override + public boolean equals(Object obj) { + return this == obj; + } + + /** + * Returns the hashCode of the underlying data. + */ + @Override + public int hashCode() { + return hashCode; + } + + /** + * Constructs a String to represent the internal data. + */ + @Override + public String toString() { + return String.valueOf(data); + } + + /** + * Write my data into a {@link java.io.OutputStream} using the encoding specified in + * {@link #CHARSET}. + */ + public void writeBytesTo(OutputStream out) throws IOException { + // TODO(scottb): avoid allocating the String. + out.write(new String(data).getBytes(CHARSET)); + } + + /** + * Write my character data into a {@link java.io.PrintStream}. + */ + public void writeCharsTo(PrintStream out) { + out.print(data); + } + + /** + * Write my character data into a {@link java.io.Writer}. + */ + public void writeCharsTo(Writer writer) throws IOException { + writer.write(data); + } + + /** + * Replace with the canonical instance. + */ + private Object readResolve() { + return Name.of(data); + } +} diff --git a/js/src/com/google/dart/compiler/common/NameFactory.java b/js/src/com/google/dart/compiler/common/NameFactory.java new file mode 100644 index 00000000000..d305f290bf9 --- /dev/null +++ b/js/src/com/google/dart/compiler/common/NameFactory.java @@ -0,0 +1,226 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.common; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.MapMaker; + +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.util.Arrays; +import java.util.concurrent.ConcurrentMap; + +/** + * Manages the life cycle, uniqueness, and object identity invariants of + * {@link Name}. + */ +final class NameFactory { + /* + * TODO: does this actually save memory in practice? For each interned Name, + * we use: + * + * 1) The data array (n bytes). + * + * 2) The Name object (2 fields) + * + * 3) The RealKey (1 field + 4 fields from Reference). + * + * 4) ConcurrentMap.Entry (4 fields) + * + * Of course, a Map is really much heavier than we need, all we really need is + * a Set where you can retrieve an object already in the Set. A bare linear + * probe hash table of RealKey would let us get rid of the Entry object. + */ + + /** + * The whole point of this class is to cheaply create a light-weight key that + * doesn't need to make its own copy of the data. This object is constructed + * with equality semantics to {com.google.dart.compiler.backend.common.NameFactory.RealKey}, for doing cheap map lookups. + */ + private static final class FakeKey { + private final char[] data; + private final int hashCode; + private final int length; + private final int offset; + + public FakeKey(char[] data, int hashCode) { + this(data, 0, data.length, hashCode); + } + + public FakeKey(char[] data, int offset, int length, int hashCode) { + this.data = data; + this.offset = offset; + this.length = length; + this.hashCode = hashCode; + } + + @Override + public boolean equals(Object obj) { + /* + * NOTE: this ONLY WORKS for comparisons to RealKey. But that's all we + * need since we only store real keys in the map. + */ + Name name = ((RealKey) obj).get(); + if (name == null) { + return false; + } + return equalsName(name); + } + + public boolean equalsName(Name name) { + if (this.length != name.data.length) { + return false; + } + int itMine = this.offset; + int itTheirs = 0; + int endMine = this.offset + this.length; + while (itMine < endMine) { + if (this.data[itMine++] != name.data[itTheirs++]) { + return false; + } + } + return true; + } + + @Override + public int hashCode() { + return hashCode; + } + + @Override + public String toString() { + return "FakeKey(" + String.valueOf(data, offset, length) + ")"; + } + } + + /** + * Adapted from {@link com.google.common.collect.Interners#newWeakInterner()}. + */ + private static final class RealKey extends WeakReference { + /** + * Must store the hashCode locally so we can be removed from + * {com.google.dart.compiler.backend.common.NameFactory#map} after our referent is cleared. + */ + private final int hashCode; + + public RealKey(Name name, ReferenceQueue queue) { + super(name, queue); + hashCode = name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof FakeKey) { + Name referent = get(); + if (referent == null) { + return false; + } + return ((FakeKey) obj).equalsName(referent); + } + if (obj instanceof RealKey) { + Name referent = get(); + if (referent == null) { + return false; + } + Name otherReferent = ((RealKey) obj).get(); + if (otherReferent == null) { + return false; + } + return Arrays.equals(referent.data, otherReferent.data); + } + return false; + } + + @Override + public int hashCode() { + return hashCode; + } + + @Override + public String toString() { + Name referent = get(); + return "RealKey(" + referent + ")"; + } + } + + private final ConcurrentMap map = new MapMaker().makeMap(); + private final ReferenceQueue queue = new ReferenceQueue(); + + /** + * Return the Name corresponding to the data. An internal reference to + * data may be kept. + */ + public Name of(char[] data) { + cleanUp(); + int hashCode = Name.computeHashCode(data, 0, data.length); + FakeKey fakeKey = new FakeKey(data, hashCode); + Name result = get(fakeKey); + if (result == null) { + result = put(new Name(data, hashCode)); + } + return result; + } + + /** + * Return the Name corresponding to the data. An internal copy of the data is + * made. + */ + public Name of(char[] data, int offset, int length) { + cleanUp(); + int hashCode = Name.computeHashCode(data, offset, length); + FakeKey fakeKey = new FakeKey(data, offset, length, hashCode); + Name result = get(fakeKey); + if (result == null) { + char[] copy = new char[length]; + System.arraycopy(data, offset, copy, 0, length); + result = put(new Name(copy, hashCode)); + } + return result; + } + + @VisibleForTesting + void cleanUp() { + RealKey item; + while ((item = (RealKey) queue.poll()) != null) { + map.remove(item); + } + } + + @VisibleForTesting + WeakReference getRefFor(Name name) { + return map.get(new FakeKey(name.data, name.hashCode())); + } + + @VisibleForTesting + int numEntries() { + return map.size(); + } + + private Name get(FakeKey fakeKey) { + RealKey realKey = map.get(fakeKey); + if (realKey != null) { + return realKey.get(); + } + return null; + } + + private Name put(Name name) { + RealKey realKey = new RealKey(name, queue); + while (true) { + RealKey sneakyRef = map.putIfAbsent(realKey, realKey); + if (sneakyRef == null) { + return name; + } else { + Name canonical = sneakyRef.get(); + if (canonical != null) { + return canonical; + } + } + } + } +} diff --git a/js/src/com/google/dart/compiler/common/SourceInfo.java b/js/src/com/google/dart/compiler/common/SourceInfo.java new file mode 100644 index 00000000000..3a5cd23f113 --- /dev/null +++ b/js/src/com/google/dart/compiler/common/SourceInfo.java @@ -0,0 +1,58 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.common; +import com.google.dart.compiler.Source; + +import java.io.Serializable; + +/** + * Tracks file and line information for AST nodes. + */ +public interface SourceInfo extends Serializable { + + /** + * The source code provider. + */ + Source getSource(); + + /** + * @return A 1-based line number into the original source file indicating + * where the source fragment begins. + */ + int getSourceLine(); + + /** + * @return A 1-based column number into the original source file indicating + * where the source fragment begins. + */ + int getSourceColumn(); + + /** + * Returns the character index into the original source file indicating + * where the source fragment corresponding to this node begins. + * + *

+ * The parser supplies useful well-defined source ranges to the nodes it creates. + * + * @return the 0-based character index, or -1 + * if no source startPosition information is recorded for this node + * @see #getSourceLength() + * @see HasSourceInfo#setSourceLocation(com.google.dart.compiler.Source, int, int, int, int) + */ + int getSourceStart(); + + /** + * Returns the length in characters of the original source file indicating + * where the source fragment corresponding to this node ends. + *

+ * The parser supplies useful well-defined source ranges to the nodes it creates. + * + * @return a (possibly 0) length, or 0 + * if no source source position information is recorded for this node + * @see #getSourceStart() + * @see HasSourceInfo#setSourceLocation(com.google.dart.compiler.Source, int, int, int, int) + */ + int getSourceLength(); +} diff --git a/js/src/com/google/dart/compiler/util/AbstractTextOutput.java b/js/src/com/google/dart/compiler/util/AbstractTextOutput.java new file mode 100644 index 00000000000..9c8d2b1cd16 --- /dev/null +++ b/js/src/com/google/dart/compiler/util/AbstractTextOutput.java @@ -0,0 +1,132 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.util; + +import java.io.PrintWriter; +import java.util.Arrays; + +/** + * An abstract base type to build TextOutput implementations. + */ +public abstract class AbstractTextOutput implements TextOutput { + private final boolean compact; + private int identLevel = 0; + private int indentGranularity = 2; + private char[][] indents = new char[][] {new char[0]}; + private boolean justNewlined; + private PrintWriter out; + private int position = 0; + private int line = 0; + private int column = 0; + + protected AbstractTextOutput(boolean compact) { + this.compact = compact; + } + + public int getPosition() { + return position; + } + + public int getLine() { + return line; + } + + public int getColumn() { + return column; + } + + public void indentIn() { + ++identLevel; + if (identLevel >= indents.length) { + // Cache a new level of indentation string. + // + char[] newIndentLevel = new char[identLevel * indentGranularity]; + Arrays.fill(newIndentLevel, ' '); + char[][] newIndents = new char[indents.length + 1][]; + System.arraycopy(indents, 0, newIndents, 0, indents.length); + newIndents[identLevel] = newIndentLevel; + indents = newIndents; + } + } + + public void indentOut() { + --identLevel; + } + + public void newline() { + out.print('\n'); + position++; + line++; + column = 0; + justNewlined = true; + } + + public void newlineOpt() { + if (!compact) { + newline(); + } + } + + public void print(char c) { + maybeIndent(); + out.print(c); + position++; + column++; + justNewlined = false; + } + + public void print(char[] s) { + maybeIndent(); + printAndCount(s); + justNewlined = false; + } + + public void print(String s) { + maybeIndent(); + printAndCount(s.toCharArray()); + justNewlined = false; + } + + // Why don't the "Opt" methods update "justNewLined"? + public void printOpt(char c) { + if (!compact) { + maybeIndent(); + out.print(c); + position += 1; + column++; + } + } + + public void printOpt(char[] s) { + if (!compact) { + maybeIndent(); + printAndCount(s); + } + } + + public void printOpt(String s) { + if (!compact) { + maybeIndent(); + printAndCount(s.toCharArray()); + } + } + + protected void setPrintWriter(PrintWriter out) { + this.out = out; + } + + private void maybeIndent() { + if (justNewlined && !compact) { + printAndCount(indents[identLevel]); + justNewlined = false; + } + } + + private void printAndCount(char[] chars) { + position += chars.length; + column += chars.length; + out.print(chars); + } +} diff --git a/js/src/com/google/dart/compiler/util/AstUtil.java b/js/src/com/google/dart/compiler/util/AstUtil.java new file mode 100644 index 00000000000..c635d696c54 --- /dev/null +++ b/js/src/com/google/dart/compiler/util/AstUtil.java @@ -0,0 +1,404 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.util; + +import com.google.dart.compiler.InternalCompilerException; +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.common.SourceInfo; +import com.sun.istack.internal.NotNull; + +import java.util.List; + +/** + * @author johnlenz@google.com (John Lenz) + */ +public class AstUtil { + + public static JsInvocation newInvocation( + JsExpression target, JsExpression... params) { + JsInvocation invoke = new JsInvocation(); + invoke.setQualifier(target); + for (JsExpression expr : params) { + invoke.getArguments().add(expr); + } + 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; + int startPos = 0; + do { + endPos = name.indexOf('.', startPos); + String part = (endPos == -1 + ? name.substring(startPos) + : name.substring(startPos, endPos)); + node = newNameRef(node, part); + startPos = endPos + 1; + } while (endPos != -1); + + return node; + } + + public static JsNameRef newNameRef(JsExpression qualifier, String prop) { + JsNameRef nameRef = new JsNameRef(prop); + if (qualifier != null) { + nameRef.setQualifier(qualifier); + } + return nameRef; + } + + public static JsNameRef nameref(SourceInfo info, JsName qualifier, JsName prop) { + JsNameRef nameRef = new JsNameRef(prop); + if (qualifier != null) { + nameRef.setQualifier(qualifier.makeRef()); + } + nameRef.setSourceRef(info); + return nameRef; + } + + public static JsNameRef newNameRef(JsExpression qualifier, JsName prop) { + JsNameRef nameRef = new JsNameRef(prop); + if (qualifier != null) { + nameRef.setQualifier(qualifier); + } + return nameRef; + } + + public static JsNameRef newPrototypeNameRef(JsExpression qualifier) { + return newNameRef(qualifier, "prototype"); + } + + public static JsArrayAccess newArrayAccess(JsExpression target, JsExpression key) { + JsArrayAccess arr = new JsArrayAccess(); + arr.setArrayExpr(target); + arr.setIndexExpr(key); + return arr; + } + + public static JsBlock newBlock(JsStatement... stmts) { + JsBlock jsBlock = new JsBlock(); + for (JsStatement stmt : stmts) { + jsBlock.getStatements().add(stmt); + } + return jsBlock; + } + + /** + * Returns a sequence of expressions (using the binary sequence operator). + * + * @param exprs - expressions to add to sequence + * @return a sequence of expressions. + */ + public static JsBinaryOperation newSequence(JsExpression... exprs) { + if (exprs.length < 2) { + throw new InternalCompilerException("newSequence expects at least two arguments"); + } + JsExpression result = exprs[exprs.length - 1]; + for (int i = exprs.length - 2; i >= 0; i--) { + result = new JsBinaryOperation(JsBinaryOperator.COMMA, exprs[i], result); + } + return (JsBinaryOperation) result; + } + + // Ensure a valid LHS + public static JsBinaryOperation newAssignment( + JsNameRef nameRef, JsExpression expr) { + return new JsBinaryOperation(JsBinaryOperator.ASG, nameRef, expr); + } + + public static JsBinaryOperation newAssignment( + JsArrayAccess target, JsExpression expr) { + return new JsBinaryOperation(JsBinaryOperator.ASG, target, expr); + } + + public static JsVars newVar(SourceInfo info, JsName name, JsExpression expr) { + JsVars.JsVar var = new JsVars.JsVar(name).setSourceRef(info); + var.setInitExpr(expr); + JsVars vars = new JsVars(); + vars.add(var); + return vars; + } + + public static JsVars newVar(JsName name, JsExpression expr) { + JsVars.JsVar var = new JsVars.JsVar(name); + if (expr != null) { + var.setInitExpr(expr); + } + JsVars vars = new JsVars(); + vars.add(var); + return vars; + } + + public static JsSwitch newSwitch( + JsExpression expr, JsSwitchMember... cases) { + JsSwitch jsSwitch = new JsSwitch(); + jsSwitch.setExpr(expr); + for (JsSwitchMember jsCase : cases) { + jsSwitch.getCases().add(jsCase); + } + return jsSwitch; + } + + public static JsCase newCase(JsExpression expr, JsStatement... stmts) { + JsCase jsCase = new JsCase(); + jsCase.setCaseExpr(expr); + for (JsStatement stmt : stmts) { + jsCase.getStmts().add(stmt); + } + return jsCase; + } + + public static JsDefault newDefaultCase(JsStatement... stmts) { + JsDefault jsCase = new JsDefault(); + for (JsStatement stmt : stmts) { + jsCase.getStmts().add(stmt); + } + return jsCase; + } + + public static JsFunction newFunction( + JsScope scope, JsName name, List params, JsBlock body) { + JsFunction fn = new JsFunction(scope); + if (name != null) { + fn.setName(name); + } + if (params != null) { + for (JsParameter param : params) { + fn.getParameters().add(param); + } + } + fn.setBody(body); + return fn; + } + + public static JsInvocation call(SourceInfo src, JsExpression target, JsExpression... params) { + return (JsInvocation) newInvocation(target, params).setSourceRef(src); + } + + public static JsBinaryOperation comma(SourceInfo src, JsExpression op1, JsExpression op2) { + return (JsBinaryOperation) new JsBinaryOperation(JsBinaryOperator.COMMA, op1, op2) + .setSourceRef(src); + } + + public static JsNameRef nameref(SourceInfo src, String name) { + return (JsNameRef) new JsNameRef(name).setSourceRef(src); + } + + public static JsNameRef nameref(SourceInfo src, JsName qualifier, String prop) { + return nameref(src, qualifier.makeRef().setSourceRef(src), prop); + } + + public static JsNameRef nameref(SourceInfo src, JsExpression qualifier, String prop) { + return (JsNameRef) newNameRef(qualifier, prop).setSourceRef(src); + } + + public static JsExpression assign(SourceInfo src, JsNameRef op1, JsExpression op2) { + return newAssignment(op1, op2).setSourceRef(src); + } + + public static JsExpression neq(SourceInfo src, JsExpression op1, JsExpression op2) { + return new JsBinaryOperation(JsBinaryOperator.NEQ, op1, op2).setSourceRef(src); + } + + public static JsExpression not(SourceInfo src, JsExpression op1) { + return new JsPrefixOperation(JsUnaryOperator.NOT, op1).setSourceRef(src); + } + + public static JsExpression preinc(SourceInfo src, JsExpression op1) { + return new JsPrefixOperation(JsUnaryOperator.INC, op1).setSourceRef(src); + } + + public static JsExpression and(SourceInfo src, JsExpression op1, JsExpression op2) { + return new JsBinaryOperation(JsBinaryOperator.AND, op1, op2).setSourceRef(src); + } + + public static JsExpression in(SourceInfo src, JsExpression propName, JsExpression obj) { + return new JsBinaryOperation(JsBinaryOperator.INOP, propName, obj).setSourceRef(src); + } + + + // Pavel Talanov + public static JsPropertyInitializer newNamedMethod(JsName name, JsFunction function) { + JsNameRef methodName = name.makeRef(); + return new JsPropertyInitializer(methodName, function); + } + + public static JsStatement convertToStatement(JsNode jsNode) { + assert (jsNode instanceof JsExpression) || (jsNode instanceof JsStatement) + : "Unexpected node of type: " + jsNode.getClass().toString(); + if (jsNode instanceof JsExpression) { + return new JsExprStmt((JsExpression) jsNode); + } + return (JsStatement) jsNode; + } + + public static JsBlock convertToBlock(JsNode jsNode) { + if (jsNode instanceof JsBlock) { + return (JsBlock) jsNode; + } + JsStatement jsStatement = convertToStatement(jsNode); + return new JsBlock(jsStatement); + } + + public static JsExpression convertToExpression(JsNode jsNode) { + assert jsNode instanceof JsExpression : "Unexpected node of type: " + jsNode.getClass().toString(); + return (JsExpression) jsNode; + } + + public static JsNameRef thisQualifiedReference(JsName name) { + JsNameRef result = name.makeRef(); + result.setQualifier(new JsThisRef()); + return result; + } + + public static JsBlock newBlock(List statements) { + JsBlock result = new JsBlock(); + result.setStatements(statements); + return result; + } + + public static JsPrefixOperation negated(JsExpression expression) { + return new JsPrefixOperation(JsUnaryOperator.NOT, expression); + } + + public static JsStatement newAssignmentStatement(JsNameRef nameRef, JsExpression expr) { + return convertToStatement(new JsBinaryOperation(JsBinaryOperator.ASG, nameRef, expr)); + } + + public static JsExpression extractExpressionFromStatement(JsStatement statement) { + assert statement instanceof JsExprStmt : "Cannot extract expression from statement: " + statement; + return (((JsExprStmt) statement).getExpression()); + } + + public static JsBinaryOperation and(JsExpression op1, JsExpression op2) { + return new JsBinaryOperation(JsBinaryOperator.AND, op1, op2); + } + + public static JsBinaryOperation or(JsExpression op1, JsExpression op2) { + return new JsBinaryOperation(JsBinaryOperator.OR, op1, op2); + } + + //TODO refactor + public static void setQualifier(JsExpression selector, JsExpression receiver) { + if (selector instanceof JsInvocation) { + setQualifier(((JsInvocation) selector).getQualifier(), receiver); + return; + } + if (selector instanceof JsNameRef) { + JsNameRef nameRef = (JsNameRef) selector; + JsExpression qualifier = nameRef.getQualifier(); + if (qualifier == null) { + nameRef.setQualifier(receiver); + } else { + setQualifier(qualifier, receiver); + } + return; + } + throw new AssertionError("Set qualifier should be applied only to JsInvocation or JsNameRef instances"); + } + + //TODO: look for should-be-usages + public static JsNameRef qualified(JsName selector, JsExpression qualifier) { + JsNameRef reference = selector.makeRef(); + AstUtil.setQualifier(reference, qualifier); + return reference; + } + + public static JsBinaryOperation equals(JsExpression arg1, JsExpression arg2) { + return new JsBinaryOperation(JsBinaryOperator.EQ, arg1, arg2); + } + + public static JsBinaryOperation notEqual(JsExpression arg1, JsExpression arg2) { + return new JsBinaryOperation(JsBinaryOperator.NEQ, arg1, arg2); + } + + public static JsExpression equalsTrue(JsExpression expression, JsProgram program) { + return equals(expression, program.getTrueLiteral()); + } + + public static JsExpression assignment(JsExpression left, JsExpression right) { + return new JsBinaryOperation(JsBinaryOperator.ASG, left, right); + } + + public static JsBinaryOperation sum(JsExpression left, JsExpression right) { + return new JsBinaryOperation(JsBinaryOperator.ADD, left, right); + } + + public static JsBinaryOperation subtract(JsExpression left, JsExpression right) { + return new JsBinaryOperation(JsBinaryOperator.SUB, left, right); + } + + public static JsPrefixOperation not(JsExpression expression) { + return new JsPrefixOperation(JsUnaryOperator.NOT, expression); + } + + public static JsBinaryOperation typeof(JsExpression expression, JsStringLiteral string) { + return equals(new JsPrefixOperation(JsUnaryOperator.TYPEOF, expression), string); + } + + public static interface Mutator { + public JsNode mutate(JsNode node); + } + + + //TODO: move somewhere + //TODO: refactor and review + public static JsNode mutateLastExpression(JsNode node, Mutator mutator) { + if (node instanceof JsBlock) { + JsBlock block = (JsBlock) node; + List statements = block.getStatements(); + + if (statements.isEmpty()) return block; + + int size = statements.size(); + statements.set(size - 1, + AstUtil.convertToStatement(mutateLastExpression(statements.get(size - 1), mutator))); + return block; + } + if (node instanceof JsIf) { + JsIf ifExpr = (JsIf) node; + ifExpr.setThenStmt(AstUtil.convertToStatement(mutateLastExpression(ifExpr.getThenStmt(), mutator))); + JsStatement elseStmt = ifExpr.getElseStmt(); + if (elseStmt != null) { + ifExpr.setElseStmt(AstUtil.convertToStatement(mutateLastExpression(elseStmt, mutator))); + } + return ifExpr; + } + if (node instanceof JsExprStmt) { + return AstUtil.convertToStatement(mutateLastExpression(((JsExprStmt) node).getExpression(), mutator)); + } + return mutator.mutate(node); + } + + + public static final class SaveLastExpressionMutator implements Mutator { + + @NotNull + private final JsExpression toAssign; + + public SaveLastExpressionMutator(@NotNull JsExpression toAssign) { + this.toAssign = toAssign; + } + + @Override + public JsNode mutate(JsNode node) { + if (!(node instanceof JsExpression)) { + return node; + } + return AstUtil.assignment(toAssign, (JsExpression) node); + } + } +} diff --git a/js/src/com/google/dart/compiler/util/DefaultTextOutput.java b/js/src/com/google/dart/compiler/util/DefaultTextOutput.java new file mode 100644 index 00000000000..2a064ff87fd --- /dev/null +++ b/js/src/com/google/dart/compiler/util/DefaultTextOutput.java @@ -0,0 +1,32 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.util; + +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * Adapts {@link TextOutput} to an internal text buffer. + */ +public class DefaultTextOutput extends AbstractTextOutput { + + private final StringWriter sw = new StringWriter(); + private final PrintWriter out; + + public DefaultTextOutput(boolean compact) { + super(compact); + setPrintWriter(out = new PrintWriter(sw)); + } + + @Override + public String toString() { + out.flush(); + if (sw != null) { + return sw.toString(); + } else { + return super.toString(); + } + } +} diff --git a/js/src/com/google/dart/compiler/util/Hack.java b/js/src/com/google/dart/compiler/util/Hack.java new file mode 100644 index 00000000000..642f416394f --- /dev/null +++ b/js/src/com/google/dart/compiler/util/Hack.java @@ -0,0 +1,16 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.util; + +/** + * Utility to hack around untypable (or yet to be) code. + */ +public class Hack { + public static T cast(Object o) { + @SuppressWarnings("unchecked") + T t = (T) o; + return t; + } +} diff --git a/js/src/com/google/dart/compiler/util/Lists.java b/js/src/com/google/dart/compiler/util/Lists.java new file mode 100644 index 00000000000..b0ca023d280 --- /dev/null +++ b/js/src/com/google/dart/compiler/util/Lists.java @@ -0,0 +1,291 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.util; + +import java.util.*; + +/** + * Utility methods for operating on memory-efficient lists. All lists of size 0 + * or 1 are assumed to be immutable. All lists of size greater than 1 are + * assumed to be mutable. + */ +public class Lists { + + private static final Class MULTI_LIST_CLASS = ArrayList.class; + private static final Class SINGLETON_LIST_CLASS = Collections.singletonList(null).getClass(); + + public static List add(List list, int index, T toAdd) { + switch (list.size()) { + case 0: + // Empty -> Singleton + if (index != 0) { + throw newIndexOutOfBounds(list, index); + } + return Collections.singletonList(toAdd); + case 1: { + // Singleton -> ArrayList + List result = new ArrayList(2); + switch (index) { + case 0: + result.add(toAdd); + result.add(list.get(0)); + return result; + case 1: + result.add(list.get(0)); + result.add(toAdd); + return result; + default: + throw newIndexOutOfBounds(list, index); + } + } + default: + // ArrayList + list.add(index, toAdd); + return list; + } + } + + public static List add(List list, T toAdd) { + switch (list.size()) { + case 0: + // Empty -> Singleton + return Collections.singletonList(toAdd); + case 1: { + // Singleton -> ArrayList + List result = new ArrayList(2); + result.add(list.get(0)); + result.add(toAdd); + return result; + } + default: + // ArrayList + list.add(toAdd); + return list; + } + } + + public static List addAll(List list, int index, List toAdd) { + switch (toAdd.size()) { + case 0: + // No-op. + return list; + case 1: + // Add one element. + return add(list, index, toAdd.get(0)); + default: + // True list merge, result >= 2. + switch (list.size()) { + case 0: + if (index != 0) { + throw newIndexOutOfBounds(list, index); + } + return new ArrayList(toAdd); + case 1: { + List result = new ArrayList(1 + toAdd.size()); + switch (index) { + case 0: + result.addAll(toAdd); + result.add(list.get(0)); + return result; + case 1: + result.add(list.get(0)); + result.addAll(toAdd); + return result; + default: + throw newIndexOutOfBounds(list, index); + } + } + default: + list.addAll(index, toAdd); + return list; + } + } + } + + public static List addAll(List list, List toAdd) { + switch (toAdd.size()) { + case 0: + // No-op. + return list; + case 1: + // Add one element. + return add(list, toAdd.get(0)); + default: + // True list merge, result >= 2. + switch (list.size()) { + case 0: + return new ArrayList(toAdd); + case 1: { + List result = new ArrayList(1 + toAdd.size()); + result.add(list.get(0)); + result.addAll(toAdd); + return result; + } + default: + list.addAll(toAdd); + return list; + } + } + } + + public static List addAll(List list, T... toAdd) { + switch (toAdd.length) { + case 0: + // No-op. + return list; + case 1: + // Add one element. + return add(list, toAdd[0]); + default: + // True list merge, result >= 2. + switch (list.size()) { + case 0: + return new ArrayList(Arrays.asList(toAdd)); + case 1: { + List result = new ArrayList(1 + toAdd.length); + result.add(list.get(0)); + result.addAll(Arrays.asList(toAdd)); + return result; + } + default: + list.addAll(Arrays.asList(toAdd)); + return list; + } + } + } + + public static List create() { + return Collections.emptyList(); + } + + public static List create(Collection collection) { + switch (collection.size()) { + case 0: + return create(); + default: + return new ArrayList(collection); + } + } + + public static List create(List list) { + switch (list.size()) { + case 0: + return create(); + case 1: + return create(list.get(0)); + default: + return new ArrayList(list); + } + } + + public static List create(T item) { + return Collections.singletonList(item); + } + + public static List create(T... items) { + switch (items.length) { + case 0: + return create(); + case 1: + return create(items[0]); + default: + return new ArrayList(Arrays.asList(items)); + } + } + + public static List normalize(List list) { + switch (list.size()) { + case 0: + return create(); + case 1: { + if (list.getClass() == SINGLETON_LIST_CLASS) { + return list; + } + return create(list.get(0)); + } + default: + if (list.getClass() == MULTI_LIST_CLASS) { + return list; + } + return new ArrayList(list); + } + } + + public static List normalizeUnmodifiable(List list) { + if (list.size() < 2) { + return normalize(list); + } else { + List copy = new ArrayList(list.size()); + Collections.copy(copy, list); + return copy; + } + } + + public static List remove(List list, int toRemove) { + switch (list.size()) { + case 0: + // Empty + throw newIndexOutOfBounds(list, toRemove); + case 1: + // Singleton -> Empty + if (toRemove == 0) { + return Collections.emptyList(); + } else { + throw newIndexOutOfBounds(list, toRemove); + } + case 2: + // ArrayList -> Singleton + switch (toRemove) { + case 0: + return Collections.singletonList(list.get(1)); + case 1: + return Collections.singletonList(list.get(0)); + default: + throw newIndexOutOfBounds(list, toRemove); + } + default: + // ArrayList + list.remove(toRemove); + return list; + } + } + + public static List set(List list, int index, T e) { + switch (list.size()) { + case 0: + // Empty + throw newIndexOutOfBounds(list, index); + case 1: + // Singleton + if (index == 0) { + return Collections.singletonList(e); + } else { + throw newIndexOutOfBounds(list, index); + } + default: + // ArrayList + list.set(index, e); + return list; + } + } + + public static > List sort(List list) { + if (list.size() > 1) { + Collections.sort(list); + } + return list; + } + + public static List sort(List list, Comparator sort) { + if (list.size() > 1) { + Collections.sort(list, sort); + } + return list; + } + + private static IndexOutOfBoundsException newIndexOutOfBounds(List list, int index) { + return new IndexOutOfBoundsException("Index: " + index + ", Size: " + list.size()); + } +} diff --git a/js/src/com/google/dart/compiler/util/Maps.java b/js/src/com/google/dart/compiler/util/Maps.java new file mode 100644 index 00000000000..15274b04902 --- /dev/null +++ b/js/src/com/google/dart/compiler/util/Maps.java @@ -0,0 +1,160 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.util; + +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Utility methods for operating on memory-efficient maps. All maps of size 0 or + * 1 are assumed to be immutable. All maps of size greater than 1 are assumed to + * be mutable. + */ +public class Maps { + + private static final Class MULTI_MAP_CLASS = HashMap.class; + private static final Class SINGLETON_MAP_CLASS = + Collections.singletonMap(null, null).getClass(); + + public static Map create() { + return Collections.emptyMap(); + } + + public static Map create(K key, V value) { + return Collections.singletonMap(key, value); + } + + public static Map normalize(Map map) { + switch (map.size()) { + case 0: + return create(); + case 1: { + if (map.getClass() == SINGLETON_MAP_CLASS) { + return map; + } + K key = map.keySet().iterator().next(); + return create(key, map.get(key)); + } + default: + if (map.getClass() == MULTI_MAP_CLASS) { + return map; + } + return new HashMap(map); + } + } + + public static Map normalizeUnmodifiable(Map map) { + if (map.size() < 2) { + return normalize(map); + } else { + // TODO: implement an UnmodifiableHashMap? + return Collections.unmodifiableMap(normalize(map)); + } + } + + public static Map put(Map map, K key, V value) { + switch (map.size()) { + case 0: + // Empty -> Singleton + return Collections.singletonMap(key, value); + case 1: { + if (map.containsKey(key)) { + return create(key, value); + } + // Singleton -> HashMap + Map result = new HashMap(); + result.put(map.keySet().iterator().next(), map.values().iterator().next()); + result.put(key, value); + return result; + } + default: + // HashMap + map.put(key, value); + return map; + } + } + + public static Map putAll(Map map, Map toAdd) { + switch (toAdd.size()) { + case 0: + // No-op. + return map; + case 1: { + // Add one element. + K key = toAdd.keySet().iterator().next(); + return put(map, key, toAdd.get(key)); + } + default: + // True list merge, result >= 2. + switch (map.size()) { + case 0: + return new HashMap(toAdd); + case 1: { + HashMap result = new HashMap(); + K key = map.keySet().iterator().next(); + result.put(key, map.get(key)); + result.putAll(toAdd); + return result; + } + default: + map.putAll(toAdd); + return map; + } + } + } + + /** + * A variation of the put method which uses a LinkedHashMap. + */ + public static Map putOrdered(Map map, K key, V value) { + switch (map.size()) { + case 0: + // Empty -> Singleton + return Collections.singletonMap(key, value); + case 1: { + if (map.containsKey(key)) { + return create(key, value); + } + // Singleton -> LinkedHashMap + Map result = new LinkedHashMap(); + result.put(map.keySet().iterator().next(), map.values().iterator().next()); + result.put(key, value); + return result; + } + default: + // LinkedHashMap + map.put(key, value); + return map; + } + } + + public static Map remove(Map map, K key) { + switch (map.size()) { + case 0: + // Empty + return map; + case 1: + // Singleton -> Empty + if (map.containsKey(key)) { + return create(); + } + return map; + case 2: + // HashMap -> Singleton + if (map.containsKey(key)) { + map.remove(key); + key = map.keySet().iterator().next(); + return create(key, map.get(key)); + } + return map; + default: + // IdentityHashMap + map.remove(key); + return map; + } + } +} diff --git a/js/src/com/google/dart/compiler/util/Paths.java b/js/src/com/google/dart/compiler/util/Paths.java new file mode 100644 index 00000000000..cdda910ccb1 --- /dev/null +++ b/js/src/com/google/dart/compiler/util/Paths.java @@ -0,0 +1,100 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.util; + +import java.io.File; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * Utility methods for obtaining relative paths from files and translating + * relative paths into files. + */ +public class Paths { + + /** + * Answer the relative path from baseFile to relFile + * + * @param baseFile the base file (not null) from which the + * desired path starts + * @param relFile the file referenced by the desired relative path (not + * null) + * @return a relative path (not null) + */ + public static String relativePathFor(File baseFile, File relFile) { + String baseFilePath = baseFile.getPath().replace(File.separatorChar, '/'); + String relFilePath = relFile.getPath().replace(File.separatorChar, '/'); + int baseFilePathLen = baseFilePath.length(); + int relFilePathLen = relFilePath.length(); + + // Find the com.google.dart.compiler.backend.common path elements + int index = 0; + while (index < baseFilePathLen - 1 && index < relFilePathLen - 1) { + if (baseFilePath.charAt(index) != relFilePath.charAt(index)) { + break; + } + index++; + } + while (index >= 0 + && (baseFilePath.charAt(index) != '/' || relFilePath.charAt(index) != '/')) { + index--; + } + int commonStart = index; + + // Build a path up from the base file + StringBuilder relPath = new StringBuilder(baseFilePathLen + relFilePathLen + - commonStart * 2); + index = commonStart + 1; + while (true) { + index = baseFilePath.indexOf('/', index); + if (index == -1) { + break; + } + relPath.append("../"); + index++; + } + relPath.append(relFilePath.substring(commonStart + 1)); + return relPath.toString(); + } + + /** + * Answer the file relative to the specified file + * + * @param baseFile the base file (not null) + * @param relPath the path to the desired file relative to baseFile + * @return the file (not null) + */ + public static File relativePathToFile(File baseFile, String relPath) { + if (relPath.startsWith("/")) { + return new File(relPath); + } + File parentFile = baseFile.getParentFile(); + String name; + if (parentFile == null) { + name = "."; + } else { + name = parentFile.getPath().replace(File.separatorChar, '/'); + } + name = URI.create(name + "/" + relPath).normalize().getPath(); + return new File(name); + } + + /** + * Given a collection of paths, return a collection of files + * + * @param a collection of paths to various files (not null, + * contains no nulls) + * @return a collection of files (not null, contains no + * nulls) + */ + public static List toFiles(List filePaths) { + List files = new ArrayList(); + for (String path : filePaths) { + files.add(new File(path)); + } + return files; + } +} diff --git a/js/src/com/google/dart/compiler/util/TextOutput.java b/js/src/com/google/dart/compiler/util/TextOutput.java new file mode 100644 index 00000000000..99a465b1532 --- /dev/null +++ b/js/src/com/google/dart/compiler/util/TextOutput.java @@ -0,0 +1,37 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.google.dart.compiler.util; + +/** + * Interface used for printing text output. + */ +public interface TextOutput { + + int getPosition(); + + int getLine(); + + int getColumn(); + + void indentIn(); + + void indentOut(); + + void newline(); + + void newlineOpt(); + + void print(char c); + + void print(char[] s); + + void print(String s); + + void printOpt(char c); + + void printOpt(char[] s); + + void printOpt(String s); +} diff --git a/jslib/jslib.iml b/jslib/jslib.iml new file mode 100644 index 00000000000..d5c07432750 --- /dev/null +++ b/jslib/jslib.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jslib/src/core/Dummy.java b/jslib/src/core/Dummy.java new file mode 100644 index 00000000000..3a72c52114b --- /dev/null +++ b/jslib/src/core/Dummy.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package core; + +/** + * @author Pavel Talanov + */ +public final class Dummy { +} diff --git a/jslib/src/core/annotations.kt b/jslib/src/core/annotations.kt new file mode 100644 index 00000000000..f63aff178ae --- /dev/null +++ b/jslib/src/core/annotations.kt @@ -0,0 +1,5 @@ +package js; +native +annotation class native(name : String = "") {} +native +annotation class library(name : String = "") {} \ No newline at end of file diff --git a/jslib/src/core/core.kt b/jslib/src/core/core.kt new file mode 100644 index 00000000000..1edf565e29d --- /dev/null +++ b/jslib/src/core/core.kt @@ -0,0 +1,39 @@ +package js; + +import js.library +import js.native +import java.util.*; + + + +native +val noImpl : Nothing = throw Exception(); + +library("println") +fun println() {} +library("println") +fun println(s : Any?) {} +library("print") +fun print(s : Any?) {} +library("parseInt") +fun parseInt(s : String) : Int = 0 +library +open class Exception() {} +library +class NumberFormatException() : Exception() {} + +native +fun setTimeout(callback : ()-> Unit) {} + +native +fun setInterval(callback : ()-> Unit, ms : Int) {} +native +fun setInterval(callback : ()-> Unit) {} + + +native +open class DomElement() { + val offsetLeft = 0.0; + val offsetTop = 0.0; + val offsetParent : DomElement? = DomElement(); +} diff --git a/jslib/src/core/javalang.kt b/jslib/src/core/javalang.kt new file mode 100644 index 00000000000..1cb140116f0 --- /dev/null +++ b/jslib/src/core/javalang.kt @@ -0,0 +1,14 @@ +package java.lang + +import java.util.Iterator; +import js.library + +library +trait Iterable { + fun iterator() : java.util.Iterator {} +} + +library("splitString") +public fun String.split(regex : String) : Array { +} + diff --git a/jslib/src/core/javautil.kt b/jslib/src/core/javautil.kt new file mode 100644 index 00000000000..64a5101bc46 --- /dev/null +++ b/jslib/src/core/javautil.kt @@ -0,0 +1,175 @@ +package java.util + +import js.*; + + +library("collectionsMax") +public fun max(col : Collection, comp : Comparator) : T {} + +library +public trait Comparator { + fun compare(obj1 : T, obj2 : T) : Int; +} + +library("comparator") +public fun comparator(f : (T, T) -> Int) : Comparator {} + + +library +public open class Iterator() { + open fun next() : T {} + open fun hasNext() : Boolean {} +} + +library +val Collections = object { + library("collectionsMax") + public fun max(col : Collection, comp : Comparator) : T = js.noImpl +} + +library +public open class ArrayList() : java.util.List { + override public fun size() : Int {} + override public fun isEmpty() : Boolean {} + override public fun contains(o : Any?) : Boolean {} + override public fun iterator() : Iterator {} + // override public fun indexOf(o : Any?) : Int {} + // override public fun lastIndexOf(o : Any?) : Int {} + // override public fun toArray() : Array {} + // override public fun toArray(a : Array) : Array {} + override public fun get(index : Int) : E {} + override public fun set(index : Int, element : E) : E {} + override public fun add(e : E) : Boolean {} + override public fun add(index : Int, element : E) : Unit {} + override public fun remove(index : Int) : E {} + override public fun remove(o : Any?) : Boolean {} + override public fun clear() : Unit {} + override public fun addAll(c : java.util.Collection) : Boolean {} + // override public fun addAll(index : Int, c : java.util.Collection) : Boolean {} +} + +library +public trait Collection : java.lang.Iterable { + open fun size() : Int + open fun isEmpty() : Boolean + open fun contains(o : Any?) : Boolean + override fun iterator() : java.util.Iterator + // open fun toArray() : Array + // open fun toArray(a : Array) : Array + open fun add(e : E) : Boolean + open fun remove(o : Any?) : Boolean + //open fun containsAll(c : java.util.Collection<*>) : Boolean + open fun addAll(c : java.util.Collection) : Boolean + //open fun removeAll(c : java.util.Collection<*>) : Boolean + //open fun retainAll(c : java.util.Collection<*>) : Boolean + open fun clear() : Unit +} + +library +public trait List : Collection { + override fun size() : Int + override fun isEmpty() : Boolean + override fun contains(o : Any?) : Boolean + override fun iterator() : java.util.Iterator + // override fun toArray() : Array + // Simulate Java's array covariance + // override fun toArray(a : Array) : Array + override fun add(e : E) : Boolean + override fun remove(o : Any?) : Boolean + // override fun containsAll(c : java.util.Collection<*>) : Boolean + override fun addAll(c : java.util.Collection) : Boolean + // open fun addAll(index : Int, c : java.util.Collection) : Boolean + // override fun removeAll(c : java.util.Collection<*>) : Boolean + // override fun retainAll(c : java.util.Collection<*>) : Boolean + override fun clear() : Unit + open fun get(index : Int) : E + open fun set(index : Int, element : E) : E + open fun add(index : Int, element : E) : Unit + open fun remove(index : Int) : E + // open fun indexOf(o : Any?) : Int + // open fun lastIndexOf(o : Any?) : Int +} + +library +public trait Set : Collection { + override fun size() : Int + override fun isEmpty() : Boolean + override fun contains(o : Any?) : Boolean + override fun iterator() : java.util.Iterator + // override fun toArray() : Array + // override fun toArray(a : Array) : Array + override fun add(e : E) : Boolean + override fun remove(o : Any?) : Boolean + //override fun containsAll(c : java.util.Collection<*>) : Boolean + override fun addAll(c : java.util.Collection) : Boolean + //override fun retainAll(c : java.util.Collection<*>) : Boolean + //override fun removeAll(c : java.util.Collection<*>) : Boolean + override fun clear() : Unit +} + +library +public open class HashSet() : java.util.Set { + override public fun iterator() : java.util.Iterator {} + override public fun size() : Int {} + override public fun isEmpty() : Boolean {} + override public fun contains(o : Any?) : Boolean {} + override public fun add(e : E) : Boolean {} + override public fun remove(o : Any?) : Boolean {} + override public fun clear() : Unit {} + override fun addAll(c : java.util.Collection) : Boolean +} + +library +public trait Map { + open fun size() : Int + open fun isEmpty() : Boolean + open fun containsKey(key : Any?) : Boolean + open fun containsValue(value : Any?) : Boolean + open fun get(key : Any?) : V? + open fun put(key : K, value : V) : V? + open fun remove(key : Any?) : V? + open fun putAll(m : java.util.Map) : Unit + open fun clear() : Unit + open fun keySet() : java.util.Set + open fun values() : java.util.Collection +} + +library +public open class HashMap() : java.util.Map { + override public fun size() : Int {} + override public fun isEmpty() : Boolean {} + override public fun get(key : Any?) : V {} + override public fun containsKey(key : Any?) : Boolean {} + override public fun put(key : K, value : V) : V {} + override public fun putAll(m : java.util.Map) : Unit {} + override public fun remove(key : Any?) : V? {} + override public fun clear() : Unit {} + override public fun containsValue(value : Any?) : Boolean {} + override public fun keySet() : java.util.Set {} + override public fun values() : java.util.Collection {} +} + +library +public open class LinkedList() : List { + override public fun iterator() : java.util.Iterator {} + override public fun isEmpty() : Boolean {} + override public fun contains(o : Any?) : Boolean {} + override public fun size() : Int {} + override public fun add(e : E) : Boolean {} + override public fun remove(o : Any?) : Boolean {} + override public fun addAll(c : java.util.Collection) : Boolean {} + override public fun clear() : Unit {} + override public fun get(index : Int) : E {} + override public fun set(index : Int, element : E) : E {} + override public fun add(index : Int, element : E) : Unit {} + override public fun remove(index : Int) : E {} + public fun poll() : E? {} + public fun peek() : E? {} + public fun offer(e : E) : Boolean {} +} + +library +public class StringBuilder() { + public fun append(obj : Any) : StringBuilder + public fun toString() : String +} \ No newline at end of file diff --git a/jslib/src/core/json.kt b/jslib/src/core/json.kt new file mode 100644 index 00000000000..df624aad0be --- /dev/null +++ b/jslib/src/core/json.kt @@ -0,0 +1,18 @@ +package js + +import java.util.*; +import js.library + +native +class Json() { + +} + +library("jsonSet") +fun Json.set(paramName : String, value : Any?) : Unit {} + +library("jsonGet") +fun Json.get(paramName : String) : Any? = null + +library("jsonFromTuples") +fun json(vararg pairs : Tuple2) = Json() diff --git a/jslib/src/core/math.kt b/jslib/src/core/math.kt new file mode 100644 index 00000000000..3566b782aa6 --- /dev/null +++ b/jslib/src/core/math.kt @@ -0,0 +1,32 @@ +package js; + +import js.native + +native +class MathClass() { + val PI : Double = 1.0; + fun random() : Double = 0.0; + fun abs(value : Double) = 0.0 + fun acos(value : Double) = 0.0 + fun asin(value : Double) = 0.0 + fun atan(value : Double) = 0.0 + fun atan2(x : Double, y : Double) = 0.0 + fun cos(value : Double) = 0.0 + fun sin(value : Double) = 0.0 + fun exp(value : Double) = 0.0 + fun max(vararg values : Double) = 0.0 + fun max(vararg values : Int) : Int = js.noImpl + fun min(vararg values : Int) : Int = js.noImpl + fun min(vararg values : Double) = 0.0 + fun sqrt(value : Double) = 0.0 + fun tan(value : Double) = 0.0 + fun log(value : Double) = 0.0 + fun pow(base : Double, exp : Double) = 0.0 + fun round(value : Double) = 0.0 + fun floor(value : Double) = 0.0 + fun ceil(value : Double) = 0.0 + +} + +native +val Math = MathClass(); \ No newline at end of file diff --git a/jslib/src/helper/ip.kt b/jslib/src/helper/ip.kt new file mode 100644 index 00000000000..d6f47cc8296 --- /dev/null +++ b/jslib/src/helper/ip.kt @@ -0,0 +1,7 @@ +package ip.helper + +import html5.HTMLInputElement +import js.native + +native +fun getInputElement() : HTMLInputElement = js.noImpl \ No newline at end of file diff --git a/jslib/src/html5/canvas.kt b/jslib/src/html5/canvas.kt new file mode 100644 index 00000000000..6caa62ab6d4 --- /dev/null +++ b/jslib/src/html5/canvas.kt @@ -0,0 +1,117 @@ +package html5 + +import js.native +import js.DomElement + +native +class Context() { + fun save() { + } + fun restore() { + } + + fun scale(x : Double, y : Double) { + } + fun rotate(angle : Double) { + } + fun translate(x : Double, y : Double) { + } + + fun clearRect(x : Double, y : Double, w : Double, h : Double) { + } + fun fillRect(x : Double, y : Double, w : Double, h : Double) { + } + fun strokeRect(x : Double, y : Double, w : Double, h : Double) { + } + + var globalAlpha : Double = 1.0; + var strokeStyle : Any = "" + var fillStyle : Any = "" + var lineWidth : Double = 1.0 + var shadowOffsetX : Double = 0.0 + var shadowOffsetY : Double = 0.0 + var shadowBlur : Double = 0.0 + var shadowColor : String = "" + var font : String = "" + + fun beginPath() { + } + fun moveTo(x : Double, y : Double) { + } + fun closePath() { + } + + fun lineTo(x : Double, y : Double) { + } + fun quadraticCurveTo(cpx : Double, cpy : Double, x : Double, y : Double) { + } + fun bezierCurveTo(cp1x : Double, cp1y : Double, cp2x : Double, cp2y : Double, x : Double, y : Double) { + } + fun arcTo(x1 : Double, y1 : Double, x2 : Double, y2 : Double, radius : Double) { + } + fun arc(x : Double, y : Double, radius : Double, startAngle : Double, endAngle : Double, anticlockwise : Boolean) { + } + + fun rect(x : Double, y : Double, w : Double, h : Double) { + } + fun fill() { + } + fun stroke() { + } + + fun fillText(text : String, x : Double, y : Double) { + } + fun fillText(text : String, x : Double, y : Double, maxWidth : Double) { + } + fun strokeText(text : String, x : Double, y : Double) { + } + fun strokeText(text : String, x : Double, y : Double, maxWidth : Double) { + } + + fun measureText(text : String) : TextMetrics = TextMetrics(); + + fun drawImage(image : HTMLImageElement, dx : Double, dy : Double) { + } + fun drawImage(image : HTMLImageElement, dx: Double, dy: Double, dw: Double, dh: Double) { + } + fun drawImage(image : HTMLImageElement, sx: Double, sy: Double, + sw: Double, sh: Double, dx: Double, dy: Double, dw: Double, dh: Double) { + } + + fun createLinearGradient(x0 : Double, y0 : Double, x1 : Double, y1 : Double) : CanvasGradient = CanvasGradient() + fun createRadialGradient(x0 : Double, y0 : Double, r0 : Double, x1 : Double, y1 : Double, r1 : Double) : CanvasGradient = CanvasGradient(); + +} + +native +open class HTMLImageElement() : DomElement() { +} + +native +class CanvasGradient() { + fun addColorStop(offset : Double, color : String) {} +} + + +native +class Canvas() : DomElement() { + var width = 0.0; + var height = 0.0; + + //DOMString toDataURL(in optional DOMString type, in any... args); + fun toDataURL() : String = js.noImpl + fun toDataURL(typ : String) : String = js.noImpl +} + +native +class TextMetrics() { + val width : Int = 0 +} + +/*custom helpers*/ +native +fun getContext() : Context = Context(); +native +fun getCanvas() : Canvas = Canvas(); +native +fun getKotlinLogo() : HTMLImageElement = HTMLImageElement(); \ No newline at end of file diff --git a/jslib/src/html5/files.kt b/jslib/src/html5/files.kt new file mode 100644 index 00000000000..8e05d2af4ef --- /dev/null +++ b/jslib/src/html5/files.kt @@ -0,0 +1,37 @@ +package html5.files + +import js.native + +native +class FileReader() { + var onloadend : ((FileReaderEvent)->Unit)? = js.noImpl // + fun readAsDataURL(blob : Blob) = js.noImpl + val result : File = js.noImpl +} + +native +class FileReaderEvent() { + val target : FileReader = js.noImpl +} + +native +class FileList() { + fun item(index : Int) : File? = js.noImpl + val length : Int = js.noImpl +} + +native +class File() : Blob() { + val name : String = js.noImpl + // readonly attribute Date lastModifiedDate; +} + +native +open class Blob() { + val size : Int = js.noImpl + val `type` : String = js.noImpl + //Blob slice(optional long long start, + //optional long long end, + //optional DOMString contentType); + // +} diff --git a/jslib/src/html5/image.kt b/jslib/src/html5/image.kt new file mode 100644 index 00000000000..dc1ec502959 --- /dev/null +++ b/jslib/src/html5/image.kt @@ -0,0 +1,25 @@ +package html5 + +import js.Exception +import js.native +import js.DomElement +import html5.files.FileList + +native +class HTMLInputElement() : DomElement() { + val files : FileList = js.noImpl + var onchange : (HTMLInputElementEvent)->Unit = js.noImpl +} + +native +class HTMLInputElementEvent() { + val target : HTMLInputElement = js.noImpl +} + +native +class Image() : HTMLImageElement() { + var height : Int = js.noImpl + var width : Int = js.noImpl + var src : String = js.noImpl + var onload : ()->Unit = js.noImpl +} \ No newline at end of file diff --git a/jslib/src/jquery/common.kt b/jslib/src/jquery/common.kt new file mode 100644 index 00000000000..54ad3feb9dd --- /dev/null +++ b/jslib/src/jquery/common.kt @@ -0,0 +1,72 @@ +package jquery; + +import js.*; +import js.DomElement + +native +class JQuery() { + fun addClass(className : String) : JQuery = js.noImpl; + fun addClass(f : DomElement.(Int, String)->String) = js.noImpl; + + fun attr(attrName : String) = ""; + fun attr(attrName : String, value : String) = this; + + fun html() : String = ""; + fun html(s : String) = this; + fun html(f : DomElement.(Int, String)->String) = this; + + + fun hasClass(className : String) = true + fun removeClass(className : String) = this + fun height() = 0 + fun width() = 0 + + fun click() = this; + + fun mousedown(handler : DomElement.(MouseEvent)->Unit) = this; + fun mouseup(handler : DomElement.(MouseEvent)->Unit) = this; + fun mousemove(handler : DomElement.(MouseEvent)->Unit) = this; + + fun dblclick(handler : DomElement.(MouseClickEvent)->Unit) = this; + fun click(handler : DomElement.(MouseClickEvent)->Unit) = this; + + fun load(handler : DomElement.()->Unit) = this; + fun change(handler : DomElement.()->Unit) = this; + + fun append(str : String) = this; + fun ready(handler : ()->Unit) = this; + fun text(text : String) = this; + fun slideUp() = this; + fun hover(handlerInOut : DomElement.() -> Unit) = this; + fun hover(handlerIn : DomElement.() -> Unit, handlerOut : DomElement.() -> Unit) = this; + fun next() : JQuery = js.noImpl + fun parent() : JQuery = js.noImpl +} + +native +open class MouseEvent() { + val pageX : Double = 0.0; + val pageY : Double = 0.0; + fun preventDefault() {} + fun isDefaultPrevented() : Boolean = true; +} + +native +class MouseClickEvent() : MouseEvent() { + val which : Int = 0; +} + + + +native("$") +fun jq(selector : String) = JQuery(); +native("$") +fun jq(selector : String, context : DomElement) = JQuery(); +native("$") +fun jq(callback : () -> Unit) = JQuery(); +native("$") +fun jq(obj : JQuery) = JQuery(); +native("$") +fun jq(el : DomElement) = JQuery(); +native("$") +fun jq() = JQuery(); diff --git a/jslib/src/jquery/ui.kt b/jslib/src/jquery/ui.kt new file mode 100644 index 00000000000..e9ca87be43a --- /dev/null +++ b/jslib/src/jquery/ui.kt @@ -0,0 +1,15 @@ +package jquery.ui + + +//jquery UI +import jquery.JQuery +import js.native + +native +fun JQuery.buttonset() : JQuery = js.noImpl; +native +fun JQuery.dialog() : JQuery = js.noImpl; +native +fun JQuery.button() : JQuery = js.noImpl; +native +fun JQuery.accordion() : JQuery = js.noImpl diff --git a/jslib/src/pixastic/pixastic.kt b/jslib/src/pixastic/pixastic.kt new file mode 100644 index 00000000000..66bcf91bf97 --- /dev/null +++ b/jslib/src/pixastic/pixastic.kt @@ -0,0 +1,11 @@ +package jquery.pixastic + +import jquery.JQuery +import js.native + +native +fun JQuery.pixastic(actionName : String) = js.noImpl + +native +fun addAction(actionName : String, + process : (oldData : Array, newData : Array, width : Int, height : Int)->Unit) = js.noImpl \ No newline at end of file diff --git a/jslib/src/raphael/raphael.kt b/jslib/src/raphael/raphael.kt new file mode 100644 index 00000000000..e30b63b15c1 --- /dev/null +++ b/jslib/src/raphael/raphael.kt @@ -0,0 +1,62 @@ +package raphael + +import js.*; +import js.*; + +native +open class Element() { + + fun attr(name : String, value : Any?) : Element = this + fun attr(nameToValue : Json) : Element = this + + fun click(handler : Element.()-> Unit) = this; + + fun mouseover(handler : Element.() -> Unit) = this + fun mouseout(handler : Element.() -> Unit) = this + + + fun getTotalLength() : Double = 0.0 + fun getPointAtLength(length : Double) : Point {} + + fun animate(params : Json, ms : Int, callback : ()-> Unit) : Element {} + fun animate(params : Json, ms : Int, s : String) : Element {} + fun animate(params : Json, ms : Int) : Element {} + //fun mouse +} + +native +class Set() : Element() { + fun push(el : Element) {} +} + +native +class Paper() { + fun path(pathString : String) : Element = Element(); + fun path() : Element = Element(); + + fun ellipse(x : Int, y : Int, rx : Int, ry : Int) : Element {} + fun circle(x : Int, y : Int, r : Int) : Element {} + fun set() : Set {} + + val customAttributes : Json = Json(); +} + +native("Raphael") +fun Raphael(elementId : String, width : Int, height : Int) : Paper = Paper(); +native("Raphael") +fun Raphael(elementId : String, width : Int, height : Int, initFun : Paper.() -> Unit) : Unit {} + +native +fun getColor() : Color {} +native +fun resetColors() {} + +native +class Color() {} + +native +class Point() { + val x = 0 + val y = 0 + val alpha = 0 +} diff --git a/k2js.iml b/k2js.iml new file mode 100644 index 00000000000..af012ea065d --- /dev/null +++ b/k2js.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/k2js/.idea/artifacts/k2js_jar.xml b/k2js/.idea/artifacts/k2js_jar.xml new file mode 100644 index 00000000000..a4f2e6c0057 --- /dev/null +++ b/k2js/.idea/artifacts/k2js_jar.xml @@ -0,0 +1,16 @@ + + + $PROJECT_DIR$/out/artifacts/k2js_jar + + + + + + + + + + + + + \ No newline at end of file diff --git a/k2js/.idea/copyright/apache.xml b/k2js/.idea/copyright/apache.xml new file mode 100644 index 00000000000..647fcdb02ef --- /dev/null +++ b/k2js/.idea/copyright/apache.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/k2js/.idea/copyright/profiles_settings.xml b/k2js/.idea/copyright/profiles_settings.xml new file mode 100644 index 00000000000..ace2e994924 --- /dev/null +++ b/k2js/.idea/copyright/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/k2js/.idea/dictionaries/Pavel_Talanov.xml b/k2js/.idea/dictionaries/Pavel_Talanov.xml new file mode 100644 index 00000000000..8bede43c190 --- /dev/null +++ b/k2js/.idea/dictionaries/Pavel_Talanov.xml @@ -0,0 +1,17 @@ + + + + accessors + aliaser + fqname + fqnames + initializers + intrinsics + kotlin + mutator + namer + overloadable + println + + + \ No newline at end of file diff --git a/k2js/.idea/inspectionProfiles/Project_Default.xml b/k2js/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000000..a76f2aecef0 --- /dev/null +++ b/k2js/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/k2js/.idea/inspectionProfiles/profiles_settings.xml b/k2js/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000000..3b312839bf2 --- /dev/null +++ b/k2js/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/k2js/.idea/scopes/scope_settings.xml b/k2js/.idea/scopes/scope_settings.xml new file mode 100644 index 00000000000..922003b8433 --- /dev/null +++ b/k2js/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/k2js/.idea/workspace.xml b/k2js/.idea/workspace.xml new file mode 100644 index 00000000000..46fab1cea58 --- /dev/null +++ b/k2js/.idea/workspace.xml @@ -0,0 +1,1736 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + org.jetbrains.k2js.translate.* + + + org.jetbrains.k2js.* + + + org.jetbrains.k2js.* + + + org.jetbrains.k2js.* + + + org.jetbrains.k2js.test.* + + + org.jetbrains.k2js.analyze.* + org.jetbrains.k2js.config.* + org.jetbrains.k2js.facade.* + org.jetbrains.k2js.generate.* + org.jetbrains.k2js.test.* + org.jetbrains.k2js.translate.* + org.jetbrains.k2js.utils.* + org.jetbrains.k2js.translate.context.* + org.jetbrains.k2js.translate.declaration.* + org.jetbrains.k2js.translate.expression.* + org.jetbrains.k2js.translate.general.* + org.jetbrains.k2js.translate.initializer.* + org.jetbrains.k2js.translate.intrinsic.* + org.jetbrains.k2js.translate.operation.* + org.jetbrains.k2js.translate.reference.* + org.jetbrains.k2js.translate.utils.* + org.jetbrains.k2js.translate.intrinsic.array.* + org.jetbrains.k2js.translate.intrinsic.primitive.* + org.jetbrains.k2js.translate.intrinsic.string.* + org.jetbrains.k2js.translate.intrinsic.tuple.* + + + org.jetbrains.k2js.test.* + org.jetbrains.k2js.translate.* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Android + + + Class structure + + + Dependency issues + + + General + + + Internationalization issues + + + Java language level migration aids + + + Logging issues + + + Numeric issues + + + OSGi + + + Plugin DevKit + + + Portability issues + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + 1319812241928 + 1319812241928 + + + 1327398620289 + 1327398620289 + + + 1327420478272 + 1327420478272 + + + 1327427513473 + 1327427513473 + + + 1329305841490 + 1329305841490 + + + 1329307398273 + 1329307398273 + + + 1329310617071 + 1329310617071 + + + 1329311170761 + 1329311170761 + + + 1329823359830 + 1329823359830 + + + 1329826525434 + 1329826525434 + + + 1329828408220 + 1329828408220 + + + 1329829777595 + 1329829777595 + + + 1329831616053 + 1329831616053 + + + 1329836574441 + 1329836574441 + + + 1329837265452 + 1329837265452 + + + 1329838186967 + 1329838186967 + + + 1329838425571 + 1329838425571 + + + 1329838613308 + 1329838613308 + + + 1329838762745 + 1329838762745 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + k2js:jar + + + + + + + + apache + + + + + + + + No facets are configured + + + + + + + + guava-10.0.1 + + + + + + + + 1.6 + + + + + + + + jslib + + + + + + + + 1.6 + + + + + + + + libs + + + + + + + + + + + + + + + + diff --git a/k2js/build.xml b/k2js/build.xml new file mode 100644 index 00000000000..c799c56523e --- /dev/null +++ b/k2js/build.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/k2js/coverage-error.log b/k2js/coverage-error.log new file mode 100644 index 00000000000..7d64d020a20 --- /dev/null +++ b/k2js/coverage-error.log @@ -0,0 +1,1478 @@ +[2011.12.13 16:49:22] (Coverage): Error during class instrumentation: org.jetbrains.k2js.translate.reference.AccessTranslator +java.lang.ClassCircularityError: org/jetbrains/k2js/translate/reference/PropertyAccessTranslator + at java.lang.Class.forName0(Native Method) + at java.lang.Class.forName(Class.java:186) + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1281) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:113) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) + at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) + at java.net.URLClassLoader.access$100(URLClassLoader.java:71) + at java.net.URLClassLoader$1.run(URLClassLoader.java:361) + at java.net.URLClassLoader$1.run(URLClassLoader.java:355) + at java.security.AccessController.doPrivileged(Native Method) + at java.net.URLClassLoader.findClass(URLClassLoader.java:354) + at java.lang.ClassLoader.loadClass(ClassLoader.java:423) + at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) + at java.lang.ClassLoader.loadClass(ClassLoader.java:356) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) + at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) + at java.net.URLClassLoader.access$100(URLClassLoader.java:71) + at java.net.URLClassLoader$1.run(URLClassLoader.java:361) + at java.net.URLClassLoader$1.run(URLClassLoader.java:355) + at java.security.AccessController.doPrivileged(Native Method) + at java.net.URLClassLoader.findClass(URLClassLoader.java:354) + at java.lang.ClassLoader.loadClass(ClassLoader.java:423) + at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) + at java.lang.ClassLoader.loadClass(ClassLoader.java:356) + at org.jetbrains.k2js.translate.reference.ReferenceTranslator.translateSimpleName(ReferenceTranslator.java:24) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitSimpleNameExpression(ExpressionVisitor.java:135) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitSimpleNameExpression(ExpressionVisitor.java:32) + at org.jetbrains.jet.lang.psi.JetSimpleNameExpression.accept(JetSimpleNameExpression.java:64) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitBlockExpression(ExpressionVisitor.java:68) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitBlockExpression(ExpressionVisitor.java:32) + at org.jetbrains.jet.lang.psi.JetBlockExpression.accept(JetBlockExpression.java:24) + at org.jetbrains.k2js.translate.general.Translation.translateExpression(Translation.java:56) + at org.jetbrains.k2js.translate.expression.FunctionTranslator.translateBody(FunctionTranslator.java:105) + at org.jetbrains.k2js.translate.expression.FunctionTranslator.generateFunctionObject(FunctionTranslator.java:68) + at org.jetbrains.k2js.translate.expression.FunctionTranslator.translateAsLiteral(FunctionTranslator.java:60) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitFunctionLiteralExpression(ExpressionVisitor.java:370) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitFunctionLiteralExpression(ExpressionVisitor.java:32) + at org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression.accept(JetFunctionLiteralExpression.java:24) + at org.jetbrains.k2js.translate.general.Translation.translateExpression(Translation.java:56) + at org.jetbrains.k2js.translate.general.Translation.translateAsExpression(Translation.java:62) + at org.jetbrains.k2js.translate.utils.TranslationUtils.translateArgument(TranslationUtils.java:56) + at org.jetbrains.k2js.translate.utils.TranslationUtils.translateArgumentList(TranslationUtils.java:45) + at org.jetbrains.k2js.translate.reference.CallTranslator.translate(CallTranslator.java:66) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitCallExpression(ExpressionVisitor.java:117) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitCallExpression(ExpressionVisitor.java:32) + at org.jetbrains.jet.lang.psi.JetCallExpression.accept(JetCallExpression.java:29) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.translateAsExpression(ExpressionVisitor.java:37) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitReturnExpression(ExpressionVisitor.java:80) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitReturnExpression(ExpressionVisitor.java:32) + at org.jetbrains.jet.lang.psi.JetReturnExpression.accept(JetReturnExpression.java:22) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitBlockExpression(ExpressionVisitor.java:68) + at org.jetbrains.k2js.translate.expression.ExpressionVisitor.visitBlockExpression(ExpressionVisitor.java:32) + at org.jetbrains.jet.lang.psi.JetBlockExpression.accept(JetBlockExpression.java:24) + at org.jetbrains.k2js.translate.general.Translation.translateExpression(Translation.java:56) + at org.jetbrains.k2js.translate.expression.FunctionTranslator.translateBody(FunctionTranslator.java:105) + at org.jetbrains.k2js.translate.expression.FunctionTranslator.generateFunctionObject(FunctionTranslator.java:68) + at org.jetbrains.k2js.translate.expression.FunctionTranslator.translateAsMethod(FunctionTranslator.java:53) + at org.jetbrains.k2js.translate.declaration.DeclarationBodyVisitor.visitNamedFunction(DeclarationBodyVisitor.java:53) + at org.jetbrains.k2js.translate.declaration.DeclarationBodyVisitor.visitNamedFunction(DeclarationBodyVisitor.java:20) + at org.jetbrains.jet.lang.psi.JetNamedFunction.accept(JetNamedFunction.java:23) + at org.jetbrains.k2js.translate.declaration.DeclarationBodyVisitor.traverseNamespace(DeclarationBodyVisitor.java:38) + at org.jetbrains.k2js.translate.declaration.NamespaceTranslator.translateNamespaceMemberDeclarations(NamespaceTranslator.java:85) + at org.jetbrains.k2js.translate.declaration.NamespaceTranslator.addMemberDeclarations(NamespaceTranslator.java:77) + at org.jetbrains.k2js.translate.declaration.NamespaceTranslator.namespaceOwnDeclarationStatement(NamespaceTranslator.java:66) + at org.jetbrains.k2js.translate.declaration.NamespaceTranslator.translateNamespace(NamespaceTranslator.java:42) + at org.jetbrains.k2js.translate.declaration.NamespaceTranslator.translateNamespace(NamespaceTranslator.java:29) + at org.jetbrains.k2js.translate.general.Translation.translateNamespace(Translation.java:40) + at org.jetbrains.k2js.translate.general.Translation.generateAst(Translation.java:100) + at org.jetbrains.k2js.K2JSTranslator.translate(K2JSTranslator.java:55) + at org.jetbrains.k2js.test.TranslationTest.translateFile(TranslationTest.java:60) + at org.jetbrains.k2js.test.TranslationTest.testFunctionOutput(TranslationTest.java:54) + at org.jetbrains.k2js.test.ExampleTest.runBoxTest(ExampleTest.java:16) + at ExampleTestSuite.runTest(ExampleTestSuite.java:21) + at junit.framework.TestCase.runBare(TestCase.java:134) + at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:266) + at com.intellij.testFramework.UsefulTestCase$3.run(UsefulTestCase.java:278) + at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:241) + at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705) + at java.awt.EventQueue.access$000(EventQueue.java:101) + at java.awt.EventQueue$3.run(EventQueue.java:666) + at java.awt.EventQueue$3.run(EventQueue.java:664) + at java.security.AccessController.doPrivileged(Native Method) + at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) + at java.awt.EventQueue.dispatchEvent(EventQueue.java:675) + at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211) + at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) + at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) + at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) + at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) + at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) +[2011.12.13 19:57:44] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_1 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_1 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.runPropertyTypeCheck(KotlinLibTest.java:26) + at org.jetbrains.k2js.test.KotlinLibTest.classObjectHasCreateMethod(KotlinLibTest.java:46) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.13 19:57:44] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_2 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_2 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.runPropertyTypeCheck(KotlinLibTest.java:26) + at org.jetbrains.k2js.test.KotlinLibTest.traitObjectHasCreateMethod(KotlinLibTest.java:62) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.13 19:57:45] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_3 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_3 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.createdTraitIsJSObject(KotlinLibTest.java:69) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.13 19:57:45] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_4 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_4 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.createdNamespaceIsJSObject(KotlinLibTest.java:77) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.13 19:57:45] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_5 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_5 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.namespaceHasDeclaredFunction(KotlinLibTest.java:85) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.13 19:57:45] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_6 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_6 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.namespaceHasDeclaredClasses(KotlinLibTest.java:92) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.13 19:57:45] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_7 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_7 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.isAncestorType(KotlinLibTest.java:104) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.13 19:57:45] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_8 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_8 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.isComplexTest(KotlinLibTest.java:110) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.13 19:57:45] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_9 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_9 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.commaExpression(KotlinLibTest.java:116) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.13 19:57:46] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_10 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_10 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.isSameType(KotlinLibTest.java:98) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.13 19:57:46] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_11 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_11 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.runPropertyTypeCheck(KotlinLibTest.java:26) + at org.jetbrains.k2js.test.KotlinLibTest.namespaceObjectHasCreateMethod(KotlinLibTest.java:54) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:19] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_1 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_1 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.runPropertyTypeCheck(KotlinLibTest.java:26) + at org.jetbrains.k2js.test.KotlinLibTest.classObjectHasCreateMethod(KotlinLibTest.java:46) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:19] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_2 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_2 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.runPropertyTypeCheck(KotlinLibTest.java:26) + at org.jetbrains.k2js.test.KotlinLibTest.traitObjectHasCreateMethod(KotlinLibTest.java:62) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:19] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_3 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_3 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.createdTraitIsJSObject(KotlinLibTest.java:69) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:19] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_4 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_4 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.createdNamespaceIsJSObject(KotlinLibTest.java:77) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:19] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_5 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_5 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.namespaceHasDeclaredFunction(KotlinLibTest.java:85) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:20] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_6 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_6 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.namespaceHasDeclaredClasses(KotlinLibTest.java:92) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:20] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_7 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_7 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.isAncestorType(KotlinLibTest.java:104) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:20] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_8 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_8 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.isComplexTest(KotlinLibTest.java:110) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:20] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_9 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_9 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.commaExpression(KotlinLibTest.java:116) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:20] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_10 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_10 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.isSameType(KotlinLibTest.java:98) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) +[2011.12.14 16:07:20] (Coverage): Error during class instrumentation: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_11 +java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mozilla.javascript.gen.translator_testFiles_kotlin_lib_js_11 + at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1284) + at org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1256) + at org.objectweb.asm.Frame.merge(Frame.java:1373) + at org.objectweb.asm.Frame.merge(Frame.java:1323) + at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1270) + at org.objectweb.asm.MethodAdapter.visitMaxs(MethodAdapter.java:189) + at com.intellij.rt.coverage.instrumentation.SamplingInstrumenter$1.visitMaxs(SamplingInstrumenter.java:78) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:1447) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:420) + at com.intellij.rt.coverage.instrumentation.Instrumentator.instrument(Instrumentator.java:148) + at com.intellij.rt.coverage.instrumentation.Instrumentator.access$000(Instrumentator.java:26) + at com.intellij.rt.coverage.instrumentation.Instrumentator$1.transform(Instrumentator.java:109) + at sun.instrument.TransformerManager.transform(TransformerManager.java:188) + at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424) + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:791) + at org.mozilla.javascript.DefiningClassLoader.defineClass(DefiningClassLoader.java:62) + at org.mozilla.javascript.optimizer.Codegen.defineClass(Codegen.java:160) + at org.mozilla.javascript.optimizer.Codegen.createScriptObject(Codegen.java:115) + at org.mozilla.javascript.Context.compileImpl(Context.java:2447) + at org.mozilla.javascript.Context.compileReader(Context.java:1328) + at org.mozilla.javascript.Context.compileReader(Context.java:1300) + at org.mozilla.javascript.Context.evaluateReader(Context.java:1139) + at org.jetbrains.k2js.test.TranslationTest.runFileWithRhino(TranslationTest.java:86) + at org.jetbrains.k2js.test.TranslationTest.runRhinoTest(TranslationTest.java:94) + at org.jetbrains.k2js.test.KotlinLibTest.runPropertyTypeCheck(KotlinLibTest.java:26) + at org.jetbrains.k2js.test.KotlinLibTest.namespaceObjectHasCreateMethod(KotlinLibTest.java:54) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runners.Suite.runChild(Suite.java:128) + at org.junit.runners.Suite.runChild(Suite.java:24) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) + at org.junit.runners.ParentRunner.run(ParentRunner.java:300) + at org.junit.runner.JUnitCore.run(JUnitCore.java:157) + at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) + at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) + at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) diff --git a/k2js/out/artifacts/k2js_jar/desktop.ini b/k2js/out/artifacts/k2js_jar/desktop.ini new file mode 100644 index 00000000000..d957fd188db --- /dev/null +++ b/k2js/out/artifacts/k2js_jar/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/k2js/out/artifacts/k2js_jar/k2js.jar b/k2js/out/artifacts/k2js_jar/k2js.jar new file mode 100644 index 00000000000..15cc859abeb Binary files /dev/null and b/k2js/out/artifacts/k2js_jar/k2js.jar differ diff --git a/k2js/out/artifacts/k2js_jar/kotlin_lib.js b/k2js/out/artifacts/k2js_jar/kotlin_lib.js new file mode 100644 index 00000000000..a6ebd687d2b --- /dev/null +++ b/k2js/out/artifacts/k2js_jar/kotlin_lib.js @@ -0,0 +1,465 @@ +function $A(iterable) { + if (!iterable) return []; + if ('toArray' in Object(iterable)) return iterable.toArray(); + var length = iterable.length || 0, results = new Array(length); + while (length--) results[length] = iterable[length]; + return results; +} + +(function () { + + + function extend(destination, source) { + for (var property in source) + destination[property] = source[property]; + return destination; + } + + + + function keys(object) { + if (Type(object) !== OBJECT_TYPE) { + throw new TypeError(); + } + var results = []; + for (var property in object) { + if (object.hasOwnProperty(property)) { + results.push(property); + } + } + return results; + } + + function values(object) { + var results = []; + for (var property in object) + results.push(object[property]); + return results; + } + + extend(Object, { + extend:extend, + keys:Object.keys || keys, + values:values + }); +})(); + + +Object.extend(Function.prototype, (function () { + var slice = Array.prototype.slice; + + function update(array, args) { + var arrayLength = array.length, length = args.length; + while (length--) array[arrayLength + length] = args[length]; + return array; + } + + function merge(array, args) { + array = slice.call(array, 0); + return update(array, args); + } + + function argumentNames() { + var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1] + .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '') + .replace(/\s+/g, '').split(','); + return names.length == 1 && !names[0] ? [] : names; + } + + function bind(context) { + if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; + var __method = this, args = slice.call(arguments, 1); + return function () { + var a = merge(args, arguments); + return __method.apply(context, a); + } + } + + function bindAsEventListener(context) { + var __method = this, args = slice.call(arguments, 1); + return function (event) { + var a = update([event || window.event], args); + return __method.apply(context, a); + } + } + + function wrap(wrapper) { + var __method = this; + return function () { + var a = update([__method.bind(this)], arguments); + return wrapper.apply(this, a); + } + } + + return { + argumentNames:argumentNames, + bind:bind, + bindAsEventListener:bindAsEventListener, + wrap:wrap + } +})()); + +var isType = function (object, klass) { + current = object.get_class(); + while (current !== klass) { + if (current === null) { + return false; + } + current = current.superclass; + } + return true; +} + +var emptyFunction = function () { +} + +var Class = (function () { + + function subclass() { + } + + ; + function create() { + var parent = null, properties = $A(arguments); + if (typeof (properties[0]) == "function") + parent = properties.shift(); + + function klass() { + this.initializing = klass; + this.initialize.apply(this, arguments); + } + + Object.extend(klass, Class.Methods); + klass.superclass = parent; + klass.subclasses = []; + + if (parent) { + subclass.prototype = parent.prototype; + klass.prototype = new subclass; + parent.subclasses.push(klass); + } + + klass.addMethods( + { + get_class:function () { + return klass; + } + }); + + if (parent != null) { + klass.addMethods( + { + super_init:function () { + this.initializing = this.initializing.superclass; + this.initializing.prototype.initialize.apply(this, arguments) + } + }); + } + + for (var i = 0, length = properties.length; i < length; i++) + klass.addMethods(properties[i]); + + if (!klass.prototype.initialize) + klass.prototype.initialize = emptyFunction; + + klass.prototype.constructor = klass; + return klass; + } + + function addMethods(source) { + var ancestor = this.superclass && this.superclass.prototype, + properties = Object.keys(source); + + + for (var i = 0, length = properties.length; i < length; i++) { + var property = properties[i], value = source[property]; + if (ancestor && (typeof (value) == "function") && + value.argumentNames()[0] == "$super") { + var method = value; + value = (function (m) { + return function () { + return ancestor[m].apply(this, arguments); + }; + })(property).wrap(method); + + } + this.prototype[property] = value; + } + + return this; + } + + return { + create:create, + Methods:{ + addMethods:addMethods + } + }; +})(); + +var Trait = (function () { + + function add(object, source) { + properties = Object.keys(source); + for (var i = 0, length = properties.length; i < length; i++) { + var property = properties[i]; + var value = source[property]; + object[property] = value; + } + return this; + } + + function create() { + + result = {} + for (var i = 0, length = arguments.length; i < length; i++) { + add(result, arguments[i]); + } + return result; + } + + return { + create:create + }; +})(); + + +var Namespace = (function () { + + function create() { + return Trait.create.apply(Trait, arguments); + } + + return { + create:create + }; +})(); + +Kotlin = {} +Kotlin.Class = Class; +Kotlin.Namespace = Namespace; +Kotlin.Trait = Trait; +Kotlin.isType = isType; + +Kotlin.equals = function (obj1, obj2) { + if (typeof obj1 == "object") { + if (obj1.equals != undefined) { + return obj1.equals(obj2); + } + } + return (obj1 === obj2); +}; + +Kotlin.Exceptions = {} +Kotlin.Exceptions.IndexOutOfBounds = {} +Kotlin.array = function (len) { + return new Kotlin.Array(len, function () { + return null + }); +} +Kotlin.Array = Class.create({ + initialize:function (len, f) { + this.array = []; + var i = 0; + while (i < len) { + this.array.push(f(i)); + ++i; + } + }, + get:function (index) { + if ((index < 0) || (index >= this.array.length)) { + throw Kotlin.Exceptions.IndexOutOfBounds; + } + return (this.array)[index]; + }, + set:function (index, value) { + if ((index < 0) || (index >= this.array.length)) { + throw Kotlin.Exceptions.IndexOutOfBounds; + } + (this.array)[index] = value; + }, + size:function () { + return this.array.length; + }, + iterator:function () { + return new Kotlin.ArrayIterator(this); + }, + indices:function() { + return new Kotlin.NumberRange(0, this.size(), false); + } +}); + + +Kotlin.ArrayList = Class.create({ + initialize:function () { + this.array = []; + this.$size = 0; + }, + get:function (index) { + if ((index < 0) || (index >= this.$size)) { + throw Kotlin.Exceptions.IndexOutOfBounds; + } + return (this.array)[index]; + }, + set:function (index, value) { + if ((index < 0) || (index >= this.$size)) { + throw Kotlin.Exceptions.IndexOutOfBounds; + } + (this.array)[index] = value; + }, + size:function () { + return this.$size; + }, + iterator:function () { + return new Kotlin.ArrayIterator(this); + }, + isEmpty:function () { + return (this.$size == 0); + }, + add:function (element) { + this.array[this.$size++] = element; + }, + addAll:function (collection) { + var it = collection.iterator(); + while (it.hasNext()) { + this.add(it.next()); + } + }, + remove:function (index) { + for (var i = index; i < this.$size - 1; ++i) { + this.array[i] = this.array[i + 1]; + } + this.$size--; + }, + contains:function (obj) { + for (var i = 0; i < this.$size; ++i) { + if (Kotlin.equals(this.array[i], obj)) { + return true; + } + } + return false; + } +}); + + +Kotlin.ArrayIterator = Class.create({ + initialize:function (array) { + this.array = array; + this.index = 0; + }, + next:function () { + return this.array.get(this.index++); + }, + hasNext:function () { + return (this.array.size() > this.index); + } +}); + +Kotlin.Integer = function () { + + return { + parseInt:function (str) { + return parseInt(str); + } + } + +}(); + +Kotlin.System = function () { + var output = ""; + + var print = function (obj) { + if (obj !== undefined) { + output += obj; + } + }; + var println = function (obj) { + this.print(obj); + output += "\n"; + }; + + return { + out:function () { + return { + print:print, + println:println + }; + }, + output:function () { + return output; + }, + flush:function () { + output = ""; + } + }; +}(); + + +Kotlin.ArrayIterator = Class.create({ + initialize:function (array) { + this.array = array; + this.index = 0; + }, + next:function () { + return this.array.get(this.index++); + }, + hasNext:function () { + return (this.array.size() > this.index); + } +}); + +Kotlin.RangeIterator = Kotlin.Class.create({initialize:function (start, count, reversed) { + this.$start = start; + this.$count = count; + this.$reversed = reversed; + this.$i = this.get_start(); +}, get_start:function () { + return this.$start; +}, get_count:function () { + return this.$count; +}, set_count:function (tmp$0) { + this.$count = tmp$0; +}, get_reversed:function () { + return this.$reversed; +}, get_i:function () { + return this.$i; +}, set_i:function (tmp$0) { + this.$i = tmp$0; +}, next:function () { + this.set_count(this.get_count() - 1); + if (this.get_reversed()) { + this.set_i(this.get_i() - 1); + return this.get_i() + 1; + } + else { + this.set_i(this.get_i() + 1); + return this.get_i() - 1; + } +}, hasNext:function () { + return this.get_count() > 0; +} +}); + +Kotlin.NumberRange = Kotlin.Class.create({initialize:function (start, size, reversed) { + this.$start = start; + this.$size = size; + this.$reversed = reversed; +}, get_start:function () { + return this.$start; +}, get_size:function () { + return this.$size; +}, get_reversed:function () { + return this.$reversed; +}, get_end:function () { + return this.get_reversed() ? this.get_start() - this.get_size() + 1 : this.get_start() + this.get_size() - 1; +}, contains:function (number) { + if (this.get_reversed()) { + return number <= this.get_start() && number > this.get_start() - this.get_size(); + } + else { + return number >= this.get_start() && number < this.get_start() + this.get_size(); + } +}, iterator:function () { + return new Kotlin.RangeIterator(this.get_start(), this.get_size(), this.get_reversed()); +} +}); diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen$1.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen$1.class new file mode 100644 index 00000000000..383114eb694 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen$2.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen$2.class new file mode 100644 index 00000000000..159b569a025 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen$2.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen$3.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen$3.class new file mode 100644 index 00000000000..db361201f74 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen$3.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen.class new file mode 100644 index 00000000000..8e94e33266d Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/AnnotationCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter$1.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter$1.class new file mode 100644 index 00000000000..79990cad6af Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter$Mode.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter$Mode.class new file mode 100644 index 00000000000..96be445492a Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter$Mode.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter$State.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter$State.class new file mode 100644 index 00000000000..c5535556b2b Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter$State.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter.class new file mode 100644 index 00000000000..b951a36e9c2 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/BothSignatureWriter.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/Callable.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/Callable.class new file mode 100644 index 00000000000..e12a7abe7a7 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/Callable.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CallableMethod.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CallableMethod.class new file mode 100644 index 00000000000..a783c90573b Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CallableMethod.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBodyCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBodyCodegen.class new file mode 100644 index 00000000000..aadc6002f60 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBodyCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilder$Concrete.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilder$Concrete.class new file mode 100644 index 00000000000..de864efce0c Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilder$Concrete.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilder.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilder.class new file mode 100644 index 00000000000..dbdd201ca76 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilder.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory$1.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory$1.class new file mode 100644 index 00000000000..6937f45ddc3 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory$2$1.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory$2$1.class new file mode 100644 index 00000000000..daa5bbdacec Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory$2$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory$2.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory$2.class new file mode 100644 index 00000000000..894657beb36 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory$2.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory.class new file mode 100644 index 00000000000..f049fb758b4 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassBuilderFactory.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassCodegen.class new file mode 100644 index 00000000000..42586a04d67 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassFileFactory.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassFileFactory.class new file mode 100644 index 00000000000..93af46526b0 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClassFileFactory.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ClosureCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClosureCodegen.class new file mode 100644 index 00000000000..2be9a6ce8c8 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ClosureCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodeChunk.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodeChunk.class new file mode 100644 index 00000000000..8d55d9fc143 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodeChunk.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$1.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$1.class new file mode 100644 index 00000000000..d6d0adb6d2d Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$AnonymousClassContext.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$AnonymousClassContext.class new file mode 100644 index 00000000000..2918bbdef80 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$AnonymousClassContext.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ClassContext.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ClassContext.class new file mode 100644 index 00000000000..9f6d937fbf6 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ClassContext.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ClosureContext.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ClosureContext.class new file mode 100644 index 00000000000..e79fef53713 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ClosureContext.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ConstructorContext.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ConstructorContext.class new file mode 100644 index 00000000000..bc9fc129742 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ConstructorContext.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$MethodContext.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$MethodContext.class new file mode 100644 index 00000000000..54a47733597 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$MethodContext.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$NamespaceContext.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$NamespaceContext.class new file mode 100644 index 00000000000..3874f505e83 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$NamespaceContext.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ReceiverContext.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ReceiverContext.class new file mode 100644 index 00000000000..25770bf884a Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext$ReceiverContext.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext.class new file mode 100644 index 00000000000..270d008317a Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenContext.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenUtil.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenUtil.class new file mode 100644 index 00000000000..ae41ab41993 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CodegenUtil.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CompilationErrorHandler$1.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CompilationErrorHandler$1.class new file mode 100644 index 00000000000..6cc81ffba46 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CompilationErrorHandler$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CompilationErrorHandler.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CompilationErrorHandler.class new file mode 100644 index 00000000000..0b201dbfc0c Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CompilationErrorHandler.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/CompilationException.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/CompilationException.class new file mode 100644 index 00000000000..97162528b35 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/CompilationException.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ConstructorFrameMap.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ConstructorFrameMap.class new file mode 100644 index 00000000000..89c9045b391 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ConstructorFrameMap.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/EnclosedValueDescriptor.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/EnclosedValueDescriptor.class new file mode 100644 index 00000000000..8f931dfc77c Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/EnclosedValueDescriptor.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$BlockStackElement.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$BlockStackElement.class new file mode 100644 index 00000000000..08e4aa12612 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$BlockStackElement.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$FinallyBlockStackElement.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$FinallyBlockStackElement.class new file mode 100644 index 00000000000..c4209cfdb6a Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$FinallyBlockStackElement.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$ForInArrayLoopGenerator.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$ForInArrayLoopGenerator.class new file mode 100644 index 00000000000..e52d4997afe Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$ForInArrayLoopGenerator.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$ForInRangeLoopGenerator.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$ForInRangeLoopGenerator.class new file mode 100644 index 00000000000..e00afde0c44 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$ForInRangeLoopGenerator.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$ForLoopGenerator.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$ForLoopGenerator.class new file mode 100644 index 00000000000..a8f32686093 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$ForLoopGenerator.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$LoopBlockStackElement.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$LoopBlockStackElement.class new file mode 100644 index 00000000000..a3ba88a6f3f Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen$LoopBlockStackElement.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen.class new file mode 100644 index 00000000000..c9891202640 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ExpressionCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/FrameMap$Mark.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/FrameMap$Mark.class new file mode 100644 index 00000000000..be857021711 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/FrameMap$Mark.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/FrameMap.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/FrameMap.class new file mode 100644 index 00000000000..f3b38735cdc Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/FrameMap.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/FunctionCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/FunctionCodegen.class new file mode 100644 index 00000000000..dfd04cc9343 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/FunctionCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/GeneratedAnonymousClassDescriptor.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/GeneratedAnonymousClassDescriptor.class new file mode 100644 index 00000000000..e862746be8d Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/GeneratedAnonymousClassDescriptor.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/GeneratedClassLoader.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/GeneratedClassLoader.class new file mode 100644 index 00000000000..e3dcdc5d59c Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/GeneratedClassLoader.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/GenerationState$1.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/GenerationState$1.class new file mode 100644 index 00000000000..a8d1d33d812 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/GenerationState$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/GenerationState.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/GenerationState.class new file mode 100644 index 00000000000..f1208b72e0d Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/GenerationState.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$1.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$1.class new file mode 100644 index 00000000000..a5284769d98 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$2.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$2.class new file mode 100644 index 00000000000..d417e78d59e Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$2.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$3.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$3.class new file mode 100644 index 00000000000..1e175d07bfe Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$3.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$4.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$4.class new file mode 100644 index 00000000000..4db5449af66 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen$4.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen.class new file mode 100644 index 00000000000..fd6be53da76 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ImplementationBodyCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/JetMethodAnnotationWriter.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/JetMethodAnnotationWriter.class new file mode 100644 index 00000000000..8a65999a336 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/JetMethodAnnotationWriter.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/JetTypeMapper.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/JetTypeMapper.class new file mode 100644 index 00000000000..409d5c347e4 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/JetTypeMapper.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmClassSignature.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmClassSignature.class new file mode 100644 index 00000000000..6cbf01cc93e Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmClassSignature.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmMethodParameterKind.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmMethodParameterKind.class new file mode 100644 index 00000000000..48de7f91330 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmMethodParameterKind.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmMethodParameterSignature.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmMethodParameterSignature.class new file mode 100644 index 00000000000..f34e5c538cb Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmMethodParameterSignature.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmMethodSignature.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmMethodSignature.class new file mode 100644 index 00000000000..27418b07075 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmMethodSignature.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmPropertyAccessorSignature.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmPropertyAccessorSignature.class new file mode 100644 index 00000000000..b6d889a041a Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/JvmPropertyAccessorSignature.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/NamespaceCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/NamespaceCodegen.class new file mode 100644 index 00000000000..cf3817fd457 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/NamespaceCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ObjectOrClosureCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ObjectOrClosureCodegen.class new file mode 100644 index 00000000000..ed8d8e94189 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ObjectOrClosureCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/OwnerKind$DelegateKind.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/OwnerKind$DelegateKind.class new file mode 100644 index 00000000000..2d08ccab0e1 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/OwnerKind$DelegateKind.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/OwnerKind.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/OwnerKind.class new file mode 100644 index 00000000000..c6cbd7dd067 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/OwnerKind.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/ProjectionErasingJetType.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/ProjectionErasingJetType.class new file mode 100644 index 00000000000..54b7dd71e27 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/ProjectionErasingJetType.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/PropertyCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/PropertyCodegen.class new file mode 100644 index 00000000000..8b64f49e696 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/PropertyCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$1.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$1.class new file mode 100644 index 00000000000..1f4dd0c4ff6 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$ArrayElement.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$ArrayElement.class new file mode 100644 index 00000000000..53a14b53e3b Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$ArrayElement.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$CallReceiver.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$CallReceiver.class new file mode 100644 index 00000000000..1290ef0a7d0 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$CallReceiver.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$CollectionElement.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$CollectionElement.class new file mode 100644 index 00000000000..1123b0ddbed Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$CollectionElement.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Composed.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Composed.class new file mode 100644 index 00000000000..115738a0823 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Composed.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Constant.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Constant.class new file mode 100644 index 00000000000..4ca9d597a62 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Constant.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Expression.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Expression.class new file mode 100644 index 00000000000..cca98f6716c Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Expression.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Field.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Field.class new file mode 100644 index 00000000000..8d8badccab8 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Field.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$FieldForSharedVar.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$FieldForSharedVar.class new file mode 100644 index 00000000000..a2fcea04fa4 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$FieldForSharedVar.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Invert.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Invert.class new file mode 100644 index 00000000000..50007b9616d Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Invert.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Local.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Local.class new file mode 100644 index 00000000000..51910f49470 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Local.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$None.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$None.class new file mode 100644 index 00000000000..e9059be6fd5 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$None.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$NumberCompare.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$NumberCompare.class new file mode 100644 index 00000000000..2b50fcaac80 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$NumberCompare.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$ObjectCompare.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$ObjectCompare.class new file mode 100644 index 00000000000..e45ebf208f2 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$ObjectCompare.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$OnStack.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$OnStack.class new file mode 100644 index 00000000000..c11c82cfd64 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$OnStack.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$PostIncrement.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$PostIncrement.class new file mode 100644 index 00000000000..147842073a5 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$PostIncrement.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$PreIncrement.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$PreIncrement.class new file mode 100644 index 00000000000..c4dcb59edc1 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$PreIncrement.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Property.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Property.class new file mode 100644 index 00000000000..6a15c1291e7 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Property.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Shared.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Shared.class new file mode 100644 index 00000000000..7709c8f6049 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$Shared.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$ThisOuter.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$ThisOuter.class new file mode 100644 index 00000000000..227e171e59d Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue$ThisOuter.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue.class new file mode 100644 index 00000000000..2632d755c27 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/StackValue.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/TraitImplBodyCodegen.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/TraitImplBodyCodegen.class new file mode 100644 index 00000000000..39eb270e9c3 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/TraitImplBodyCodegen.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArrayGet.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArrayGet.class new file mode 100644 index 00000000000..ac1fa95d0b8 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArrayGet.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArrayIndices.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArrayIndices.class new file mode 100644 index 00000000000..684cdf0f81a Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArrayIndices.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArrayIterator.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArrayIterator.class new file mode 100644 index 00000000000..164a7869dc9 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArrayIterator.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArraySet.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArraySet.class new file mode 100644 index 00000000000..15d3b65fc2b Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArraySet.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArraySize.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArraySize.class new file mode 100644 index 00000000000..76ef3d685e4 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ArraySize.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/BinaryOp.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/BinaryOp.class new file mode 100644 index 00000000000..bff577c964f Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/BinaryOp.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/CompareTo.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/CompareTo.class new file mode 100644 index 00000000000..7754b121ef2 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/CompareTo.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Concat.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Concat.class new file mode 100644 index 00000000000..014278c2445 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Concat.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Equals.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Equals.class new file mode 100644 index 00000000000..ba6380f8dd2 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Equals.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Increment.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Increment.class new file mode 100644 index 00000000000..efa18ea69d5 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Increment.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethod.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethod.class new file mode 100644 index 00000000000..a9d78e4e913 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethod.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods$1.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods$1.class new file mode 100644 index 00000000000..64a90f04c0a Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.class new file mode 100644 index 00000000000..24017ceda6b Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Inv.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Inv.class new file mode 100644 index 00000000000..51d4122f139 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Inv.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IteratorIterator.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IteratorIterator.class new file mode 100644 index 00000000000..11234b9b4b3 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IteratorIterator.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IteratorNext.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IteratorNext.class new file mode 100644 index 00000000000..878868b861e Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/IteratorNext.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/NewArray.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/NewArray.class new file mode 100644 index 00000000000..d8f1bcc0a86 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/NewArray.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Not.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Not.class new file mode 100644 index 00000000000..5b41a2d0802 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Not.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/NumberCast.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/NumberCast.class new file mode 100644 index 00000000000..4e1309555d6 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/NumberCast.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/PsiMethodCall.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/PsiMethodCall.class new file mode 100644 index 00000000000..eb4099fba72 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/PsiMethodCall.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StringGetChar.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StringGetChar.class new file mode 100644 index 00000000000..ef1a9139a24 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StringGetChar.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StringLength.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StringLength.class new file mode 100644 index 00000000000..a49b1c44cb9 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StringLength.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StringPlus.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StringPlus.class new file mode 100644 index 00000000000..13f503b0bfd Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StringPlus.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StupidSync.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StupidSync.class new file mode 100644 index 00000000000..992ba825a8b Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/StupidSync.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Sure.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Sure.class new file mode 100644 index 00000000000..3dc467f47aa Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/Sure.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ToString.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ToString.class new file mode 100644 index 00000000000..0430945603a Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ToString.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/TypeInfo.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/TypeInfo.class new file mode 100644 index 00000000000..9b1a506a64e Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/TypeInfo.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/UnaryMinus.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/UnaryMinus.class new file mode 100644 index 00000000000..9543ed5ab28 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/UnaryMinus.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/UnaryPlus.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/UnaryPlus.class new file mode 100644 index 00000000000..a5f9ee06fbc Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/UnaryPlus.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/UpTo.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/UpTo.class new file mode 100644 index 00000000000..1521b36d069 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/UpTo.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ValueTypeInfo.class b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ValueTypeInfo.class new file mode 100644 index 00000000000..5be663d5aa2 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/codegen/intrinsics/ValueTypeInfo.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/compiler/FileNameTransformer$1.class b/k2js/out/production/backend/org/jetbrains/jet/compiler/FileNameTransformer$1.class new file mode 100644 index 00000000000..a1d34ffd059 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/compiler/FileNameTransformer$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/compiler/FileNameTransformer.class b/k2js/out/production/backend/org/jetbrains/jet/compiler/FileNameTransformer.class new file mode 100644 index 00000000000..dab3e838de5 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/compiler/FileNameTransformer.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$1.class b/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$1.class new file mode 100644 index 00000000000..a09318caa44 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$1.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$2.class b/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$2.class new file mode 100644 index 00000000000..26d78e33d85 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$2.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$3.class b/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$3.class new file mode 100644 index 00000000000..e59569444a6 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$3.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$4.class b/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$4.class new file mode 100644 index 00000000000..1551d73a3a8 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager$4.class differ diff --git a/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager.class b/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager.class new file mode 100644 index 00000000000..b7bd2014272 Binary files /dev/null and b/k2js/out/production/backend/org/jetbrains/jet/compiler/TipsManager.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/cli/KotlinCompiler$1.class b/k2js/out/production/cli/org/jetbrains/jet/cli/KotlinCompiler$1.class new file mode 100644 index 00000000000..27e5e8b9933 Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/cli/KotlinCompiler$1.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/cli/KotlinCompiler$Arguments.class b/k2js/out/production/cli/org/jetbrains/jet/cli/KotlinCompiler$Arguments.class new file mode 100644 index 00000000000..a7337dd9971 Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/cli/KotlinCompiler$Arguments.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/cli/KotlinCompiler.class b/k2js/out/production/cli/org/jetbrains/jet/cli/KotlinCompiler.class new file mode 100644 index 00000000000..6798b5cee59 Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/cli/KotlinCompiler.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironment$1.class b/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironment$1.class new file mode 100644 index 00000000000..61d853adba8 Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironment$1.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironment$2.class b/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironment$2.class new file mode 100644 index 00000000000..08e182d60bc Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironment$2.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironment.class b/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironment.class new file mode 100644 index 00000000000..52f0f6d62f1 Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironment.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironmentException.class b/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironmentException.class new file mode 100644 index 00000000000..8613d75370c Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileEnvironmentException.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileSession.class b/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileSession.class new file mode 100644 index 00000000000..5d0415b21c8 Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/compiler/CompileSession.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/compiler/ErrorCollector.class b/k2js/out/production/cli/org/jetbrains/jet/compiler/ErrorCollector.class new file mode 100644 index 00000000000..4a93aed6472 Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/compiler/ErrorCollector.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/compiler/JetCoreEnvironment.class b/k2js/out/production/cli/org/jetbrains/jet/compiler/JetCoreEnvironment.class new file mode 100644 index 00000000000..a77d77740f6 Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/compiler/JetCoreEnvironment.class differ diff --git a/k2js/out/production/cli/org/jetbrains/jet/compiler/ModuleExecutionException.class b/k2js/out/production/cli/org/jetbrains/jet/compiler/ModuleExecutionException.class new file mode 100644 index 00000000000..607576d88b7 Binary files /dev/null and b/k2js/out/production/cli/org/jetbrains/jet/compiler/ModuleExecutionException.class differ diff --git a/k2js/out/production/examplesForWebDemo/html5/creatures/kotlinlogo.png b/k2js/out/production/examplesForWebDemo/html5/creatures/kotlinlogo.png new file mode 100644 index 00000000000..5394223b3d6 Binary files /dev/null and b/k2js/out/production/examplesForWebDemo/html5/creatures/kotlinlogo.png differ diff --git a/k2js/out/production/examplesForWebDemo/html5/creatures/main.kt b/k2js/out/production/examplesForWebDemo/html5/creatures/main.kt new file mode 100644 index 00000000000..46e0d92b8c2 --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/creatures/main.kt @@ -0,0 +1,331 @@ +/* +In this example strange creatures are watching the kotlin logo. You can drag'n'drop them as well as the logo. +Doubleclick to add more creatures but be careful. They may be watching you! +*/ +package creatures +// importing some of the API defined +import jquery.* +import html5.* +import java.util.ArrayList +import js.* +import js.Math +import js.setInterval +import html5.getCanvas +import html5.getKotlinLogo +import jquery.jq +import js.setTimeout +import java.util.List + + +abstract class Shape() { + + abstract fun draw(state : CanvasState) + // these two abstract methods defines that our shapes can be dragged + abstract fun contains(mousePos : Vector) : Boolean + abstract var pos : Vector + + var selected : Boolean = false + + // a couple of helper extension methods we'll be using in the derived classes + fun Context.shadowed(shadowOffset : Vector, alpha : Double, render : Context.() -> Unit) { + save() + shadowColor = "rgba(100, 100, 100, $alpha)" + shadowBlur = 5.0 + shadowOffsetX = shadowOffset.x + shadowOffsetY = shadowOffset.y + render() + restore() + } + + fun Context.fillPath(constructPath : Context.() -> Unit) { + beginPath() + constructPath() + closePath() + fill() + } +} + +val Kotlin = Logo(v(300.0, 100.0)) + +class Logo(override var pos : Vector) : Shape() +{ + val relSize : Double = 0.25 + val shadowOffset = v(-3.0, 3.0) + val imageSize = v(377.0, 393.0) + var size : Vector = imageSize * relSize + // get-only properties like this saves you lots of typing and are very expressive + val position : Vector + get() = if (selected) pos - shadowOffset else pos + + + fun drawLogo(state : CanvasState) { + size = imageSize * (state.size.x / imageSize.x) * relSize + // getKotlinLogo() is a 'magic' function here defined only for purposes of demonstration but in fact it just find an element containing the logo + state.context.drawImage(getKotlinLogo(), 0.0, 0.0, imageSize.x, imageSize.y, position.x, position.y, size.x, size.y) + } + + override fun draw(state : CanvasState) { + val context = state.context + if (selected) { + // using helper we defined in Shape class + context.shadowed(shadowOffset, 0.2) { + drawLogo(state) + } + } else { + drawLogo(state) + } + } + + override fun contains(mousePos: Vector): Boolean = mousePos.isInRect(pos, size) + + val centre : Vector + get() = pos + size * 0.5 +} + +val gradientGenerator = RadialGradientGenerator(getContext()) + +class Creature(override var pos : Vector, val state : CanvasState) : Shape() { + + val shadowOffset = v(-5.0, 5.0) + val colorStops = gradientGenerator.getNext() + val relSize = 0.05 + // these properties have no backing fields and in java/javascript they could be represented as little helper functions + val radius : Double + get() = state.width * relSize + val position : Vector + get() = if (selected) pos - shadowOffset else pos + val directionToLogo : Vector + get() = (Kotlin.centre - position).normalized + + //notice how the infix call can make some expressions extremely expressive + override fun contains(mousePos : Vector) = pos distanceTo mousePos < radius + + // defining more nice extension functions + fun Context.circlePath(position : Vector, rad : Double) { + arc(position.x, position.y, rad, 0.0, 2 * Math.PI, false) + } + + //notice we can use an extension function we just defined inside another extension function + fun Context.fillCircle(position : Vector, rad : Double) { + fillPath { + circlePath(position, rad) + } + } + + override fun draw(state : CanvasState) { + val context = state.context + if (!selected) { + drawCreature(context) + } else { + drawCreatureWithShadow(context) + } + } + + fun drawCreature(context : Context) { + context.fillStyle = getGradient(context) + context.fillPath { + tailPath(context) + circlePath(position, radius) + } + drawEye(context) + } + + fun getGradient(context : Context) : CanvasGradient { + val gradientCentre = position + directionToLogo * (radius / 4) + val gradient = context.createRadialGradient(gradientCentre.x, gradientCentre.y, 1.0, gradientCentre.x, gradientCentre.y, 2 * radius) + for (colorStop in colorStops) { + gradient.addColorStop(colorStop._1, colorStop._2) + } + return gradient + } + + fun tailPath(context : Context) { + val tailDirection = -directionToLogo + val tailPos = position + tailDirection * radius * 1.0 + val tailSize = radius * 1.6 + val angle = Math.PI / 6.0 + val p1 = tailPos + tailDirection.rotatedBy(angle) * tailSize + val p2 = tailPos + tailDirection.rotatedBy(-angle) * tailSize + val middlePoint = position + tailDirection * radius * 1.0 + context.moveTo(tailPos.x, tailPos.y) + context.lineTo(p1.x, p1.y) + context.quadraticCurveTo(middlePoint.x, middlePoint.y, p2.x, p2.y) + context.lineTo(tailPos.x, tailPos.y) + } + + fun drawEye(context : Context) { + val eyePos = directionToLogo * radius * 0.6 + position + val eyeRadius = radius / 3 + val eyeLidRadius = eyeRadius / 2 + context.fillStyle = "#FFFFFF" + context.fillCircle(eyePos, eyeRadius) + context.fillStyle = "#000000" + context.fillCircle(eyePos, eyeLidRadius) + } + + fun drawCreatureWithShadow(context : Context) { + context.shadowed(shadowOffset, 0.7) { + context.fillStyle = getGradient(context) + fillPath { + tailPath(context) + context.circlePath(position, radius) + } + } + drawEye(context) + } +} + +class CanvasState(val canvas : Canvas) { + var width = canvas.width + var height = canvas.height + val size : Vector + get() = v(width, height) + val context = getContext() + var valid = false + var shapes = ArrayList() + var selection : Shape? = null + var dragOff = Vector() + val interval = 1000 / 30 + + { + jq(canvas).mousedown { + valid = false + selection = null + val mousePos = mousePos(it) + for (shape in shapes) { + if (mousePos in shape) { + dragOff = mousePos - shape.pos + shape.selected = true + selection = shape + break + } + } + } + + jq(canvas).mousemove { + if (selection != null) { + selection.sure().pos = mousePos(it) - dragOff + valid = false + } + } + + jq(canvas).mouseup { + if (selection != null) { + selection.sure().selected = false + } + selection = null + valid = false + } + + jq(canvas).dblclick { + val newCreature = Creature(mousePos(it), this @CanvasState) + addShape(newCreature) + valid = false + } + + setInterval({ + draw() + }, interval) + } + + fun mousePos(e : MouseEvent) : Vector { + var offset = Vector() + var element : DomElement? = canvas + while (element != null) { + val el : DomElement = element.sure() + offset += Vector(el.offsetLeft, el.offsetTop) + element = el.offsetParent + } + return Vector(e.pageX, e.pageY) - offset + } + + fun addShape(shape : Shape) { + shapes.add(shape) + valid = false + } + + fun clear() { + context.fillStyle = "#FFFFFF" + context.fillRect(0.0, 0.0, width, height) + context.strokeStyle = "#000000" + context.lineWidth = 4.0 + context.strokeRect(0.0, 0.0, width, height) + } + + fun draw() { + if (valid) return + + clear() + for (shape in shapes.reversed()) { + shape.draw(this) + } + Kotlin.draw(this) + valid = true + } +} + +class RadialGradientGenerator(val context : Context) { + val gradients = ArrayList>() + var current = 0 + + fun newColorStops(vararg colorStops : #(Double, String)) { + gradients.add(colorStops) + } + + { + newColorStops(#(0.0, "#F59898"), #(0.5, "#F57373"), #(1.0, "#DB6B6B")) + newColorStops(#(0.39, "rgb(140,167,209)"), #(0.7, "rgb(104,139,209)"), #(0.85, "rgb(67,122,217)")) + newColorStops(#(0.0, "rgb(255,222,255)"), #(0.5, "rgb(255,185,222)"), #(1.0, "rgb(230,154,185)")) + newColorStops(#(0.0, "rgb(255,209,114)"), #(0.5, "rgb(255,174,81)"), #(1.0, "rgb(241,145,54)")) + newColorStops(#(0.0, "rgb(132,240,135)"), #(0.5, "rgb(91,240,96)"), #(1.0, "rgb(27,245,41)")) + newColorStops(#(0.0, "rgb(250,147,250)"), #(0.5, "rgb(255,80,255)"), #(1.0, "rgb(250,0,217)")) + } + + fun getNext() : Array<#(Double, String)> { + val result = gradients.get(current) + current = (current + 1) % gradients.size() + return result + } +} + +fun v(x : Double, y : Double) = Vector(x, y) + +class Vector(val x : Double = 0.0, val y : Double = 0.0) { + fun plus(v : Vector) = v(x + v.x, y + v.y) + fun minus() = v(-x, -y) + fun minus(v : Vector) = v(x - v.x, y - v.y) + fun times(koef : Double) = v(x * koef, y * koef) + fun distanceTo(v : Vector) = Math.sqrt((this - v).sqr) + fun rotatedBy(theta : Double) : Vector { + val sin = Math.sin(theta) + val cos = Math.cos(theta) + return v(x * cos - y * sin, x * sin + y * cos) + } + + fun isInRect(topLeft : Vector, size : Vector) = (x >= topLeft.x) && (x <= topLeft.x + size.x) && + (y >= topLeft.y) && (y <= topLeft.y + size.y) + + val sqr : Double + get() = x * x + y * y + val normalized : Vector + get() = this * (1.0 / Math.sqrt(sqr)) +} + +fun main() { + val state = CanvasState(getCanvas()) + state.addShape(Kotlin) + state.addShape(Creature(state.size * 0.25, state)) + state.addShape(Creature(state.size * 0.75, state)) + setTimeout({ + state.valid = false + }) +} + +fun List.reversed() : List { + val result = ArrayList() + var i = size() + while (i > 0) { + result.add(get(--i)) + } + return result +} \ No newline at end of file diff --git a/k2js/out/production/examplesForWebDemo/html5/creatures/template.html b/k2js/out/production/examplesForWebDemo/html5/creatures/template.html new file mode 100644 index 00000000000..466bfa8168f --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/creatures/template.html @@ -0,0 +1,32 @@ + + + + + + Canvas demo + + + + + + + + + + + \ No newline at end of file diff --git a/k2js/out/production/examplesForWebDemo/html5/fancyLines/template.html b/k2js/out/production/examplesForWebDemo/html5/fancyLines/template.html new file mode 100644 index 00000000000..64a717ea926 --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/fancyLines/template.html @@ -0,0 +1,30 @@ + + + + + + Canvas demo + + + + + + + + + \ No newline at end of file diff --git a/k2js/out/production/examplesForWebDemo/html5/fancyLines/test.kt b/k2js/out/production/examplesForWebDemo/html5/fancyLines/test.kt new file mode 100644 index 00000000000..892bc4695cc --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/fancyLines/test.kt @@ -0,0 +1,64 @@ +/* +This example is based on example from html5 canvas2D docs: + http://www.w3.org/TR/2dcontext/ +Note that only a subset of the api is supported for now. +*/ + +package fancylines + +import js.*; +import html5.*; +import jquery.*; + +fun main() { + //jq is a name for JQuery function + jq { + FancyLines().run(); + } +} + +class FancyLines() { + // we use two 'magic' functions here getContext() and getCanvas() + val context = getContext(); + val height = getCanvas().height; + val width = getCanvas().width; + var x = width * Math.random(); + var y = height * Math.random(); + var hue = 0; + + fun line() { + context.save(); + + context.beginPath(); + + context.lineWidth = 20.0 * Math.random(); + context.moveTo(x, y); + + x = width * Math.random(); + y = height * Math.random(); + + context.bezierCurveTo(width * Math.random(), height * Math.random(), + width * Math.random(), height * Math.random(), x, y); + + hue += Math.random() * 10; + + context.strokeStyle = "hsl($hue, 50%, 50%)"; + + context.shadowColor = "white"; + context.shadowBlur = 10.0; + + context.stroke(); + + context.restore(); + } + + fun blank() { + context.fillStyle = "rgba(255,255,1,0.1)"; + context.fillRect(0.0, 0.0, width, height); + } + + fun run() { + setInterval({line()}, 40); + setInterval({blank()}, 100); + } +} \ No newline at end of file diff --git a/k2js/out/production/examplesForWebDemo/html5/floatingText/template.html b/k2js/out/production/examplesForWebDemo/html5/floatingText/template.html new file mode 100644 index 00000000000..557ab5c8b6f --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/floatingText/template.html @@ -0,0 +1,30 @@ + + + + + + Canvas demo + + + + + + + + + \ No newline at end of file diff --git a/k2js/out/production/examplesForWebDemo/html5/floatingText/test.kt b/k2js/out/production/examplesForWebDemo/html5/floatingText/test.kt new file mode 100644 index 00000000000..e5bca3ea4d9 --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/floatingText/test.kt @@ -0,0 +1,91 @@ +/* + This example is just simple text floating around. If u are using chrome, there is a bug that spoil the visuals. +*/ +package hello + +import js.* +import html5.* +import jquery.* + +val context = getContext() +val height = getCanvas().height +val width = getCanvas().width + +// class representing a floating text +class HelloKotlin() { + var relX = 0.2 + 0.2 * Math.random() + var relY = 0.4 + 0.2 * Math.random() + + val absX : Double + get() = (relX * width) + val absY : Double + get() = (relY * height) + + var relXVelocity = randomVelocity() + var relYVelocity = randomVelocity() + + + val message = "Hello, Kotlin!" + val textHeightInPixels = 60 + { + context.font = "bold ${textHeightInPixels}px Georgia, serif" + } + val textWidthInPixels = context.measureText(message).width + + fun draw() { + context.save() + move() + // if you using chrome chances are good you wont see the shadow + context.shadowColor = "#000000" + context.shadowBlur = 5.0 + context.shadowOffsetX = -4.0 + context.shadowOffsetY = 4.0 + context.fillStyle = "rgb(242,160,110)" + context.fillText(message, absX, absY) + context.restore() + } + + fun move() { + val relTextWidth = textWidthInPixels / width + if (relX > (1.0 - relTextWidth - relXVelocity.abs) || relX < relXVelocity.abs) { + relXVelocity *= -1 + } + val relTextHeight = textHeightInPixels / height + if (relY > (1.0 - relYVelocity.abs) || relY < relYVelocity.abs + relTextHeight) { + relYVelocity *= -1 + } + relX += relXVelocity + relY += relYVelocity + } + + fun randomVelocity() = 0.03 * Math.random() * (if (Math.random() < 0.5) 1 else -1) + + + val Double.abs : Double + get() = if (this > 0) this else -this +} + +fun renderBackground() { + context.save() + context.fillStyle = "#5C7EED" + context.fillRect(0.0, 0.0, width, height) + context.restore() +} + +fun main() { + val interval = 50 + // we pass a literal that constructs a new HelloKotlin object + val logos = Array(3) { + HelloKotlin() + } + jq { + setInterval({ + renderBackground() + for (logo in logos) { + logo.draw() + } + }, interval) + } +} + + diff --git a/k2js/out/production/examplesForWebDemo/html5/interactive/jbLogo.png b/k2js/out/production/examplesForWebDemo/html5/interactive/jbLogo.png new file mode 100644 index 00000000000..759aa8ae05a Binary files /dev/null and b/k2js/out/production/examplesForWebDemo/html5/interactive/jbLogo.png differ diff --git a/k2js/out/production/examplesForWebDemo/html5/interactive/main.kt b/k2js/out/production/examplesForWebDemo/html5/interactive/main.kt new file mode 100644 index 00000000000..86eb1c1fdfc --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/interactive/main.kt @@ -0,0 +1,183 @@ +package interactive; + +import jquery.*; +import html5.*; +import java.util.ArrayList; +import js.*; +import js.Math; +import js.setInterval +import html5.getCanvas +import html5.getKotlinLogo +import jquery.jq +import js.setTimeout + +val state = CanvasState(getCanvas()); + +fun doWithPeriod(period : Int, f : ()->Unit) { + setInterval(f, period); +} + +abstract class Shape() { + abstract fun draw(state : CanvasState); + abstract fun contains(mousePos : Vector) : Boolean; + abstract var pos : Vector; + var selected : Boolean = false; +} + +class Circle(override var pos : Vector, + var radius : Double = 1.0, + var fillColor : String = "#AAAAAA") : Shape() { + + override fun draw(state : CanvasState) { + val context = state.context; + context.shadowColor = "white"; + context.shadowBlur = 10.0; + context.fillStyle = fillColor; + context.beginPath(); + context.arc(pos.x, pos.y, radius, 0.0, 2 * Math.PI, false); + context.closePath(); + context.fill(); + } + + override fun contains(mousePos : Vector) = pos.distanceTo(mousePos) < radius; +} + +class Rectangle(override var pos : Vector, + var size : Vector) : Shape() +{ + override fun draw(state : CanvasState) { + val context = state.context; + context.fillStyle = "rgba(0,255,0,.6)"; + context.fillRect(pos.x, pos.y, size.x, size.y); + if (selected) { + context.strokeStyle = "#FF0000" + context.lineWidth = 2.0; + context.strokeRect(pos.x, pos.y, size.x, size.y) + } + } + + override fun contains(mousePos : Vector) = mousePos.isInRect(pos, size); +} + +class JB(override var pos : Vector, + var relSize : Double = 0.3) : Shape() +{ + + val imageSize = v(704.0, 254.0) + val canvasSize = imageSize * relSize + + override fun draw(state : CanvasState) { + val context = state.context; + context.drawImage(getKotlinLogo(), 0.0, 0.0, imageSize.x, imageSize.y, pos.x, pos.y, canvasSize.x, canvasSize.y) + } + + override fun contains(mousePos: Vector): Boolean = mousePos.isInRect(pos, canvasSize) +} + +class CanvasState(val canvas : Canvas) { + val width = canvas.width; + val height = canvas.height; + val context = getContext(); + var valid = false; + var shapes = ArrayList(); + var selection : Shape? = null; + var dragOff = Vector(); + val interval = 1000 / 30; + val size = 20.0; + + { + jq(canvas).mousedown { + valid = false; + selection = null; + val mousePos = mousePos(it); + for (shape in shapes) { + if (mousePos in shape) { + dragOff = mousePos - shape.pos; + shape.selected = true; + selection = shape; + break; + } + } + } + + jq(canvas).mousemove { + if (selection != null) { + selection.sure().pos = mousePos(it) - dragOff; + valid = false; + } + } + + jq(canvas).mouseup { + if (selection != null) { + selection.sure().selected = false; + } + selection = null; + valid = false; + } + + jq(canvas).dblclick { + val redTransparentCircle = Circle(mousePos(it), size, "rgba(200, 100, 100, 0.3)"); + addShape(redTransparentCircle); + valid = false; + } + + doWithPeriod(interval) { + draw(); + } + } + + fun mousePos(e : MouseEvent) : Vector { + var offset = Vector(); + var element : DomElement? = canvas; + while (element != null) { + val el : DomElement = element.sure(); + offset += Vector(el.offsetLeft, el.offsetTop); + element = el.offsetParent; + } + return Vector(e.pageX, e.pageY) - offset; + } + + fun addShape(shape : Shape) { + shapes.add(shape); + valid = false; + } + + fun clear() { + context.fillStyle = "#FFFFFF" + context.fillRect(0.0, 0.0, width, height) + context.strokeStyle = "#000000" + context.lineWidth = 4.0; + context.strokeRect(0.0, 0.0, width, height) + } + + fun draw() { + if (valid) return + + clear(); + for (shape in shapes) { + shape.draw(this); + } + valid = true; + } +} + +fun v(x : Double, y : Double) = Vector(x, y); + +class Vector(var x : Double = 0.0, var y : Double = 0.0) { + fun plus(v : Vector) = v(x + v.x, y + v.y); + fun minus(v : Vector) = v(x - v.x, y - v.y); + fun times(coef : Double) = v(x * coef, y * coef); + fun distanceTo(v : Vector) = Math.sqrt((this - v).sqr); + fun isInRect(topLeft : Vector, size : Vector) = (x >= topLeft.x) && (x <= topLeft.x + size.x) && + (y >= topLeft.y) && (y <= topLeft.y + size.y) + val sqr : Double + get() = x * x + y * y; +} + +fun main() { + val state = CanvasState(getCanvas()); + state.addShape(JB(v(1.0, 1.0))); + setTimeout({ + state.valid = false + }) +} \ No newline at end of file diff --git a/k2js/out/production/examplesForWebDemo/html5/interactive/template.html b/k2js/out/production/examplesForWebDemo/html5/interactive/template.html new file mode 100644 index 00000000000..d976e3dafc2 --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/interactive/template.html @@ -0,0 +1,31 @@ + + + + + + Canvas demo + + + + + + + + + + \ No newline at end of file diff --git a/k2js/out/production/examplesForWebDemo/html5/interactive/template_copy.html b/k2js/out/production/examplesForWebDemo/html5/interactive/template_copy.html new file mode 100644 index 00000000000..d3319ca6c00 --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/interactive/template_copy.html @@ -0,0 +1,30 @@ + + + + + + Canvas demo + + + + + + + + + \ No newline at end of file diff --git a/k2js/out/production/examplesForWebDemo/html5/interactive2/jbLogo.png b/k2js/out/production/examplesForWebDemo/html5/interactive2/jbLogo.png new file mode 100644 index 00000000000..759aa8ae05a Binary files /dev/null and b/k2js/out/production/examplesForWebDemo/html5/interactive2/jbLogo.png differ diff --git a/k2js/out/production/examplesForWebDemo/html5/interactive2/main.kt b/k2js/out/production/examplesForWebDemo/html5/interactive2/main.kt new file mode 100644 index 00000000000..e4bacc02865 --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/interactive2/main.kt @@ -0,0 +1,280 @@ +package interactive2; + +import jquery.*; +import html5.*; +import java.util.ArrayList; +import js.*; +import js.Math; +import js.setInterval +import html5.getCanvas +import html5.getKotlinLogo +import jquery.jq +import js.setTimeout + +val gradientGenerator = RadialGradientGenerator(getContext()) +val JB = Logo(v(20.0, 20.0)) + +fun doWithPeriod(period : Int, f : ()->Unit) { + setInterval(f, period); +} + +abstract class Shape() { + abstract fun draw(state : CanvasState); + abstract fun contains(mousePos : Vector) : Boolean; + abstract var pos : Vector; + var selected : Boolean = false; +} + +class Logo(override var pos : Vector, + var relSize : Double = 0.3) + : Shape() +{ + val imageSize = v(704.0, 254.0) + val canvasSize = imageSize * relSize + + override fun draw(state : CanvasState) { + val context = state.context; + context.drawImage(getKotlinLogo(), 0.0, 0.0, imageSize.x, imageSize.y, pos.x, pos.y, canvasSize.x, canvasSize.y) + } + + override fun contains(mousePos: Vector): Boolean = mousePos.isInRect(pos, canvasSize) + + val centre : Vector + get() = pos + canvasSize * 0.5 +} + +class Creature(override var pos : Vector, + var state : CanvasState) : Shape() { + + val shadowOffset = v(-5.0, 5.0) + val colorStops = gradientGenerator.getNext() + val relSize = 0.05; + val radius : Double + get() = state.width * relSize; + + val position : Vector + get() = if (selected) pos - shadowOffset else pos + + val directionToLogo : Vector + get() = (JB.centre - position).normalized + + override fun contains(mousePos : Vector) = pos.distanceTo(mousePos) < radius; + + fun Context.fillCircle(position : Vector, rad : Double) { + beginPath(); + arc(position.x, position.y, rad, 0.0, 2 * Math.PI, false); + closePath(); + fill() + } + + override fun draw(state : CanvasState) { + val context = state.context; + if (!selected) { + drawCreature(context) + } else { + drawCreatureWithShadow(context) + } + } + + fun drawCreature(context : Context) { + context.fillStyle = getGradient(context); + context.fillCircle(position, radius) + drawEye(context) + drawTail(context) + } + + fun getGradient(context : Context) : CanvasGradient { + val gradientCentre = position + directionToLogo * (radius / 4) + val gradient = context.createRadialGradient(gradientCentre.x, gradientCentre.y, 1.0, gradientCentre.x, gradientCentre.y, 2 * radius) + for (colorStop in colorStops) { + gradient.addColorStop(colorStop._1, colorStop._2) + } + return gradient; + } + + fun drawTail(context : Context) { + val tailDirection = -directionToLogo; + val tailPos = position + tailDirection * radius * 0.7 + val tailSize = radius * 1.6 + val angle = Math.PI / 6.0; + val p1 = tailPos + tailDirection.rotatedBy(angle) * tailSize + val p2 = tailPos + tailDirection.rotatedBy(-angle) * tailSize + context.fillStyle = getGradient(context) + context.beginPath() + context.moveTo(tailPos.x, tailPos.y) + context.lineTo(p1.x, p1.y) + val middlePoint = position + tailDirection * radius * 1.0 + context.quadraticCurveTo(middlePoint.x, middlePoint.y, p2.x, p2.y) + context.lineTo(tailPos.x, tailPos.y) + context.closePath() + context.fill() + } + + fun drawEye(context : Context) {; + val eyePos = directionToLogo * radius * 0.6 + position; + val eyeRadius = radius / 3; + val eyeLidRadius = eyeRadius / 2; + context.fillStyle = "#FFFFFF"; + context.fillCircle(eyePos, eyeRadius) + context.fillStyle = "#000000" + context.fillCircle(eyePos, eyeLidRadius) + } + + fun drawCreatureWithShadow(context : Context) { + context.save() + setShadow(context) + context.fillStyle = getGradient(context) + context.fillCircle(position, radius) + context.restore(); + drawEye(context) + drawTail(context) + } + + fun setShadow(context : Context) { + context.shadowColor = "rgba(100, 100, 100, 0.7)"; + context.shadowBlur = 5.0; + context.shadowOffsetX = shadowOffset.x; + context.shadowOffsetY = shadowOffset.y; + } +} + +class CanvasState(val canvas : Canvas) { + val width = canvas.width; + val height = canvas.height; + val context = getContext(); + var valid = false; + var shapes = ArrayList(); + var selection : Shape? = null; + var dragOff = Vector(); + val interval = 1000 / 30; + + { + jq(canvas).mousedown { + valid = false; + selection = null; + val mousePos = mousePos(it); + for (shape in shapes) { + if (mousePos in shape) { + dragOff = mousePos - shape.pos; + shape.selected = true; + selection = shape; + break; + } + } + } + + jq(canvas).mousemove { + if (selection != null) { + selection.sure().pos = mousePos(it) - dragOff; + valid = false; + } + } + + jq(canvas).mouseup { + if (selection != null) { + selection.sure().selected = false; + } + selection = null; + valid = false; + } + + jq(canvas).dblclick { + val redTransparentCircle = Creature(mousePos(it), this @CanvasState); + addShape(redTransparentCircle); + valid = false; + } + + doWithPeriod(interval) { + draw(); + } + } + + fun mousePos(e : MouseEvent) : Vector { + var offset = Vector(); + var element : DomElement? = canvas; + while (element != null) { + val el : DomElement = element.sure(); + offset += Vector(el.offsetLeft, el.offsetTop); + element = el.offsetParent; + } + return Vector(e.pageX, e.pageY) - offset; + } + + fun addShape(shape : Shape) { + shapes.add(shape); + valid = false; + } + + fun clear() { + context.fillStyle = "#FFFFFF" + context.fillRect(0.0, 0.0, width, height) + context.strokeStyle = "#000000" + context.lineWidth = 4.0; + context.strokeRect(0.0, 0.0, width, height) + } + + fun draw() { + if (valid) return + + clear(); + for (shape in shapes) { + shape.draw(this); + } + valid = true; + } +} + +class RadialGradientGenerator(val context : Context) { + val gradients = ArrayList>(); + var current = 0 + + fun newColorStops(vararg colorStops : #(Double, String)) { + gradients.add(colorStops) + } + + { + newColorStops(#(0.0, "#F59898"), #(0.5, "#F57373"), #(1.0, "#DB6B6B")) + newColorStops(#(0.39, "rgb(140,167,209)"), #(0.7, "rgb(104,139,209)"), #(0.85, "rgb(67,122,217)")) + newColorStops(#(0.0, "rgb(255,222,255)"), #(0.5, "rgb(255,185,222)"), #(1.0, "rgb(230,154,185)")) + newColorStops(#(0.0, "rgb(255,209,114)"), #(0.5, "rgb(255,174,81)"), #(1.0, "rgb(241,145,54)")) + newColorStops(#(0.0, "rgb(132,240,135)"), #(0.5, "rgb(91,240,96)"), #(1.0, "rgb(27,245,41)")) + newColorStops(#(0.0, "rgb(250,147,250)"), #(0.5, "rgb(255,80,255)"), #(1.0, "rgb(250,0,217)")) +} + + fun getNext() : Array<#(Double, String)> { + val result = gradients.get(current) + current = (current + 1) % gradients.size() + return result + } +} + +fun v(x : Double, y : Double) = Vector(x, y); + +class Vector(val x : Double = 0.0, val y : Double = 0.0) { + fun plus(v : Vector) = v(x + v.x, y + v.y); + fun minus() = v(-x, -y) + fun minus(v : Vector) = v(x - v.x, y - v.y) + fun times(coef : Double) = v(x * coef, y * coef) + fun distanceTo(v : Vector) = Math.sqrt((this - v).sqr) + fun rotatedBy(theta : Double) : Vector { + val sin = Math.sin(theta) + val cos = Math.cos(theta) + return v(x * cos - y * sin, x * sin + y * cos) + } + + fun isInRect(topLeft : Vector, size : Vector) = (x >= topLeft.x) && (x <= topLeft.x + size.x) && + (y >= topLeft.y) && (y <= topLeft.y + size.y) + + val sqr : Double + get() = x * x + y * y + val normalized : Vector + get() = this * (1.0 / Math.sqrt(sqr)) +} + +fun main() { + val state = CanvasState(getCanvas()); + state.addShape(JB); + setTimeout({ + state.valid = false + }) +} \ No newline at end of file diff --git a/k2js/out/production/examplesForWebDemo/html5/interactive2/template.html b/k2js/out/production/examplesForWebDemo/html5/interactive2/template.html new file mode 100644 index 00000000000..f7399d7ee00 --- /dev/null +++ b/k2js/out/production/examplesForWebDemo/html5/interactive2/template.html @@ -0,0 +1,31 @@ + + + + + + Canvas demo + + + + + + + + + + \ No newline at end of file diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade$1.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade$1.class new file mode 100644 index 00000000000..105fe787b6c Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade$1.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade$2.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade$2.class new file mode 100644 index 00000000000..c7c92880287 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade$2.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade$3.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade$3.class new file mode 100644 index 00000000000..dbb559e9a16 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade$3.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade.class new file mode 100644 index 00000000000..c0612986958 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/AnalyzerFacade.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaBridgeConfiguration.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaBridgeConfiguration.class new file mode 100644 index 00000000000..ad0d1b9bd4b Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaBridgeConfiguration.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.class new file mode 100644 index 00000000000..f2fe26edc0c Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaClassOrPackageScope.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaClassOrPackageScope.class new file mode 100644 index 00000000000..b53e735db73 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaClassOrPackageScope.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$1.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$1.class new file mode 100644 index 00000000000..005b926c46d Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$1.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$1GroupingValue.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$1GroupingValue.class new file mode 100644 index 00000000000..3b3526f66f0 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$1GroupingValue.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$2.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$2.class new file mode 100644 index 00000000000..2d958903ae0 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$2.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$3.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$3.class new file mode 100644 index 00000000000..cf66beeb7f9 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$3.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$4$1.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$4$1.class new file mode 100644 index 00000000000..7b2a6e148be Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$4$1.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$4.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$4.class new file mode 100644 index 00000000000..c45e2795e42 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$4.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$5$1.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$5$1.class new file mode 100644 index 00000000000..b18cb919a88 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$5$1.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$5$2.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$5$2.class new file mode 100644 index 00000000000..5d12124d7c1 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$5$2.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$5.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$5.class new file mode 100644 index 00000000000..a132b9ac63b Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$5.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$6.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$6.class new file mode 100644 index 00000000000..b2158308f92 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$6.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$7$1.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$7$1.class new file mode 100644 index 00000000000..962189cc166 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$7$1.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$7.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$7.class new file mode 100644 index 00000000000..2cc4b84cc9b Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$7.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JetSignatureTypeParameterVisitor$1.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JetSignatureTypeParameterVisitor$1.class new file mode 100644 index 00000000000..5c1f71999e4 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JetSignatureTypeParameterVisitor$1.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JetSignatureTypeParameterVisitor$2.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JetSignatureTypeParameterVisitor$2.class new file mode 100644 index 00000000000..cca86d5fcbb Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JetSignatureTypeParameterVisitor$2.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JetSignatureTypeParameterVisitor.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JetSignatureTypeParameterVisitor.class new file mode 100644 index 00000000000..cc10ba7f643 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JetSignatureTypeParameterVisitor.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JvmMethodParameterKind.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JvmMethodParameterKind.class new file mode 100644 index 00000000000..a0372e84b84 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JvmMethodParameterKind.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JvmMethodParameterMeaning.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JvmMethodParameterMeaning.class new file mode 100644 index 00000000000..90abdef0a39 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$JvmMethodParameterMeaning.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverBinaryClassData.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverBinaryClassData.class new file mode 100644 index 00000000000..b69dfdedbb0 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverBinaryClassData.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverClassData.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverClassData.class new file mode 100644 index 00000000000..d6533391ea5 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverClassData.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverNamespaceData.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverNamespaceData.class new file mode 100644 index 00000000000..86ee3453747 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverNamespaceData.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverScopeData.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverScopeData.class new file mode 100644 index 00000000000..bb7ed66bb09 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverScopeData.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverSrcClassData.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverSrcClassData.class new file mode 100644 index 00000000000..77548e3565c Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ResolverSrcClassData.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$TypeParameterDescriptorInitialization.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$TypeParameterDescriptorInitialization.class new file mode 100644 index 00000000000..e03400b06d5 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$TypeParameterDescriptorInitialization.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$TypeParameterDescriptorOrigin.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$TypeParameterDescriptorOrigin.class new file mode 100644 index 00000000000..ead9200bdcc Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$TypeParameterDescriptorOrigin.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ValueParameterDescriptors.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ValueParameterDescriptors.class new file mode 100644 index 00000000000..1456e888b71 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver$ValueParameterDescriptors.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.class new file mode 100644 index 00000000000..1f97e7f1606 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper$1.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper$1.class new file mode 100644 index 00000000000..0daec696c8e Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper$1.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper$Builder.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper$Builder.class new file mode 100644 index 00000000000..f859c1b762f Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper$Builder.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper.class new file mode 100644 index 00000000000..c95ebb3b616 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaNamespaceDescriptor.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaNamespaceDescriptor.class new file mode 100644 index 00000000000..aa3a91a44b2 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaNamespaceDescriptor.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.class new file mode 100644 index 00000000000..2c46decd378 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaSemanticServices.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaSemanticServices.class new file mode 100644 index 00000000000..04390c35eed Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaSemanticServices.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer$1.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer$1.class new file mode 100644 index 00000000000..138b4c9917f Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer$1.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer$2.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer$2.class new file mode 100644 index 00000000000..94b85103e24 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer$2.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer$3.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer$3.class new file mode 100644 index 00000000000..4c3be1e48bc Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer$3.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.class new file mode 100644 index 00000000000..9dd87cd8c85 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetJavaMirrorMarker.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetJavaMirrorMarker.class new file mode 100644 index 00000000000..dd04962f535 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetJavaMirrorMarker.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetSignatureUtils.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetSignatureUtils.class new file mode 100644 index 00000000000..0f96197eee7 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetSignatureUtils.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader$1.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader$1.class new file mode 100644 index 00000000000..deae9e68143 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader$1.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader$2.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader$2.class new file mode 100644 index 00000000000..2a05b904457 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader$2.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader$3.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader$3.class new file mode 100644 index 00000000000..1e5a3b7a5da Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader$3.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader.class new file mode 100644 index 00000000000..99072f15b14 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmAbi.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmAbi.class new file mode 100644 index 00000000000..addf271b2d2 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmAbi.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmClassName.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmClassName.class new file mode 100644 index 00000000000..bf0e9ea87a3 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmClassName.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmPrimitiveType$MapByAsmTypeHolder.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmPrimitiveType$MapByAsmTypeHolder.class new file mode 100644 index 00000000000..1e8db6cea9e Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmPrimitiveType$MapByAsmTypeHolder.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmPrimitiveType$MapByWrapperAsmTypeHolder.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmPrimitiveType$MapByWrapperAsmTypeHolder.class new file mode 100644 index 00000000000..f5dd3173474 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmPrimitiveType$MapByWrapperAsmTypeHolder.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmPrimitiveType.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmPrimitiveType.class new file mode 100644 index 00000000000..915a2b8e9c7 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmPrimitiveType.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmStdlibNames.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmStdlibNames.class new file mode 100644 index 00000000000..fb9d2bc6cc7 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/JvmStdlibNames.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/NamedMembers.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/NamedMembers.class new file mode 100644 index 00000000000..df278f24f55 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/NamedMembers.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PropertyAccessorData.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PropertyAccessorData.class new file mode 100644 index 00000000000..5ac3763aed6 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PropertyAccessorData.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiClassWrapper.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiClassWrapper.class new file mode 100644 index 00000000000..3476245b2d9 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiClassWrapper.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiFieldWrapper.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiFieldWrapper.class new file mode 100644 index 00000000000..dca2aa518ab Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiFieldWrapper.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiMemberWrapper.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiMemberWrapper.class new file mode 100644 index 00000000000..de77533d633 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiMemberWrapper.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiMethodWrapper.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiMethodWrapper.class new file mode 100644 index 00000000000..d8574080949 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiMethodWrapper.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiParameterWrapper.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiParameterWrapper.class new file mode 100644 index 00000000000..e9713dd04da Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/PsiParameterWrapper.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeSource.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeSource.class new file mode 100644 index 00000000000..9b59708ab5e Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeSource.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolver.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolver.class new file mode 100644 index 00000000000..67f4a8f32fc Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolver.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolverFromOuters.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolverFromOuters.class new file mode 100644 index 00000000000..d2c58a30947 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolverFromOuters.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolverFromTypeDescriptors.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolverFromTypeDescriptors.class new file mode 100644 index 00000000000..5f7e502bded Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolverFromTypeDescriptors.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolvers.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolvers.class new file mode 100644 index 00000000000..74af84f3344 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/TypeVariableResolvers.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/alt/AltClassFinder.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/alt/AltClassFinder.class new file mode 100644 index 00000000000..1bdc1829963 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/alt/AltClassFinder.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetClassAnnotation.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetClassAnnotation.class new file mode 100644 index 00000000000..82d6dc0f5d5 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetClassAnnotation.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetConstructorAnnotation.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetConstructorAnnotation.class new file mode 100644 index 00000000000..d201de9055a Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetConstructorAnnotation.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetMethodAnnotation.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetMethodAnnotation.class new file mode 100644 index 00000000000..6c931b4ad56 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetMethodAnnotation.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetTypeParameterAnnotation.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetTypeParameterAnnotation.class new file mode 100644 index 00000000000..7edb588d6dd Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetTypeParameterAnnotation.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetValueParameterAnnotation.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetValueParameterAnnotation.class new file mode 100644 index 00000000000..022d1ad61a7 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/JetValueParameterAnnotation.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/PsiAnnotationUtils.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/PsiAnnotationUtils.class new file mode 100644 index 00000000000..f5ba0a12e93 Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/PsiAnnotationUtils.class differ diff --git a/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/PsiAnnotationWrapper.class b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/PsiAnnotationWrapper.class new file mode 100644 index 00000000000..5b62e8d97ee Binary files /dev/null and b/k2js/out/production/frontend.java/org/jetbrains/jet/lang/resolve/java/kt/PsiAnnotationWrapper.class differ diff --git a/k2js/out/production/frontend/jet/Arrays.jet b/k2js/out/production/frontend/jet/Arrays.jet new file mode 100644 index 00000000000..be3608b03ef --- /dev/null +++ b/k2js/out/production/frontend/jet/Arrays.jet @@ -0,0 +1,84 @@ +package jet + +fun Array(val size : Int) : Array + +class Array(val size : Int, init : (Int) -> T) { + 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() : ByteIterator + + val indices : IntRange +} + +class ShortArray(val size : Int) { + fun get(index : Int) : Short + fun set(index : Int, value : Short) : Unit + + fun iterator() : ShortIterator + + val indices : IntRange +} + +class IntArray(val size : Int) { + fun get(index : Int) : Int + fun set(index : Int, value : Int) : Unit + + fun iterator() : IntIterator + + val indices : IntRange +} + +class LongArray(val size : Int) { + fun get(index : Int) : Long + fun set(index : Int, value : Long) : Unit + + fun iterator() : LongIterator + + val indices : IntRange +} + +class FloatArray(val size : Int) { + fun get(index : Int) : Float + fun set(index : Int, value : Float) : Unit + + fun iterator() : FloatIterator + + val indices : IntRange +} + +class DoubleArray(val size : Int) { + fun get(index : Int) : Double + fun set(index : Int, value : Double) : Unit + + fun iterator() : DoubleIterator + + val indices : IntRange +} + +class CharArray(val size : Int) { + fun get(index : Int) : Char + fun set(index : Int, value : Char) : Unit + + fun iterator() : CharIterator + + val indices : IntRange +} + +class BooleanArray(val size : Int) { + fun get(index : Int) : Boolean + fun set(index : Int, value : Boolean) : Unit + + fun iterator() : BooleanIterator + + val indices : IntRange +} diff --git a/k2js/out/production/frontend/jet/Iterables.jet b/k2js/out/production/frontend/jet/Iterables.jet new file mode 100644 index 00000000000..900ed28a17b --- /dev/null +++ b/k2js/out/production/frontend/jet/Iterables.jet @@ -0,0 +1,37 @@ +package jet + +trait Iterable { + fun iterator() : Iterator +} + +trait ByteIterable : Iterable { + override fun iterator() : ByteIterator +} + +trait ShortIterable : Iterable { + override fun iterator() : ShortIterator +} + +trait IntIterable : Iterable { + override fun iterator() : IntIterator +} + +trait LongIterable : Iterable { + override fun iterator() : LongIterator +} + +trait FloatIterable : Iterable { + override fun iterator() : FloatIterator +} + +trait DoubleIterable : Iterable { + override fun iterator() : DoubleIterator +} + +trait BooleanIterable : Iterable { + override fun iterator() : BooleanIterator +} + +trait CharIterable : Iterable { + override fun iterator() : CharIterator +} diff --git a/k2js/out/production/frontend/jet/Iterators.jet b/k2js/out/production/frontend/jet/Iterators.jet new file mode 100644 index 00000000000..d96b8e3bad6 --- /dev/null +++ b/k2js/out/production/frontend/jet/Iterators.jet @@ -0,0 +1,73 @@ +package.jet + +trait Iterator { + fun next() : T + val hasNext : Boolean +} + +abstract open class ByteIterator() : Iterator { + abstract open fun nextByte() : Byte + + override fun next() : Byte +} + +abstract open class ShortIterator() : Iterator { + abstract open fun nextShort() : Short + + override fun next() : Short +} + +abstract open class CharIterator() : Iterator { + abstract open fun nextChar() : Char + + override fun next() : Char +} + +abstract open class IntIterator() : Iterator { + abstract open fun nextInt() : Int + + override fun next() : Int +} + +abstract open class LongIterator() : Iterator { + abstract open fun nextLong() : Long + + override fun next() : Long +} + +abstract open class FloatIterator() : Iterator { + abstract open fun nextFloat() : Float + + override fun next() : Float +} + +abstract open class DoubleIterator() : Iterator { + abstract open fun nextDouble() : Double + + override fun next() : Double +} + +abstract open class BooleanIterator() : Iterator { + abstract open fun nextBoolean() : Boolean + + override fun next() : Boolean +} + +fun Iterator.iterator() : Iterator + +fun ByteIterator.iterator() : ByteIterator + +fun ShortIterator.iterator() : ShortIterator + +fun CharIterator.iterator() : CharIterator + +fun IntIterator.iterator() : IntIterator + +fun BooleanIterator.iterator() : BooleanIterator + +fun DoubleIterator.iterator() : DoubleIterator + +fun FloatIterator.iterator() : FloatIterator + +fun LongIterator.iterator() : LongIterator + diff --git a/k2js/out/production/frontend/jet/Library.jet b/k2js/out/production/frontend/jet/Library.jet new file mode 100644 index 00000000000..6d15cfc9d09 --- /dev/null +++ b/k2js/out/production/frontend/jet/Library.jet @@ -0,0 +1,61 @@ +package jet + +class TypeInfo { + fun isSubtypeOf(other : TypeInfo<*>) : Boolean + fun isInstance(obj : Any?) : Boolean +} + +fun typeinfo() : TypeInfo +fun typeinfo(expression : T) : TypeInfo + +annotation class volatile +annotation class atomic + +fun synchronized(lock: Any, block : () -> R) : R + +fun Any?.identityEquals(other : Any?) : Boolean // = this === other + +// 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 T?.sure() : T + +fun String?.plus(other: Any?) : String + +trait Comparable { + fun compareTo(other : T) : Int +} + +trait Hashable { + fun hashCode() : Int + fun equals(other : Any?) : Boolean +} + +class Boolean : Comparable { + fun not() : Boolean + + fun and(other : Boolean) : Boolean + + fun or(other : Boolean) : Boolean + + fun xor(other : Boolean) : Boolean + + fun equals(other : Any?) : Boolean +} + +trait CharSequence { + fun get(index : Int) : Char + + val length : Int + + fun toString() : String +} + +class String() : Comparable, CharSequence { + fun plus(other : Any?) : String + + fun equals(other : Any?) : Boolean +} diff --git a/k2js/out/production/frontend/jet/Numbers.jet b/k2js/out/production/frontend/jet/Numbers.jet new file mode 100644 index 00000000000..719bcf2ea52 --- /dev/null +++ b/k2js/out/production/frontend/jet/Numbers.jet @@ -0,0 +1,586 @@ +package jet + +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) : DoubleRange + fun rangeTo(other : Float) : DoubleRange + fun rangeTo(other : Long) : DoubleRange + fun rangeTo(other : Int) : DoubleRange + fun rangeTo(other : Short) : DoubleRange + fun rangeTo(other : Byte) : DoubleRange + fun rangeTo(other : Char) : DoubleRange + + fun upto(other : Double) : DoubleRange + fun upto(other : Float) : DoubleRange + fun upto(other : Long) : DoubleRange + fun upto(other : Int) : DoubleRange + fun upto(other : Short) : DoubleRange + fun upto(other : Byte) : DoubleRange + fun upto(other : Char) : DoubleRange + + fun downto(other : Double) : DoubleRange + fun downto(other : Float) : DoubleRange + fun downto(other : Long) : DoubleRange + fun downto(other : Int) : DoubleRange + fun downto(other : Short) : DoubleRange + fun downto(other : Byte) : DoubleRange + fun downto(other : Char) : DoubleRange + + 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) : DoubleRange + fun rangeTo(other : Float) : FloatRange + fun rangeTo(other : Long) : DoubleRange + fun rangeTo(other : Int) : FloatRange + fun rangeTo(other : Short) : FloatRange + fun rangeTo(other : Byte) : FloatRange + fun rangeTo(other : Char) : FloatRange + + fun upto(other : Double) : DoubleRange + fun upto(other : Float) : FloatRange + fun upto(other : Long) : DoubleRange + fun upto(other : Int) : FloatRange + fun upto(other : Short) : FloatRange + fun upto(other : Byte) : FloatRange + fun upto(other : Char) : FloatRange + + fun downto(other : Double) : DoubleRange + fun downto(other : Float) : FloatRange + fun downto(other : Long) : DoubleRange + fun downto(other : Int) : FloatRange + fun downto(other : Short) : FloatRange + fun downto(other : Byte) : FloatRange + fun downto(other : Char) : FloatRange + + 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) : DoubleRange + fun rangeTo(other : Float) : FloatRange + 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 upto(other : Double) : DoubleRange + fun upto(other : Float) : FloatRange + fun upto(other : Long) : LongRange + fun upto(other : Int) : LongRange + fun upto(other : Short) : LongRange + fun upto(other : Byte) : LongRange + fun upto(other : Char) : LongRange + + fun downto(other : Double) : DoubleRange + fun downto(other : Float) : FloatRange + fun downto(other : Long) : LongRange + fun downto(other : Int) : LongRange + fun downto(other : Short) : LongRange + fun downto(other : Byte) : LongRange + fun downto(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) : DoubleRange + fun rangeTo(other : Float) : FloatRange + 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 upto(other : Double) : DoubleRange + fun upto(other : Float) : FloatRange + fun upto(other : Long) : LongRange + fun upto(other : Int) : IntRange + fun upto(other : Short) : IntRange + fun upto(other : Byte) : IntRange + fun upto(other : Char) : IntRange + + fun downto(other : Double) : DoubleRange + fun downto(other : Float) : FloatRange + fun downto(other : Long) : LongRange + fun downto(other : Int) : IntRange + fun downto(other : Short) : IntRange + fun downto(other : Byte) : IntRange + fun downto(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) : DoubleRange + fun rangeTo(other : Float) : FloatRange + fun rangeTo(other : Long) : LongRange + fun rangeTo(other : Int) : IntRange + fun rangeTo(other : Short) : ShortRange + fun rangeTo(other : Byte) : CharRange + fun rangeTo(other : Char) : CharRange + + fun upto(other : Double) : DoubleRange + fun upto(other : Float) : FloatRange + fun upto(other : Long) : LongRange + fun upto(other : Int) : IntRange + fun upto(other : Short) : ShortRange + fun upto(other : Byte) : CharRange + fun upto(other : Char) : CharRange + + fun downto(other : Double) : DoubleRange + fun downto(other : Float) : FloatRange + fun downto(other : Long) : LongRange + fun downto(other : Int) : IntRange + fun downto(other : Short) : ShortRange + fun downto(other : Byte) : CharRange + fun downto(other : Char) : CharRange + + 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) : DoubleRange + fun rangeTo(other : Float) : FloatRange + fun rangeTo(other : Long) : LongRange + fun rangeTo(other : Int) : IntRange + fun rangeTo(other : Short) : ShortRange + fun rangeTo(other : Byte) : ShortRange + fun rangeTo(other : Char) : ShortRange + + fun upto(other : Double) : DoubleRange + fun upto(other : Float) : FloatRange + fun upto(other : Long) : LongRange + fun upto(other : Int) : IntRange + fun upto(other : Short) : ShortRange + fun upto(other : Byte) : ShortRange + fun upto(other : Char) : ShortRange + + fun downto(other : Double) : DoubleRange + fun downto(other : Float) : FloatRange + fun downto(other : Long) : LongRange + fun downto(other : Int) : IntRange + fun downto(other : Short) : ShortRange + fun downto(other : Byte) : ShortRange + fun downto(other : Char) : ShortRange + + fun inc() : Short + fun dec() : Short + fun plus() : Short + fun minus() : Short +} + +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) : DoubleRange + fun rangeTo(other : Float) : FloatRange + fun rangeTo(other : Long) : LongRange + fun rangeTo(other : Int) : IntRange + fun rangeTo(other : Short) : ShortRange + fun rangeTo(other : Byte) : ByteRange + fun rangeTo(other : Char) : CharRange + + fun upto(other : Double) : DoubleRange + fun upto(other : Float) : FloatRange + fun upto(other : Long) : LongRange + fun upto(other : Int) : IntRange + fun upto(other : Short) : ShortRange + fun upto(other : Byte) : ByteRange + fun upto(other : Char) : CharRange + + fun downto(other : Double) : DoubleRange + fun downto(other : Float) : FloatRange + fun downto(other : Long) : LongRange + fun downto(other : Int) : IntRange + fun downto(other : Short) : ShortRange + fun downto(other : Byte) : ByteRange + fun downto(other : Char) : CharRange + + fun inc() : Byte + fun dec() : Byte + fun plus() : Byte + fun minus() : Byte +} \ No newline at end of file diff --git a/k2js/out/production/frontend/jet/Ranges.jet b/k2js/out/production/frontend/jet/Ranges.jet new file mode 100644 index 00000000000..2426900bf78 --- /dev/null +++ b/k2js/out/production/frontend/jet/Ranges.jet @@ -0,0 +1,109 @@ +package jet + +trait Range> { + fun contains(item : T) : Boolean +} + +class IntRange(val start : Int, val size : Int) : Range, IntIterable { + fun iterator () : IntIterator + + fun contains (elem: Int) : Boolean + + val end : Int + + val iteratorStart : Int + + fun minus() : IntRange + + fun step(step: Int) : IntIterator + + val isReversed : Boolean +} + +class LongRange(val start : Long, val size : Long) : Range, LongIterable { + fun iterator () : LongIterator + + fun contains (elem: Long) : Boolean + + val iteratorStart : Long + + val end : Long + + fun minus() : LongRange + + fun step(step: Long) : LongIterator + + val isReversed : Boolean +} + +class ByteRange(val start : Byte, val size : Int) : Range, ByteIterable { + fun iterator () : ByteIterator + + fun contains (elem: Byte) : Boolean + + val end : Byte + + val iteratorStart : Byte + + fun minus() : ByteRange + + fun step(step: Int) : ByteIterator + + val isReversed : Boolean +} + +class ShortRange(val start : Short, val size : Int) : Range, ShortIterable { + fun iterator () : ShortIterator + + fun contains (elem: Byte) : Boolean + + val iteratorStart : Short + + val end : Short + + fun minus() : ShortRange + + fun step(step: Int) : ShortIterator + + val isReversed : Boolean +} + +class CharRange(val start : Char, val size : Int) : Range, CharIterable { + fun iterator () : CharIterator + + fun contains (elem: Char) : Boolean + + val iteratorStart : Char + + val end : Char + + fun minus() : CharRange + + fun step(step: Int) : CharIterator + + val isReversed : Boolean +} + +class FloatRange(val start : Float, val size : Float) : Range { + fun contains (elem: Float) : Boolean + + val end : Float + + fun minus() : FloatRange + + fun step(step: Float) : FloatIterator + + val isReversed : Boolean +} + +class DoubleRange(val start : Double, val size : Double) : Range { + fun contains (elem: Double) : Boolean + + val end : Double + + fun minus() : DoubleRange + + fun step(step: Double) : DoubleIterator + + val isReversed : Boolean +} diff --git a/k2js/out/production/frontend/org/jetbrains/jet/JetNodeType.class b/k2js/out/production/frontend/org/jetbrains/jet/JetNodeType.class new file mode 100644 index 00000000000..441961cbe76 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/JetNodeType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/JetNodeTypes.class b/k2js/out/production/frontend/org/jetbrains/jet/JetNodeTypes.class new file mode 100644 index 00000000000..47ea6ccb58f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/JetNodeTypes.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$1.class b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$1.class new file mode 100644 index 00000000000..a50f8459484 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$2.class b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$2.class new file mode 100644 index 00000000000..79356c8d5ac Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$DiagnosedRange.class b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$DiagnosedRange.class new file mode 100644 index 00000000000..c275931edbb Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$DiagnosedRange.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$DiagnosticDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$DiagnosticDescriptor.class new file mode 100644 index 00000000000..1b2273e634b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$DiagnosticDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$DiagnosticDiffCallbacks.class b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$DiagnosticDiffCallbacks.class new file mode 100644 index 00000000000..9eedf7f4631 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$DiagnosticDiffCallbacks.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$SyntaxErrorDiagnostic.class b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$SyntaxErrorDiagnostic.class new file mode 100644 index 00000000000..6985743bc1b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$SyntaxErrorDiagnostic.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$SyntaxErrorDiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$SyntaxErrorDiagnosticFactory.class new file mode 100644 index 00000000000..d12b7e57a04 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil$SyntaxErrorDiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil.class b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil.class new file mode 100644 index 00000000000..ca05ae6ce62 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/checkers/CheckerTestUtil.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/Configuration$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/Configuration$1.class new file mode 100644 index 00000000000..fb5ba788b34 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/Configuration$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/Configuration.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/Configuration.class new file mode 100644 index 00000000000..b54d750a6f1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/Configuration.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/JetSemanticServices.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/JetSemanticServices.class new file mode 100644 index 00000000000..1e6ccc540fc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/JetSemanticServices.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/StandardConfiguration.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/StandardConfiguration.class new file mode 100644 index 00000000000..2bea3366203 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/StandardConfiguration.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/BlockInfo.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/BlockInfo.class new file mode 100644 index 00000000000..8adca3ba009 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/BlockInfo.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/BreakableBlockInfo.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/BreakableBlockInfo.class new file mode 100644 index 00000000000..d0805e6d9bf Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/BreakableBlockInfo.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/GenerationTrigger.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/GenerationTrigger.class new file mode 100644 index 00000000000..de475f9bb0e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/GenerationTrigger.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.class new file mode 100644 index 00000000000..6790cba4ed8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.class new file mode 100644 index 00000000000..712dab40ee2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser$InstructionDataAnalyzeStrategy.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser$InstructionDataAnalyzeStrategy.class new file mode 100644 index 00000000000..af3d25b7f87 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser$InstructionDataAnalyzeStrategy.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser$InstructionDataMergeStrategy.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser$InstructionDataMergeStrategy.class new file mode 100644 index 00000000000..0651c0732af Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser$InstructionDataMergeStrategy.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser.class new file mode 100644 index 00000000000..a87f4230f19 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$1.class new file mode 100644 index 00000000000..90be101e433 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor$1.class new file mode 100644 index 00000000000..f6927bd8aea Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor$2.class new file mode 100644 index 00000000000..7c399f9ba8c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor$3.class new file mode 100644 index 00000000000..c762df3436d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor.class new file mode 100644 index 00000000000..aae041ba08f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor$CFPVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.class new file mode 100644 index 00000000000..e498a964bf7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$1.class new file mode 100644 index 00000000000..87eeccbf604 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$10.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$10.class new file mode 100644 index 00000000000..ba856584de3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$10.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$11.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$11.class new file mode 100644 index 00000000000..bbccb0d42ac Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$11.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$12.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$12.class new file mode 100644 index 00000000000..ca4275fd8c7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$12.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$2.class new file mode 100644 index 00000000000..e12b4f2e3ac Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$3.class new file mode 100644 index 00000000000..b84a3fe2cce Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$4.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$4.class new file mode 100644 index 00000000000..89940ab6001 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$4.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$5.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$5.class new file mode 100644 index 00000000000..3600462081a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$5.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$6.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$6.class new file mode 100644 index 00000000000..af783720dcd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$6.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$7.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$7.class new file mode 100644 index 00000000000..398902a282b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$7.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$8.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$8.class new file mode 100644 index 00000000000..ab17225e2ca Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$8.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$9.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$9.class new file mode 100644 index 00000000000..b479b5c3ae7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$9.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$VariableInitializers.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$VariableInitializers.class new file mode 100644 index 00000000000..dce1b31d67e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$VariableInitializers.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$VariableStatus.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$VariableStatus.class new file mode 100644 index 00000000000..cb36600c529 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider$VariableStatus.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.class new file mode 100644 index 00000000000..62df65d8225 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/Label.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/Label.class new file mode 100644 index 00000000000..a20ab42e4b5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/Label.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/LoopInfo.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/LoopInfo.class new file mode 100644 index 00000000000..8b1529d76cc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/LoopInfo.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/WhenChecker.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/WhenChecker.class new file mode 100644 index 00000000000..b48b5e9a03a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/WhenChecker.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/AbstractJumpInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/AbstractJumpInstruction.class new file mode 100644 index 00000000000..054916098e0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/AbstractJumpInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ConditionalJumpInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ConditionalJumpInstruction.class new file mode 100644 index 00000000000..a87949fa968 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ConditionalJumpInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Instruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Instruction.class new file mode 100644 index 00000000000..6a14eb49ee2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Instruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/InstructionImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/InstructionImpl.class new file mode 100644 index 00000000000..f1978d1cafc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/InstructionImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.class new file mode 100644 index 00000000000..68f2bf3bfda Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.class new file mode 100644 index 00000000000..bf58be40cf2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowDataTraceFactory$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowDataTraceFactory$1.class new file mode 100644 index 00000000000..56ece0c3fd1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowDataTraceFactory$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowDataTraceFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowDataTraceFactory.class new file mode 100644 index 00000000000..4f8ad115efb Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowDataTraceFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator$1.class new file mode 100644 index 00000000000..6de521549ac Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator$JetControlFlowInstructionsGeneratorWorker.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator$JetControlFlowInstructionsGeneratorWorker.class new file mode 100644 index 00000000000..3887707eae6 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator$JetControlFlowInstructionsGeneratorWorker.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator$TryFinallyBlockInfo.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator$TryFinallyBlockInfo.class new file mode 100644 index 00000000000..2e9a8e64cc2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator$TryFinallyBlockInfo.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.class new file mode 100644 index 00000000000..7ff0d2dd269 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstruction.class new file mode 100644 index 00000000000..322e1656c02 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstructionImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstructionImpl.class new file mode 100644 index 00000000000..14edffaa28b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstructionImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetPseudocodeTrace$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetPseudocodeTrace$1.class new file mode 100644 index 00000000000..60f1da6b34b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetPseudocodeTrace$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetPseudocodeTrace.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetPseudocodeTrace.class new file mode 100644 index 00000000000..211a73e7126 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/JetPseudocodeTrace.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/LocalDeclarationInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/LocalDeclarationInstruction.class new file mode 100644 index 00000000000..201bc7e9628 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/LocalDeclarationInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/NondeterministicJumpInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/NondeterministicJumpInstruction.class new file mode 100644 index 00000000000..4fd78533bec Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/NondeterministicJumpInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode$1.class new file mode 100644 index 00000000000..c0f9c6d3815 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode$PseudocodeLabel.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode$PseudocodeLabel.class new file mode 100644 index 00000000000..fcab94a3fa5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode$PseudocodeLabel.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode.class new file mode 100644 index 00000000000..27be70a75af Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReadUnitValueInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReadUnitValueInstruction.class new file mode 100644 index 00000000000..32360706ae9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReadUnitValueInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReadValueInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReadValueInstruction.class new file mode 100644 index 00000000000..3d8452fe879 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReadValueInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReturnNoValueInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReturnNoValueInstruction.class new file mode 100644 index 00000000000..2b08b05b4a2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReturnNoValueInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReturnValueInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReturnValueInstruction.class new file mode 100644 index 00000000000..364ced86fad Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/ReturnValueInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/SubroutineEnterInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/SubroutineEnterInstruction.class new file mode 100644 index 00000000000..124b7967eaf Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/SubroutineEnterInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/SubroutineExitInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/SubroutineExitInstruction.class new file mode 100644 index 00000000000..6a660b05323 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/SubroutineExitInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/SubroutineSinkInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/SubroutineSinkInstruction.class new file mode 100644 index 00000000000..8c93d7f716f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/SubroutineSinkInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/UnconditionalJumpInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/UnconditionalJumpInstruction.class new file mode 100644 index 00000000000..4c1aa8ba49d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/UnconditionalJumpInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/UnsupportedElementInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/UnsupportedElementInstruction.class new file mode 100644 index 00000000000..3b33ed4d238 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/UnsupportedElementInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/VariableDeclarationInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/VariableDeclarationInstruction.class new file mode 100644 index 00000000000..75262ef842f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/VariableDeclarationInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/WriteValueInstruction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/WriteValueInstruction.class new file mode 100644 index 00000000000..59c47f66b94 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/cfg/pseudocode/WriteValueInstruction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/AbstractNamespaceDescriptorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/AbstractNamespaceDescriptorImpl.class new file mode 100644 index 00000000000..a98b526c103 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/AbstractNamespaceDescriptorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Annotation.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Annotation.class new file mode 100644 index 00000000000..8acd377f3d9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Annotation.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/CallableDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/CallableDescriptor.class new file mode 100644 index 00000000000..bc6332ab191 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/CallableDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/CallableMemberDescriptor$Kind.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/CallableMemberDescriptor$Kind.class new file mode 100644 index 00000000000..f52dadbd1c4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/CallableMemberDescriptor$Kind.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/CallableMemberDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/CallableMemberDescriptor.class new file mode 100644 index 00000000000..d671ce470b4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/CallableMemberDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassDescriptor.class new file mode 100644 index 00000000000..22c2260e213 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.class new file mode 100644 index 00000000000..dd60027ebbc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassKind.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassKind.class new file mode 100644 index 00000000000..58f74f3d395 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassKind.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassOrNamespaceDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassOrNamespaceDescriptor.class new file mode 100644 index 00000000000..38e843e919c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassOrNamespaceDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassifierDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassifierDescriptor.class new file mode 100644 index 00000000000..673cd0ceaa0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ClassifierDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ConstructorDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ConstructorDescriptor.class new file mode 100644 index 00000000000..1f8088c49ca Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ConstructorDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.class new file mode 100644 index 00000000000..0142dde888d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptor.class new file mode 100644 index 00000000000..33e9461456e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.class new file mode 100644 index 00000000000..ba631eae149 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorVisitor.class new file mode 100644 index 00000000000..880cf3c942d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorWithVisibility.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorWithVisibility.class new file mode 100644 index 00000000000..b69108560da Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorWithVisibility.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ExtensionDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ExtensionDescriptor.class new file mode 100644 index 00000000000..d76e85766b3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ExtensionDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptor.class new file mode 100644 index 00000000000..f5f6bd32932 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.class new file mode 100644 index 00000000000..262c8a74158 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil$1.class new file mode 100644 index 00000000000..530f89d9348 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.class new file mode 100644 index 00000000000..e3c89441bed Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.class new file mode 100644 index 00000000000..6d27eafca74 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/LocalVariableDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/LocalVariableDescriptor.class new file mode 100644 index 00000000000..02d9cc076e7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/LocalVariableDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MemberDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MemberDescriptor.class new file mode 100644 index 00000000000..55980253950 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MemberDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Modality.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Modality.class new file mode 100644 index 00000000000..d6cca985d91 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Modality.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ModuleDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ModuleDescriptor.class new file mode 100644 index 00000000000..4a09a36b4c2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ModuleDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor$1.class new file mode 100644 index 00000000000..518e67a4720 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.class new file mode 100644 index 00000000000..45075d49e9e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.class new file mode 100644 index 00000000000..539397f5ec6 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableDeclarationDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableDeclarationDescriptor.class new file mode 100644 index 00000000000..2bd2be7ba3a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableDeclarationDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableValueParameterDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableValueParameterDescriptor.class new file mode 100644 index 00000000000..341f4edeb92 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/MutableValueParameterDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Named.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Named.class new file mode 100644 index 00000000000..f6c4ff15010 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Named.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamedFunctionDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamedFunctionDescriptor.class new file mode 100644 index 00000000000..b12d6d5c109 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamedFunctionDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamedFunctionDescriptorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamedFunctionDescriptorImpl.class new file mode 100644 index 00000000000..f76ace63206 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamedFunctionDescriptorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceDescriptor.class new file mode 100644 index 00000000000..2059ed094a5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceDescriptorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceDescriptorImpl.class new file mode 100644 index 00000000000..a1e9c5ec121 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceDescriptorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceLike$Adapter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceLike$Adapter.class new file mode 100644 index 00000000000..17831853f6c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceLike$Adapter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceLike$ClassObjectStatus.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceLike$ClassObjectStatus.class new file mode 100644 index 00000000000..a6bc4629de8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceLike$ClassObjectStatus.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceLike.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceLike.class new file mode 100644 index 00000000000..0eb08bbdc2e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/NamespaceLike.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.class new file mode 100644 index 00000000000..1eb00ee9267 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.class new file mode 100644 index 00000000000..a4b83f4915b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.class new file mode 100644 index 00000000000..5c39212e234 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertySetterDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertySetterDescriptor.class new file mode 100644 index 00000000000..e75d96ba5e1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/PropertySetterDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/TypeParameterDescriptor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/TypeParameterDescriptor$1.class new file mode 100644 index 00000000000..a9baed1a21e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/TypeParameterDescriptor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/TypeParameterDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/TypeParameterDescriptor.class new file mode 100644 index 00000000000..36d1714ea64 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/TypeParameterDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ValueParameterDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ValueParameterDescriptor.class new file mode 100644 index 00000000000..a424f94e510 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ValueParameterDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ValueParameterDescriptorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ValueParameterDescriptorImpl.class new file mode 100644 index 00000000000..118c2ed2735 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/ValueParameterDescriptorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/VariableAsFunctionDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/VariableAsFunctionDescriptor.class new file mode 100644 index 00000000000..1d1c72eec32 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/VariableAsFunctionDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/VariableDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/VariableDescriptor.class new file mode 100644 index 00000000000..bda2f38b816 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/VariableDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/VariableDescriptorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/VariableDescriptorImpl.class new file mode 100644 index 00000000000..48d742e2acc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/VariableDescriptorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Visibility.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Visibility.class new file mode 100644 index 00000000000..45bd92f3dcb Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/Visibility.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/Annotated.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/Annotated.class new file mode 100644 index 00000000000..93aed1ba923 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/Annotated.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/AnnotatedImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/AnnotatedImpl.class new file mode 100644 index 00000000000..5b422d22db5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/AnnotatedImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/AnnotationArgumentVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/AnnotationArgumentVisitor.class new file mode 100644 index 00000000000..8c09876a8b6 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/AnnotationArgumentVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/AnnotationDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/AnnotationDescriptor.class new file mode 100644 index 00000000000..1062df6f9a4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/descriptors/annotations/AnnotationDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/AbstractDiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/AbstractDiagnosticFactory.class new file mode 100644 index 00000000000..9101bbc29c3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/AbstractDiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/AmbiguousDescriptorDiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/AmbiguousDescriptorDiagnosticFactory.class new file mode 100644 index 00000000000..f377a609e8a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/AmbiguousDescriptorDiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Diagnostic.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Diagnostic.class new file mode 100644 index 00000000000..a87a3c4f2d2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Diagnostic.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory.class new file mode 100644 index 00000000000..a2143811227 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithMessageFormat.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithMessageFormat.class new file mode 100644 index 00000000000..12fdcba54b0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithMessageFormat.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithPsiElement1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithPsiElement1.class new file mode 100644 index 00000000000..ca7e9c4d751 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithPsiElement1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithPsiElement2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithPsiElement2.class new file mode 100644 index 00000000000..f140d8c3c89 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithPsiElement2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithPsiElement3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithPsiElement3.class new file mode 100644 index 00000000000..0d0029ade2f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithPsiElement3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithSeverity.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithSeverity.class new file mode 100644 index 00000000000..c9b580ab7ff Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithSeverity.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder$1.class new file mode 100644 index 00000000000..4682da2eeb7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder$2.class new file mode 100644 index 00000000000..753c31e7a4f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.class new file mode 100644 index 00000000000..8580c99e0c7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticParameter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticParameter.class new file mode 100644 index 00000000000..6463d345593 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticParameter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticParameterImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticParameterImpl.class new file mode 100644 index 00000000000..025a3ab99a7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticParameterImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticParameters.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticParameters.class new file mode 100644 index 00000000000..dba843045bd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticParameters.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticUtils.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticUtils.class new file mode 100644 index 00000000000..5d8909193b8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticUtils.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameterFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameterFactory.class new file mode 100644 index 00000000000..481fd8e7fc7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameterFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters.class new file mode 100644 index 00000000000..98c8d75c2bd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithPsiElement.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithPsiElement.class new file mode 100644 index 00000000000..0163a2ef918 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithPsiElement.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithPsiElementImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithPsiElementImpl.class new file mode 100644 index 00000000000..c8da99fe0c7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithPsiElementImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithTextRange.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithTextRange.class new file mode 100644 index 00000000000..f6bbf9d31d2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/DiagnosticWithTextRange.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$1.class new file mode 100644 index 00000000000..194b1200421 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$10.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$10.class new file mode 100644 index 00000000000..4ea29d34e24 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$10.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$11.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$11.class new file mode 100644 index 00000000000..6383619fc84 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$11.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$12.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$12.class new file mode 100644 index 00000000000..eac7063b351 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$12.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$13.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$13.class new file mode 100644 index 00000000000..1361e20ec8a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$13.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$14.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$14.class new file mode 100644 index 00000000000..e4880ff6397 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$14.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$15.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$15.class new file mode 100644 index 00000000000..e937d9ffa7a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$15.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$16.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$16.class new file mode 100644 index 00000000000..bed389f38b0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$16.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$17.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$17.class new file mode 100644 index 00000000000..aecc53e05db Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$17.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$18.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$18.class new file mode 100644 index 00000000000..04050415760 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$18.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$19.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$19.class new file mode 100644 index 00000000000..861493ebab9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$19.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$2.class new file mode 100644 index 00000000000..03d6e5eb8c2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$20.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$20.class new file mode 100644 index 00000000000..6be9d7699b9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$20.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$21.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$21.class new file mode 100644 index 00000000000..27c9c274592 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$21.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$3.class new file mode 100644 index 00000000000..78554c8b93a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$4.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$4.class new file mode 100644 index 00000000000..0a592dabff9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$4.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$5.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$5.class new file mode 100644 index 00000000000..d0eed611738 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$5.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$6.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$6.class new file mode 100644 index 00000000000..ae270320b45 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$6.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$7.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$7.class new file mode 100644 index 00000000000..c9b0cec891b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$7.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$8.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$8.class new file mode 100644 index 00000000000..8d43ef08f26 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$8.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$9.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$9.class new file mode 100644 index 00000000000..3273b6f799e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$9.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$Initializer.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$Initializer.class new file mode 100644 index 00000000000..d5d5e2b675b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors$Initializer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors.class new file mode 100644 index 00000000000..3a42f40a2a9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Errors.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/FunctionSignatureDiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/FunctionSignatureDiagnosticFactory.class new file mode 100644 index 00000000000..940389e579d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/FunctionSignatureDiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/GenericDiagnostic.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/GenericDiagnostic.class new file mode 100644 index 00000000000..398742220ee Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/GenericDiagnostic.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/ParameterizedDiagnosticFactory1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/ParameterizedDiagnosticFactory1.class new file mode 100644 index 00000000000..f03f9beadaa Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/ParameterizedDiagnosticFactory1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/ParameterizedDiagnosticFactory2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/ParameterizedDiagnosticFactory2.class new file mode 100644 index 00000000000..0ca320b4962 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/ParameterizedDiagnosticFactory2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/ParameterizedDiagnosticFactory3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/ParameterizedDiagnosticFactory3.class new file mode 100644 index 00000000000..67dfece8dab Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/ParameterizedDiagnosticFactory3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory.class new file mode 100644 index 00000000000..974f3a4cef5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory1.class new file mode 100644 index 00000000000..8fb1e780e83 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory2.class new file mode 100644 index 00000000000..3606977743f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory3.class new file mode 100644 index 00000000000..bd69e29a91e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/PsiElementOnlyDiagnosticFactory3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnostic$RedeclarationDiagnosticWithDeferredResolution.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnostic$RedeclarationDiagnosticWithDeferredResolution.class new file mode 100644 index 00000000000..0bd14b4255d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnostic$RedeclarationDiagnosticWithDeferredResolution.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnostic$SimpleRedeclarationDiagnostic.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnostic$SimpleRedeclarationDiagnostic.class new file mode 100644 index 00000000000..46b2f46422b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnostic$SimpleRedeclarationDiagnostic.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnostic.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnostic.class new file mode 100644 index 00000000000..543d2aa1492 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnostic.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnosticFactory.class new file mode 100644 index 00000000000..9316171544a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Renderer$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Renderer$1.class new file mode 100644 index 00000000000..fd741f270be Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Renderer$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Renderer.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Renderer.class new file mode 100644 index 00000000000..4bfcbae11bf Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Renderer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Severity.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Severity.class new file mode 100644 index 00000000000..5714d8c3a44 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/Severity.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactory.class new file mode 100644 index 00000000000..f0ba7e8f798 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactoryWithPsiElement.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactoryWithPsiElement.class new file mode 100644 index 00000000000..952e37fbb83 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactoryWithPsiElement.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/SimplePsiElementOnlyDiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/SimplePsiElementOnlyDiagnosticFactory.class new file mode 100644 index 00000000000..cf989fb1a89 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/SimplePsiElementOnlyDiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/UnresolvedReferenceDiagnostic.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/UnresolvedReferenceDiagnostic.class new file mode 100644 index 00000000000..f6d09387318 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/UnresolvedReferenceDiagnostic.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/UnresolvedReferenceDiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/UnresolvedReferenceDiagnosticFactory.class new file mode 100644 index 00000000000..60d93722d82 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/UnresolvedReferenceDiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/UnusedElementDiagnosticFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/UnusedElementDiagnosticFactory.class new file mode 100644 index 00000000000..288aa19c25f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/diagnostics/UnusedElementDiagnosticFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$At.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$At.class new file mode 100644 index 00000000000..5d3bba872bb Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$At.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$AtFirstTokenOfTokens.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$AtFirstTokenOfTokens.class new file mode 100644 index 00000000000..ebc33ce1be8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$AtFirstTokenOfTokens.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$AtOffset.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$AtOffset.class new file mode 100644 index 00000000000..1b3f397ec1d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$AtOffset.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$AtSet.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$AtSet.class new file mode 100644 index 00000000000..0e26ef16bcd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing$AtSet.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing.class new file mode 100644 index 00000000000..6365cba4d2d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractJetParsing.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractTokenStreamPattern.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractTokenStreamPattern.class new file mode 100644 index 00000000000..285445d047f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractTokenStreamPattern.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractTokenStreamPredicate$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractTokenStreamPredicate$1.class new file mode 100644 index 00000000000..59ce724c183 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractTokenStreamPredicate$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractTokenStreamPredicate.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractTokenStreamPredicate.class new file mode 100644 index 00000000000..9110aa4afb9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/AbstractTokenStreamPredicate.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/Consumer.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/Consumer.class new file mode 100644 index 00000000000..8b545ee979e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/Consumer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/FirstBefore.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/FirstBefore.class new file mode 100644 index 00000000000..809cc6ddfa0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/FirstBefore.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$1.class new file mode 100644 index 00000000000..36637c403c0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence$1.class new file mode 100644 index 00000000000..aa3fd345d5f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence$2.class new file mode 100644 index 00000000000..73f681631a7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence$3.class new file mode 100644 index 00000000000..59fbbd66dc1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence.class new file mode 100644 index 00000000000..61627b2a9f0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing$Precedence.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing.class new file mode 100644 index 00000000000..bafbbd1da09 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetExpressionParsing.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParser.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParser.class new file mode 100644 index 00000000000..bb4425f0c0b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParser.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParserDefinition.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParserDefinition.class new file mode 100644 index 00000000000..8f32e0babd5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParserDefinition.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing$1.class new file mode 100644 index 00000000000..3829fd714df Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing$2.class new file mode 100644 index 00000000000..f0f9994d0c0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing$TokenDetector.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing$TokenDetector.class new file mode 100644 index 00000000000..3958059a680 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing$TokenDetector.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing.class new file mode 100644 index 00000000000..07fbe5b54d7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/JetParsing.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/LastBefore.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/LastBefore.class new file mode 100644 index 00000000000..95018ababec Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/LastBefore.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/MarkerAdapter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/MarkerAdapter.class new file mode 100644 index 00000000000..73fe4fa5fe2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/MarkerAdapter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilder.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilder.class new file mode 100644 index 00000000000..2cc223e7731 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilder.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderAdapter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderAdapter.class new file mode 100644 index 00000000000..adb2b23cdf4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderAdapter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderForByClause.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderForByClause.class new file mode 100644 index 00000000000..9c3d75566c3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderForByClause.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderImpl.class new file mode 100644 index 00000000000..f7275192187 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/TokenStreamPattern.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/TokenStreamPattern.class new file mode 100644 index 00000000000..16e0f1edd4b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/TokenStreamPattern.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/TokenStreamPredicate.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/TokenStreamPredicate.class new file mode 100644 index 00000000000..ce73a88834f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/TokenStreamPredicate.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/TruncatedSemanticWhitespaceAwarePsiBuilder.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/TruncatedSemanticWhitespaceAwarePsiBuilder.class new file mode 100644 index 00000000000..06aaaa8e69d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/parsing/TruncatedSemanticWhitespaceAwarePsiBuilder.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/Call.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/Call.class new file mode 100644 index 00000000000..c7ac0323b47 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/Call.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.class new file mode 100644 index 00000000000..dd1a9eae0b7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetAnnotation.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetAnnotation.class new file mode 100644 index 00000000000..901ab6c86e5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetAnnotation.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetAnnotationEntry.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetAnnotationEntry.class new file mode 100644 index 00000000000..6b17911cd90 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetAnnotationEntry.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetArrayAccessExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetArrayAccessExpression.class new file mode 100644 index 00000000000..e6912ac6f72 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetArrayAccessExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBinaryExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBinaryExpression.class new file mode 100644 index 00000000000..180736ef0f4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBinaryExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBinaryExpressionWithTypeRHS.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBinaryExpressionWithTypeRHS.class new file mode 100644 index 00000000000..c1f067c8ea5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBinaryExpressionWithTypeRHS.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBindingPattern.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBindingPattern.class new file mode 100644 index 00000000000..abdba24c021 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBindingPattern.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBlockExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBlockExpression.class new file mode 100644 index 00000000000..293d335d144 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBlockExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBlockStringTemplateEntry.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBlockStringTemplateEntry.class new file mode 100644 index 00000000000..74236af1aa3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBlockStringTemplateEntry.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBreakExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBreakExpression.class new file mode 100644 index 00000000000..828e619fbd9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetBreakExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetCallElement.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetCallElement.class new file mode 100644 index 00000000000..bbd2a6db034 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetCallElement.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetCallExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetCallExpression.class new file mode 100644 index 00000000000..f1861928211 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetCallExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetCatchClause.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetCatchClause.class new file mode 100644 index 00000000000..210ee9a4d0c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetCatchClause.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClass.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClass.class new file mode 100644 index 00000000000..b95572a1b0b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClass.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassBody.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassBody.class new file mode 100644 index 00000000000..3f9338f0436 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassBody.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassInitializer.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassInitializer.class new file mode 100644 index 00000000000..387fb341ce8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassInitializer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassObject.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassObject.class new file mode 100644 index 00000000000..2c0ed64d89c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassObject.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassOrObject.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassOrObject.class new file mode 100644 index 00000000000..623b4aad2a3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetClassOrObject.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetConstantExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetConstantExpression.class new file mode 100644 index 00000000000..67ef9a99f84 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetConstantExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetConstructorCalleeExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetConstructorCalleeExpression.class new file mode 100644 index 00000000000..f73cd423ffe Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetConstructorCalleeExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetContainerNode.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetContainerNode.class new file mode 100644 index 00000000000..75769b198f3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetContainerNode.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetContinueExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetContinueExpression.class new file mode 100644 index 00000000000..c5b6735a258 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetContinueExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDeclaration.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDeclaration.class new file mode 100644 index 00000000000..e41968e86cf Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDeclaration.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDeclarationWithBody.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDeclarationWithBody.class new file mode 100644 index 00000000000..d53a9d74082 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDeclarationWithBody.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDecomposerPattern.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDecomposerPattern.class new file mode 100644 index 00000000000..5d2731b94e1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDecomposerPattern.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegationSpecifier.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegationSpecifier.class new file mode 100644 index 00000000000..4d7da3e416a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegationSpecifier.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegationSpecifierList.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegationSpecifierList.class new file mode 100644 index 00000000000..a68a4250c22 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegationSpecifierList.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorByExpressionSpecifier.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorByExpressionSpecifier.class new file mode 100644 index 00000000000..8b88641d7b9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorByExpressionSpecifier.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.class new file mode 100644 index 00000000000..863b95174e9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorToSuperCall.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorToSuperClass.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorToSuperClass.class new file mode 100644 index 00000000000..37041b2e5f7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorToSuperClass.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorToThisCall.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorToThisCall.class new file mode 100644 index 00000000000..d3842e854b5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDelegatorToThisCall.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDoWhileExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDoWhileExpression.class new file mode 100644 index 00000000000..6131dffa9cd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDoWhileExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDotQualifiedExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDotQualifiedExpression.class new file mode 100644 index 00000000000..4fc13f479f3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetDotQualifiedExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetElement$IfNotParsed.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetElement$IfNotParsed.class new file mode 100644 index 00000000000..4ca366696bc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetElement$IfNotParsed.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetElement.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetElement.class new file mode 100644 index 00000000000..6fc0cdef755 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetElement.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetEnumEntry.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetEnumEntry.class new file mode 100644 index 00000000000..656f65ab778 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetEnumEntry.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetEscapeStringTemplateEntry.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetEscapeStringTemplateEntry.class new file mode 100644 index 00000000000..1404c219861 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetEscapeStringTemplateEntry.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetExpression.class new file mode 100644 index 00000000000..b1749da1af1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetExpressionPattern.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetExpressionPattern.class new file mode 100644 index 00000000000..ee3a368b7f1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetExpressionPattern.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFile.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFile.class new file mode 100644 index 00000000000..2ac0739afb5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFile.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFinallySection.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFinallySection.class new file mode 100644 index 00000000000..a129576ca75 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFinallySection.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetForExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetForExpression.class new file mode 100644 index 00000000000..940f68bc316 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetForExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunction.class new file mode 100644 index 00000000000..866ae120300 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunctionLiteral.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunctionLiteral.class new file mode 100644 index 00000000000..2e3635fb987 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunctionLiteral.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunctionLiteralExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunctionLiteralExpression.class new file mode 100644 index 00000000000..a95fb61defa Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunctionLiteralExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunctionType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunctionType.class new file mode 100644 index 00000000000..1f8fa6e179a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetFunctionType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetHashQualifiedExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetHashQualifiedExpression.class new file mode 100644 index 00000000000..1caabc9cf31 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetHashQualifiedExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetIdeTemplateExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetIdeTemplateExpression.class new file mode 100644 index 00000000000..fd5536453fe Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetIdeTemplateExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetIfExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetIfExpression.class new file mode 100644 index 00000000000..dc642d20c0c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetIfExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetImportDirective.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetImportDirective.class new file mode 100644 index 00000000000..fb803bf3d14 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetImportDirective.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetInitializerList.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetInitializerList.class new file mode 100644 index 00000000000..fe984a34bf8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetInitializerList.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetIsExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetIsExpression.class new file mode 100644 index 00000000000..abb91eebbcd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetIsExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLabelQualifiedExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLabelQualifiedExpression.class new file mode 100644 index 00000000000..fd6249dc3c1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLabelQualifiedExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLabelQualifiedInstanceExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLabelQualifiedInstanceExpression.class new file mode 100644 index 00000000000..469254e7f2e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLabelQualifiedInstanceExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLiteralStringTemplateEntry.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLiteralStringTemplateEntry.class new file mode 100644 index 00000000000..af796350a2d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLiteralStringTemplateEntry.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLoopExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLoopExpression.class new file mode 100644 index 00000000000..be2b69f290a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetLoopExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetModifierList.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetModifierList.class new file mode 100644 index 00000000000..68358338524 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetModifierList.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetModifierListOwner.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetModifierListOwner.class new file mode 100644 index 00000000000..dcaf91100c9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetModifierListOwner.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamedArgumentImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamedArgumentImpl.class new file mode 100644 index 00000000000..18f06d70fc8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamedArgumentImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamedDeclaration.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamedDeclaration.class new file mode 100644 index 00000000000..fd49be525e4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamedDeclaration.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamedFunction.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamedFunction.class new file mode 100644 index 00000000000..0077bb0a066 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamedFunction.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamespaceBody.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamespaceBody.class new file mode 100644 index 00000000000..d3103115372 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamespaceBody.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamespaceHeader.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamespaceHeader.class new file mode 100644 index 00000000000..0b78e9381ad Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNamespaceHeader.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNullableType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNullableType.class new file mode 100644 index 00000000000..bdb1d073a87 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetNullableType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetObjectDeclaration.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetObjectDeclaration.class new file mode 100644 index 00000000000..ef581b089f1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetObjectDeclaration.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetObjectDeclarationName.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetObjectDeclarationName.class new file mode 100644 index 00000000000..b5cfefc48b9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetObjectDeclarationName.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetObjectLiteralExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetObjectLiteralExpression.class new file mode 100644 index 00000000000..c5c1fb5e53d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetObjectLiteralExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetOperationExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetOperationExpression.class new file mode 100644 index 00000000000..38eb5df8a0c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetOperationExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetParameter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetParameter.class new file mode 100644 index 00000000000..b0cc607208a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetParameter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetParameterList.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetParameterList.class new file mode 100644 index 00000000000..1b0214ad3ac Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetParameterList.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetParenthesizedExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetParenthesizedExpression.class new file mode 100644 index 00000000000..53f42ab0d0b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetParenthesizedExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPattern.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPattern.class new file mode 100644 index 00000000000..ff64fac5c82 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPattern.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPostfixExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPostfixExpression.class new file mode 100644 index 00000000000..be9fbe7e7a0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPostfixExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPredicateExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPredicateExpression.class new file mode 100644 index 00000000000..d888c17f348 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPredicateExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPrefixExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPrefixExpression.class new file mode 100644 index 00000000000..8257aae7cc2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPrefixExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetProjectionKind.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetProjectionKind.class new file mode 100644 index 00000000000..1e2a9b8e289 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetProjectionKind.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetProperty.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetProperty.class new file mode 100644 index 00000000000..8f0de269a32 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetProperty.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPropertyAccessor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPropertyAccessor.class new file mode 100644 index 00000000000..56f41172362 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPropertyAccessor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPsiFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPsiFactory.class new file mode 100644 index 00000000000..3d9c1aae2ed Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPsiFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPsiUtil$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPsiUtil$1.class new file mode 100644 index 00000000000..cf16bcf8521 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPsiUtil$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPsiUtil.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPsiUtil.class new file mode 100644 index 00000000000..bd5dc5ad145 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetPsiUtil.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetQualifiedExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetQualifiedExpression.class new file mode 100644 index 00000000000..8fa28c3a48b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetQualifiedExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetReferenceExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetReferenceExpression.class new file mode 100644 index 00000000000..b138ee56931 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetReferenceExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetReturnExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetReturnExpression.class new file mode 100644 index 00000000000..e297c34fbf5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetReturnExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetRootNamespaceExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetRootNamespaceExpression.class new file mode 100644 index 00000000000..56740c4613c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetRootNamespaceExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSafeQualifiedExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSafeQualifiedExpression.class new file mode 100644 index 00000000000..176ff3e99e0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSafeQualifiedExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSecondaryConstructor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSecondaryConstructor.class new file mode 100644 index 00000000000..96143b46d6d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSecondaryConstructor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSelfType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSelfType.class new file mode 100644 index 00000000000..61c41d0cf01 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSelfType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.class new file mode 100644 index 00000000000..ac9c289165e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSimpleNameExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSimpleNameStringTemplateEntry.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSimpleNameStringTemplateEntry.class new file mode 100644 index 00000000000..d97022c59f7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSimpleNameStringTemplateEntry.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStatementExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStatementExpression.class new file mode 100644 index 00000000000..089f3fa8cad Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStatementExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStringTemplateEntry.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStringTemplateEntry.class new file mode 100644 index 00000000000..303dc8bac01 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStringTemplateEntry.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStringTemplateEntryWithExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStringTemplateEntryWithExpression.class new file mode 100644 index 00000000000..6e7d48e71aa Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStringTemplateEntryWithExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStringTemplateExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStringTemplateExpression.class new file mode 100644 index 00000000000..b5fa824b051 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetStringTemplateExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSuperExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSuperExpression.class new file mode 100644 index 00000000000..996ab22e63d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetSuperExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetThisExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetThisExpression.class new file mode 100644 index 00000000000..6050c837760 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetThisExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetThisReferenceExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetThisReferenceExpression.class new file mode 100644 index 00000000000..92d4bb771b7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetThisReferenceExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetThrowExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetThrowExpression.class new file mode 100644 index 00000000000..3086e82bfc5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetThrowExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTreeVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTreeVisitor.class new file mode 100644 index 00000000000..a11ddde2581 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTreeVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTryExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTryExpression.class new file mode 100644 index 00000000000..d644cdfcd95 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTryExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTupleExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTupleExpression.class new file mode 100644 index 00000000000..00fcebbb194 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTupleExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTuplePattern.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTuplePattern.class new file mode 100644 index 00000000000..b2da11e351d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTuplePattern.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTuplePatternEntry.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTuplePatternEntry.class new file mode 100644 index 00000000000..b20dffd0749 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTuplePatternEntry.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTupleType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTupleType.class new file mode 100644 index 00000000000..7c687d1a34a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTupleType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeArgumentList.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeArgumentList.class new file mode 100644 index 00000000000..ec272f2a750 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeArgumentList.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeConstraint.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeConstraint.class new file mode 100644 index 00000000000..6b6233fd42c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeConstraint.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeConstraintList.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeConstraintList.class new file mode 100644 index 00000000000..f4ee6a34a36 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeConstraintList.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeElement.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeElement.class new file mode 100644 index 00000000000..b452339ba6b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeElement.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeParameter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeParameter.class new file mode 100644 index 00000000000..e1386853f0f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeParameter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeParameterList.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeParameterList.class new file mode 100644 index 00000000000..7f2c050a081 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeParameterList.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeParameterListOwner.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeParameterListOwner.class new file mode 100644 index 00000000000..eb3cb4c63ab Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeParameterListOwner.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypePattern.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypePattern.class new file mode 100644 index 00000000000..510ef717920 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypePattern.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeProjection.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeProjection.class new file mode 100644 index 00000000000..2254a9d92aa Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeProjection.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeReference.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeReference.class new file mode 100644 index 00000000000..71f63ad545f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypeReference.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypedef.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypedef.class new file mode 100644 index 00000000000..cb3adcbba2f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetTypedef.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetUnaryExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetUnaryExpression.class new file mode 100644 index 00000000000..a9f53dce1fe Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetUnaryExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetUserType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetUserType.class new file mode 100644 index 00000000000..f802ec788a4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetUserType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetValueArgument.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetValueArgument.class new file mode 100644 index 00000000000..d85e8c26680 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetValueArgument.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetValueArgumentList.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetValueArgumentList.class new file mode 100644 index 00000000000..9cace34c7e2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetValueArgumentList.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetValueArgumentName.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetValueArgumentName.class new file mode 100644 index 00000000000..8f09cde3432 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetValueArgumentName.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetVisitor.class new file mode 100644 index 00000000000..79abc416886 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetVisitorVoid.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetVisitorVoid.class new file mode 100644 index 00000000000..38f7ace5401 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetVisitorVoid.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenCondition.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenCondition.class new file mode 100644 index 00000000000..50c3cbc04be Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenCondition.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenConditionInRange.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenConditionInRange.class new file mode 100644 index 00000000000..bf2d0941806 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenConditionInRange.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenConditionIsPattern.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenConditionIsPattern.class new file mode 100644 index 00000000000..53bd23af924 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenConditionIsPattern.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenConditionWithExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenConditionWithExpression.class new file mode 100644 index 00000000000..9dd3620d485 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenConditionWithExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenEntry.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenEntry.class new file mode 100644 index 00000000000..3e7a8556c9f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenEntry.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenExpression.class new file mode 100644 index 00000000000..459774194f4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhenExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhileExpression.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhileExpression.class new file mode 100644 index 00000000000..c5753302f27 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWhileExpression.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWildcardPattern.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWildcardPattern.class new file mode 100644 index 00000000000..ce5618cb149 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/JetWildcardPattern.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/ValueArgument.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/ValueArgument.class new file mode 100644 index 00000000000..f47c2dc2622 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/ValueArgument.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/PsiJetClassStub.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/PsiJetClassStub.class new file mode 100644 index 00000000000..99ca48f179c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/PsiJetClassStub.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/PsiJetFileStub.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/PsiJetFileStub.class new file mode 100644 index 00000000000..a325f811f41 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/PsiJetFileStub.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/PsiJetFunctionStub.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/PsiJetFunctionStub.class new file mode 100644 index 00000000000..d74f3944ca8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/PsiJetFunctionStub.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetClassElementType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetClassElementType.class new file mode 100644 index 00000000000..99ebc96bd33 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetClassElementType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.class new file mode 100644 index 00000000000..e988141e429 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetFileStubBuilder.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetFileStubBuilder.class new file mode 100644 index 00000000000..de771321708 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetFileStubBuilder.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.class new file mode 100644 index 00000000000..9eba021fa1f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementType.class new file mode 100644 index 00000000000..711b1a14021 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.class new file mode 100644 index 00000000000..5b41a785823 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/StubIndexService$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/StubIndexService$1.class new file mode 100644 index 00000000000..f2e6f03569a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/StubIndexService$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/StubIndexService.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/StubIndexService.class new file mode 100644 index 00000000000..56c5f1e0e17 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/StubIndexService.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/StubIndexServiceFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/StubIndexServiceFactory.class new file mode 100644 index 00000000000..9adc74ca5cf Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/elements/StubIndexServiceFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetClassStubImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetClassStubImpl.class new file mode 100644 index 00000000000..0f6f14ae38b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetClassStubImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetFileStubImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetFileStubImpl.class new file mode 100644 index 00000000000..b0d8b8b57c0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetFileStubImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetFunctionStubImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetFunctionStubImpl.class new file mode 100644 index 00000000000..fc588a62dde Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetFunctionStubImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AbstractScopeAdapter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AbstractScopeAdapter.class new file mode 100644 index 00000000000..af970c9624b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AbstractScopeAdapter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils$1.class new file mode 100644 index 00000000000..7e69bd109e4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils$2.class new file mode 100644 index 00000000000..41042a2fb06 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils$3.class new file mode 100644 index 00000000000..5e4a6c5e936 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils.class new file mode 100644 index 00000000000..e223f04a20c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnalyzingUtils.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnnotationResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnnotationResolver$1.class new file mode 100644 index 00000000000..030b457aba2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnnotationResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnnotationResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnnotationResolver.class new file mode 100644 index 00000000000..fcb386be8eb Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/AnnotationResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext$1.class new file mode 100644 index 00000000000..ac7104871a9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext$2.class new file mode 100644 index 00000000000..39987628f98 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext$3.class new file mode 100644 index 00000000000..37f019f17dc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext.class new file mode 100644 index 00000000000..360ea6535e2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContext.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContextUtils.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContextUtils.class new file mode 100644 index 00000000000..277085c22e6 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingContextUtils.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingTrace.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingTrace.class new file mode 100644 index 00000000000..2a07b082889 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingTrace.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingTraceContext$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingTraceContext$1.class new file mode 100644 index 00000000000..2e5082d5028 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingTraceContext$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingTraceContext.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingTraceContext.class new file mode 100644 index 00000000000..2d77a9a3c19 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BindingTraceContext.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$1.class new file mode 100644 index 00000000000..0086a259692 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$2.class new file mode 100644 index 00000000000..436dfc9325f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$3.class new file mode 100644 index 00000000000..3d0cd23087e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$4.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$4.class new file mode 100644 index 00000000000..66a19e596ae Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver$4.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver.class new file mode 100644 index 00000000000..a829b0c03cc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/BodyResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.class new file mode 100644 index 00000000000..440fd687e89 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DeclarationResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DeclarationResolver$1.class new file mode 100644 index 00000000000..fd38a314219 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DeclarationResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DeclarationResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DeclarationResolver.class new file mode 100644 index 00000000000..603911c6e8a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DeclarationResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DeclarationsChecker.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DeclarationsChecker.class new file mode 100644 index 00000000000..636258db55e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DeclarationsChecker.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DelegatingBindingTrace$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DelegatingBindingTrace$1.class new file mode 100644 index 00000000000..ed371116764 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DelegatingBindingTrace$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DelegatingBindingTrace.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DelegatingBindingTrace.class new file mode 100644 index 00000000000..54519b23dbe Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DelegatingBindingTrace.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DelegationResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DelegationResolver.class new file mode 100644 index 00000000000..a68d782dec0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DelegationResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorResolver$1.class new file mode 100644 index 00000000000..e0c8bc1a7ae Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorResolver$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorResolver$2.class new file mode 100644 index 00000000000..278454aef4a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorResolver$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorResolver.class new file mode 100644 index 00000000000..e67dd7e18cd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils$1.class new file mode 100644 index 00000000000..17767f69efd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils$2.class new file mode 100644 index 00000000000..42647f7ff8f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils$3.class new file mode 100644 index 00000000000..27fae4f56ac Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils.class new file mode 100644 index 00000000000..5778d233a92 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/DescriptorUtils.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/Importer$DelayedImporter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/Importer$DelayedImporter.class new file mode 100644 index 00000000000..7e24e879eef Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/Importer$DelayedImporter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/Importer$StandardImporter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/Importer$StandardImporter.class new file mode 100644 index 00000000000..7910ec8931c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/Importer$StandardImporter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/Importer.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/Importer.class new file mode 100644 index 00000000000..5bbcc907d43 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/Importer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver$ImportResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver$ImportResolver$1.class new file mode 100644 index 00000000000..7cc70bf0dcb Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver$ImportResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver$ImportResolver$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver$ImportResolver$2.class new file mode 100644 index 00000000000..e951a1408de Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver$ImportResolver$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver$ImportResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver$ImportResolver.class new file mode 100644 index 00000000000..9b8ace2f65c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver$ImportResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver.class new file mode 100644 index 00000000000..1012a9e8012 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ImportsResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/JetModuleUtil.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/JetModuleUtil.class new file mode 100644 index 00000000000..58b3276d1e9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/JetModuleUtil.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/JetVisibilityChecker.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/JetVisibilityChecker.class new file mode 100644 index 00000000000..52d6c24c746 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/JetVisibilityChecker.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ObservableBindingTrace$RecordHandler.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ObservableBindingTrace$RecordHandler.class new file mode 100644 index 00000000000..7989dfe7170 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ObservableBindingTrace$RecordHandler.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ObservableBindingTrace.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ObservableBindingTrace.class new file mode 100644 index 00000000000..3a446bf475c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/ObservableBindingTrace.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadResolver$Key.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadResolver$Key.class new file mode 100644 index 00000000000..f2e90e4b6f9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadResolver$Key.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadResolver.class new file mode 100644 index 00000000000..d15dfd4bf53 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadUtil$OverloadCompatibilityInfo.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadUtil$OverloadCompatibilityInfo.class new file mode 100644 index 00000000000..df0541ef302 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadUtil$OverloadCompatibilityInfo.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadUtil.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadUtil.class new file mode 100644 index 00000000000..2cf60b2c57f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverloadUtil.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver$1.class new file mode 100644 index 00000000000..cbbd0a54aa5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver$2.class new file mode 100644 index 00000000000..5daf2017411 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver$DescriptorSink.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver$DescriptorSink.class new file mode 100644 index 00000000000..3636b186c46 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver$DescriptorSink.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver.class new file mode 100644 index 00000000000..f5e22452815 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverrideResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverridingUtil$OverrideCompatibilityInfo.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverridingUtil$OverrideCompatibilityInfo.class new file mode 100644 index 00000000000..a2d9cad60e3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverridingUtil$OverrideCompatibilityInfo.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverridingUtil.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverridingUtil.class new file mode 100644 index 00000000000..d6198fc92bd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/OverridingUtil.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TemporaryBindingTrace.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TemporaryBindingTrace.class new file mode 100644 index 00000000000..ba174955bdd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TemporaryBindingTrace.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TopDownAnalysisContext.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TopDownAnalysisContext.class new file mode 100644 index 00000000000..cc567599dd1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TopDownAnalysisContext.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TopDownAnalyzer$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TopDownAnalyzer$1.class new file mode 100644 index 00000000000..cf1ace71b21 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TopDownAnalyzer$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.class new file mode 100644 index 00000000000..2d1c21ce39f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TraceBasedRedeclarationHandler.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TraceBasedRedeclarationHandler.class new file mode 100644 index 00000000000..539a52fe770 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TraceBasedRedeclarationHandler.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$1$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$1$1.class new file mode 100644 index 00000000000..4fd8c885553 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$1$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$1.class new file mode 100644 index 00000000000..715d0e0d1b9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$2.class new file mode 100644 index 00000000000..dc8a647426d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$Filter$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$Filter$1.class new file mode 100644 index 00000000000..93e0e9f9b73 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$Filter$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$Filter$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$Filter$2.class new file mode 100644 index 00000000000..bb19bb7d8ea Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$Filter$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$Filter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$Filter.class new file mode 100644 index 00000000000..fab3f508ff3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver$Filter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.class new file mode 100644 index 00000000000..8b35edb62bc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver$1.class new file mode 100644 index 00000000000..ce357ca378a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver$2.class new file mode 100644 index 00000000000..9317929118b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver$3.class new file mode 100644 index 00000000000..ea56e6c90da Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver.class new file mode 100644 index 00000000000..5c2c422abc8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/TypeResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/AutoCastReceiver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/AutoCastReceiver.class new file mode 100644 index 00000000000..437031754cc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/AutoCastReceiver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker$1.class new file mode 100644 index 00000000000..cd9368af037 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker$CallImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker$CallImpl.class new file mode 100644 index 00000000000..7295a51b82a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker$CallImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker$ExpressionValueArgument.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker$ExpressionValueArgument.class new file mode 100644 index 00000000000..98f1d61965d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker$ExpressionValueArgument.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker.class new file mode 100644 index 00000000000..bb215ff2425 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallMaker.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallResolver$1.class new file mode 100644 index 00000000000..d5630105ff5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallResolver$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallResolver$2.class new file mode 100644 index 00000000000..bcb3b022589 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallResolver$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallResolver.class new file mode 100644 index 00000000000..9feafed1669 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/CallResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/DefaultValueArgument.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/DefaultValueArgument.class new file mode 100644 index 00000000000..a5ed66f6888 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/DefaultValueArgument.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ExpressionAsFunctionDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ExpressionAsFunctionDescriptor.class new file mode 100644 index 00000000000..335325383a6 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ExpressionAsFunctionDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ExpressionValueArgument.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ExpressionValueArgument.class new file mode 100644 index 00000000000..d8e4db7a259 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ExpressionValueArgument.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/JetFakeReference.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/JetFakeReference.class new file mode 100644 index 00000000000..62aca8c3767 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/JetFakeReference.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResults$Code.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResults$Code.class new file mode 100644 index 00000000000..299f1b30b28 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResults$Code.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResults.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResults.class new file mode 100644 index 00000000000..cb4fd48794e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResults.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResultsImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResultsImpl.class new file mode 100644 index 00000000000..f392a54482d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResultsImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResultsUtil.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResultsUtil.class new file mode 100644 index 00000000000..447412deb5c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadResolutionResultsUtil.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadingConflictResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadingConflictResolver$1.class new file mode 100644 index 00000000000..af379ea2993 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadingConflictResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadingConflictResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadingConflictResolver.class new file mode 100644 index 00000000000..0ad6f570be4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/OverloadingConflictResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$1.class new file mode 100644 index 00000000000..39de974084e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$2.class new file mode 100644 index 00000000000..384e8ce8834 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$AbstractData.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$AbstractData.class new file mode 100644 index 00000000000..b99d547a64d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$AbstractData.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$Data.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$Data.class new file mode 100644 index 00000000000..f5f638e4960 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$Data.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$DataImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$DataImpl.class new file mode 100644 index 00000000000..26447d250cd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$DataImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$One.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$One.class new file mode 100644 index 00000000000..45b9d282013 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo$One.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo.class new file mode 100644 index 00000000000..2048c7a75f6 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionDebugInfo.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionStatus.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionStatus.class new file mode 100644 index 00000000000..a49254c7a3c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionStatus.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionTask$DescriptorCheckStrategy.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionTask$DescriptorCheckStrategy.class new file mode 100644 index 00000000000..9a9db3b0e53 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionTask$DescriptorCheckStrategy.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionTask.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionTask.class new file mode 100644 index 00000000000..5f64556102d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolutionTask.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCall.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCall.class new file mode 100644 index 00000000000..c0979aeb1e8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCall.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl$1.class new file mode 100644 index 00000000000..1a3505f0226 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl$2.class new file mode 100644 index 00000000000..f129760219a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl.class new file mode 100644 index 00000000000..d12fa25d2a5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedValueArgument.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedValueArgument.class new file mode 100644 index 00000000000..dcf48cbd6d8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ResolvedValueArgument.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.class new file mode 100644 index 00000000000..c356e2a3835 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$1.class new file mode 100644 index 00000000000..056b8453286 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$2$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$2$1.class new file mode 100644 index 00000000000..fd225deea5d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$2$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$2.class new file mode 100644 index 00000000000..7bca0cf32d5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$3.class new file mode 100644 index 00000000000..2775de1db6b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers.class new file mode 100644 index 00000000000..dd130c39858 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizers.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TracingStrategy$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TracingStrategy$1.class new file mode 100644 index 00000000000..c88e4126d0a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TracingStrategy$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TracingStrategy.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TracingStrategy.class new file mode 100644 index 00000000000..9099fb5d836 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/TracingStrategy.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ValueArgumentsToParametersMapper.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ValueArgumentsToParametersMapper.class new file mode 100644 index 00000000000..96030e5e9f2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/ValueArgumentsToParametersMapper.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/VarargValueArgument.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/VarargValueArgument.class new file mode 100644 index 00000000000..46d8dd45c96 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/VarargValueArgument.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastService$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastService$1.class new file mode 100644 index 00000000000..044e99bffba Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastService$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastService.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastService.class new file mode 100644 index 00000000000..5d483323864 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastService.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastServiceImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastServiceImpl.class new file mode 100644 index 00000000000..ca0a9859a98 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastServiceImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils$1.class new file mode 100644 index 00000000000..345775606fa Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils.class new file mode 100644 index 00000000000..8f2e646a2b0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo$1.class new file mode 100644 index 00000000000..b43fdf78510 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo$2.class new file mode 100644 index 00000000000..0c3cf0a02ea Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo$CompositionOperator.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo$CompositionOperator.class new file mode 100644 index 00000000000..375b14fb948 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo$CompositionOperator.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.class new file mode 100644 index 00000000000..9a1b2c53c5d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValue.class new file mode 100644 index 00000000000..578df72a7e6 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValueFactory.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValueFactory.class new file mode 100644 index 00000000000..0b5ae60941e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValueFactory.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/Nullability$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/Nullability$1.class new file mode 100644 index 00000000000..07d04f6307d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/Nullability$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/Nullability.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/Nullability.class new file mode 100644 index 00000000000..cdc945b9f95 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/autocasts/Nullability.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/BoundsOwner.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/BoundsOwner.class new file mode 100644 index 00000000000..94d707f6594 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/BoundsOwner.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintResolutionListener$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintResolutionListener$1.class new file mode 100644 index 00000000000..97d382f22d9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintResolutionListener$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintResolutionListener.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintResolutionListener.class new file mode 100644 index 00000000000..ef6001026e1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintResolutionListener.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystem.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystem.class new file mode 100644 index 00000000000..ffc953c782c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystem.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$1.class new file mode 100644 index 00000000000..e1e35fa83b2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$2.class new file mode 100644 index 00000000000..660d2f646a3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$Error.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$Error.class new file mode 100644 index 00000000000..c6385a84e7f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$Error.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$KnownType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$KnownType.class new file mode 100644 index 00000000000..e1ed388ea4a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$KnownType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$LoopInTypeVariableConstraintsException.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$LoopInTypeVariableConstraintsException.class new file mode 100644 index 00000000000..a9ccf3016e9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$LoopInTypeVariableConstraintsException.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$Solution$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$Solution$1.class new file mode 100644 index 00000000000..20187847e8e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$Solution$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$Solution.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$Solution.class new file mode 100644 index 00000000000..e317b3bb72a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$Solution.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$TypeConstraintBuilderAdapter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$TypeConstraintBuilderAdapter.class new file mode 100644 index 00000000000..d8872666d36 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$TypeConstraintBuilderAdapter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$TypeValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$TypeValue.class new file mode 100644 index 00000000000..f03cdf76e71 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$TypeValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$UnknownType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$UnknownType.class new file mode 100644 index 00000000000..1eef3e46ff4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl$UnknownType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.class new file mode 100644 index 00000000000..f93dff55fa9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemSolution.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemSolution.class new file mode 100644 index 00000000000..5962ff08fa4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemSolution.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$1.class new file mode 100644 index 00000000000..bb900749ef4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$2.class new file mode 100644 index 00000000000..d1fa5d7f6e5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$Error.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$Error.class new file mode 100644 index 00000000000..092b0d622cc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$Error.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$LoopInTypeVariableConstraintsException.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$LoopInTypeVariableConstraintsException.class new file mode 100644 index 00000000000..3da73c0a39e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$LoopInTypeVariableConstraintsException.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$Solution$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$Solution$1.class new file mode 100644 index 00000000000..597f862ee92 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$Solution$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$Solution.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$Solution.class new file mode 100644 index 00000000000..169636f63e6 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$Solution.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$TypeConstraintBuilderAdapter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$TypeConstraintBuilderAdapter.class new file mode 100644 index 00000000000..87cd8bf6e30 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities$TypeConstraintBuilderAdapter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities.class new file mode 100644 index 00000000000..ee958dc7ed0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemWithPriorities.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintType.class new file mode 100644 index 00000000000..8ac8a439418 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/DebugConstraintResolutionListener.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/DebugConstraintResolutionListener.class new file mode 100644 index 00000000000..021559ecd8a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/DebugConstraintResolutionListener.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/PrintingConstraintResolutionListener.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/PrintingConstraintResolutionListener.class new file mode 100644 index 00000000000..ec2d53927e9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/PrintingConstraintResolutionListener.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/SolutionStatus$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/SolutionStatus$1.class new file mode 100644 index 00000000000..2e499b3c7f2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/SolutionStatus$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/SolutionStatus.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/SolutionStatus.class new file mode 100644 index 00000000000..6b06fecf970 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/SolutionStatus.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/SubtypingConstraint.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/SubtypingConstraint.class new file mode 100644 index 00000000000..e84e7a149e8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/SubtypingConstraint.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/TypeValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/TypeValue.class new file mode 100644 index 00000000000..fd679f83df3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/calls/inference/TypeValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/BooleanValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/BooleanValue.class new file mode 100644 index 00000000000..f4557c5a626 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/BooleanValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ByteValue$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ByteValue$1.class new file mode 100644 index 00000000000..14dec1a43cc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ByteValue$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ByteValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ByteValue.class new file mode 100644 index 00000000000..b0809cefe9d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ByteValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CharValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CharValue.class new file mode 100644 index 00000000000..c29adf23559 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CharValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstant.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstant.class new file mode 100644 index 00000000000..dc1f661ed63 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstant.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver$1.class new file mode 100644 index 00000000000..1ffb79b8a6d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.class new file mode 100644 index 00000000000..befe17ff1f3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/DoubleValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/DoubleValue.class new file mode 100644 index 00000000000..5d698d22457 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/DoubleValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ErrorValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ErrorValue.class new file mode 100644 index 00000000000..3829b1f14e9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ErrorValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/FloatValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/FloatValue.class new file mode 100644 index 00000000000..647a757a213 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/FloatValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/IntValue$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/IntValue$1.class new file mode 100644 index 00000000000..d2386bd082a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/IntValue$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/IntValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/IntValue.class new file mode 100644 index 00000000000..5dfcea0bc3d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/IntValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/LongValue$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/LongValue$1.class new file mode 100644 index 00000000000..3b2ae1c6297 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/LongValue$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/LongValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/LongValue.class new file mode 100644 index 00000000000..7530a14876c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/LongValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/NullValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/NullValue.class new file mode 100644 index 00000000000..ff6d9afb4f6 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/NullValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ShortValue$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ShortValue$1.class new file mode 100644 index 00000000000..f8e9bab8c5b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ShortValue$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ShortValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ShortValue.class new file mode 100644 index 00000000000..6fb039880ab Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/ShortValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/StringValue.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/StringValue.class new file mode 100644 index 00000000000..3bb73292a0e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/constants/StringValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/ChainedScope.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/ChainedScope.class new file mode 100644 index 00000000000..772eb6c3df3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/ChainedScope.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScope$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScope$1.class new file mode 100644 index 00000000000..5a75eb03f82 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScope$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScope.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScope.class new file mode 100644 index 00000000000..a8c11ff1ad2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScope.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScopeAdapter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScopeAdapter.class new file mode 100644 index 00000000000..742f0748158 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScopeAdapter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScopeImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScopeImpl.class new file mode 100644 index 00000000000..d94a55a2250 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScopeImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScopeUtils.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScopeUtils.class new file mode 100644 index 00000000000..66923d77173 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/JetScopeUtils.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/LazyScopeAdapter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/LazyScopeAdapter.class new file mode 100644 index 00000000000..8e30dbee50d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/LazyScopeAdapter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/RedeclarationHandler$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/RedeclarationHandler$1.class new file mode 100644 index 00000000000..1df28725960 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/RedeclarationHandler$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/RedeclarationHandler$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/RedeclarationHandler$2.class new file mode 100644 index 00000000000..de64ca80373 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/RedeclarationHandler$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/RedeclarationHandler.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/RedeclarationHandler.class new file mode 100644 index 00000000000..153ea9d9440 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/RedeclarationHandler.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/SubstitutingScope.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/SubstitutingScope.class new file mode 100644 index 00000000000..af0f77faf4f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/SubstitutingScope.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScope$LockLevel.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScope$LockLevel.class new file mode 100644 index 00000000000..62fd43d442d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScope$LockLevel.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScope.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScope.class new file mode 100644 index 00000000000..e0c1c8f07ab Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScope.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.class new file mode 100644 index 00000000000..110b87e36be Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.class new file mode 100644 index 00000000000..0f99c57bc20 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.class new file mode 100644 index 00000000000..8b04947e527 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/AbstractReceiverDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/AbstractReceiverDescriptor.class new file mode 100644 index 00000000000..6e51d316c84 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/AbstractReceiverDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ClassReceiver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ClassReceiver.class new file mode 100644 index 00000000000..1697daf2555 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ClassReceiver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ExpressionReceiver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ExpressionReceiver.class new file mode 100644 index 00000000000..6af7e42c24a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ExpressionReceiver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ExtensionReceiver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ExtensionReceiver.class new file mode 100644 index 00000000000..ac3a2a8c555 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ExtensionReceiver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ReceiverDescriptor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ReceiverDescriptor$1.class new file mode 100644 index 00000000000..c087bbb1b86 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ReceiverDescriptor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ReceiverDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ReceiverDescriptor.class new file mode 100644 index 00000000000..465528bd6e8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ReceiverDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ReceiverDescriptorVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ReceiverDescriptorVisitor.class new file mode 100644 index 00000000000..ff61115fdf0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ReceiverDescriptorVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ThisReceiverDescriptor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ThisReceiverDescriptor.class new file mode 100644 index 00000000000..c4cece0afe7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/ThisReceiverDescriptor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/TransientReceiver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/TransientReceiver.class new file mode 100644 index 00000000000..ed4741d4566 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/resolve/scopes/receivers/TransientReceiver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes$1.class new file mode 100644 index 00000000000..8fa770b5138 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes$2.class new file mode 100644 index 00000000000..e1152f28511 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes$DfsNodeHandler.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes$DfsNodeHandler.class new file mode 100644 index 00000000000..5eb5c165846 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes$DfsNodeHandler.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes.class new file mode 100644 index 00000000000..9d4addcd252 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CommonSupertypes.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CompositeTypeSubstitution.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CompositeTypeSubstitution.class new file mode 100644 index 00000000000..1d22d5c9d68 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/CompositeTypeSubstitution.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/DeferredType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/DeferredType.class new file mode 100644 index 00000000000..dd3ea5874e7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/DeferredType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/DescriptorSubstitutor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/DescriptorSubstitutor$1.class new file mode 100644 index 00000000000..9992fd69e25 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/DescriptorSubstitutor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/DescriptorSubstitutor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/DescriptorSubstitutor.class new file mode 100644 index 00000000000..cdbfb1eb209 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/DescriptorSubstitutor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils$1.class new file mode 100644 index 00000000000..a1ad0599271 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils$ErrorScope.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils$ErrorScope.class new file mode 100644 index 00000000000..7709292fb90 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils$ErrorScope.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils$ErrorTypeImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils$ErrorTypeImpl.class new file mode 100644 index 00000000000..ad1c3b91e99 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils$ErrorTypeImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils.class new file mode 100644 index 00000000000..1e2f325ed0d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/ErrorUtils.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardClasses$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardClasses$1.class new file mode 100644 index 00000000000..57c08b5e451 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardClasses$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardClasses$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardClasses$2.class new file mode 100644 index 00000000000..50421396c5f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardClasses$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardClasses.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardClasses.class new file mode 100644 index 00000000000..66bb5c7cbcf Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardClasses.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardLibrary.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardLibrary.class new file mode 100644 index 00000000000..83979a8ee4e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetStandardLibrary.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetType.class new file mode 100644 index 00000000000..cba4ffdc210 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetTypeImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetTypeImpl.class new file mode 100644 index 00000000000..0dbe7e70894 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/JetTypeImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/NamespaceType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/NamespaceType.class new file mode 100644 index 00000000000..2a4f25c5ad0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/NamespaceType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/PrimitiveType.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/PrimitiveType.class new file mode 100644 index 00000000000..e2e47965136 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/PrimitiveType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeConstructor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeConstructor.class new file mode 100644 index 00000000000..4fd1c7871f5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeConstructor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeConstructorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeConstructorImpl.class new file mode 100644 index 00000000000..100666f8992 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeConstructorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeProjection.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeProjection.class new file mode 100644 index 00000000000..4be5a3925d3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeProjection.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$1.class new file mode 100644 index 00000000000..249087a3616 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$2.class new file mode 100644 index 00000000000..5ed8e38d0b6 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$MapToTypeSubstitutionAdapter.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$MapToTypeSubstitutionAdapter.class new file mode 100644 index 00000000000..abb2e1d2f7b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$MapToTypeSubstitutionAdapter.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$SubstitutionException.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$SubstitutionException.class new file mode 100644 index 00000000000..28cb25e2874 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$SubstitutionException.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$TypeSubstitution$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$TypeSubstitution$1.class new file mode 100644 index 00000000000..6a5efc2a76d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$TypeSubstitution$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$TypeSubstitution.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$TypeSubstitution.class new file mode 100644 index 00000000000..c54b65456fd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor$TypeSubstitution.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor.class new file mode 100644 index 00000000000..fd12f31d383 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeSubstitutor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils$1.class new file mode 100644 index 00000000000..9cb6583fee9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils$2.class new file mode 100644 index 00000000000..a49afa270dc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils$3.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils$3.class new file mode 100644 index 00000000000..9f494a92d71 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils.class new file mode 100644 index 00000000000..2dbe9bee6a3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/TypeUtils.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/Variance$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/Variance$1.class new file mode 100644 index 00000000000..0b7413e58fa Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/Variance$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/Variance.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/Variance.class new file mode 100644 index 00000000000..75b16814762 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/Variance.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/JetTypeChecker$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/JetTypeChecker$1.class new file mode 100644 index 00000000000..c0aa764cb51 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/JetTypeChecker$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/JetTypeChecker$TypeCheckerTypingConstraints.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/JetTypeChecker$TypeCheckerTypingConstraints.class new file mode 100644 index 00000000000..7ae6aafe94d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/JetTypeChecker$TypeCheckerTypingConstraints.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/JetTypeChecker.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/JetTypeChecker.class new file mode 100644 index 00000000000..562ea668e3c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/JetTypeChecker.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/TypeCheckingProcedure.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/TypeCheckingProcedure.class new file mode 100644 index 00000000000..933bac881c4 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/TypeCheckingProcedure.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/TypingConstraints.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/TypingConstraints.class new file mode 100644 index 00000000000..82d3caacf9d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/checker/TypingConstraints.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/error/ErrorNamedFunctionDescriptorImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/error/ErrorNamedFunctionDescriptorImpl.class new file mode 100644 index 00000000000..0c1cf1f6342 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/error/ErrorNamedFunctionDescriptorImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor$1.class new file mode 100644 index 00000000000..d9ed3b7fcf5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.class new file mode 100644 index 00000000000..ac247379607 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor$1$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor$1$1.class new file mode 100644 index 00000000000..5bc6cb3ae1c Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor$1$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor$1.class new file mode 100644 index 00000000000..5eb31f47200 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.class new file mode 100644 index 00000000000..bc66ac826c2 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/CoercionStrategy.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/CoercionStrategy.class new file mode 100644 index 00000000000..1021ce24709 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/CoercionStrategy.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor$1.class new file mode 100644 index 00000000000..6cf74d60c96 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.class new file mode 100644 index 00000000000..9c7cb36d053 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/DataFlowUtils$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/DataFlowUtils$1.class new file mode 100644 index 00000000000..49f51194d10 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/DataFlowUtils$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/DataFlowUtils.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/DataFlowUtils.class new file mode 100644 index 00000000000..2e0cd4a9b28 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/DataFlowUtils.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.class new file mode 100644 index 00000000000..3005c9df877 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingFacade.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingFacade.class new file mode 100644 index 00000000000..13674b6dfff Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingFacade.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingInternals.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingInternals.class new file mode 100644 index 00000000000..601e1ae51bb Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingInternals.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices$1.class new file mode 100644 index 00000000000..302901afdf0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices$2.class new file mode 100644 index 00000000000..fa272d715e5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.class new file mode 100644 index 00000000000..38982754885 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.class new file mode 100644 index 00000000000..d4284dbff64 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitor.class new file mode 100644 index 00000000000..2a4f8f59c2d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.class new file mode 100644 index 00000000000..6676a721def Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.class new file mode 100644 index 00000000000..32da6ce3cf8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/LabelResolver.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/LabelResolver.class new file mode 100644 index 00000000000..4446b771d2b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/LabelResolver.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/OperatorConventions.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/OperatorConventions.class new file mode 100644 index 00000000000..173da326548 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/OperatorConventions.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor$1.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor$1.class new file mode 100644 index 00000000000..0d21d4c5477 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor$2.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor$2.class new file mode 100644 index 00000000000..0e713855d1f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.class new file mode 100644 index 00000000000..3f3192bc0bb Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetKeywordToken.class b/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetKeywordToken.class new file mode 100644 index 00000000000..4f5365d22d5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetKeywordToken.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetLexer.class b/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetLexer.class new file mode 100644 index 00000000000..d97bed10e90 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetLexer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetToken.class b/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetToken.class new file mode 100644 index 00000000000..dd73472f508 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetToken.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetTokens.class b/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetTokens.class new file mode 100644 index 00000000000..62f64f8f290 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lexer/JetTokens.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lexer/_JetLexer$State.class b/k2js/out/production/frontend/org/jetbrains/jet/lexer/_JetLexer$State.class new file mode 100644 index 00000000000..a04260caade Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lexer/_JetLexer$State.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/lexer/_JetLexer.class b/k2js/out/production/frontend/org/jetbrains/jet/lexer/_JetLexer.class new file mode 100644 index 00000000000..5adc082c353 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/lexer/_JetLexer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetFileType$1.class b/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetFileType$1.class new file mode 100644 index 00000000000..ca3927dbdc0 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetFileType$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetFileType.class b/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetFileType.class new file mode 100644 index 00000000000..68ef012e5b7 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetFileType.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetLanguage.class b/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetLanguage.class new file mode 100644 index 00000000000..7aa640b7bea Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetLanguage.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetMainDetector.class b/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetMainDetector.class new file mode 100644 index 00000000000..84594b2d03f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/plugin/JetMainDetector.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$1.class b/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$1.class new file mode 100644 index 00000000000..d73f9d78499 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$2.class b/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$2.class new file mode 100644 index 00000000000..2860f258204 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$3.class b/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$3.class new file mode 100644 index 00000000000..264b9e5b769 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$RenderDeclarationDescriptorVisitor.class b/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$RenderDeclarationDescriptorVisitor.class new file mode 100644 index 00000000000..6b699636305 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer$RenderDeclarationDescriptorVisitor.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer.class b/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer.class new file mode 100644 index 00000000000..509ae302200 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/resolve/DescriptorRenderer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/Box.class b/k2js/out/production/frontend/org/jetbrains/jet/util/Box.class new file mode 100644 index 00000000000..a812cfdf150 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/Box.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers$1.class b/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers$1.class new file mode 100644 index 00000000000..82b5cd0adbf Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers$2.class b/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers$2.class new file mode 100644 index 00000000000..68e77400e46 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers$3.class b/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers$3.class new file mode 100644 index 00000000000..930959e961f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers$3.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers.class b/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers.class new file mode 100644 index 00000000000..2e7aec2a284 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/CommonSuppliers.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/QualifiedNamesUtil.class b/k2js/out/production/frontend/org/jetbrains/jet/util/QualifiedNamesUtil.class new file mode 100644 index 00000000000..6895d4ce192 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/QualifiedNamesUtil.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValue$1.class b/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValue$1.class new file mode 100644 index 00000000000..1c72f2bb1a8 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValue$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValue$State.class b/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValue$State.class new file mode 100644 index 00000000000..a77f73044fc Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValue$State.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValue.class b/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValue.class new file mode 100644 index 00000000000..0678c3e9251 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValue.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValueWithDefault.class b/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValueWithDefault.class new file mode 100644 index 00000000000..fd90b95434f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/LazyValueWithDefault.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/ReenteringLazyValueComputationException.class b/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/ReenteringLazyValueComputationException.class new file mode 100644 index 00000000000..040e092b9d9 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/lazy/ReenteringLazyValueComputationException.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/BasicWritableSlice$1.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/BasicWritableSlice$1.class new file mode 100644 index 00000000000..0c6d743fea3 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/BasicWritableSlice$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/BasicWritableSlice.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/BasicWritableSlice.class new file mode 100644 index 00000000000..ccb5efa8f0d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/BasicWritableSlice.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/DelegatingSlice.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/DelegatingSlice.class new file mode 100644 index 00000000000..aa37270d94d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/DelegatingSlice.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MapSupplier$1.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MapSupplier$1.class new file mode 100644 index 00000000000..f4367ce193e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MapSupplier$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MapSupplier$2.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MapSupplier$2.class new file mode 100644 index 00000000000..97f3e87a214 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MapSupplier$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MapSupplier.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MapSupplier.class new file mode 100644 index 00000000000..8178ed7bc70 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MapSupplier.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MutableSlicedMap.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MutableSlicedMap.class new file mode 100644 index 00000000000..f512cd4be59 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/MutableSlicedMap.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/ReadOnlySlice.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/ReadOnlySlice.class new file mode 100644 index 00000000000..a79ff6c447f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/ReadOnlySlice.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/RemovableSlice.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/RemovableSlice.class new file mode 100644 index 00000000000..76bca87817d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/RemovableSlice.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/RewritePolicy$1.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/RewritePolicy$1.class new file mode 100644 index 00000000000..8e0aa9e67a1 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/RewritePolicy$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/RewritePolicy.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/RewritePolicy.class new file mode 100644 index 00000000000..c72f0301972 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/RewritePolicy.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMap$1.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMap$1.class new file mode 100644 index 00000000000..ffb4605a274 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMap$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMap.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMap.class new file mode 100644 index 00000000000..746919e6e0b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMap.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMapImpl.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMapImpl.class new file mode 100644 index 00000000000..3f7cab3121e Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMapImpl.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMapKey.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMapKey.class new file mode 100644 index 00000000000..1089949a15f Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/SlicedMapKey.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$1.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$1.class new file mode 100644 index 00000000000..aa44838517d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$BasicRemovableSlice.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$BasicRemovableSlice.class new file mode 100644 index 00000000000..7de302ad3e5 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$BasicRemovableSlice.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$KeyNormalizer$1.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$KeyNormalizer$1.class new file mode 100644 index 00000000000..56127f12ccd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$KeyNormalizer$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$KeyNormalizer.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$KeyNormalizer.class new file mode 100644 index 00000000000..9fbb414f2cd Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$KeyNormalizer.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SetSlice.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SetSlice.class new file mode 100644 index 00000000000..06da9c1439b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SetSlice.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceBuilder$1.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceBuilder$1.class new file mode 100644 index 00000000000..3d5567c86bb Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceBuilder$1.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceBuilder$2.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceBuilder$2.class new file mode 100644 index 00000000000..6d43b1c998a Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceBuilder$2.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceBuilder.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceBuilder.class new file mode 100644 index 00000000000..f747dc4941d Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceBuilder.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceWithOpposite.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceWithOpposite.class new file mode 100644 index 00000000000..5f356d8c59b Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices$SliceWithOpposite.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices.class new file mode 100644 index 00000000000..33e1015e5ac Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/Slices.class differ diff --git a/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/WritableSlice.class b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/WritableSlice.class new file mode 100644 index 00000000000..181bf6c5169 Binary files /dev/null and b/k2js/out/production/frontend/org/jetbrains/jet/util/slicedmap/WritableSlice.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/InternalCompilerException.class b/k2js/out/production/js/com/google/dart/compiler/InternalCompilerException.class new file mode 100644 index 00000000000..e90e21f352b Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/InternalCompilerException.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/Source.class b/k2js/out/production/js/com/google/dart/compiler/Source.class new file mode 100644 index 00000000000..c1bbb35bbdd Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/Source.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/Cloner.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/Cloner.class new file mode 100644 index 00000000000..f98d0647b07 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/Cloner.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.class new file mode 100644 index 00000000000..bd899df681e Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsFirstExpressionVisitor.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsFirstExpressionVisitor.class new file mode 100644 index 00000000000..d29f46c9242 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsFirstExpressionVisitor.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNamer.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNamer.class new file mode 100644 index 00000000000..a2f3be662d5 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNamer.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNormalizer$1.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNormalizer$1.class new file mode 100644 index 00000000000..4f5caf72c85 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNormalizer$1.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNormalizer$JsNormalizing.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNormalizer$JsNormalizing.class new file mode 100644 index 00000000000..9f224885d3b Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNormalizer$JsNormalizing.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNormalizer.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNormalizer.class new file mode 100644 index 00000000000..a1a2d171ba0 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsNormalizer.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsParserException$SourceDetail.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsParserException$SourceDetail.class new file mode 100644 index 00000000000..7530587299c Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsParserException$SourceDetail.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsParserException.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsParserException.class new file mode 100644 index 00000000000..261c4e62b1a Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsParserException.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsPrecedenceVisitor.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsPrecedenceVisitor.class new file mode 100644 index 00000000000..8590bb12921 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsPrecedenceVisitor.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsPrettyNamer.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsPrettyNamer.class new file mode 100644 index 00000000000..ec7ea5d1c55 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsPrettyNamer.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsRequiresSemiVisitor.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsRequiresSemiVisitor.class new file mode 100644 index 00000000000..c1fee06ba8b Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsRequiresSemiVisitor.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsReservedIdentifiers.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsReservedIdentifiers.class new file mode 100644 index 00000000000..447a2842d95 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsReservedIdentifiers.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsSourceGenerationVisitor.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsSourceGenerationVisitor.class new file mode 100644 index 00000000000..86b0c5fc0a1 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsSourceGenerationVisitor.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/JsToStringGenerationVisitor.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsToStringGenerationVisitor.class new file mode 100644 index 00000000000..483876a133a Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/JsToStringGenerationVisitor.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/UncheckedJsParserException.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/UncheckedJsParserException.class new file mode 100644 index 00000000000..bf1ea91ee01 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/UncheckedJsParserException.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/CanBooleanEval.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/CanBooleanEval.class new file mode 100644 index 00000000000..0f8c465b259 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/CanBooleanEval.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/HasArguments.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/HasArguments.class new file mode 100644 index 00000000000..08c78a57dd9 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/HasArguments.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/HasCondition.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/HasCondition.class new file mode 100644 index 00000000000..feb9659dee5 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/HasCondition.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/HasName.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/HasName.class new file mode 100644 index 00000000000..e713e590e4c Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/HasName.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsArrayAccess.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsArrayAccess.class new file mode 100644 index 00000000000..4f12989a7dd Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsArrayAccess.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsArrayLiteral.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsArrayLiteral.class new file mode 100644 index 00000000000..a2d486bbdbd Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsArrayLiteral.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBinaryOperation.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBinaryOperation.class new file mode 100644 index 00000000000..080e4cb0a90 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBinaryOperation.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBinaryOperator.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBinaryOperator.class new file mode 100644 index 00000000000..c2f33de9503 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBinaryOperator.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBlock.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBlock.class new file mode 100644 index 00000000000..0ca29337506 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBlock.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBooleanLiteral.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBooleanLiteral.class new file mode 100644 index 00000000000..e3bd7cbab2f Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBooleanLiteral.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBreak.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBreak.class new file mode 100644 index 00000000000..2ef7b216557 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsBreak.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCase.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCase.class new file mode 100644 index 00000000000..01164ddc925 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCase.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCatch.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCatch.class new file mode 100644 index 00000000000..69754fe5aa0 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCatch.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCatchScope$1.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCatchScope$1.class new file mode 100644 index 00000000000..c302d9fd1a0 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCatchScope$1.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCatchScope.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCatchScope.class new file mode 100644 index 00000000000..b8182b27596 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsCatchScope.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsConditional.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsConditional.class new file mode 100644 index 00000000000..93c438e5696 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsConditional.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsContext.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsContext.class new file mode 100644 index 00000000000..67151644783 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsContext.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsContinue.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsContinue.class new file mode 100644 index 00000000000..74bd3e0192e Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsContinue.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsDebugger.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsDebugger.class new file mode 100644 index 00000000000..56e908cbb5b Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsDebugger.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsDefault.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsDefault.class new file mode 100644 index 00000000000..3e725b1cb6c Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsDefault.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsDoWhile.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsDoWhile.class new file mode 100644 index 00000000000..e2b0a2f833f Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsDoWhile.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsEmpty.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsEmpty.class new file mode 100644 index 00000000000..6903d45f4b9 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsEmpty.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsExprStmt.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsExprStmt.class new file mode 100644 index 00000000000..8bedf484039 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsExprStmt.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsExpression.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsExpression.class new file mode 100644 index 00000000000..46042c4047e Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsExpression.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsFor.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsFor.class new file mode 100644 index 00000000000..55252602ad8 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsFor.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsForIn.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsForIn.class new file mode 100644 index 00000000000..c7c9f723fe0 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsForIn.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsFunction.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsFunction.class new file mode 100644 index 00000000000..981d3a8a86a Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsFunction.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsGlobalBlock.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsGlobalBlock.class new file mode 100644 index 00000000000..d2551ba57e3 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsGlobalBlock.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsIf.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsIf.class new file mode 100644 index 00000000000..ac1a529bc78 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsIf.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsInvocation.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsInvocation.class new file mode 100644 index 00000000000..79397ce516a Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsInvocation.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsLabel.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsLabel.class new file mode 100644 index 00000000000..9458fff5d62 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsLabel.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsLiteral.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsLiteral.class new file mode 100644 index 00000000000..aa95bc0b81e Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsLiteral.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$1.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$1.class new file mode 100644 index 00000000000..cf2dfd079ce Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$1.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$ListContext.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$ListContext.class new file mode 100644 index 00000000000..875e314b49e Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$ListContext.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$LvalueContext.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$LvalueContext.class new file mode 100644 index 00000000000..39052ed7ff0 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$LvalueContext.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$NodeContext.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$NodeContext.class new file mode 100644 index 00000000000..2aa9d3e97b8 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor$NodeContext.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor.class new file mode 100644 index 00000000000..3b17c877718 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsModVisitor.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsName.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsName.class new file mode 100644 index 00000000000..06cdd835eaa Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsName.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNameRef.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNameRef.class new file mode 100644 index 00000000000..4f321ba01b4 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNameRef.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNew.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNew.class new file mode 100644 index 00000000000..ec1eb5eec96 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNew.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNode.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNode.class new file mode 100644 index 00000000000..1d6645609ad Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNode.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNullLiteral.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNullLiteral.class new file mode 100644 index 00000000000..5125d7d6734 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNullLiteral.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNumberLiteral.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNumberLiteral.class new file mode 100644 index 00000000000..306ec87b9e1 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsNumberLiteral.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsObjectLiteral.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsObjectLiteral.class new file mode 100644 index 00000000000..c7a311a68eb Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsObjectLiteral.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsOperator.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsOperator.class new file mode 100644 index 00000000000..5aa8ee16f29 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsOperator.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsParameter.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsParameter.class new file mode 100644 index 00000000000..0a6a39dedb7 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsParameter.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsPostfixOperation.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsPostfixOperation.class new file mode 100644 index 00000000000..c0cc818da1d Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsPostfixOperation.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.class new file mode 100644 index 00000000000..f310664e665 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsProgram.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsProgram.class new file mode 100644 index 00000000000..d14a8704abc Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsProgram.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsProgramFragment.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsProgramFragment.class new file mode 100644 index 00000000000..610b487220a Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsProgramFragment.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.class new file mode 100644 index 00000000000..1d4c754e71e Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsRegExp.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsRegExp.class new file mode 100644 index 00000000000..269aeb19cb8 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsRegExp.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsReturn.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsReturn.class new file mode 100644 index 00000000000..32af8941698 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsReturn.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsRootScope.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsRootScope.class new file mode 100644 index 00000000000..675ec034567 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsRootScope.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsScope.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsScope.class new file mode 100644 index 00000000000..ce11a8356dc Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsScope.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsStatement.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsStatement.class new file mode 100644 index 00000000000..4e2da233947 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsStatement.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsStringLiteral.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsStringLiteral.class new file mode 100644 index 00000000000..aecd3760012 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsStringLiteral.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsSwitch.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsSwitch.class new file mode 100644 index 00000000000..fb06aa9d5fc Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsSwitch.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsSwitchMember.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsSwitchMember.class new file mode 100644 index 00000000000..22974f03fe4 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsSwitchMember.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsThisRef.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsThisRef.class new file mode 100644 index 00000000000..6f2c76e92f4 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsThisRef.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsThrow.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsThrow.class new file mode 100644 index 00000000000..816f332556e Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsThrow.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsTry.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsTry.class new file mode 100644 index 00000000000..c0e40e2af87 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsTry.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsUnaryOperation.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsUnaryOperation.class new file mode 100644 index 00000000000..c51260cb92c Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsUnaryOperation.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsUnaryOperator.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsUnaryOperator.class new file mode 100644 index 00000000000..72c8784bb7a Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsUnaryOperator.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsValueLiteral.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsValueLiteral.class new file mode 100644 index 00000000000..5481c5cd317 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsValueLiteral.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVars$JsVar.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVars$JsVar.class new file mode 100644 index 00000000000..93212c2af77 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVars$JsVar.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVars.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVars.class new file mode 100644 index 00000000000..c369ad56705 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVars.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitable.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitable.class new file mode 100644 index 00000000000..10651420c8c Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitable.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitor$1.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitor$1.class new file mode 100644 index 00000000000..f801d2780d4 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitor$1.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitor$2.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitor$2.class new file mode 100644 index 00000000000..a5437dce68c Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitor$2.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitor.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitor.class new file mode 100644 index 00000000000..09102391519 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsVisitor.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsWhile.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsWhile.class new file mode 100644 index 00000000000..d8ad387e9cb Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/JsWhile.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/NodeKind.class b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/NodeKind.class new file mode 100644 index 00000000000..a81b8f957ec Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/backend/js/ast/NodeKind.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/common/AbstractNode.class b/k2js/out/production/js/com/google/dart/compiler/common/AbstractNode.class new file mode 100644 index 00000000000..956f713b4f3 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/common/AbstractNode.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/common/HasSourceInfo.class b/k2js/out/production/js/com/google/dart/compiler/common/HasSourceInfo.class new file mode 100644 index 00000000000..9cd3d54d59c Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/common/HasSourceInfo.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/common/Name.class b/k2js/out/production/js/com/google/dart/compiler/common/Name.class new file mode 100644 index 00000000000..62dbf1c9281 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/common/Name.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/common/NameFactory$FakeKey.class b/k2js/out/production/js/com/google/dart/compiler/common/NameFactory$FakeKey.class new file mode 100644 index 00000000000..2b72e01fc04 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/common/NameFactory$FakeKey.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/common/NameFactory$RealKey.class b/k2js/out/production/js/com/google/dart/compiler/common/NameFactory$RealKey.class new file mode 100644 index 00000000000..6e75def2dc7 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/common/NameFactory$RealKey.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/common/NameFactory.class b/k2js/out/production/js/com/google/dart/compiler/common/NameFactory.class new file mode 100644 index 00000000000..49ab0778638 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/common/NameFactory.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/common/SourceInfo.class b/k2js/out/production/js/com/google/dart/compiler/common/SourceInfo.class new file mode 100644 index 00000000000..d519868779d Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/common/SourceInfo.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/util/AbstractTextOutput.class b/k2js/out/production/js/com/google/dart/compiler/util/AbstractTextOutput.class new file mode 100644 index 00000000000..c7fb5102c0a Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/util/AbstractTextOutput.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/util/AstUtil$Mutator.class b/k2js/out/production/js/com/google/dart/compiler/util/AstUtil$Mutator.class new file mode 100644 index 00000000000..4ad65a73be1 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/util/AstUtil$Mutator.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/util/AstUtil$SaveLastExpressionMutator.class b/k2js/out/production/js/com/google/dart/compiler/util/AstUtil$SaveLastExpressionMutator.class new file mode 100644 index 00000000000..544df59a35e Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/util/AstUtil$SaveLastExpressionMutator.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/util/AstUtil.class b/k2js/out/production/js/com/google/dart/compiler/util/AstUtil.class new file mode 100644 index 00000000000..55145d5c001 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/util/AstUtil.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/util/DefaultTextOutput.class b/k2js/out/production/js/com/google/dart/compiler/util/DefaultTextOutput.class new file mode 100644 index 00000000000..e8b8e9bba94 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/util/DefaultTextOutput.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/util/Hack.class b/k2js/out/production/js/com/google/dart/compiler/util/Hack.class new file mode 100644 index 00000000000..1e8fa5d2c8e Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/util/Hack.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/util/Lists.class b/k2js/out/production/js/com/google/dart/compiler/util/Lists.class new file mode 100644 index 00000000000..835e058e9c0 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/util/Lists.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/util/Maps.class b/k2js/out/production/js/com/google/dart/compiler/util/Maps.class new file mode 100644 index 00000000000..729c1d10a67 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/util/Maps.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/util/Paths.class b/k2js/out/production/js/com/google/dart/compiler/util/Paths.class new file mode 100644 index 00000000000..6f2e67fa4b4 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/util/Paths.class differ diff --git a/k2js/out/production/js/com/google/dart/compiler/util/TextOutput.class b/k2js/out/production/js/com/google/dart/compiler/util/TextOutput.class new file mode 100644 index 00000000000..0bcead984a9 Binary files /dev/null and b/k2js/out/production/js/com/google/dart/compiler/util/TextOutput.class differ diff --git a/k2js/out/production/jslib/core/Dummy.class b/k2js/out/production/jslib/core/Dummy.class new file mode 100644 index 00000000000..513f8142ae4 Binary files /dev/null and b/k2js/out/production/jslib/core/Dummy.class differ diff --git a/k2js/out/production/jslib/core/annotations.kt b/k2js/out/production/jslib/core/annotations.kt new file mode 100644 index 00000000000..f63aff178ae --- /dev/null +++ b/k2js/out/production/jslib/core/annotations.kt @@ -0,0 +1,5 @@ +package js; +native +annotation class native(name : String = "") {} +native +annotation class library(name : String = "") {} \ No newline at end of file diff --git a/k2js/out/production/jslib/core/core.kt b/k2js/out/production/jslib/core/core.kt new file mode 100644 index 00000000000..1edf565e29d --- /dev/null +++ b/k2js/out/production/jslib/core/core.kt @@ -0,0 +1,39 @@ +package js; + +import js.library +import js.native +import java.util.*; + + + +native +val noImpl : Nothing = throw Exception(); + +library("println") +fun println() {} +library("println") +fun println(s : Any?) {} +library("print") +fun print(s : Any?) {} +library("parseInt") +fun parseInt(s : String) : Int = 0 +library +open class Exception() {} +library +class NumberFormatException() : Exception() {} + +native +fun setTimeout(callback : ()-> Unit) {} + +native +fun setInterval(callback : ()-> Unit, ms : Int) {} +native +fun setInterval(callback : ()-> Unit) {} + + +native +open class DomElement() { + val offsetLeft = 0.0; + val offsetTop = 0.0; + val offsetParent : DomElement? = DomElement(); +} diff --git a/k2js/out/production/jslib/core/javalang.kt b/k2js/out/production/jslib/core/javalang.kt new file mode 100644 index 00000000000..1cb140116f0 --- /dev/null +++ b/k2js/out/production/jslib/core/javalang.kt @@ -0,0 +1,14 @@ +package java.lang + +import java.util.Iterator; +import js.library + +library +trait Iterable { + fun iterator() : java.util.Iterator {} +} + +library("splitString") +public fun String.split(regex : String) : Array { +} + diff --git a/k2js/out/production/jslib/core/javautil.kt b/k2js/out/production/jslib/core/javautil.kt new file mode 100644 index 00000000000..64a5101bc46 --- /dev/null +++ b/k2js/out/production/jslib/core/javautil.kt @@ -0,0 +1,175 @@ +package java.util + +import js.*; + + +library("collectionsMax") +public fun max(col : Collection, comp : Comparator) : T {} + +library +public trait Comparator { + fun compare(obj1 : T, obj2 : T) : Int; +} + +library("comparator") +public fun comparator(f : (T, T) -> Int) : Comparator {} + + +library +public open class Iterator() { + open fun next() : T {} + open fun hasNext() : Boolean {} +} + +library +val Collections = object { + library("collectionsMax") + public fun max(col : Collection, comp : Comparator) : T = js.noImpl +} + +library +public open class ArrayList() : java.util.List { + override public fun size() : Int {} + override public fun isEmpty() : Boolean {} + override public fun contains(o : Any?) : Boolean {} + override public fun iterator() : Iterator {} + // override public fun indexOf(o : Any?) : Int {} + // override public fun lastIndexOf(o : Any?) : Int {} + // override public fun toArray() : Array {} + // override public fun toArray(a : Array) : Array {} + override public fun get(index : Int) : E {} + override public fun set(index : Int, element : E) : E {} + override public fun add(e : E) : Boolean {} + override public fun add(index : Int, element : E) : Unit {} + override public fun remove(index : Int) : E {} + override public fun remove(o : Any?) : Boolean {} + override public fun clear() : Unit {} + override public fun addAll(c : java.util.Collection) : Boolean {} + // override public fun addAll(index : Int, c : java.util.Collection) : Boolean {} +} + +library +public trait Collection : java.lang.Iterable { + open fun size() : Int + open fun isEmpty() : Boolean + open fun contains(o : Any?) : Boolean + override fun iterator() : java.util.Iterator + // open fun toArray() : Array + // open fun toArray(a : Array) : Array + open fun add(e : E) : Boolean + open fun remove(o : Any?) : Boolean + //open fun containsAll(c : java.util.Collection<*>) : Boolean + open fun addAll(c : java.util.Collection) : Boolean + //open fun removeAll(c : java.util.Collection<*>) : Boolean + //open fun retainAll(c : java.util.Collection<*>) : Boolean + open fun clear() : Unit +} + +library +public trait List : Collection { + override fun size() : Int + override fun isEmpty() : Boolean + override fun contains(o : Any?) : Boolean + override fun iterator() : java.util.Iterator + // override fun toArray() : Array + // Simulate Java's array covariance + // override fun toArray(a : Array) : Array + override fun add(e : E) : Boolean + override fun remove(o : Any?) : Boolean + // override fun containsAll(c : java.util.Collection<*>) : Boolean + override fun addAll(c : java.util.Collection) : Boolean + // open fun addAll(index : Int, c : java.util.Collection) : Boolean + // override fun removeAll(c : java.util.Collection<*>) : Boolean + // override fun retainAll(c : java.util.Collection<*>) : Boolean + override fun clear() : Unit + open fun get(index : Int) : E + open fun set(index : Int, element : E) : E + open fun add(index : Int, element : E) : Unit + open fun remove(index : Int) : E + // open fun indexOf(o : Any?) : Int + // open fun lastIndexOf(o : Any?) : Int +} + +library +public trait Set : Collection { + override fun size() : Int + override fun isEmpty() : Boolean + override fun contains(o : Any?) : Boolean + override fun iterator() : java.util.Iterator + // override fun toArray() : Array + // override fun toArray(a : Array) : Array + override fun add(e : E) : Boolean + override fun remove(o : Any?) : Boolean + //override fun containsAll(c : java.util.Collection<*>) : Boolean + override fun addAll(c : java.util.Collection) : Boolean + //override fun retainAll(c : java.util.Collection<*>) : Boolean + //override fun removeAll(c : java.util.Collection<*>) : Boolean + override fun clear() : Unit +} + +library +public open class HashSet() : java.util.Set { + override public fun iterator() : java.util.Iterator {} + override public fun size() : Int {} + override public fun isEmpty() : Boolean {} + override public fun contains(o : Any?) : Boolean {} + override public fun add(e : E) : Boolean {} + override public fun remove(o : Any?) : Boolean {} + override public fun clear() : Unit {} + override fun addAll(c : java.util.Collection) : Boolean +} + +library +public trait Map { + open fun size() : Int + open fun isEmpty() : Boolean + open fun containsKey(key : Any?) : Boolean + open fun containsValue(value : Any?) : Boolean + open fun get(key : Any?) : V? + open fun put(key : K, value : V) : V? + open fun remove(key : Any?) : V? + open fun putAll(m : java.util.Map) : Unit + open fun clear() : Unit + open fun keySet() : java.util.Set + open fun values() : java.util.Collection +} + +library +public open class HashMap() : java.util.Map { + override public fun size() : Int {} + override public fun isEmpty() : Boolean {} + override public fun get(key : Any?) : V {} + override public fun containsKey(key : Any?) : Boolean {} + override public fun put(key : K, value : V) : V {} + override public fun putAll(m : java.util.Map) : Unit {} + override public fun remove(key : Any?) : V? {} + override public fun clear() : Unit {} + override public fun containsValue(value : Any?) : Boolean {} + override public fun keySet() : java.util.Set {} + override public fun values() : java.util.Collection {} +} + +library +public open class LinkedList() : List { + override public fun iterator() : java.util.Iterator {} + override public fun isEmpty() : Boolean {} + override public fun contains(o : Any?) : Boolean {} + override public fun size() : Int {} + override public fun add(e : E) : Boolean {} + override public fun remove(o : Any?) : Boolean {} + override public fun addAll(c : java.util.Collection) : Boolean {} + override public fun clear() : Unit {} + override public fun get(index : Int) : E {} + override public fun set(index : Int, element : E) : E {} + override public fun add(index : Int, element : E) : Unit {} + override public fun remove(index : Int) : E {} + public fun poll() : E? {} + public fun peek() : E? {} + public fun offer(e : E) : Boolean {} +} + +library +public class StringBuilder() { + public fun append(obj : Any) : StringBuilder + public fun toString() : String +} \ No newline at end of file diff --git a/k2js/out/production/jslib/core/json.kt b/k2js/out/production/jslib/core/json.kt new file mode 100644 index 00000000000..df624aad0be --- /dev/null +++ b/k2js/out/production/jslib/core/json.kt @@ -0,0 +1,18 @@ +package js + +import java.util.*; +import js.library + +native +class Json() { + +} + +library("jsonSet") +fun Json.set(paramName : String, value : Any?) : Unit {} + +library("jsonGet") +fun Json.get(paramName : String) : Any? = null + +library("jsonFromTuples") +fun json(vararg pairs : Tuple2) = Json() diff --git a/k2js/out/production/jslib/core/math.kt b/k2js/out/production/jslib/core/math.kt new file mode 100644 index 00000000000..3566b782aa6 --- /dev/null +++ b/k2js/out/production/jslib/core/math.kt @@ -0,0 +1,32 @@ +package js; + +import js.native + +native +class MathClass() { + val PI : Double = 1.0; + fun random() : Double = 0.0; + fun abs(value : Double) = 0.0 + fun acos(value : Double) = 0.0 + fun asin(value : Double) = 0.0 + fun atan(value : Double) = 0.0 + fun atan2(x : Double, y : Double) = 0.0 + fun cos(value : Double) = 0.0 + fun sin(value : Double) = 0.0 + fun exp(value : Double) = 0.0 + fun max(vararg values : Double) = 0.0 + fun max(vararg values : Int) : Int = js.noImpl + fun min(vararg values : Int) : Int = js.noImpl + fun min(vararg values : Double) = 0.0 + fun sqrt(value : Double) = 0.0 + fun tan(value : Double) = 0.0 + fun log(value : Double) = 0.0 + fun pow(base : Double, exp : Double) = 0.0 + fun round(value : Double) = 0.0 + fun floor(value : Double) = 0.0 + fun ceil(value : Double) = 0.0 + +} + +native +val Math = MathClass(); \ No newline at end of file diff --git a/k2js/out/production/jslib/helper/ip.kt b/k2js/out/production/jslib/helper/ip.kt new file mode 100644 index 00000000000..d6f47cc8296 --- /dev/null +++ b/k2js/out/production/jslib/helper/ip.kt @@ -0,0 +1,7 @@ +package ip.helper + +import html5.HTMLInputElement +import js.native + +native +fun getInputElement() : HTMLInputElement = js.noImpl \ No newline at end of file diff --git a/k2js/out/production/jslib/html5/canvas.kt b/k2js/out/production/jslib/html5/canvas.kt new file mode 100644 index 00000000000..6caa62ab6d4 --- /dev/null +++ b/k2js/out/production/jslib/html5/canvas.kt @@ -0,0 +1,117 @@ +package html5 + +import js.native +import js.DomElement + +native +class Context() { + fun save() { + } + fun restore() { + } + + fun scale(x : Double, y : Double) { + } + fun rotate(angle : Double) { + } + fun translate(x : Double, y : Double) { + } + + fun clearRect(x : Double, y : Double, w : Double, h : Double) { + } + fun fillRect(x : Double, y : Double, w : Double, h : Double) { + } + fun strokeRect(x : Double, y : Double, w : Double, h : Double) { + } + + var globalAlpha : Double = 1.0; + var strokeStyle : Any = "" + var fillStyle : Any = "" + var lineWidth : Double = 1.0 + var shadowOffsetX : Double = 0.0 + var shadowOffsetY : Double = 0.0 + var shadowBlur : Double = 0.0 + var shadowColor : String = "" + var font : String = "" + + fun beginPath() { + } + fun moveTo(x : Double, y : Double) { + } + fun closePath() { + } + + fun lineTo(x : Double, y : Double) { + } + fun quadraticCurveTo(cpx : Double, cpy : Double, x : Double, y : Double) { + } + fun bezierCurveTo(cp1x : Double, cp1y : Double, cp2x : Double, cp2y : Double, x : Double, y : Double) { + } + fun arcTo(x1 : Double, y1 : Double, x2 : Double, y2 : Double, radius : Double) { + } + fun arc(x : Double, y : Double, radius : Double, startAngle : Double, endAngle : Double, anticlockwise : Boolean) { + } + + fun rect(x : Double, y : Double, w : Double, h : Double) { + } + fun fill() { + } + fun stroke() { + } + + fun fillText(text : String, x : Double, y : Double) { + } + fun fillText(text : String, x : Double, y : Double, maxWidth : Double) { + } + fun strokeText(text : String, x : Double, y : Double) { + } + fun strokeText(text : String, x : Double, y : Double, maxWidth : Double) { + } + + fun measureText(text : String) : TextMetrics = TextMetrics(); + + fun drawImage(image : HTMLImageElement, dx : Double, dy : Double) { + } + fun drawImage(image : HTMLImageElement, dx: Double, dy: Double, dw: Double, dh: Double) { + } + fun drawImage(image : HTMLImageElement, sx: Double, sy: Double, + sw: Double, sh: Double, dx: Double, dy: Double, dw: Double, dh: Double) { + } + + fun createLinearGradient(x0 : Double, y0 : Double, x1 : Double, y1 : Double) : CanvasGradient = CanvasGradient() + fun createRadialGradient(x0 : Double, y0 : Double, r0 : Double, x1 : Double, y1 : Double, r1 : Double) : CanvasGradient = CanvasGradient(); + +} + +native +open class HTMLImageElement() : DomElement() { +} + +native +class CanvasGradient() { + fun addColorStop(offset : Double, color : String) {} +} + + +native +class Canvas() : DomElement() { + var width = 0.0; + var height = 0.0; + + //DOMString toDataURL(in optional DOMString type, in any... args); + fun toDataURL() : String = js.noImpl + fun toDataURL(typ : String) : String = js.noImpl +} + +native +class TextMetrics() { + val width : Int = 0 +} + +/*custom helpers*/ +native +fun getContext() : Context = Context(); +native +fun getCanvas() : Canvas = Canvas(); +native +fun getKotlinLogo() : HTMLImageElement = HTMLImageElement(); \ No newline at end of file diff --git a/k2js/out/production/jslib/html5/files.kt b/k2js/out/production/jslib/html5/files.kt new file mode 100644 index 00000000000..8e05d2af4ef --- /dev/null +++ b/k2js/out/production/jslib/html5/files.kt @@ -0,0 +1,37 @@ +package html5.files + +import js.native + +native +class FileReader() { + var onloadend : ((FileReaderEvent)->Unit)? = js.noImpl // + fun readAsDataURL(blob : Blob) = js.noImpl + val result : File = js.noImpl +} + +native +class FileReaderEvent() { + val target : FileReader = js.noImpl +} + +native +class FileList() { + fun item(index : Int) : File? = js.noImpl + val length : Int = js.noImpl +} + +native +class File() : Blob() { + val name : String = js.noImpl + // readonly attribute Date lastModifiedDate; +} + +native +open class Blob() { + val size : Int = js.noImpl + val `type` : String = js.noImpl + //Blob slice(optional long long start, + //optional long long end, + //optional DOMString contentType); + // +} diff --git a/k2js/out/production/jslib/html5/image.kt b/k2js/out/production/jslib/html5/image.kt new file mode 100644 index 00000000000..dc1ec502959 --- /dev/null +++ b/k2js/out/production/jslib/html5/image.kt @@ -0,0 +1,25 @@ +package html5 + +import js.Exception +import js.native +import js.DomElement +import html5.files.FileList + +native +class HTMLInputElement() : DomElement() { + val files : FileList = js.noImpl + var onchange : (HTMLInputElementEvent)->Unit = js.noImpl +} + +native +class HTMLInputElementEvent() { + val target : HTMLInputElement = js.noImpl +} + +native +class Image() : HTMLImageElement() { + var height : Int = js.noImpl + var width : Int = js.noImpl + var src : String = js.noImpl + var onload : ()->Unit = js.noImpl +} \ No newline at end of file diff --git a/k2js/out/production/jslib/jquery/common.kt b/k2js/out/production/jslib/jquery/common.kt new file mode 100644 index 00000000000..54ad3feb9dd --- /dev/null +++ b/k2js/out/production/jslib/jquery/common.kt @@ -0,0 +1,72 @@ +package jquery; + +import js.*; +import js.DomElement + +native +class JQuery() { + fun addClass(className : String) : JQuery = js.noImpl; + fun addClass(f : DomElement.(Int, String)->String) = js.noImpl; + + fun attr(attrName : String) = ""; + fun attr(attrName : String, value : String) = this; + + fun html() : String = ""; + fun html(s : String) = this; + fun html(f : DomElement.(Int, String)->String) = this; + + + fun hasClass(className : String) = true + fun removeClass(className : String) = this + fun height() = 0 + fun width() = 0 + + fun click() = this; + + fun mousedown(handler : DomElement.(MouseEvent)->Unit) = this; + fun mouseup(handler : DomElement.(MouseEvent)->Unit) = this; + fun mousemove(handler : DomElement.(MouseEvent)->Unit) = this; + + fun dblclick(handler : DomElement.(MouseClickEvent)->Unit) = this; + fun click(handler : DomElement.(MouseClickEvent)->Unit) = this; + + fun load(handler : DomElement.()->Unit) = this; + fun change(handler : DomElement.()->Unit) = this; + + fun append(str : String) = this; + fun ready(handler : ()->Unit) = this; + fun text(text : String) = this; + fun slideUp() = this; + fun hover(handlerInOut : DomElement.() -> Unit) = this; + fun hover(handlerIn : DomElement.() -> Unit, handlerOut : DomElement.() -> Unit) = this; + fun next() : JQuery = js.noImpl + fun parent() : JQuery = js.noImpl +} + +native +open class MouseEvent() { + val pageX : Double = 0.0; + val pageY : Double = 0.0; + fun preventDefault() {} + fun isDefaultPrevented() : Boolean = true; +} + +native +class MouseClickEvent() : MouseEvent() { + val which : Int = 0; +} + + + +native("$") +fun jq(selector : String) = JQuery(); +native("$") +fun jq(selector : String, context : DomElement) = JQuery(); +native("$") +fun jq(callback : () -> Unit) = JQuery(); +native("$") +fun jq(obj : JQuery) = JQuery(); +native("$") +fun jq(el : DomElement) = JQuery(); +native("$") +fun jq() = JQuery(); diff --git a/k2js/out/production/jslib/jquery/ui.kt b/k2js/out/production/jslib/jquery/ui.kt new file mode 100644 index 00000000000..e9ca87be43a --- /dev/null +++ b/k2js/out/production/jslib/jquery/ui.kt @@ -0,0 +1,15 @@ +package jquery.ui + + +//jquery UI +import jquery.JQuery +import js.native + +native +fun JQuery.buttonset() : JQuery = js.noImpl; +native +fun JQuery.dialog() : JQuery = js.noImpl; +native +fun JQuery.button() : JQuery = js.noImpl; +native +fun JQuery.accordion() : JQuery = js.noImpl diff --git a/k2js/out/production/jslib/pixastic/pixastic.kt b/k2js/out/production/jslib/pixastic/pixastic.kt new file mode 100644 index 00000000000..66bcf91bf97 --- /dev/null +++ b/k2js/out/production/jslib/pixastic/pixastic.kt @@ -0,0 +1,11 @@ +package jquery.pixastic + +import jquery.JQuery +import js.native + +native +fun JQuery.pixastic(actionName : String) = js.noImpl + +native +fun addAction(actionName : String, + process : (oldData : Array, newData : Array, width : Int, height : Int)->Unit) = js.noImpl \ No newline at end of file diff --git a/k2js/out/production/jslib/raphael/raphael.kt b/k2js/out/production/jslib/raphael/raphael.kt new file mode 100644 index 00000000000..e30b63b15c1 --- /dev/null +++ b/k2js/out/production/jslib/raphael/raphael.kt @@ -0,0 +1,62 @@ +package raphael + +import js.*; +import js.*; + +native +open class Element() { + + fun attr(name : String, value : Any?) : Element = this + fun attr(nameToValue : Json) : Element = this + + fun click(handler : Element.()-> Unit) = this; + + fun mouseover(handler : Element.() -> Unit) = this + fun mouseout(handler : Element.() -> Unit) = this + + + fun getTotalLength() : Double = 0.0 + fun getPointAtLength(length : Double) : Point {} + + fun animate(params : Json, ms : Int, callback : ()-> Unit) : Element {} + fun animate(params : Json, ms : Int, s : String) : Element {} + fun animate(params : Json, ms : Int) : Element {} + //fun mouse +} + +native +class Set() : Element() { + fun push(el : Element) {} +} + +native +class Paper() { + fun path(pathString : String) : Element = Element(); + fun path() : Element = Element(); + + fun ellipse(x : Int, y : Int, rx : Int, ry : Int) : Element {} + fun circle(x : Int, y : Int, r : Int) : Element {} + fun set() : Set {} + + val customAttributes : Json = Json(); +} + +native("Raphael") +fun Raphael(elementId : String, width : Int, height : Int) : Paper = Paper(); +native("Raphael") +fun Raphael(elementId : String, width : Int, height : Int, initFun : Paper.() -> Unit) : Unit {} + +native +fun getColor() : Color {} +native +fun resetColors() {} + +native +class Color() {} + +native +class Point() { + val x = 0 + val y = 0 + val alpha = 0 +} diff --git a/k2js/out/production/stdlib/Arrays.kt b/k2js/out/production/stdlib/Arrays.kt new file mode 100644 index 00000000000..48e1c8fc595 --- /dev/null +++ b/k2js/out/production/stdlib/Arrays.kt @@ -0,0 +1,103 @@ +package std + +import java.io.ByteArrayInputStream + +import java.util.Arrays + +// Array "constructor" +inline fun array(vararg t : T) : Array = t + +// "constructors" for primitive types array +inline fun doubleArray(vararg content : Double) = content + +inline fun floatArray(vararg content : Float) = content + +inline fun longArray(vararg content : Long) = content + +inline fun intArray(vararg content : Int) = content + +inline fun charArray(vararg content : Char) = content + +inline fun shortArray(vararg content : Short) = content + +inline fun byteArray(vararg content : Byte) = content + +inline fun booleanArray(vararg content : Boolean) = content + +inline fun ByteArray.binarySearch(key: Byte) = Arrays.binarySearch(this, key) +inline fun ShortArray.binarySearch(key: Short) = Arrays.binarySearch(this, key) +inline fun IntArray.binarySearch(key: Int) = Arrays.binarySearch(this, key) +inline fun LongArray.binarySearch(key: Long) = Arrays.binarySearch(this, key) +inline fun FloatArray.binarySearch(key: Float) = Arrays.binarySearch(this, key) +inline fun DoubleArray.binarySearch(key: Double) = Arrays.binarySearch(this, key) +inline fun CharArray.binarySearch(key: Char) = Arrays.binarySearch(this, key) + +inline fun ByteArray.binarySearch(fromIndex: Int, toIndex: Int, key: Byte) = Arrays.binarySearch(this, fromIndex, toIndex, key) +inline fun ShortArray.binarySearch(fromIndex: Int, toIndex: Int, key: Short) = Arrays.binarySearch(this, fromIndex, toIndex, key) +inline fun IntArray.binarySearch(fromIndex: Int, toIndex: Int, key: Int) = Arrays.binarySearch(this, fromIndex, toIndex, key) +inline fun LongArray.binarySearch(fromIndex: Int, toIndex: Int, key: Long) = Arrays.binarySearch(this, fromIndex, toIndex, key) +inline fun FloatArray.binarySearch(fromIndex: Int, toIndex: Int, key: Float) = Arrays.binarySearch(this, fromIndex, toIndex, key) +inline fun DoubleArray.binarySearch(fromIndex: Int, toIndex: Int, key: Double) = Arrays.binarySearch(this, fromIndex, toIndex, key) +inline fun CharArray.binarySearch(fromIndex: Int, toIndex: Int, key: Char) = Arrays.binarySearch(this, fromIndex, toIndex, key) + +/* +inline fun Array.binarySearch(key: T, comparator: fun(T,T):Int) = Arrays.binarySearch(this, key, object: java.util.Comparator { + override fun compare(a: T, b: T) = comparator(a, b) + + override fun equals(obj: Any?) = obj.identityEquals(this) +}) +*/ +inline fun BooleanArray.fill(value: Boolean) = Arrays.fill(this, value) +inline fun ByteArray.fill(value: Byte) = Arrays.fill(this, value) +inline fun ShortArray.fill(value: Short) = Arrays.fill(this, value) +inline fun IntArray.fill(value: Int) = Arrays.fill(this, value) +inline fun LongArray.fill(value: Long) = Arrays.fill(this, value) +inline fun FloatArray.fill(value: Float) = Arrays.fill(this, value) +inline fun DoubleArray.fill(value: Double) = Arrays.fill(this, value) +inline fun CharArray.fill(value: Char) = Arrays.fill(this, value) + +inline fun Array.fill(value: T) = Arrays.fill(this as Array, value) + +inline fun ByteArray.sort() = Arrays.sort(this) +inline fun ShortArray.sort() = Arrays.sort(this) +inline fun IntArray.sort() = Arrays.sort(this) +inline fun LongArray.sort() = Arrays.sort(this) +inline fun FloatArray.sort() = Arrays.sort(this) +inline fun DoubleArray.sort() = Arrays.sort(this) +inline fun CharArray.sort() = Arrays.sort(this) + +inline fun ByteArray.sort(fromIndex: Int, toIndex: Int) = Arrays.sort(this, fromIndex, toIndex) +inline fun ShortArray.sort(fromIndex: Int, toIndex: Int) = Arrays.sort(this, fromIndex, toIndex) +inline fun IntArray.sort(fromIndex: Int, toIndex: Int) = Arrays.sort(this, fromIndex, toIndex) +inline fun LongArray.sort(fromIndex: Int, toIndex: Int) = Arrays.sort(this, fromIndex, toIndex) +inline fun FloatArray.sort(fromIndex: Int, toIndex: Int) = Arrays.sort(this, fromIndex, toIndex) +inline fun DoubleArray.sort(fromIndex: Int, toIndex: Int) = Arrays.sort(this, fromIndex, toIndex) +inline fun CharArray.sort(fromIndex: Int, toIndex: Int) = Arrays.sort(this, fromIndex, toIndex) + +inline fun BooleanArray.copyOf(newLength: Int = this.size) = Arrays.copyOf(this, newLength) +inline fun ByteArray.copyOf(newLength: Int = this.size) = Arrays.copyOf(this, newLength) +inline fun ShortArray.copyOf(newLength: Int = this.size) = Arrays.copyOf(this, newLength) +inline fun IntArray.copyOf(newLength: Int = this.size) = Arrays.copyOf(this, newLength) +inline fun LongArray.copyOf(newLength: Int = this.size) = Arrays.copyOf(this, newLength) +inline fun FloatArray.copyOf(newLength: Int = this.size) = Arrays.copyOf(this, newLength) +inline fun DoubleArray.copyOf(newLength: Int = this.size) = Arrays.copyOf(this, newLength) +inline fun CharArray.copyOf(newLength: Int = this.size) = Arrays.copyOf(this, newLength) + +inline fun Array.copyOf(newLength: Int = this.size) : Array = Arrays.copyOf(this, newLength).sure() + +inline fun BooleanArray.copyOfRange(from: Int, to: Int) = Arrays.copyOfRange(this, from, to) +inline fun ByteArray.copyOfRange(from: Int, to: Int) = Arrays.copyOfRange(this, from, to) +inline fun ShortArray.copyOfRange(from: Int, to: Int) = Arrays.copyOfRange(this, from, to) +inline fun IntArray.copyOfRange(from: Int, to: Int) = Arrays.copyOfRange(this, from, to) +inline fun LongArray.copyOfRange(from: Int, to: Int) = Arrays.copyOfRange(this, from, to) +inline fun FloatArray.copyOfRange(from: Int, to: Int) = Arrays.copyOfRange(this, from, to) +inline fun DoubleArray.copyOfRange(from: Int, to: Int) = Arrays.copyOfRange(this, from, to) +inline fun CharArray.copyOfRange(from: Int, to: Int) = Arrays.copyOfRange(this, from, to) + +inline fun Array.copyOfRange(from: Int, to: Int) : Array = Arrays.copyOfRange(this, from, to).sure() + +inline val ByteArray.inputStream : ByteArrayInputStream + get() = ByteArrayInputStream(this) + +inline fun ByteArray.inputStream(offset: Int, length: Int) = ByteArrayInputStream(this, offset, length) + diff --git a/k2js/out/production/stdlib/Filter.kt b/k2js/out/production/stdlib/Filter.kt new file mode 100644 index 00000000000..bf458ae0fb8 --- /dev/null +++ b/k2js/out/production/stdlib/Filter.kt @@ -0,0 +1,64 @@ +package std + +import java.util.* +import java.lang.Iterable + +/* +Filters given iterator +*/ +inline fun java.util.Iterator.filter(f: (T)-> Boolean) : java.util.Iterator = FilterIterator(this, f) + +/* +Adds filtered elements in to given container +*/ +inline fun > java.lang.Iterable.filterTo(var container: U, filter: (T)->Boolean) : U { + for(element in this) { + if(filter(element)) + container.add(element) + } + return container +} + +/* +Create iterator filtering given java.lang.Iterable +*/ +/* +inline fun java.lang.Iterable.filter(f: (T)->Boolean) : java.util.Iterator = (iterator() as java.util.Iterator).filter(f) +*/ + +private class FilterIterator(val original: java.util.Iterator, val filter: (T)-> Boolean) : java.util.Iterator { + var state = 0 + var nextElement: T? = null + + override fun hasNext(): Boolean = + when(state) { + 1 -> true // checked and next present + 2 -> false // checked and next not present + else -> { + while(original.hasNext()) { + val candidate = original.next() + if((filter)(candidate)) { + nextElement = candidate + state = 1 + true + } + } + state = 2 + false + } + } + + override fun next(): T = + if(state != 1) + throw java.util.NoSuchElementException() + else { + val res = nextElement as T + nextElement = null + state = 0 + res + } + + override fun remove() { + throw java.lang.UnsupportedOperationException() + } +} diff --git a/k2js/out/production/stdlib/Integer.kt b/k2js/out/production/stdlib/Integer.kt new file mode 100644 index 00000000000..1010327414d --- /dev/null +++ b/k2js/out/production/stdlib/Integer.kt @@ -0,0 +1,18 @@ +package std + +inline fun Int.times(body : () -> Unit) { + var count = this; + while (count > 0) { + body() + count-- + } +} + +inline fun parseInt(str : String) : Int? { + try { + return Integer.parseInt(str).sure(); + } + catch (e : NumberFormatException) { + return null; + } +} diff --git a/k2js/out/production/stdlib/Iterators.kt b/k2js/out/production/stdlib/Iterators.kt new file mode 100644 index 00000000000..7b3087e952e --- /dev/null +++ b/k2js/out/production/stdlib/Iterators.kt @@ -0,0 +1,38 @@ +package std.util + +import java.util.* +import java.util.Iterator + +/* +Add iterated elements to given container +*/ +fun > java.util.Iterator.to(container: U) : U { + while(hasNext()) + container.add(next()) + return container +} + +/* +Add iterated elements to java.util.ArrayList +*/ +inline fun java.util.Iterator.toArrayList() = to(ArrayList()) + +/* +Add iterated elements to java.util.LinkedList +*/ +inline fun java.util.Iterator.toLinkedList() = to(LinkedList()) + +/* +Add iterated elements to java.util.HashSet +*/ +inline fun java.util.Iterator.toHashSet() = to(HashSet()) + +/* +Add iterated elements to java.util.LinkedHashSet +*/ +inline fun java.util.Iterator.toLinkedHashSet() = to(LinkedHashSet()) + +/* +Add iterated elements to java.util.TreeSet +*/ +inline fun java.util.Iterator.toTreeSet() = to(TreeSet()) diff --git a/k2js/out/production/stdlib/JavaCollections.kt b/k2js/out/production/stdlib/JavaCollections.kt new file mode 100644 index 00000000000..d788529d489 --- /dev/null +++ b/k2js/out/production/stdlib/JavaCollections.kt @@ -0,0 +1,10 @@ +package std.util + +import java.util.* + +/** Returns a new collection containing the results of applying the given function to each element in this collection */ +inline fun java.util.Collection.map(result: Collection = ArrayList(this.size), transform : (T) -> R) : Collection { + for (item in this) + result.add(transform(item)) + return result +} diff --git a/k2js/out/production/stdlib/JavaIo.kt b/k2js/out/production/stdlib/JavaIo.kt new file mode 100644 index 00000000000..5897db01e3f --- /dev/null +++ b/k2js/out/production/stdlib/JavaIo.kt @@ -0,0 +1,171 @@ +package std.io + +import java.io.* +import java.nio.charset.* +import java.util.NoSuchElementException + +inline fun print(message : Any?) { System.out?.print(message) } +inline fun print(message : Int) { System.out?.print(message) } +inline fun print(message : Long) { System.out?.print(message) } +inline fun print(message : Byte) { System.out?.print(message) } +inline fun print(message : Short) { System.out?.print(message) } +inline fun print(message : Char) { System.out?.print(message) } +inline fun print(message : Boolean) { System.out?.print(message) } +inline fun print(message : Float) { System.out?.print(message) } +inline fun print(message : Double) { System.out?.print(message) } +inline fun print(message : CharArray) { System.out?.print(message) } + +inline fun println(message : Any?) { System.out?.println(message) } +inline fun println(message : Int) { System.out?.println(message) } +inline fun println(message : Long) { System.out?.println(message) } +inline fun println(message : Byte) { System.out?.println(message) } +inline fun println(message : Short) { System.out?.println(message) } +inline fun println(message : Char) { System.out?.println(message) } +inline fun println(message : Boolean) { System.out?.println(message) } +inline fun println(message : Float) { System.out?.println(message) } +inline fun println(message : Double) { System.out?.println(message) } +inline fun println(message : CharArray) { System.out?.println(message) } +inline fun println() { System.out?.println() } + +private val stdin : BufferedReader = BufferedReader(InputStreamReader(object : InputStream() { + override fun read() : Int { + return System.`in`?.read() ?: -1 + } + + override fun reset() { + System.`in`?.reset() + } + + override fun read(b: ByteArray?): Int { + return System.`in`?.read(b) ?: -1 + } + + override fun close() { + System.`in`?.close() + } + + override fun mark(readlimit: Int) { + System.`in`?.mark(readlimit) + } + + override fun skip(n: Long): Long { + return System.`in`?.skip(n) ?: -1.lng + } + + override fun available(): Int { + return System.`in`?.available() ?: 0 + } + + override fun markSupported(): Boolean { + return System.`in`?.markSupported() ?: false + } + + override fun read(b: ByteArray?, off: Int, len: Int): Int { + return System.`in`?.read(b, off, len) ?: -1 + } +})) + +inline fun readLine() : String? = stdin.readLine() + +/** Uses the given resource then closes it to ensure its closed again */ +inline fun T.foreach(block: (T)-> R) : R { + var closed = false + try { + return block(this) + } catch (e: Exception) { + closed = true + try { + this.close() + } catch (closeException: Exception) { + // eat the closeException as we are already throwing the original cause + // and we don't want to mask the real exception + + // TODO on Java 7 we should call + // e.addSuppressed(closeException) + // to work like try-with-resources + // http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html#suppressed-exceptions + } + throw e + } finally { + if (!closed) { + this.close() + } + } +} + +fun InputStream.iterator() : ByteIterator = + object: ByteIterator() { + override val hasNext : Boolean + get() = available() > 0 + + override fun nextByte() = read().byt + } + +inline fun InputStream.buffered(bufferSize: Int) = BufferedInputStream(this, bufferSize) + +inline val InputStream.reader : InputStreamReader + get() = InputStreamReader(this) + +inline val InputStream.bufferedReader : BufferedReader + get() = BufferedReader(reader) + +inline fun InputStream.reader(charset: Charset) : InputStreamReader = InputStreamReader(this, charset) + +inline fun InputStream.reader(charsetName: String) = InputStreamReader(this, charsetName) + +inline fun InputStream.reader(charsetDecoder: CharsetDecoder) = InputStreamReader(this, charsetDecoder) + +inline val InputStream.buffered : BufferedInputStream + get() = if(this is BufferedInputStream) this else BufferedInputStream(this) + +// inline val Reader.buffered : BufferedReader +// get() = if(this is BufferedReader) this else BufferedReader(this) + +inline fun Reader.buffered(): BufferedReader = if(this is BufferedReader) this else BufferedReader(this) + +inline fun Reader.buffered(bufferSize: Int) = BufferedReader(this, bufferSize) + +inline fun Reader.foreachLine(block: (String) -> Unit): Unit { + this.foreach{ + val iter = buffered().lineIterator() + while (iter.hasNext) { + val elem = iter.next() + block(elem) + } + } +} + +inline fun Reader.useLines(block: (Iterator) -> T): T = this.buffered().foreach{block(it.lineIterator())} +/** + * Returns an iterator over each line. + * Note the caller must close the underlying BufferedReader + * when the iteration is finished; as the user may not complete the iteration loop (e.g. using a method like find() or any() on the iterator + * may terminate the iteration early. + *
+ * We suggest you try the method useLines() instead which closes the stream when the processing is complete. + */ +inline fun BufferedReader.lineIterator() : Iterator = LineIterator(this) + +protected class LineIterator(val reader: BufferedReader) : Iterator { + private var nextValue: String? = null + private var done = false + + override val hasNext: Boolean + get() { + if (nextValue == null && !done) { + nextValue = reader.readLine() + if (nextValue == null) done = true + } + return nextValue != null + } + + override fun next(): String { + if (!hasNext) { + throw NoSuchElementException() + } + val answer = nextValue + nextValue = null + return answer.sure() + } +} + diff --git a/k2js/out/production/stdlib/JavaIterables.kt b/k2js/out/production/stdlib/JavaIterables.kt new file mode 100644 index 00000000000..8815f7e929d --- /dev/null +++ b/k2js/out/production/stdlib/JavaIterables.kt @@ -0,0 +1,163 @@ +package std.util + +import java.util.* + +/** Returns true if any elements in the collection match the given predicate */ +inline fun java.lang.Iterable.any(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (predicate(elem)) { + return true + } + } + return false +} + +/** Returns true if all elements in the collection match the given predicate */ +inline fun java.lang.Iterable.all(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (!predicate(elem)) { + return false + } + } + return true +} + +/** Returns the number of items which match the given predicate */ +inline fun java.lang.Iterable.count(predicate: (T)-> Boolean) : Int { + var answer = 0 + for (elem in this) { + if (predicate(elem)) + answer += 1 + } + return answer +} + +/** Returns the first item in the collection which matches the given predicate or null if none matched */ +inline fun java.lang.Iterable.find(predicate: (T)-> Boolean) : T? { + for (elem in this) { + if (predicate(elem)) + return elem + } + return null +} + +/** Returns a new collection containing all elements in this collection which match the given predicate */ +inline fun java.lang.Iterable.filter(result: Collection = ArrayList(), predicate: (T)-> Boolean) : Collection { + for (elem in this) { + if (predicate(elem)) + result.add(elem) + } + return result +} + +/** Returns a new collection containing all elements in this collection which do not match the given predicate */ +inline fun java.lang.Iterable.filterNot(result: Collection = ArrayList(), predicate: (T)-> Boolean) : Collection { + for (elem in this) { + if (!predicate(elem)) + result.add(elem) + } + return result +} + +/** + * Returns the result of transforming each item in the collection to a one or more values which + * are concatenated together into a single collection + */ +inline fun java.lang.Iterable.flatMap(result: Collection = ArrayList(), transform: (T)-> Collection) : Collection { + for (elem in this) { + val coll = transform(elem) + if (coll != null) { + for (r in coll) { + result.add(r) + } + } + } + return result +} + +/** Performs the given operation on each element inside the collection */ +inline fun java.lang.Iterable.foreach(operation: (element: T) -> Unit) { + for (elem in this) + operation(elem) +} + +/** + * Folds all the values from from left to right with the initial value to perform the operation on sequential pairs of values + * + * For example to sum together all numeric values in a collection of numbers it would be + * {code}val total = numbers.fold(0){(a, b) -> a + b}{code} + */ +inline fun java.lang.Iterable.fold(initial: T, operation: (it: T, it2: T) -> T): T { + var answer = initial + for (elem in this) { + answer = operation(answer, elem) + } + return answer +} + +/** + * Folds all the values from right to left with the initial value to perform the operation on sequential pairs of values + */ +inline fun java.lang.Iterable.foldRight(initial: T, operation: (it: T, it2: T) -> T): T { + val reversed = this.reverse() + return reversed.fold(initial, operation) +} + +/** + * Iterates through the collection performing the transformation on each element and using the result + * as the key in a map to group elements by the result + */ +inline fun java.lang.Iterable.groupBy(result: Map> = HashMap>(), toKey: (T)-> K) : Map> { + for (elem in this) { + val key = toKey(elem) + val list = result.getOrElseUpdate(key){ ArrayList() } + list.add(elem) + } + return result +} + + +/** Creates a String from all the elements in the collection, using the seperator between them and using the given prefix and postfix if supplied */ +inline fun java.lang.Iterable.join(separator: String, prefix: String = "", postfix: String = "") : String { + val buffer = StringBuilder(prefix) + var first = true + for (elem in this) { + if (first) + first = false + else + buffer.append(separator) + buffer.append(elem) + } + buffer.append(postfix) + return buffer.toString().sure() +} + +/** Returns a reversed List of this collection */ +inline fun java.lang.Iterable.reverse() : List { + val answer = LinkedList() + for (elem in this) { + answer.addFirst(elem) + } + return answer +} + +inline fun > java.lang.Iterable.to(result: C) : C { + for (elem in this) + result.add(elem) + return result +} + +inline fun java.lang.Iterable.toLinkedList() : LinkedList = this.to(LinkedList()) + +inline fun java.lang.Iterable.toList() : List = this.to(ArrayList()) + +inline fun java.lang.Iterable.toSet() : Set = this.to(HashSet()) + +/** + TODO figure out necessary variance/generics ninja stuff... :) +inline fun java.lang.Iterable.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { + val answer = this.toList() + answer.sort(transform) + return answer +} +*/ diff --git a/k2js/out/production/stdlib/JavaIterablesSpecial.kt b/k2js/out/production/stdlib/JavaIterablesSpecial.kt new file mode 100644 index 00000000000..3a564fabeb8 --- /dev/null +++ b/k2js/out/production/stdlib/JavaIterablesSpecial.kt @@ -0,0 +1,85 @@ +package std.util +// Number of extension function for ava.lang.Iterable that shouldn't participate in auto generation + +import java.util.Collection +import java.util.List +import java.util.AbstractList + +/** + * Count the number of elements in collection. + * + * If base collection implements Collection interface method Collection#size() will be used. + * Otherwise, this method determines the count by iterating through the all items. + */ +fun java.lang.Iterable.count() : Int { + if (this is Collection) { + return this.size() + } + + var number : Int = 0 + for (elem in this) { + ++number + } + return number +} + +/** + * Get the first element in the collection. + * + * Will throw an exception if there are no elements + * TODO: Specify type of the exception + */ +inline fun java.lang.Iterable.first() : T { + if (this is AbstractList) { + return this.get(0) + } + + return this.iterator().sure().next() +} + +/** + * Get the last element in the collection. + * + * If base collection implements List interface, the combination of size() and get() + * methods will be used for getting last element. Otherwise, this method determines the + * last item by iterating through the all items. + * + * Will throw an exception if there are no elements. + * TODO: Specify type of the exception + */ +fun java.lang.Iterable.last() : T { + if (this is List) { + return this.get(this.size() - 1); + } + + val iterator = this.iterator().sure() + var last : T = iterator.next() + + while (iterator.hasNext()) { + last = iterator.next() + } + + return last; +} + +/** + * Checks if collection contains given item. + * + * Method checks equality of the objects with T.equals method. + * If collection implements java.util.AbstractCollection an overridden implementation of the contains + * method will be used. + */ +fun java.lang.Iterable.contains(item : T) : Boolean { + std.io.println("!!!!!") + if (this is java.util.AbstractCollection) { + return this.contains(item); + } + + for (var elem in this) { + if (elem.equals(item)) { + return true + } + } + + return false +} diff --git a/k2js/out/production/stdlib/JavaLang.kt b/k2js/out/production/stdlib/JavaLang.kt new file mode 100644 index 00000000000..66009d500cf --- /dev/null +++ b/k2js/out/production/stdlib/JavaLang.kt @@ -0,0 +1,14 @@ +package std + +import java.lang.Class +import java.lang.Object + +val T.javaClass : Class + get() = jet.runtime.Intrinsics.getJavaClass(this) as Class + +fun javaClass() : Class = (typeinfo() as org.jetbrains.jet.rt.TypeInfoImpl).getJavaClass().sure() + +val TypeInfo.javaClassForType : Class + get() { + return (this as org.jetbrains.jet.rt.TypeInfoImpl).getJavaClass().sure() + } diff --git a/k2js/out/production/stdlib/JavaMath.kt b/k2js/out/production/stdlib/JavaMath.kt new file mode 100644 index 00000000000..726ad082f58 --- /dev/null +++ b/k2js/out/production/stdlib/JavaMath.kt @@ -0,0 +1,27 @@ +package std.math + +import java.math.BigInteger +import java.math.BigDecimal + +fun BigInteger.plus(other: BigInteger) = this.add(other).sure() + +fun BigInteger.minus(other: BigInteger) = this.subtract(other).sure() + +fun BigInteger.times(other: BigInteger) = this.multiply(other).sure() + +fun BigInteger.div(other: BigInteger) = this.divide(other).sure() + +fun BigInteger.minus() = this.negate().sure() + + +fun BigDecimal.plus(other: BigDecimal) = this.add(other).sure() + +fun BigDecimal.minus(other: BigDecimal) = this.subtract(other).sure() + +fun BigDecimal.times(other: BigDecimal) = this.multiply(other).sure() + +fun BigDecimal.div(other: BigDecimal) = this.divide(other).sure() + +fun BigDecimal.mod(other: BigDecimal) = this.remainder(other).sure() + +fun BigDecimal.minus() = this.negate().sure() \ No newline at end of file diff --git a/k2js/out/production/stdlib/JavaUtil.kt b/k2js/out/production/stdlib/JavaUtil.kt new file mode 100644 index 00000000000..36fc28165ec --- /dev/null +++ b/k2js/out/production/stdlib/JavaUtil.kt @@ -0,0 +1,86 @@ +package std.util + +import java.util.* + +/** Returns the size of the collection */ +val Collection<*>.size : Int + get() = size() + +/** Returns true if this collection is empty */ +val Collection<*>.empty : Boolean + get() = isEmpty() + +/** Returns a new ArrayList with a variable number of initial elements */ +inline fun arrayList(vararg values: T) : ArrayList = values.to(ArrayList(values.size)) + +/** Returns a new LinkedList with a variable number of initial elements */ +inline fun linkedList(vararg values: T) : LinkedList = values.to(LinkedList()) + +/** Returns a new HashSet with a variable number of initial elements */ +inline fun hashSet(vararg values: T) : HashSet = values.to(HashSet(values.size)) + +val Collection<*>.indices : IntRange + get() = 0..size-1 + +inline fun java.util.Collection.toArray() : Array { + val answer = Array(this.size) + var idx = 0 + for (elem in this) + answer[idx++] = elem + return answer as Array +} + +/** TODO these functions don't work when they generate the Array versions when they are in JavaIterables */ +inline fun > java.lang.Iterable.toSortedList() : List = toList().sort() + +inline fun > java.lang.Iterable.toSortedList(comparator: java.util.Comparator) : List = toList().sort(comparator) + + + +// List APIs + +inline fun > List.sort() : List { + Collections.sort(this) + return this +} + +inline fun > List.sort(comparator: java.util.Comparator) : List { + Collections.sort(this, comparator) + return this +} + +/** + TODO figure out necessary variance/generics ninja stuff... :) +inline fun List.sort(transform: fun(T) : java.lang.Comparable<*>) : List { + val comparator = java.util.Comparator() { + fun compare(o1: T, o2: T): Int { + val v1 = transform(o1) + val v2 = transform(o2) + if (v1 == v2) { + return 0 + } else { + return v1.compareTo(v2) + } + } + } + answer.sort(comparator) +} +*/ + +val List.head : T? + get() = this.get(0) + +val List.first : T? + get() = this.head + +val List.tail : T? + get() { + val s = this.size + return if (s > 0) this.get(s - 1) else null + } + +val List.last : T? + get() = this.tail + + + diff --git a/k2js/out/production/stdlib/JavaUtilMap.kt b/k2js/out/production/stdlib/JavaUtilMap.kt new file mode 100644 index 00000000000..cafdafc967d --- /dev/null +++ b/k2js/out/production/stdlib/JavaUtilMap.kt @@ -0,0 +1,52 @@ +package std.util + +import java.util.Map as JMap + +// Temporary workaround: commenting out +//import java.util.Map.Entry as JEntry + +// Map APIs + +/** Returns the size of the map */ +val JMap<*,*>.size : Int + get() = size() + +/** Returns true if this map is empty */ +val JMap<*,*>.empty : Boolean + get() = isEmpty() + +/** Provides [] access to maps */ +fun JMap.set(key : K, value : V) = this.put(key, value) + + +/** Returns the key of the entry */ +// Temporary workaround: commenting out +//val JEntry.key : K +// get() = getKey().sure() + +/** Returns the value of the entry */ +// Temporary workaround: commenting out +//val JEntry.value : V +// get() = getValue().sure() + +/** Returns the value for the given key or returns the result of the defaultValue function if there was no entry for the given key */ +inline fun java.util.Map.getOrElse(key: K, defaultValue: ()-> V) : V { + val current = this.get(key) + if (current != null) { + return current + } else { + return defaultValue() + } +} + +/** Returns the value for the given key or the result of the defaultValue function is put into the map for the given value and returned */ +inline fun java.util.Map.getOrElseUpdate(key: K, defaultValue: ()-> V) : V { + val current = this.get(key) + if (current != null) { + return current + } else { + val answer = defaultValue() + this.put(key, answer) + return answer + } +} diff --git a/k2js/out/production/stdlib/Standard.kt b/k2js/out/production/stdlib/Standard.kt new file mode 100644 index 00000000000..bcbd9db2ac1 --- /dev/null +++ b/k2js/out/production/stdlib/Standard.kt @@ -0,0 +1,71 @@ +package std + +import java.util.Collection +import java.util.ArrayList +import java.util.LinkedList +import java.util.HashSet +import java.util.LinkedHashSet +import java.util.TreeSet + +/* +Helper to make jet.Iterator usable in for +*/ +inline fun jet.Iterator.iterator() = this + +/* +Helper to make java.util.Iterator usable in for +*/ +inline fun java.util.Iterator.iterator() = this + +/* +Helper to make java.util.Enumeration usable in for +*/ +fun java.util.Enumeration.iterator(): Iterator = object: Iterator { + override val hasNext: Boolean + get() = hasMoreElements() + + override fun next() = nextElement() +} + +/* + * Extension functions on the standard Kotlin types to behave like the java.lang.* and java.util.* collections + */ + +/* +Add iterated elements to given container +*/ +fun > Iterator.to(container: U) : U { + while(hasNext) + container.add(next()) + return container +} + +/* +Add iterated elements to java.util.ArrayList +*/ +inline fun Iterator.toArrayList() = to(ArrayList()) + +/* +Add iterated elements to java.util.LinkedList +*/ +inline fun Iterator.toLinkedList() = to(LinkedList()) + +/* +Add iterated elements to java.util.HashSet +*/ +inline fun Iterator.toHashSet() = to(HashSet()) + +/* +Add iterated elements to java.util.LinkedHashSet +*/ +inline fun Iterator.toLinkedHashSet() = to(LinkedHashSet()) + +/* +Add iterated elements to java.util.TreeSet +*/ +inline fun Iterator.toTreeSet() = to(TreeSet()) + +/* +Run function f +*/ +inline fun run(f: () -> T) = f() diff --git a/k2js/out/production/stdlib/String.kt b/k2js/out/production/stdlib/String.kt new file mode 100644 index 00000000000..e756e338ff4 --- /dev/null +++ b/k2js/out/production/stdlib/String.kt @@ -0,0 +1,83 @@ +package std + +import java.io.StringReader + +inline fun String.lastIndexOf(s: String) = (this as java.lang.String).lastIndexOf(s) + +inline fun String.lastIndexOf(s: Char) = (this as java.lang.String).lastIndexOf(s.toString()) + +inline fun String.equalsIgnoreCase(s: String) = (this as java.lang.String).equalsIgnoreCase(s) + +inline fun String.indexOf(s : String) = (this as java.lang.String).indexOf(s) + +inline fun String.indexOf(p0 : String, p1 : Int) = (this as java.lang.String).indexOf(p0, p1) + +inline fun String.replace(s: Char, s1 : Char) = (this as java.lang.String).replace(s, s1).sure() + +inline fun String.replaceAll(s: String, s1 : String) = (this as java.lang.String).replaceAll(s, s1).sure() + +inline fun String.trim() = (this as java.lang.String).trim().sure() + +inline fun String.toUpperCase() = (this as java.lang.String).toUpperCase().sure() + +inline fun String.toLowerCase() = (this as java.lang.String).toLowerCase().sure() + +inline fun String.length() = (this as java.lang.String).length() + +inline fun String.getBytes() = (this as java.lang.String).getBytes().sure() + +inline fun String.toCharArray() = (this as java.lang.String).toCharArray().sure() + +inline fun String.format(s : String, vararg objects : Any?) = java.lang.String.format(s, objects).sure() + +inline fun String.split(s : String) = (this as java.lang.String).split(s) + +inline fun String.substring(i : Int) = (this as java.lang.String).substring(i).sure() + +inline fun String.substring(i0 : Int, i1 : Int) = (this as java.lang.String).substring(i0, i1).sure() + +inline fun String.startsWith(prefix: String) = (this as java.lang.String).startsWith(prefix) + +inline fun String.startsWith(prefix: String, toffset: Int) = (this as java.lang.String).startsWith(prefix, toffset) + +inline fun String.contains(seq: CharSequence) : Boolean = (this as java.lang.String).contains(seq) + +inline fun String.endsWith(seq: String) : Boolean = (this as java.lang.String).endsWith(seq) + +inline val String.size : Int + get() = length() + +inline val String.reader : StringReader + get() = StringReader(this) + +// "constructors" for String + +inline fun String(bytes : ByteArray, i : Int, i1 : Int, s : String) = java.lang.String(bytes, i, i1, s) as String + +inline fun String(bytes : ByteArray, i : Int, i1 : Int, charset : java.nio.charset.Charset) = java.lang.String(bytes, i, i1, charset) as String + +inline fun String(bytes : ByteArray, s : String?) = java.lang.String(bytes, s) as String + +inline fun String(bytes : ByteArray, charset : java.nio.charset.Charset) = java.lang.String(bytes, charset) as String + +inline fun String(bytes : ByteArray, i : Int, i1 : Int) = java.lang.String(bytes, i, i1) as String + +inline fun String(bytes : ByteArray) = java.lang.String(bytes) as String + +inline fun String(chars : CharArray) = java.lang.String(chars) as String + +inline fun String(stringBuffer : java.lang.StringBuffer) = java.lang.String(stringBuffer) as String + +inline fun String(stringBuilder : java.lang.StringBuilder) = java.lang.String(stringBuilder) as String + +/* +Iterator for characters of given CharSequence +*/ +inline fun CharSequence.iterator() : CharIterator = object: jet.CharIterator() { + private var index = 0 + + public override fun nextChar(): Char = get(index++) + + public override val hasNext: Boolean + get() = index < length +} diff --git a/k2js/out/production/stdlib/System.kt b/k2js/out/production/stdlib/System.kt new file mode 100644 index 00000000000..bd761eac5fe --- /dev/null +++ b/k2js/out/production/stdlib/System.kt @@ -0,0 +1,19 @@ +package std.util + +/** +Executes current block and returns elapsed time in milliseconds +*/ +fun measureTimeMillis(block: () -> Unit) : Long { + val start = System.currentTimeMillis() + block() + return System.currentTimeMillis() - start +} + +/** +Executes current block and returns elapsed time in nanoseconds +*/ +fun measureTimeNano(block: () -> Unit) : Long { + val start = System.nanoTime() + block() + return System.nanoTime() - start +} diff --git a/k2js/out/production/stdlib/concurrent/FunctionalList.kt b/k2js/out/production/stdlib/concurrent/FunctionalList.kt new file mode 100644 index 00000000000..d3b4f2cd1ff --- /dev/null +++ b/k2js/out/production/stdlib/concurrent/FunctionalList.kt @@ -0,0 +1,57 @@ +package std.concurrent + +abstract class FunctionalList(public val size: Int) { + public abstract val head: T + public abstract val tail: FunctionalList + + val empty : Boolean + get() = size == 0 + + fun add(element: T) : FunctionalList = FunctionalList.Standard(element, this) + + fun reversed() : FunctionalList { + if(empty) + return this + + var cur = tail + var new = of(head) + + while(!cur.empty) { + new = new.add(cur.head) + cur = cur.tail + } + return new + } + + fun iterator() = object: Iterator { + var cur = this@FunctionalList + + override fun next(): T { + if(cur.empty) + throw java.util.NoSuchElementException() + + val head = cur.head + cur = cur.tail + return head + } + + override val hasNext: Boolean + get() = !cur.empty + } + + class object { + class Empty() : FunctionalList(0) { + override val head: T + get() = throw java.util.NoSuchElementException() + override val tail: FunctionalList + get() = throw java.util.NoSuchElementException() + } + + class Standard(override val head: T, override val tail: FunctionalList) : FunctionalList(tail.size+1) + + fun emptyList() = Empty() + + fun of(element: T) : FunctionalList = FunctionalList.Standard(element,emptyList()) + } +} + diff --git a/k2js/out/production/stdlib/concurrent/FunctionalQueue.kt b/k2js/out/production/stdlib/concurrent/FunctionalQueue.kt new file mode 100644 index 00000000000..3dc6ee83303 --- /dev/null +++ b/k2js/out/production/stdlib/concurrent/FunctionalQueue.kt @@ -0,0 +1,30 @@ +package std.concurrent + +import java.util.concurrent.Executor +import jet.Iterator + +class FunctionalQueue ( + val input: FunctionalList = FunctionalList.emptyList(), + val output: FunctionalList = FunctionalList.emptyList()) { + + val size : Int + get() = input.size + output.size + + val empty : Boolean + get() = size == 0 + + fun add(element: T) = FunctionalQueue(input add element, output) + + fun addFirst(element: T) = FunctionalQueue(input, output add element) + + fun removeFirst() : #(T,FunctionalQueue) = + if(output.empty) { + if(input.empty) + throw java.util.NoSuchElementException() + else + FunctionalQueue(FunctionalList.emptyList(), input.reversed()).removeFirst() + } + else { + #(output.head, FunctionalQueue(input, output.tail)) + } +} diff --git a/k2js/out/production/stdlib/concurrent/Locks.kt b/k2js/out/production/stdlib/concurrent/Locks.kt new file mode 100644 index 00000000000..54a5126f751 --- /dev/null +++ b/k2js/out/production/stdlib/concurrent/Locks.kt @@ -0,0 +1,58 @@ +package std.concurrent + +import java.util.concurrent.locks.Lock +import java.util.concurrent.locks.ReadWriteLock +import java.util.concurrent.locks.ReentrantReadWriteLock +import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock + +/* +Executes given calculation under lock +Returns result of the calculation +*/ +inline fun Lock.withLock(action: ()->T) : T { + lock() + try { + return action() + } + finally { + unlock(); + } +} + +/* +Executes given calculation under read lock +Returns result of the calculation +*/ +inline fun ReentrantReadWriteLock.read(action: ()->T) : T { + val rl = readLock().sure() + rl.lock() + try { + return action() + } + finally { + rl.unlock() + } +} + +/* +Executes given calculation under write lock. +The method does upgrade from read to write lock if needed +If such write has been initiated by checking some condition, the condition must be rechecked inside the action to avoid possible races +Returns result of the calculation +*/ +inline fun ReentrantReadWriteLock.write(action: ()->T) : T { + val rl = readLock().sure() + + val readCount = if (getWriteHoldCount() == 0) getReadHoldCount() else 0 + readCount times { rl.unlock() } + + val wl = writeLock().sure() + wl.lock() + try { + return action() + } + finally { + readCount times { rl.lock() } + wl.unlock() + } +} diff --git a/k2js/out/production/stdlib/concurrent/Thread.kt b/k2js/out/production/stdlib/concurrent/Thread.kt new file mode 100644 index 00000000000..a6ecf1eaee3 --- /dev/null +++ b/k2js/out/production/stdlib/concurrent/Thread.kt @@ -0,0 +1,53 @@ +package std.concurrent + +import java.lang.* +import java.util.concurrent.Executor + +inline val currentThread : Thread + get() = Thread.currentThread().sure() + +inline var Thread.name : String + get() = getName().sure() + set(name: String) { setName(name) } + +inline var Thread.daemon : Boolean + get() = isDaemon() + set(on: Boolean) { setDaemon(on) } + +inline val Thread.alive : Boolean + get() = isAlive() + +inline var Thread.priority : Int + get() = getPriority() + set(prio: Int) { setPriority(prio) } + +inline var Thread.contextClassLoader : ClassLoader? + get() = getContextClassLoader() + set(loader: ClassLoader?) { setContextClassLoader(loader) } + +fun thread(start: Boolean = true, daemon: Boolean = false, contextClassLoader: ClassLoader? = null, name: String? = null, priority: Int = -1, block: ()->Unit) : Thread { + val thread = object: Thread() { + override fun run() { + block() + } + } + if(daemon) + thread.setDaemon(true) + if(priority > 0) + thread.setPriority(priority) + if(name != null) + thread.setName(name) + if(contextClassLoader != null) + thread.setContextClassLoader(contextClassLoader) + if(start) + thread.start() + return thread +} + +inline fun Executor.execute(action: ()->Unit) { + execute(object: Runnable{ + override fun run() { + action() + } + }) +} diff --git a/k2js/out/production/stdlib/concurrent/Timer.kt b/k2js/out/production/stdlib/concurrent/Timer.kt new file mode 100644 index 00000000000..5278efcba4d --- /dev/null +++ b/k2js/out/production/stdlib/concurrent/Timer.kt @@ -0,0 +1,71 @@ +package std.concurrent + +import java.util.Timer +import java.util.TimerTask +import java.util.Date + +fun Timer.schedule(delay: Long, action: TimerTask.()->Unit) : TimerTask { + val task = createTask(action) + schedule(task, delay) + return task +} + +fun Timer.schedule(time: Date, action: TimerTask.()->Unit) : TimerTask { + val task = createTask(action) + schedule(task, time) + return task +} + +fun Timer.schedule(delay: Long, period: Long, action: TimerTask.()->Unit) : TimerTask { + val task = createTask(action) + schedule(task, delay, period) + return task +} + +fun Timer.schedule(time: Date, period: Long, action: TimerTask.()->Unit) : TimerTask { + val task = createTask(action) + schedule(task, time, period) + return task +} + +fun Timer.scheduleAtFixedRate(delay: Long, period: Long, action: TimerTask.()->Unit) : TimerTask { + val task = createTask(action) + scheduleAtFixedRate(task, delay, period) + return task +} + +fun Timer.scheduleAtFixedRate(time: Date, period: Long, action: TimerTask.()->Unit) : TimerTask { + val task = createTask(action) + scheduleAtFixedRate(task, time, period) + return task +} + +fun timer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.lng, period: Long, action: TimerTask.()->Unit) : Timer { + val timer = if(name == null) Timer(daemon) else Timer(name, daemon) + timer.schedule(initialDelay, period, action) + return timer +} + +fun timer(name: String? = null, daemon: Boolean = false, startAt: Date, period: Long, action: TimerTask.()->Unit) : Timer { + val timer = if(name == null) Timer(daemon) else Timer(name, daemon) + timer.schedule(startAt, period, action) + return timer +} + +fun fixedRateTimer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.lng, period: Long, action: TimerTask.()->Unit) : Timer { + val timer = if(name == null) Timer(daemon) else Timer(name, daemon) + timer.scheduleAtFixedRate(initialDelay, period, action) + return timer +} + +fun fixedRateTimer(name: String? = null, daemon: Boolean = false, startAt: Date, period : Long, action: TimerTask.()->Unit) : Timer { + val timer = if(name == null) Timer(daemon) else Timer(name, daemon) + timer.scheduleAtFixedRate(startAt, period, action) + return timer +} + +private fun createTask(action: TimerTask.()->Unit) : TimerTask = object: TimerTask() { + override fun run() { + action() + } +} \ No newline at end of file diff --git a/k2js/out/production/stdlib/dom/Dom.kt b/k2js/out/production/stdlib/dom/Dom.kt new file mode 100644 index 00000000000..268d58d4a2a --- /dev/null +++ b/k2js/out/production/stdlib/dom/Dom.kt @@ -0,0 +1,104 @@ +package std.dom + +import std.* +import org.w3c.dom.* + + +// Properties + +var Element.id : String +get() = this.getAttribute("id")?: "" +set(value) { + this.setAttribute("id", value) +} + +var Element.style : String +get() = this.getAttribute("style")?: "" +set(value) { + this.setAttribute("style", value) +} + +// TODO can we come up with a better name; 'class' is a reserved word? +var Element.cssClass : String +get() = this.getAttribute("class")?: "" +set(value) { + this.setAttribute("class", value) +} + +// Syntax sugar + +inline fun Node.plus(child: Node?): Node { + if (child != null) { + this.appendChild(child) + } + return this +} + +inline fun Element.plus(text: String?): Element = this.addText(text) + +inline fun Element.plusAssign(text: String?): Element = this.addText(text) + + +// Builder + +/* +Creates a new element which can be configured via a function +*/ +fun Document.createElement(name: String, init: Element.()-> Unit): Element { + val elem = this.createElement(name).sure() + elem.init() + return elem +} + +/* +Creates a new element to an element which has an owner Document which can be configured via a function +*/ +fun Element.createElement(name: String, doc: Document? = null, init: Element.()-> Unit): Element { + val elem = ownerDocument(doc).createElement(name).sure() + elem.init() + return elem +} + +/* +Returns the owner document of the element or uses the provided document +*/ +fun Node.ownerDocument(doc: Document? = null): Document { + val answer = if (this is Document) this as Document + else if (doc == null) this.getOwnerDocument() + else doc + + if (answer == null) { + throw IllegalArgumentException("Element does not have an ownerDocument and none was provided for: ${this}") + } else { + return answer + } +} + +/* +Adds a newly created element which can be configured via a function +*/ +fun Document.addElement(name: String, init: Element.()-> Unit): Element { + val child = createElement(name, init) + this.appendChild(child) + return child +} + +/* +Adds a newly created element to an element which has an owner Document which can be configured via a function +*/ +fun Element.addElement(name: String, doc: Document? = null, init: Element.()-> Unit): Element { + val child = createElement(name, doc, init) + this.appendChild(child) + return child +} + +/* +Adds a newly created text node to an element which either already has an owner Document or one must be provided as a parameter +*/ +fun Element.addText(text: String?, doc: Document? = null): Element { + if (text != null) { + val child = ownerDocument(doc).createTextNode(text) + this.appendChild(child) + } + return this +} diff --git a/k2js/out/production/stdlib/dom/DomJVM.kt b/k2js/out/production/stdlib/dom/DomJVM.kt new file mode 100644 index 00000000000..f281b56f358 --- /dev/null +++ b/k2js/out/production/stdlib/dom/DomJVM.kt @@ -0,0 +1,53 @@ +/** + * JVM specific API implementations using JAXB and so forth which would not be used when compiling to JS + */ +package std.dom + +import org.w3c.dom.* +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory +import javax.xml.transform.Transformer +import javax.xml.transform.TransformerFactory +import javax.xml.transform.Source +import javax.xml.transform.dom.DOMSource +import javax.xml.transform.stream.StreamResult + +import java.io.StringWriter +import javax.xml.transform.OutputKeys + +fun createDocument(builder: DocumentBuilder): Document { + return builder.newDocument().sure() +} + +fun createDocument(builderFactory: DocumentBuilderFactory = DocumentBuilderFactory.newInstance().sure()): Document { + return createDocument(builderFactory.newDocumentBuilder().sure()) +} + +fun createTransformer(source: Source? = null, factory: TransformerFactory = TransformerFactory.newInstance().sure()): Transformer { + val transformer = if (source != null) { + factory.newTransformer(source) + } else { + factory.newTransformer() + } + return transformer.sure() +} + +fun Node.toXmlString(xmlDeclaration: Boolean = this is Document): String { + return nodeToXmlString(this, xmlDeclaration) +} + +/* +fun Document.toXmlString(xmlDeclaration: Boolean = true): String { + return nodeToXmlString(this, xmlDeclaration) +} +*/ + +fun nodeToXmlString(node: Node, xmlDeclaration: Boolean): String { + val transformer = createTransformer() + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, if (xmlDeclaration) "no" else "yes") + val buffer = StringWriter() + transformer.transform(DOMSource(node), StreamResult(buffer)) + return buffer.toString().sure() + +} + diff --git a/k2js/out/production/stdlib/generated/ArraysFromJavaCollections.kt b/k2js/out/production/stdlib/generated/ArraysFromJavaCollections.kt new file mode 100644 index 00000000000..12db122013e --- /dev/null +++ b/k2js/out/production/stdlib/generated/ArraysFromJavaCollections.kt @@ -0,0 +1,11 @@ +// NOTE this file is auto-generated from stdlib/ktSrc/JavaCollections.kt +package std + +import java.util.* + +/** Returns a new collection containing the results of applying the given function to each element in this collection */ +inline fun Array.map(result: Collection = ArrayList(this.size), transform : (T) -> R) : Collection { + for (item in this) + result.add(transform(item)) + return result +} diff --git a/k2js/out/production/stdlib/generated/ArraysFromJavaIterables.kt b/k2js/out/production/stdlib/generated/ArraysFromJavaIterables.kt new file mode 100644 index 00000000000..9794644f7d7 --- /dev/null +++ b/k2js/out/production/stdlib/generated/ArraysFromJavaIterables.kt @@ -0,0 +1,109 @@ +// NOTE this file is auto-generated from stdlib/ktSrc/JavaIterables.kt +package std + +import java.util.* + +/** Returns true if any elements in the collection match the given predicate */ +inline fun Array.any(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (predicate(elem)) { + return true + } + } + return false +} + +/** Returns true if all elements in the collection match the given predicate */ +inline fun Array.all(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (!predicate(elem)) { + return false + } + } + return true +} + +/** Returns the first item in the collection which matches the given predicate or null if none matched */ +inline fun Array.find(predicate: (T)-> Boolean) : T? { + for (elem in this) { + if (predicate(elem)) + return elem + } + return null +} + +/** Returns a new collection containing all elements in this collection which match the given predicate */ +inline fun Array.filter(result: Collection = ArrayList(), predicate: (T)-> Boolean) : Collection { + for (elem in this) { + if (predicate(elem)) + result.add(elem) + } + return result +} + +/** Returns a new collection containing all elements in this collection which do not match the given predicate */ +inline fun Array.filterNot(result: Collection = ArrayList(), predicate: (T)-> Boolean) : Collection { + for (elem in this) { + if (!predicate(elem)) + result.add(elem) + } + return result +} + +/** + * Returns the result of transforming each item in the collection to a one or more values which + * are concatenated together into a single collection + */ +inline fun Array.flatMap(result: Collection = ArrayList(), transform: (T)-> Collection) : Collection { + for (elem in this) { + val coll = transform(elem) + if (coll != null) { + for (r in coll) { + result.add(r) + } + } + } + return result +} + +/** Performs the given operation on each element inside the collection */ +inline fun Array.foreach(operation: (element: T) -> Unit) { + for (elem in this) + operation(elem) +} + +/** Creates a String from all the elements in the collection, using the seperator between them and using the given prefix and postfix if supplied */ +inline fun Array.join(separator: String, prefix: String = "", postfix: String = "") : String { + val buffer = StringBuilder(prefix) + var first = true + for (elem in this) { + if (first) + first = false + else + buffer.append(separator) + buffer.append(elem) + } + buffer.append(postfix) + return buffer.toString().sure() +} + +inline fun > Array.to(result: C) : C { + for (elem in this) + result.add(elem) + return result +} + +inline fun Array.toLinkedList() : LinkedList = this.to(LinkedList()) + +inline fun Array.toList() : List = this.to(ArrayList()) + +inline fun Array.toSet() : Set = this.to(HashSet()) + +/** + TODO figure out necessary variance/generics ninja stuff... :) +inline fun Array.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { + val answer = this.toList() + answer.sort(transform) + return answer +} +*/ diff --git a/k2js/out/production/stdlib/generated/JavaUtilIterablesFromJavaCollections.kt b/k2js/out/production/stdlib/generated/JavaUtilIterablesFromJavaCollections.kt new file mode 100644 index 00000000000..e4592189fca --- /dev/null +++ b/k2js/out/production/stdlib/generated/JavaUtilIterablesFromJavaCollections.kt @@ -0,0 +1,11 @@ +// NOTE this file is auto-generated from stdlib/ktSrc/JavaCollections.kt +package std.util + +import java.util.* + +/** Returns a new collection containing the results of applying the given function to each element in this collection */ +inline fun java.lang.Iterable.map(result: Collection = ArrayList(), transform : (T) -> R) : Collection { + for (item in this) + result.add(transform(item)) + return result +} diff --git a/k2js/out/production/stdlib/generated/StandardFromJavaCollections.kt b/k2js/out/production/stdlib/generated/StandardFromJavaCollections.kt new file mode 100644 index 00000000000..e94ec1d52d3 --- /dev/null +++ b/k2js/out/production/stdlib/generated/StandardFromJavaCollections.kt @@ -0,0 +1,11 @@ +// NOTE this file is auto-generated from stdlib/ktSrc/JavaCollections.kt +package std + +import java.util.* + +/** Returns a new collection containing the results of applying the given function to each element in this collection */ +inline fun Iterable.map(result: Collection = ArrayList(), transform : (T) -> R) : Collection { + for (item in this) + result.add(transform(item)) + return result +} diff --git a/k2js/out/production/stdlib/generated/StandardFromJavaIterables.kt b/k2js/out/production/stdlib/generated/StandardFromJavaIterables.kt new file mode 100644 index 00000000000..00a566350ec --- /dev/null +++ b/k2js/out/production/stdlib/generated/StandardFromJavaIterables.kt @@ -0,0 +1,109 @@ +// NOTE this file is auto-generated from stdlib/ktSrc/JavaIterables.kt +package std + +import java.util.* + +/** Returns true if any elements in the collection match the given predicate */ +inline fun Iterable.any(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (predicate(elem)) { + return true + } + } + return false +} + +/** Returns true if all elements in the collection match the given predicate */ +inline fun Iterable.all(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (!predicate(elem)) { + return false + } + } + return true +} + +/** Returns the first item in the collection which matches the given predicate or null if none matched */ +inline fun Iterable.find(predicate: (T)-> Boolean) : T? { + for (elem in this) { + if (predicate(elem)) + return elem + } + return null +} + +/** Returns a new collection containing all elements in this collection which match the given predicate */ +inline fun Iterable.filter(result: Collection = ArrayList(), predicate: (T)-> Boolean) : Collection { + for (elem in this) { + if (predicate(elem)) + result.add(elem) + } + return result +} + +/** Returns a new collection containing all elements in this collection which do not match the given predicate */ +inline fun Iterable.filterNot(result: Collection = ArrayList(), predicate: (T)-> Boolean) : Collection { + for (elem in this) { + if (!predicate(elem)) + result.add(elem) + } + return result +} + +/** + * Returns the result of transforming each item in the collection to a one or more values which + * are concatenated together into a single collection + */ +inline fun Iterable.flatMap(result: Collection = ArrayList(), transform: (T)-> Collection) : Collection { + for (elem in this) { + val coll = transform(elem) + if (coll != null) { + for (r in coll) { + result.add(r) + } + } + } + return result +} + +/** Performs the given operation on each element inside the collection */ +inline fun Iterable.foreach(operation: (element: T) -> Unit) { + for (elem in this) + operation(elem) +} + +/** Creates a String from all the elements in the collection, using the seperator between them and using the given prefix and postfix if supplied */ +inline fun Iterable.join(separator: String, prefix: String = "", postfix: String = "") : String { + val buffer = StringBuilder(prefix) + var first = true + for (elem in this) { + if (first) + first = false + else + buffer.append(separator) + buffer.append(elem) + } + buffer.append(postfix) + return buffer.toString().sure() +} + +inline fun > Iterable.to(result: C) : C { + for (elem in this) + result.add(elem) + return result +} + +inline fun Iterable.toLinkedList() : LinkedList = this.to(LinkedList()) + +inline fun Iterable.toList() : List = this.to(ArrayList()) + +inline fun Iterable.toSet() : Set = this.to(HashSet()) + +/** + TODO figure out necessary variance/generics ninja stuff... :) +inline fun Iterable.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { + val answer = this.toList() + answer.sort(transform) + return answer +} +*/ diff --git a/k2js/out/production/stdlib/jet/BooleanIterable.class b/k2js/out/production/stdlib/jet/BooleanIterable.class new file mode 100644 index 00000000000..0bbaeeb5f9f Binary files /dev/null and b/k2js/out/production/stdlib/jet/BooleanIterable.class differ diff --git a/k2js/out/production/stdlib/jet/BooleanIterator.class b/k2js/out/production/stdlib/jet/BooleanIterator.class new file mode 100644 index 00000000000..e5de89abd5f Binary files /dev/null and b/k2js/out/production/stdlib/jet/BooleanIterator.class differ diff --git a/k2js/out/production/stdlib/jet/ByteIterable.class b/k2js/out/production/stdlib/jet/ByteIterable.class new file mode 100644 index 00000000000..4c843f9f0d7 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ByteIterable.class differ diff --git a/k2js/out/production/stdlib/jet/ByteIterator.class b/k2js/out/production/stdlib/jet/ByteIterator.class new file mode 100644 index 00000000000..54942895d46 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ByteIterator.class differ diff --git a/k2js/out/production/stdlib/jet/ByteRange$MyIterator.class b/k2js/out/production/stdlib/jet/ByteRange$MyIterator.class new file mode 100644 index 00000000000..fc68f40d2c3 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ByteRange$MyIterator.class differ diff --git a/k2js/out/production/stdlib/jet/ByteRange.class b/k2js/out/production/stdlib/jet/ByteRange.class new file mode 100644 index 00000000000..83499e05605 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ByteRange.class differ diff --git a/k2js/out/production/stdlib/jet/CharIterable.class b/k2js/out/production/stdlib/jet/CharIterable.class new file mode 100644 index 00000000000..4a0ffdeacf3 Binary files /dev/null and b/k2js/out/production/stdlib/jet/CharIterable.class differ diff --git a/k2js/out/production/stdlib/jet/CharIterator.class b/k2js/out/production/stdlib/jet/CharIterator.class new file mode 100644 index 00000000000..1ce7eaf9187 Binary files /dev/null and b/k2js/out/production/stdlib/jet/CharIterator.class differ diff --git a/k2js/out/production/stdlib/jet/CharRange$MyIterator.class b/k2js/out/production/stdlib/jet/CharRange$MyIterator.class new file mode 100644 index 00000000000..8f379f69d27 Binary files /dev/null and b/k2js/out/production/stdlib/jet/CharRange$MyIterator.class differ diff --git a/k2js/out/production/stdlib/jet/CharRange.class b/k2js/out/production/stdlib/jet/CharRange.class new file mode 100644 index 00000000000..598259786a9 Binary files /dev/null and b/k2js/out/production/stdlib/jet/CharRange.class differ diff --git a/k2js/out/production/stdlib/jet/DefaultJetObject.class b/k2js/out/production/stdlib/jet/DefaultJetObject.class new file mode 100644 index 00000000000..a69bd72e8c2 Binary files /dev/null and b/k2js/out/production/stdlib/jet/DefaultJetObject.class differ diff --git a/k2js/out/production/stdlib/jet/DoubleIterable.class b/k2js/out/production/stdlib/jet/DoubleIterable.class new file mode 100644 index 00000000000..2184b39b43c Binary files /dev/null and b/k2js/out/production/stdlib/jet/DoubleIterable.class differ diff --git a/k2js/out/production/stdlib/jet/DoubleIterator.class b/k2js/out/production/stdlib/jet/DoubleIterator.class new file mode 100644 index 00000000000..76170cad341 Binary files /dev/null and b/k2js/out/production/stdlib/jet/DoubleIterator.class differ diff --git a/k2js/out/production/stdlib/jet/DoubleRange$MyIterator.class b/k2js/out/production/stdlib/jet/DoubleRange$MyIterator.class new file mode 100644 index 00000000000..faaf41646da Binary files /dev/null and b/k2js/out/production/stdlib/jet/DoubleRange$MyIterator.class differ diff --git a/k2js/out/production/stdlib/jet/DoubleRange.class b/k2js/out/production/stdlib/jet/DoubleRange.class new file mode 100644 index 00000000000..84a4feb8cfb Binary files /dev/null and b/k2js/out/production/stdlib/jet/DoubleRange.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction0.class b/k2js/out/production/stdlib/jet/ExtensionFunction0.class new file mode 100644 index 00000000000..50711016e33 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction0.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction1.class b/k2js/out/production/stdlib/jet/ExtensionFunction1.class new file mode 100644 index 00000000000..2d582b2ab65 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction1.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction10.class b/k2js/out/production/stdlib/jet/ExtensionFunction10.class new file mode 100644 index 00000000000..72c1b0508e8 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction10.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction11.class b/k2js/out/production/stdlib/jet/ExtensionFunction11.class new file mode 100644 index 00000000000..08e2a7ca4dd Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction11.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction12.class b/k2js/out/production/stdlib/jet/ExtensionFunction12.class new file mode 100644 index 00000000000..6d5160e7544 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction12.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction13.class b/k2js/out/production/stdlib/jet/ExtensionFunction13.class new file mode 100644 index 00000000000..8aad1c630ed Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction13.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction14.class b/k2js/out/production/stdlib/jet/ExtensionFunction14.class new file mode 100644 index 00000000000..f51f42da5b6 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction14.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction15.class b/k2js/out/production/stdlib/jet/ExtensionFunction15.class new file mode 100644 index 00000000000..5a722e99381 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction15.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction16.class b/k2js/out/production/stdlib/jet/ExtensionFunction16.class new file mode 100644 index 00000000000..c9f63ed31e4 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction16.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction17.class b/k2js/out/production/stdlib/jet/ExtensionFunction17.class new file mode 100644 index 00000000000..88e8f0fc2ba Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction17.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction18.class b/k2js/out/production/stdlib/jet/ExtensionFunction18.class new file mode 100644 index 00000000000..b5702e72379 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction18.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction19.class b/k2js/out/production/stdlib/jet/ExtensionFunction19.class new file mode 100644 index 00000000000..66ac7aaf08f Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction19.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction2.class b/k2js/out/production/stdlib/jet/ExtensionFunction2.class new file mode 100644 index 00000000000..5a7f89205ec Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction2.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction20.class b/k2js/out/production/stdlib/jet/ExtensionFunction20.class new file mode 100644 index 00000000000..ccae62cb808 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction20.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction21.class b/k2js/out/production/stdlib/jet/ExtensionFunction21.class new file mode 100644 index 00000000000..b9197103b22 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction21.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction22.class b/k2js/out/production/stdlib/jet/ExtensionFunction22.class new file mode 100644 index 00000000000..e4a213f8642 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction22.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction3.class b/k2js/out/production/stdlib/jet/ExtensionFunction3.class new file mode 100644 index 00000000000..de3d2a3f7cb Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction3.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction4.class b/k2js/out/production/stdlib/jet/ExtensionFunction4.class new file mode 100644 index 00000000000..f4585c00ef7 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction4.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction5.class b/k2js/out/production/stdlib/jet/ExtensionFunction5.class new file mode 100644 index 00000000000..b2c7d09a4a5 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction5.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction6.class b/k2js/out/production/stdlib/jet/ExtensionFunction6.class new file mode 100644 index 00000000000..51607183702 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction6.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction7.class b/k2js/out/production/stdlib/jet/ExtensionFunction7.class new file mode 100644 index 00000000000..762ee76241e Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction7.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction8.class b/k2js/out/production/stdlib/jet/ExtensionFunction8.class new file mode 100644 index 00000000000..2e7ae583fd7 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction8.class differ diff --git a/k2js/out/production/stdlib/jet/ExtensionFunction9.class b/k2js/out/production/stdlib/jet/ExtensionFunction9.class new file mode 100644 index 00000000000..32bbf02586a Binary files /dev/null and b/k2js/out/production/stdlib/jet/ExtensionFunction9.class differ diff --git a/k2js/out/production/stdlib/jet/FloatIterable.class b/k2js/out/production/stdlib/jet/FloatIterable.class new file mode 100644 index 00000000000..c5d0cb7d0e8 Binary files /dev/null and b/k2js/out/production/stdlib/jet/FloatIterable.class differ diff --git a/k2js/out/production/stdlib/jet/FloatIterator.class b/k2js/out/production/stdlib/jet/FloatIterator.class new file mode 100644 index 00000000000..59da8c2f1f5 Binary files /dev/null and b/k2js/out/production/stdlib/jet/FloatIterator.class differ diff --git a/k2js/out/production/stdlib/jet/FloatRange$MyIterator.class b/k2js/out/production/stdlib/jet/FloatRange$MyIterator.class new file mode 100644 index 00000000000..5c01b59fe58 Binary files /dev/null and b/k2js/out/production/stdlib/jet/FloatRange$MyIterator.class differ diff --git a/k2js/out/production/stdlib/jet/FloatRange.class b/k2js/out/production/stdlib/jet/FloatRange.class new file mode 100644 index 00000000000..a4351005054 Binary files /dev/null and b/k2js/out/production/stdlib/jet/FloatRange.class differ diff --git a/k2js/out/production/stdlib/jet/Function0.class b/k2js/out/production/stdlib/jet/Function0.class new file mode 100644 index 00000000000..9f6aa08281a Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function0.class differ diff --git a/k2js/out/production/stdlib/jet/Function1.class b/k2js/out/production/stdlib/jet/Function1.class new file mode 100644 index 00000000000..6426310d619 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function1.class differ diff --git a/k2js/out/production/stdlib/jet/Function10.class b/k2js/out/production/stdlib/jet/Function10.class new file mode 100644 index 00000000000..74fff27d525 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function10.class differ diff --git a/k2js/out/production/stdlib/jet/Function11.class b/k2js/out/production/stdlib/jet/Function11.class new file mode 100644 index 00000000000..b89f3c686dc Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function11.class differ diff --git a/k2js/out/production/stdlib/jet/Function12.class b/k2js/out/production/stdlib/jet/Function12.class new file mode 100644 index 00000000000..c3c0e35f796 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function12.class differ diff --git a/k2js/out/production/stdlib/jet/Function13.class b/k2js/out/production/stdlib/jet/Function13.class new file mode 100644 index 00000000000..bbf6ae010bc Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function13.class differ diff --git a/k2js/out/production/stdlib/jet/Function14.class b/k2js/out/production/stdlib/jet/Function14.class new file mode 100644 index 00000000000..c455359f17f Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function14.class differ diff --git a/k2js/out/production/stdlib/jet/Function15.class b/k2js/out/production/stdlib/jet/Function15.class new file mode 100644 index 00000000000..c9a053707fe Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function15.class differ diff --git a/k2js/out/production/stdlib/jet/Function16.class b/k2js/out/production/stdlib/jet/Function16.class new file mode 100644 index 00000000000..de173044756 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function16.class differ diff --git a/k2js/out/production/stdlib/jet/Function17.class b/k2js/out/production/stdlib/jet/Function17.class new file mode 100644 index 00000000000..010e900b04c Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function17.class differ diff --git a/k2js/out/production/stdlib/jet/Function18.class b/k2js/out/production/stdlib/jet/Function18.class new file mode 100644 index 00000000000..34f229cb66a Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function18.class differ diff --git a/k2js/out/production/stdlib/jet/Function19.class b/k2js/out/production/stdlib/jet/Function19.class new file mode 100644 index 00000000000..e7bf140334c Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function19.class differ diff --git a/k2js/out/production/stdlib/jet/Function2.class b/k2js/out/production/stdlib/jet/Function2.class new file mode 100644 index 00000000000..a4c3e2b45db Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function2.class differ diff --git a/k2js/out/production/stdlib/jet/Function20.class b/k2js/out/production/stdlib/jet/Function20.class new file mode 100644 index 00000000000..341ee1a4f0a Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function20.class differ diff --git a/k2js/out/production/stdlib/jet/Function21.class b/k2js/out/production/stdlib/jet/Function21.class new file mode 100644 index 00000000000..f421de32cd0 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function21.class differ diff --git a/k2js/out/production/stdlib/jet/Function22.class b/k2js/out/production/stdlib/jet/Function22.class new file mode 100644 index 00000000000..dcb66d1594f Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function22.class differ diff --git a/k2js/out/production/stdlib/jet/Function3.class b/k2js/out/production/stdlib/jet/Function3.class new file mode 100644 index 00000000000..5655fac3744 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function3.class differ diff --git a/k2js/out/production/stdlib/jet/Function4.class b/k2js/out/production/stdlib/jet/Function4.class new file mode 100644 index 00000000000..547d883bc9c Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function4.class differ diff --git a/k2js/out/production/stdlib/jet/Function5.class b/k2js/out/production/stdlib/jet/Function5.class new file mode 100644 index 00000000000..6f30c906564 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function5.class differ diff --git a/k2js/out/production/stdlib/jet/Function6.class b/k2js/out/production/stdlib/jet/Function6.class new file mode 100644 index 00000000000..ee63cc67160 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function6.class differ diff --git a/k2js/out/production/stdlib/jet/Function7.class b/k2js/out/production/stdlib/jet/Function7.class new file mode 100644 index 00000000000..05a595a85bd Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function7.class differ diff --git a/k2js/out/production/stdlib/jet/Function8.class b/k2js/out/production/stdlib/jet/Function8.class new file mode 100644 index 00000000000..8ca27a9a86c Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function8.class differ diff --git a/k2js/out/production/stdlib/jet/Function9.class b/k2js/out/production/stdlib/jet/Function9.class new file mode 100644 index 00000000000..366f019cf31 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Function9.class differ diff --git a/k2js/out/production/stdlib/jet/IntIterable.class b/k2js/out/production/stdlib/jet/IntIterable.class new file mode 100644 index 00000000000..4fe090e4b9e Binary files /dev/null and b/k2js/out/production/stdlib/jet/IntIterable.class differ diff --git a/k2js/out/production/stdlib/jet/IntIterator.class b/k2js/out/production/stdlib/jet/IntIterator.class new file mode 100644 index 00000000000..1cdf77f3237 Binary files /dev/null and b/k2js/out/production/stdlib/jet/IntIterator.class differ diff --git a/k2js/out/production/stdlib/jet/IntRange$MyIterator.class b/k2js/out/production/stdlib/jet/IntRange$MyIterator.class new file mode 100644 index 00000000000..0100458372b Binary files /dev/null and b/k2js/out/production/stdlib/jet/IntRange$MyIterator.class differ diff --git a/k2js/out/production/stdlib/jet/IntRange.class b/k2js/out/production/stdlib/jet/IntRange.class new file mode 100644 index 00000000000..e1dcb613796 Binary files /dev/null and b/k2js/out/production/stdlib/jet/IntRange.class differ diff --git a/k2js/out/production/stdlib/jet/Iterable.class b/k2js/out/production/stdlib/jet/Iterable.class new file mode 100644 index 00000000000..c4f783a2bcc Binary files /dev/null and b/k2js/out/production/stdlib/jet/Iterable.class differ diff --git a/k2js/out/production/stdlib/jet/Iterator.class b/k2js/out/production/stdlib/jet/Iterator.class new file mode 100644 index 00000000000..a8330222e11 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Iterator.class differ diff --git a/k2js/out/production/stdlib/jet/JetObject.class b/k2js/out/production/stdlib/jet/JetObject.class new file mode 100644 index 00000000000..567b5815b4e Binary files /dev/null and b/k2js/out/production/stdlib/jet/JetObject.class differ diff --git a/k2js/out/production/stdlib/jet/LongIterable.class b/k2js/out/production/stdlib/jet/LongIterable.class new file mode 100644 index 00000000000..b22306e9330 Binary files /dev/null and b/k2js/out/production/stdlib/jet/LongIterable.class differ diff --git a/k2js/out/production/stdlib/jet/LongIterator.class b/k2js/out/production/stdlib/jet/LongIterator.class new file mode 100644 index 00000000000..c3ad6118d2d Binary files /dev/null and b/k2js/out/production/stdlib/jet/LongIterator.class differ diff --git a/k2js/out/production/stdlib/jet/LongRange$MyIterator.class b/k2js/out/production/stdlib/jet/LongRange$MyIterator.class new file mode 100644 index 00000000000..eef6b8f6a3e Binary files /dev/null and b/k2js/out/production/stdlib/jet/LongRange$MyIterator.class differ diff --git a/k2js/out/production/stdlib/jet/LongRange.class b/k2js/out/production/stdlib/jet/LongRange.class new file mode 100644 index 00000000000..60003b9e7c1 Binary files /dev/null and b/k2js/out/production/stdlib/jet/LongRange.class differ diff --git a/k2js/out/production/stdlib/jet/NoPatternMatchedException.class b/k2js/out/production/stdlib/jet/NoPatternMatchedException.class new file mode 100644 index 00000000000..17e68f06867 Binary files /dev/null and b/k2js/out/production/stdlib/jet/NoPatternMatchedException.class differ diff --git a/k2js/out/production/stdlib/jet/Range.class b/k2js/out/production/stdlib/jet/Range.class new file mode 100644 index 00000000000..44e8f096b4d Binary files /dev/null and b/k2js/out/production/stdlib/jet/Range.class differ diff --git a/k2js/out/production/stdlib/jet/ShortIterable.class b/k2js/out/production/stdlib/jet/ShortIterable.class new file mode 100644 index 00000000000..f1d05522ec8 Binary files /dev/null and b/k2js/out/production/stdlib/jet/ShortIterable.class differ diff --git a/k2js/out/production/stdlib/jet/ShortIterator.class b/k2js/out/production/stdlib/jet/ShortIterator.class new file mode 100644 index 00000000000..762e05a697f Binary files /dev/null and b/k2js/out/production/stdlib/jet/ShortIterator.class differ diff --git a/k2js/out/production/stdlib/jet/ShortRange$MyIterator.class b/k2js/out/production/stdlib/jet/ShortRange$MyIterator.class new file mode 100644 index 00000000000..38805e95a8c Binary files /dev/null and b/k2js/out/production/stdlib/jet/ShortRange$MyIterator.class differ diff --git a/k2js/out/production/stdlib/jet/ShortRange.class b/k2js/out/production/stdlib/jet/ShortRange.class new file mode 100644 index 00000000000..2370a29d63f Binary files /dev/null and b/k2js/out/production/stdlib/jet/ShortRange.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple0.class b/k2js/out/production/stdlib/jet/Tuple0.class new file mode 100644 index 00000000000..94e12965e44 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple0.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple1.class b/k2js/out/production/stdlib/jet/Tuple1.class new file mode 100644 index 00000000000..1578f8f970d Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple1.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple10.class b/k2js/out/production/stdlib/jet/Tuple10.class new file mode 100644 index 00000000000..d0d984caf78 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple10.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple11.class b/k2js/out/production/stdlib/jet/Tuple11.class new file mode 100644 index 00000000000..ce61d758ca9 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple11.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple12.class b/k2js/out/production/stdlib/jet/Tuple12.class new file mode 100644 index 00000000000..65bfb2ca043 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple12.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple13.class b/k2js/out/production/stdlib/jet/Tuple13.class new file mode 100644 index 00000000000..34128f94875 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple13.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple14.class b/k2js/out/production/stdlib/jet/Tuple14.class new file mode 100644 index 00000000000..06a850ec285 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple14.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple15.class b/k2js/out/production/stdlib/jet/Tuple15.class new file mode 100644 index 00000000000..e166df71826 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple15.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple16.class b/k2js/out/production/stdlib/jet/Tuple16.class new file mode 100644 index 00000000000..1a9beb8c7a5 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple16.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple17.class b/k2js/out/production/stdlib/jet/Tuple17.class new file mode 100644 index 00000000000..a34c862d7df Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple17.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple18.class b/k2js/out/production/stdlib/jet/Tuple18.class new file mode 100644 index 00000000000..4c30def1b56 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple18.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple19.class b/k2js/out/production/stdlib/jet/Tuple19.class new file mode 100644 index 00000000000..c67db5ae251 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple19.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple2.class b/k2js/out/production/stdlib/jet/Tuple2.class new file mode 100644 index 00000000000..635d6d9a53e Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple2.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple20.class b/k2js/out/production/stdlib/jet/Tuple20.class new file mode 100644 index 00000000000..1b6ce91c263 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple20.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple21.class b/k2js/out/production/stdlib/jet/Tuple21.class new file mode 100644 index 00000000000..854b4d121a9 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple21.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple22.class b/k2js/out/production/stdlib/jet/Tuple22.class new file mode 100644 index 00000000000..acda19f0385 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple22.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple3.class b/k2js/out/production/stdlib/jet/Tuple3.class new file mode 100644 index 00000000000..e963ddba7a3 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple3.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple4.class b/k2js/out/production/stdlib/jet/Tuple4.class new file mode 100644 index 00000000000..8fa2e093e05 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple4.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple5.class b/k2js/out/production/stdlib/jet/Tuple5.class new file mode 100644 index 00000000000..36dd286be11 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple5.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple6.class b/k2js/out/production/stdlib/jet/Tuple6.class new file mode 100644 index 00000000000..7e53b797160 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple6.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple7.class b/k2js/out/production/stdlib/jet/Tuple7.class new file mode 100644 index 00000000000..2c90416a6df Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple7.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple8.class b/k2js/out/production/stdlib/jet/Tuple8.class new file mode 100644 index 00000000000..6228f7c9239 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple8.class differ diff --git a/k2js/out/production/stdlib/jet/Tuple9.class b/k2js/out/production/stdlib/jet/Tuple9.class new file mode 100644 index 00000000000..efd7c0e1e77 Binary files /dev/null and b/k2js/out/production/stdlib/jet/Tuple9.class differ diff --git a/k2js/out/production/stdlib/jet/TypeCastException.class b/k2js/out/production/stdlib/jet/TypeCastException.class new file mode 100644 index 00000000000..2a16f921272 Binary files /dev/null and b/k2js/out/production/stdlib/jet/TypeCastException.class differ diff --git a/k2js/out/production/stdlib/jet/TypeInfo$1.class b/k2js/out/production/stdlib/jet/TypeInfo$1.class new file mode 100644 index 00000000000..adc3a49e508 Binary files /dev/null and b/k2js/out/production/stdlib/jet/TypeInfo$1.class differ diff --git a/k2js/out/production/stdlib/jet/TypeInfo$2.class b/k2js/out/production/stdlib/jet/TypeInfo$2.class new file mode 100644 index 00000000000..5f4095a6adb Binary files /dev/null and b/k2js/out/production/stdlib/jet/TypeInfo$2.class differ diff --git a/k2js/out/production/stdlib/jet/TypeInfo$3.class b/k2js/out/production/stdlib/jet/TypeInfo$3.class new file mode 100644 index 00000000000..ccdf1ef5c8e Binary files /dev/null and b/k2js/out/production/stdlib/jet/TypeInfo$3.class differ diff --git a/k2js/out/production/stdlib/jet/TypeInfo.class b/k2js/out/production/stdlib/jet/TypeInfo.class new file mode 100644 index 00000000000..a9217cb09d4 Binary files /dev/null and b/k2js/out/production/stdlib/jet/TypeInfo.class differ diff --git a/k2js/out/production/stdlib/jet/modules/AllModules.class b/k2js/out/production/stdlib/jet/modules/AllModules.class new file mode 100644 index 00000000000..9c1c9d324f0 Binary files /dev/null and b/k2js/out/production/stdlib/jet/modules/AllModules.class differ diff --git a/k2js/out/production/stdlib/jet/modules/Module.class b/k2js/out/production/stdlib/jet/modules/Module.class new file mode 100644 index 00000000000..6bd245bf7a3 Binary files /dev/null and b/k2js/out/production/stdlib/jet/modules/Module.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator$1.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$1.class new file mode 100644 index 00000000000..ac8a6549dc8 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$1.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayBooleanIterator.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayBooleanIterator.class new file mode 100644 index 00000000000..1b048e8db1e Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayBooleanIterator.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayByteIterator.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayByteIterator.class new file mode 100644 index 00000000000..e2683fd48bf Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayByteIterator.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayCharacterIterator.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayCharacterIterator.class new file mode 100644 index 00000000000..c44a7156739 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayCharacterIterator.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayDoubleIterator.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayDoubleIterator.class new file mode 100644 index 00000000000..254a11a7a38 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayDoubleIterator.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayFloatIterator.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayFloatIterator.class new file mode 100644 index 00000000000..c0675863f82 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayFloatIterator.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayIntegerIterator.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayIntegerIterator.class new file mode 100644 index 00000000000..71c12f52969 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayIntegerIterator.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayLongIterator.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayLongIterator.class new file mode 100644 index 00000000000..2d7482b852f Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayLongIterator.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayShortIterator.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayShortIterator.class new file mode 100644 index 00000000000..c0a3bdde0e2 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$ArrayShortIterator.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator$GenericIterator.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$GenericIterator.class new file mode 100644 index 00000000000..310659f1366 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator$GenericIterator.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/ArrayIterator.class b/k2js/out/production/stdlib/jet/runtime/ArrayIterator.class new file mode 100644 index 00000000000..77cf4586109 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/ArrayIterator.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/Intrinsics$1.class b/k2js/out/production/stdlib/jet/runtime/Intrinsics$1.class new file mode 100644 index 00000000000..4edabe4924b Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/Intrinsics$1.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/Intrinsics$JetNullPointerException.class b/k2js/out/production/stdlib/jet/runtime/Intrinsics$JetNullPointerException.class new file mode 100644 index 00000000000..3aec2414d35 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/Intrinsics$JetNullPointerException.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/Intrinsics.class b/k2js/out/production/stdlib/jet/runtime/Intrinsics.class new file mode 100644 index 00000000000..154c8e3dbf3 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/Intrinsics.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/Ranges.class b/k2js/out/production/stdlib/jet/runtime/Ranges.class new file mode 100644 index 00000000000..2069ee977db Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/Ranges.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/SharedVar$Boolean.class b/k2js/out/production/stdlib/jet/runtime/SharedVar$Boolean.class new file mode 100644 index 00000000000..a70db88e494 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/SharedVar$Boolean.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/SharedVar$Byte.class b/k2js/out/production/stdlib/jet/runtime/SharedVar$Byte.class new file mode 100644 index 00000000000..dbbf4f3e7e7 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/SharedVar$Byte.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/SharedVar$Char.class b/k2js/out/production/stdlib/jet/runtime/SharedVar$Char.class new file mode 100644 index 00000000000..4823f88b21d Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/SharedVar$Char.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/SharedVar$Double.class b/k2js/out/production/stdlib/jet/runtime/SharedVar$Double.class new file mode 100644 index 00000000000..5f73ce1bbae Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/SharedVar$Double.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/SharedVar$Float.class b/k2js/out/production/stdlib/jet/runtime/SharedVar$Float.class new file mode 100644 index 00000000000..522bbf9d0a7 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/SharedVar$Float.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/SharedVar$Int.class b/k2js/out/production/stdlib/jet/runtime/SharedVar$Int.class new file mode 100644 index 00000000000..431fcebe8b0 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/SharedVar$Int.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/SharedVar$Long.class b/k2js/out/production/stdlib/jet/runtime/SharedVar$Long.class new file mode 100644 index 00000000000..6fc639a2dcd Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/SharedVar$Long.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/SharedVar$Object.class b/k2js/out/production/stdlib/jet/runtime/SharedVar$Object.class new file mode 100644 index 00000000000..a27f033cc2f Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/SharedVar$Object.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/SharedVar$Short.class b/k2js/out/production/stdlib/jet/runtime/SharedVar$Short.class new file mode 100644 index 00000000000..1220388c8a6 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/SharedVar$Short.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/SharedVar.class b/k2js/out/production/stdlib/jet/runtime/SharedVar.class new file mode 100644 index 00000000000..b4e76ad3815 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/SharedVar.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/typeinfo/JetClass.class b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetClass.class new file mode 100644 index 00000000000..1dd02445ef8 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetClass.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/typeinfo/JetConstructor.class b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetConstructor.class new file mode 100644 index 00000000000..d07cf5db30f Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetConstructor.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/typeinfo/JetMethod.class b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetMethod.class new file mode 100644 index 00000000000..973a8ee6d86 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetMethod.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/typeinfo/JetTypeDescriptor.class b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetTypeDescriptor.class new file mode 100644 index 00000000000..6ac855f73ed Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetTypeDescriptor.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/typeinfo/JetTypeParameter.class b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetTypeParameter.class new file mode 100644 index 00000000000..adc5002474a Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetTypeParameter.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/typeinfo/JetTypeProjection.class b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetTypeProjection.class new file mode 100644 index 00000000000..61dba1807b6 Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetTypeProjection.class differ diff --git a/k2js/out/production/stdlib/jet/runtime/typeinfo/JetValueParameter.class b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetValueParameter.class new file mode 100644 index 00000000000..63dbd0247ba Binary files /dev/null and b/k2js/out/production/stdlib/jet/runtime/typeinfo/JetValueParameter.class differ diff --git a/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$Const.class b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$Const.class new file mode 100644 index 00000000000..e3f40094c27 Binary files /dev/null and b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$Const.class differ diff --git a/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$Pattern.class b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$Pattern.class new file mode 100644 index 00000000000..5b1cbdb87f2 Binary files /dev/null and b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$Pattern.class differ diff --git a/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$TypeInfoPatternProjection$1.class b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$TypeInfoPatternProjection$1.class new file mode 100644 index 00000000000..c3db0f8f388 Binary files /dev/null and b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$TypeInfoPatternProjection$1.class differ diff --git a/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$TypeInfoPatternProjection.class b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$TypeInfoPatternProjection.class new file mode 100644 index 00000000000..09ddd9df33a Binary files /dev/null and b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$TypeInfoPatternProjection.class differ diff --git a/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$Var.class b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$Var.class new file mode 100644 index 00000000000..8b2391e51a1 Binary files /dev/null and b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern$Var.class differ diff --git a/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern.class b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern.class new file mode 100644 index 00000000000..2a1f6768864 Binary files /dev/null and b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoPattern.class differ diff --git a/k2js/out/production/stdlib/jet/typeinfo/TypeInfoProjection.class b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoProjection.class new file mode 100644 index 00000000000..de728fe29df Binary files /dev/null and b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoProjection.class differ diff --git a/k2js/out/production/stdlib/jet/typeinfo/TypeInfoVariance.class b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoVariance.class new file mode 100644 index 00000000000..577beb0caf4 Binary files /dev/null and b/k2js/out/production/stdlib/jet/typeinfo/TypeInfoVariance.class differ diff --git a/k2js/out/production/stdlib/modules/ModuleBuilder.kt b/k2js/out/production/stdlib/modules/ModuleBuilder.kt new file mode 100644 index 00000000000..487ef408f20 --- /dev/null +++ b/k2js/out/production/stdlib/modules/ModuleBuilder.kt @@ -0,0 +1,47 @@ +package kotlin.modules + +import java.util.* +import jet.modules.* + +fun module(name: String, callback: ModuleBuilder.() -> Unit) { + val builder = ModuleBuilder(name) + builder.callback() + AllModules.modules?.add(builder) +} + +class SourcesBuilder(val parent: ModuleBuilder) { + fun plusAssign(pattern: String) { + parent.addSourceFiles(pattern) + } +} + +class ClasspathBuilder(val parent: ModuleBuilder) { + fun plusAssign(name: String) { + parent.addClasspathEntry(name) + } +} + +open class ModuleBuilder(val name: String): Module { + // http://youtrack.jetbrains.net/issue/KT-904 + private val sourceFiles0: ArrayList = ArrayList() + private val classpathRoots0: ArrayList = ArrayList() + + val sources: SourcesBuilder + get() = SourcesBuilder(this) + + val classpath: ClasspathBuilder + get() = ClasspathBuilder(this) + + fun addSourceFiles(pattern: String) { + sourceFiles0.add(pattern) + } + + fun addClasspathEntry(name: String) { + classpathRoots0.add(name) + } + + override fun getSourceFiles(): List? = sourceFiles0 + override fun getClasspathRoots(): List? = classpathRoots0 + override fun getModuleName(): String? = name +} + diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/Signature.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/Signature.class new file mode 100644 index 00000000000..ded17fb3747 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/Signature.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoImpl$1.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoImpl$1.class new file mode 100644 index 00000000000..0a71c63159d Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoImpl$1.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoImpl$2.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoImpl$2.class new file mode 100644 index 00000000000..526240c6cc5 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoImpl$2.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoImpl.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoImpl.class new file mode 100644 index 00000000000..4cff09d2427 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoImpl.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1$1.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1$1.class new file mode 100644 index 00000000000..53c93550d63 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1$1.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1$2.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1$2.class new file mode 100644 index 00000000000..507b74c06dd Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1$2.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1$3.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1$3.class new file mode 100644 index 00000000000..87c93a0464e Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1$3.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1.class new file mode 100644 index 00000000000..ea6c0d310e2 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$1.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$2.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$2.class new file mode 100644 index 00000000000..9fe0a7aa652 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$2.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$3.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$3.class new file mode 100644 index 00000000000..b14e8ccf9d3 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1$3.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1.class new file mode 100644 index 00000000000..6d1178d564e Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$1.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$2.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$2.class new file mode 100644 index 00000000000..9e77962f975 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$2.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$3.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$3.class new file mode 100644 index 00000000000..7adf26c17d8 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$3.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$ArraySignature$1.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$ArraySignature$1.class new file mode 100644 index 00000000000..1254afa9766 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$ArraySignature$1.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$ArraySignature.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$ArraySignature.class new file mode 100644 index 00000000000..b36c6cbc18f Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$ArraySignature.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$SignatureParserJetSignatureAdapter$1$1.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$SignatureParserJetSignatureAdapter$1$1.class new file mode 100644 index 00000000000..cb869b19a06 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$SignatureParserJetSignatureAdapter$1$1.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$SignatureParserJetSignatureAdapter$1.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$SignatureParserJetSignatureAdapter$1.class new file mode 100644 index 00000000000..e746a9fa0f3 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$SignatureParserJetSignatureAdapter$1.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$SignatureParserJetSignatureAdapter.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$SignatureParserJetSignatureAdapter.class new file mode 100644 index 00000000000..7eb64cd529b Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser$SignatureParserJetSignatureAdapter.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser.class new file mode 100644 index 00000000000..00fb5c5639a Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoParser.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoProjectionImpl.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoProjectionImpl.class new file mode 100644 index 00000000000..cee559a3502 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoProjectionImpl.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoUtils.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoUtils.class new file mode 100644 index 00000000000..6cd38eda27b Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoUtils.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoVar.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoVar.class new file mode 100644 index 00000000000..cf4eebaded1 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/TypeInfoVar.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureAdapter.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureAdapter.class new file mode 100644 index 00000000000..1e00c207bcf Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureAdapter.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureExceptionsAdapter.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureExceptionsAdapter.class new file mode 100644 index 00000000000..9ca663be9a5 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureExceptionsAdapter.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureReader.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureReader.class new file mode 100644 index 00000000000..628bc793912 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureReader.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureVariance.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureVariance.class new file mode 100644 index 00000000000..70579b0327c Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureVariance.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureVisitor.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureVisitor.class new file mode 100644 index 00000000000..286bcf837b6 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureVisitor.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureWriter$1.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureWriter$1.class new file mode 100644 index 00000000000..195b999043c Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureWriter$1.class differ diff --git a/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureWriter.class b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureWriter.class new file mode 100644 index 00000000000..0d3fe618703 Binary files /dev/null and b/k2js/out/production/stdlib/org/jetbrains/jet/rt/signature/JetSignatureWriter.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/analyze/Analyzer$1.class b/k2js/out/production/translator/org/jetbrains/k2js/analyze/Analyzer$1.class new file mode 100644 index 00000000000..55b8fb64ccb Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/analyze/Analyzer$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/analyze/Analyzer$JsConfiguration.class b/k2js/out/production/translator/org/jetbrains/k2js/analyze/Analyzer$JsConfiguration.class new file mode 100644 index 00000000000..14f56141141 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/analyze/Analyzer$JsConfiguration.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/analyze/Analyzer.class b/k2js/out/production/translator/org/jetbrains/k2js/analyze/Analyzer.class new file mode 100644 index 00000000000..b3df255100d Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/analyze/Analyzer.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/config/Config.class b/k2js/out/production/translator/org/jetbrains/k2js/config/Config.class new file mode 100644 index 00000000000..0a53dc3b315 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/config/Config.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/config/IDEAConfig.class b/k2js/out/production/translator/org/jetbrains/k2js/config/IDEAConfig.class new file mode 100644 index 00000000000..b240f0dfa1e Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/config/IDEAConfig.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/config/TestConfig$1.class b/k2js/out/production/translator/org/jetbrains/k2js/config/TestConfig$1.class new file mode 100644 index 00000000000..a737c923435 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/config/TestConfig$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/config/TestConfig.class b/k2js/out/production/translator/org/jetbrains/k2js/config/TestConfig.class new file mode 100644 index 00000000000..1c810ea2a09 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/config/TestConfig.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/facade/K2JSTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/facade/K2JSTranslator.class new file mode 100644 index 00000000000..fc04f04051b Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/facade/K2JSTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/facade/K2JSTranslatorUtils.class b/k2js/out/production/translator/org/jetbrains/k2js/facade/K2JSTranslatorUtils.class new file mode 100644 index 00000000000..e279a430f93 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/facade/K2JSTranslatorUtils.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/generate/CodeGenerator.class b/k2js/out/production/translator/org/jetbrains/k2js/generate/CodeGenerator.class new file mode 100644 index 00000000000..de5e617153b Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/generate/CodeGenerator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/Aliaser.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/Aliaser.class new file mode 100644 index 00000000000..39dff663cf1 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/Aliaser.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/DynamicContext.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/DynamicContext.class new file mode 100644 index 00000000000..a3cf259e6ae Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/DynamicContext.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/Namer.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/Namer.class new file mode 100644 index 00000000000..931e80c2935 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/Namer.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/NamingScope.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/NamingScope.class new file mode 100644 index 00000000000..ef346fffdee Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/NamingScope.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StandardClasses$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StandardClasses$1.class new file mode 100644 index 00000000000..f2d5f3cd5da Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StandardClasses$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StandardClasses$Builder.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StandardClasses$Builder.class new file mode 100644 index 00000000000..9b7a0d99475 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StandardClasses$Builder.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StandardClasses.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StandardClasses.class new file mode 100644 index 00000000000..afefb41cc2b Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StandardClasses.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$1.class new file mode 100644 index 00000000000..702fb772dc3 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$1.class new file mode 100644 index 00000000000..de1d1d9c5c7 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$10.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$10.class new file mode 100644 index 00000000000..1b80238dde3 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$10.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$2.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$2.class new file mode 100644 index 00000000000..68a970538b3 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$2.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$3.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$3.class new file mode 100644 index 00000000000..58de4d54d8a Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$3.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$4.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$4.class new file mode 100644 index 00000000000..82f89150319 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$4.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$5.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$5.class new file mode 100644 index 00000000000..534d4dca531 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$5.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$6.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$6.class new file mode 100644 index 00000000000..018be2474da Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$6.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$7.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$7.class new file mode 100644 index 00000000000..dd51ac6c3ae Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$7.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$8.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$8.class new file mode 100644 index 00000000000..3937e4ad173 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$8.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$9.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$9.class new file mode 100644 index 00000000000..e7c033228ee Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator$9.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator.class new file mode 100644 index 00000000000..986659dc5d2 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$NameGenerator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$1.class new file mode 100644 index 00000000000..d3b30af9489 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$2.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$2.class new file mode 100644 index 00000000000..6883565197d Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$2.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$3.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$3.class new file mode 100644 index 00000000000..279d2d01548 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$3.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$4.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$4.class new file mode 100644 index 00000000000..f98ac7618d1 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$4.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$5.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$5.class new file mode 100644 index 00000000000..10d693ccf57 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator$5.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator.class new file mode 100644 index 00000000000..7bbf52a9846 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierGenerator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator$1.class new file mode 100644 index 00000000000..dcf8e7c7a19 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator$2.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator$2.class new file mode 100644 index 00000000000..43ccba2e532 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator$2.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator$3.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator$3.class new file mode 100644 index 00000000000..d2d2484bb2a Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator$3.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator.class new file mode 100644 index 00000000000..136dbff629f Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$QualifierIsNullGenerator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$1.class new file mode 100644 index 00000000000..a1aab1d77d2 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$2.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$2.class new file mode 100644 index 00000000000..c96e980ce1e Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$2.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$3.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$3.class new file mode 100644 index 00000000000..5892a1dfb12 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$3.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$4.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$4.class new file mode 100644 index 00000000000..4cad1f61b1b Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator$4.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator.class new file mode 100644 index 00000000000..0d5e7ea6866 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext$ScopeGenerator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext.class new file mode 100644 index 00000000000..9c88388283d Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/StaticContext.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/TemporaryVariable.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/TemporaryVariable.class new file mode 100644 index 00000000000..611dd0af6a9 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/TemporaryVariable.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/TranslationContext.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/TranslationContext.class new file mode 100644 index 00000000000..a04372fcb00 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/TranslationContext.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/generator/Generator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/generator/Generator.class new file mode 100644 index 00000000000..136fede43e2 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/generator/Generator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/context/generator/Rule.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/generator/Rule.class new file mode 100644 index 00000000000..aceefab61d9 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/context/generator/Rule.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/ClassDeclarationTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/ClassDeclarationTranslator.class new file mode 100644 index 00000000000..06761378d68 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/ClassDeclarationTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/ClassTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/ClassTranslator.class new file mode 100644 index 00000000000..b13cb1bdfb4 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/ClassTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/DeclarationBodyVisitor.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/DeclarationBodyVisitor.class new file mode 100644 index 00000000000..acb89b3f536 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/DeclarationBodyVisitor.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/NamespaceDeclarationTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/NamespaceDeclarationTranslator.class new file mode 100644 index 00000000000..77f77d63eb2 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/NamespaceDeclarationTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/NamespaceTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/NamespaceTranslator.class new file mode 100644 index 00000000000..de072f1f24d Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/NamespaceTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/PropertyTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/PropertyTranslator.class new file mode 100644 index 00000000000..8dd88f57a66 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/declaration/PropertyTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/ExpressionVisitor.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/ExpressionVisitor.class new file mode 100644 index 00000000000..1b72f350b3d Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/ExpressionVisitor.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/ForTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/ForTranslator.class new file mode 100644 index 00000000000..eb3db5d03f5 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/ForTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/FunctionTranslator$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/FunctionTranslator$1.class new file mode 100644 index 00000000000..4db7dc9d5e7 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/FunctionTranslator$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/FunctionTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/FunctionTranslator.class new file mode 100644 index 00000000000..d1a8ab4a534 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/FunctionTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/PatternTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/PatternTranslator.class new file mode 100644 index 00000000000..a8d0838ab99 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/PatternTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/StringTemplateTranslator$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/StringTemplateTranslator$1.class new file mode 100644 index 00000000000..1774008904a Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/StringTemplateTranslator$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/StringTemplateTranslator$EntryVisitor.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/StringTemplateTranslator$EntryVisitor.class new file mode 100644 index 00000000000..89339878eb9 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/StringTemplateTranslator$EntryVisitor.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/StringTemplateTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/StringTemplateTranslator.class new file mode 100644 index 00000000000..cb7b534b825 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/StringTemplateTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/TryTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/TryTranslator.class new file mode 100644 index 00000000000..eb44b6bd0fa Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/TryTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/WhenTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/WhenTranslator.class new file mode 100644 index 00000000000..cf74f3926b5 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/expression/WhenTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/general/AbstractTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/general/AbstractTranslator.class new file mode 100644 index 00000000000..3ea600a2e68 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/general/AbstractTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/general/Translation.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/general/Translation.class new file mode 100644 index 00000000000..6bda847891d Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/general/Translation.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/general/TranslatorVisitor.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/general/TranslatorVisitor.class new file mode 100644 index 00000000000..7c65d666546 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/general/TranslatorVisitor.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/AbstractInitializerTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/AbstractInitializerTranslator.class new file mode 100644 index 00000000000..6f5f9a5d6e0 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/AbstractInitializerTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/ClassInitializerTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/ClassInitializerTranslator.class new file mode 100644 index 00000000000..fcef9bf7bea Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/ClassInitializerTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/InitializerVisitor.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/InitializerVisitor.class new file mode 100644 index 00000000000..fbee763c329 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/InitializerVisitor.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/NamespaceInitializerTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/NamespaceInitializerTranslator.class new file mode 100644 index 00000000000..a0d44e4c2b7 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/initializer/NamespaceInitializerTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/CompareToIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/CompareToIntrinsic.class new file mode 100644 index 00000000000..28df2220c06 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/CompareToIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/EqualsIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/EqualsIntrinsic.class new file mode 100644 index 00000000000..e7265f43275 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/EqualsIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/FunctionIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/FunctionIntrinsic.class new file mode 100644 index 00000000000..fd3c86c9817 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/FunctionIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsic.class new file mode 100644 index 00000000000..cc87bea628c Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsics$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsics$1.class new file mode 100644 index 00000000000..200aee2f8d7 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsics$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsics$IntrinsicDeclarationVisitor.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsics$IntrinsicDeclarationVisitor.class new file mode 100644 index 00000000000..8d69bf9582e Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsics$IntrinsicDeclarationVisitor.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsics.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsics.class new file mode 100644 index 00000000000..bf3114ca26b Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/Intrinsics.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayFunctionConstructorIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayFunctionConstructorIntrinsic.class new file mode 100644 index 00000000000..4d232811db7 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayFunctionConstructorIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayGetIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayGetIntrinsic.class new file mode 100644 index 00000000000..c3f7084078a Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayGetIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayIndicesIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayIndicesIntrinsic.class new file mode 100644 index 00000000000..a6d36fcfd5c Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayIndicesIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayIteratorIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayIteratorIntrinsic.class new file mode 100644 index 00000000000..bcb1a580013 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayIteratorIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayNullConstructorIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayNullConstructorIntrinsic.class new file mode 100644 index 00000000000..d21f722d56b Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArrayNullConstructorIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArraySetIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArraySetIntrinsic.class new file mode 100644 index 00000000000..984e764202e Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArraySetIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArraySizeIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArraySizeIntrinsic.class new file mode 100644 index 00000000000..9508e07970e Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/array/ArraySizeIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveBinaryOperationIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveBinaryOperationIntrinsic.class new file mode 100644 index 00000000000..45792e418b5 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveBinaryOperationIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveCompareToIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveCompareToIntrinsic.class new file mode 100644 index 00000000000..1f16142de25 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveCompareToIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveEqualsIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveEqualsIntrinsic.class new file mode 100644 index 00000000000..54d59fe259b Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveEqualsIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveRangeToIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveRangeToIntrinsic.class new file mode 100644 index 00000000000..00ddc748d44 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveRangeToIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveUnaryOperationIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveUnaryOperationIntrinsic.class new file mode 100644 index 00000000000..914c0916aeb Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveUnaryOperationIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/string/CharAtIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/string/CharAtIntrinsic.class new file mode 100644 index 00000000000..d847a97ba07 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/string/CharAtIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/string/LengthIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/string/LengthIntrinsic.class new file mode 100644 index 00000000000..7322d293f2b Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/string/LengthIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/tuple/TupleAccessIntrinsic.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/tuple/TupleAccessIntrinsic.class new file mode 100644 index 00000000000..4cfdc7622d5 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/intrinsic/tuple/TupleAccessIntrinsic.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/AssignmentTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/AssignmentTranslator.class new file mode 100644 index 00000000000..7b6594c6c62 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/AssignmentTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/BinaryOperationTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/BinaryOperationTranslator.class new file mode 100644 index 00000000000..1a461268252 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/BinaryOperationTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/CompareToTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/CompareToTranslator.class new file mode 100644 index 00000000000..841ede7d436 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/CompareToTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/IncrementTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/IncrementTranslator.class new file mode 100644 index 00000000000..3060da32013 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/IncrementTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/IntrinsicAssignmentTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/IntrinsicAssignmentTranslator.class new file mode 100644 index 00000000000..eefe43bec8d Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/IntrinsicAssignmentTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/IntrinsicIncrementTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/IntrinsicIncrementTranslator.class new file mode 100644 index 00000000000..2e70a8bd14d Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/IntrinsicIncrementTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/OperatorTable.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/OperatorTable.class new file mode 100644 index 00000000000..ee6c297fcb3 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/OperatorTable.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/OverloadedAssignmentTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/OverloadedAssignmentTranslator.class new file mode 100644 index 00000000000..b89ec807f8c Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/OverloadedAssignmentTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/OverloadedIncrementTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/OverloadedIncrementTranslator.class new file mode 100644 index 00000000000..3ff52a3a5a9 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/OverloadedIncrementTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/UnaryOperationTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/UnaryOperationTranslator.class new file mode 100644 index 00000000000..9dbe4cc129c Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/operation/UnaryOperationTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/AccessTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/AccessTranslator.class new file mode 100644 index 00000000000..d0fd9bfb184 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/AccessTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/ArrayAccessTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/ArrayAccessTranslator.class new file mode 100644 index 00000000000..925e1e3ee49 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/ArrayAccessTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallBuilder.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallBuilder.class new file mode 100644 index 00000000000..058251befa2 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallBuilder.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallExpressionTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallExpressionTranslator.class new file mode 100644 index 00000000000..7f1b922db32 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallExpressionTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$1.class new file mode 100644 index 00000000000..a03585a4af2 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$2.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$2.class new file mode 100644 index 00000000000..389f90ac41b Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$2.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$3.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$3.class new file mode 100644 index 00000000000..ac72cd05f27 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$3.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$CallParameters.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$CallParameters.class new file mode 100644 index 00000000000..1a2b0dd6f7f Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator$CallParameters.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator.class new file mode 100644 index 00000000000..eff97b301ae Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType$1.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType$1.class new file mode 100644 index 00000000000..11bf54772e5 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType$2.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType$2.class new file mode 100644 index 00000000000..c448fea6eb0 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType$2.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType$CallConstructor.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType$CallConstructor.class new file mode 100644 index 00000000000..c66c26e2c37 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType$CallConstructor.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType.class new file mode 100644 index 00000000000..27094251066 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/CallType.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/KotlinPropertyAccessTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/KotlinPropertyAccessTranslator.class new file mode 100644 index 00000000000..89d3da98388 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/KotlinPropertyAccessTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/NativePropertyAccessTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/NativePropertyAccessTranslator.class new file mode 100644 index 00000000000..d19d4ce678a Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/NativePropertyAccessTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/PropertyAccessTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/PropertyAccessTranslator.class new file mode 100644 index 00000000000..374df25795a Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/PropertyAccessTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/QualifiedExpressionTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/QualifiedExpressionTranslator.class new file mode 100644 index 00000000000..af51cbad365 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/QualifiedExpressionTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/ReferenceAccessTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/ReferenceAccessTranslator.class new file mode 100644 index 00000000000..79080ce34ff Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/ReferenceAccessTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/ReferenceTranslator.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/ReferenceTranslator.class new file mode 100644 index 00000000000..32e2e701cc2 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/reference/ReferenceTranslator.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/AnnotationsUtils.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/AnnotationsUtils.class new file mode 100644 index 00000000000..6228fd87c48 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/AnnotationsUtils.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/BindingUtils.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/BindingUtils.class new file mode 100644 index 00000000000..5fb575f9146 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/BindingUtils.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/ClassSorter.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/ClassSorter.class new file mode 100644 index 00000000000..b948afd2e85 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/ClassSorter.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/DescriptorUtils.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/DescriptorUtils.class new file mode 100644 index 00000000000..6371e87c551 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/DescriptorUtils.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/PsiUtils.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/PsiUtils.class new file mode 100644 index 00000000000..6109092a792 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/PsiUtils.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/TranslationUtils.class b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/TranslationUtils.class new file mode 100644 index 00000000000..33f42f9b4ad Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/translate/utils/TranslationUtils.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/utils/GenerationUtils.class b/k2js/out/production/translator/org/jetbrains/k2js/utils/GenerationUtils.class new file mode 100644 index 00000000000..434a267c837 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/utils/GenerationUtils.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/utils/JetFileUtils.class b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetFileUtils.class new file mode 100644 index 00000000000..9436f995d40 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetFileUtils.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$1$1.class b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$1$1.class new file mode 100644 index 00000000000..adb777e51b7 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$1$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$1.class b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$1.class new file mode 100644 index 00000000000..e64592a32db Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$2$1.class b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$2$1.class new file mode 100644 index 00000000000..6cbaadad570 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$2$1.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$2.class b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$2.class new file mode 100644 index 00000000000..68c36efeb71 Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils$2.class differ diff --git a/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils.class b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils.class new file mode 100644 index 00000000000..f6d2db30d1a Binary files /dev/null and b/k2js/out/production/translator/org/jetbrains/k2js/utils/JetTestUtils.class differ diff --git a/k2js/out/production/util/org/jetbrains/jet/plugin/compiler/PathUtil.class b/k2js/out/production/util/org/jetbrains/jet/plugin/compiler/PathUtil.class new file mode 100644 index 00000000000..d659457aa3b Binary files /dev/null and b/k2js/out/production/util/org/jetbrains/jet/plugin/compiler/PathUtil.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetLiteFixture$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetLiteFixture$1.class new file mode 100644 index 00000000000..44626181a67 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetLiteFixture$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetLiteFixture.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetLiteFixture.class new file mode 100644 index 00000000000..9cc699cc514 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetLiteFixture.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$1.class new file mode 100644 index 00000000000..d5865ed7957 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$2.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$2.class new file mode 100644 index 00000000000..4dab837116d Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$2.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$3.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$3.class new file mode 100644 index 00000000000..2e2ab428abb Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$3.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$4.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$4.class new file mode 100644 index 00000000000..b38885b8fb1 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$4.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$NamedTestFactory.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$NamedTestFactory.class new file mode 100644 index 00000000000..00ac4bc66c1 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder$NamedTestFactory.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder.class new file mode 100644 index 00000000000..1c040a3c7e1 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestCaseBuilder.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$1$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$1$1.class new file mode 100644 index 00000000000..e4c1d3a98ed Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$1$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$1.class new file mode 100644 index 00000000000..3f648ea9aca Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$2$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$2$1.class new file mode 100644 index 00000000000..1c3b2108b0e Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$2$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$2.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$2.class new file mode 100644 index 00000000000..002efa1e629 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$2.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$3$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$3$1.class new file mode 100644 index 00000000000..9056624b375 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$3$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$3.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$3.class new file mode 100644 index 00000000000..dc105ee01aa Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$3.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$TestFileFactory.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$TestFileFactory.class new file mode 100644 index 00000000000..66c83676c89 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils$TestFileFactory.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils.class new file mode 100644 index 00000000000..2e3b130e24e Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/JetTestUtils.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$1.class new file mode 100644 index 00000000000..d2c5fcc5bd4 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$2.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$2.class new file mode 100644 index 00000000000..ea3d513570b Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$2.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$3.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$3.class new file mode 100644 index 00000000000..9c87a408b64 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$3.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$4.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$4.class new file mode 100644 index 00000000000..cd73523cf99 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest$4.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest.class new file mode 100644 index 00000000000..534f0ebc9f7 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/cfg/JetControlFlowTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$1.class new file mode 100644 index 00000000000..97fdab61fbf Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$2.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$2.class new file mode 100644 index 00000000000..037895884b3 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$2.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$3.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$3.class new file mode 100644 index 00000000000..9d664d83255 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$3.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$4.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$4.class new file mode 100644 index 00000000000..6878e12f459 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$4.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$5.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$5.class new file mode 100644 index 00000000000..62149acc0e3 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$5.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$TheTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$TheTest$1.class new file mode 100644 index 00000000000..181efa9414d Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$TheTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$TheTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$TheTest.class new file mode 100644 index 00000000000..cd95ad08a55 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest$TheTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.class new file mode 100644 index 00000000000..47f4ac7b740 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$1.class new file mode 100644 index 00000000000..b57e430c92f Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$2.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$2.class new file mode 100644 index 00000000000..e2fdc5b3aa9 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$2.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$TestFile$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$TestFile$1.class new file mode 100644 index 00000000000..9118d4970f0 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$TestFile$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$TestFile.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$TestFile.class new file mode 100644 index 00000000000..9faf4dd49ad Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest$TestFile.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.class new file mode 100644 index 00000000000..b844c3758f5 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/AnnotationGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/AnnotationGenTest.class new file mode 100644 index 00000000000..c4c7719595c Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/AnnotationGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ArrayGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ArrayGenTest.class new file mode 100644 index 00000000000..c2ba23c0a73 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ArrayGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/BridgeMethodGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/BridgeMethodGenTest.class new file mode 100644 index 00000000000..47f64beb0dc Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/BridgeMethodGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ClassGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ClassGenTest.class new file mode 100644 index 00000000000..5f718a14011 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ClassGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ClosuresGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ClosuresGenTest.class new file mode 100644 index 00000000000..50b3f74f9ab Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ClosuresGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/CodegenTestCase$MyClassLoader.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/CodegenTestCase$MyClassLoader.class new file mode 100644 index 00000000000..14d4117bf04 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/CodegenTestCase$MyClassLoader.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/CodegenTestCase.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/CodegenTestCase.class new file mode 100644 index 00000000000..f4861a8b1c3 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/CodegenTestCase.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ControlStructuresTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ControlStructuresTest.class new file mode 100644 index 00000000000..5b2f86ada37 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ControlStructuresTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.class new file mode 100644 index 00000000000..47b20da436d Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ForTestCompileStdlib.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ForTestCompileStdlib.class new file mode 100644 index 00000000000..47f22aac70b Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ForTestCompileStdlib.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/FunctionGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/FunctionGenTest.class new file mode 100644 index 00000000000..cd618f8b906 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/FunctionGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/NamespaceGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/NamespaceGenTest.class new file mode 100644 index 00000000000..97991d59be7 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/NamespaceGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ObjectGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ObjectGenTest.class new file mode 100644 index 00000000000..dc6810bdd7b Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/ObjectGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/PatternMatchingTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/PatternMatchingTest.class new file mode 100644 index 00000000000..d63a8fd9a0d Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/PatternMatchingTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.class new file mode 100644 index 00000000000..2cbc62399db Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/PropertyGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/PropertyGenTest.class new file mode 100644 index 00000000000..bb5d1d8621c Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/PropertyGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/SafeRefTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/SafeRefTest.class new file mode 100644 index 00000000000..b423b5fd0bf Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/SafeRefTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/StdlibTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/StdlibTest.class new file mode 100644 index 00000000000..5174cb56a4c Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/StdlibTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/StringsTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/StringsTest.class new file mode 100644 index 00000000000..422be6480a2 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/StringsTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/SuperGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/SuperGenTest.class new file mode 100644 index 00000000000..feb1560e244 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/SuperGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TestlibTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TestlibTest.class new file mode 100644 index 00000000000..30c2068652c Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TestlibTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TraitsTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TraitsTest.class new file mode 100644 index 00000000000..392b0dc74af Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TraitsTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TupleGenTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TupleGenTest.class new file mode 100644 index 00000000000..6d6aa7932c5 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TupleGenTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TypeInfoTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TypeInfoTest$1.class new file mode 100644 index 00000000000..06e69516abb Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TypeInfoTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TypeInfoTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TypeInfoTest.class new file mode 100644 index 00000000000..22b4640be5d Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/TypeInfoTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/VarArgTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/VarArgTest.class new file mode 100644 index 00000000000..4b1e1324be4 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/codegen/VarArgTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileEnvironmentTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileEnvironmentTest.class new file mode 100644 index 00000000000..199d9ba6604 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileEnvironmentTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileJavaAgainstKotlinTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileJavaAgainstKotlinTest$1.class new file mode 100644 index 00000000000..3092d9c530f Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileJavaAgainstKotlinTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileJavaAgainstKotlinTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileJavaAgainstKotlinTest.class new file mode 100644 index 00000000000..2668dc95e69 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileJavaAgainstKotlinTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileKotlinAgainstKotlinTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileKotlinAgainstKotlinTest$1.class new file mode 100644 index 00000000000..75bc1e2a33e Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileKotlinAgainstKotlinTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileKotlinAgainstKotlinTest$1Filter.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileKotlinAgainstKotlinTest$1Filter.class new file mode 100644 index 00000000000..6da835ea945 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileKotlinAgainstKotlinTest$1Filter.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileKotlinAgainstKotlinTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileKotlinAgainstKotlinTest.class new file mode 100644 index 00000000000..70138bb4e21 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/CompileKotlinAgainstKotlinTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$1.class new file mode 100644 index 00000000000..53b66058c1a Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$FullContentSerialier.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$FullContentSerialier.class new file mode 100644 index 00000000000..3d5363c4dd6 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$FullContentSerialier.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$NamespacePrefixSerializer.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$NamespacePrefixSerializer.class new file mode 100644 index 00000000000..b23e0d82067 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$NamespacePrefixSerializer.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$Serializer.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$Serializer.class new file mode 100644 index 00000000000..bb1f89da7cf Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$Serializer.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$ValueParameterSerializer.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$ValueParameterSerializer.class new file mode 100644 index 00000000000..7a29b2089b4 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator$ValueParameterSerializer.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator.class new file mode 100644 index 00000000000..4e4b8de9788 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/NamespaceComparator.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadJavaBinaryClassTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadJavaBinaryClassTest$1.class new file mode 100644 index 00000000000..eaac51dd4d6 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadJavaBinaryClassTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadJavaBinaryClassTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadJavaBinaryClassTest.class new file mode 100644 index 00000000000..bf61d2bdf64 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadJavaBinaryClassTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadKotlinBinaryClassTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadKotlinBinaryClassTest$1.class new file mode 100644 index 00000000000..33d2781eb0c Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadKotlinBinaryClassTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadKotlinBinaryClassTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadKotlinBinaryClassTest.class new file mode 100644 index 00000000000..ad688b3bf2a Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/ReadKotlinBinaryClassTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/TestCaseWithTmpdir.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/TestCaseWithTmpdir.class new file mode 100644 index 00000000000..1f721c2cd41 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/TestCaseWithTmpdir.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1.class new file mode 100644 index 00000000000..df256c830cd Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor$1$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor$1$1.class new file mode 100644 index 00000000000..6a906ef18fb Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor$1$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor$1$2.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor$1$2.class new file mode 100644 index 00000000000..1f725404d4f Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor$1$2.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor$1.class new file mode 100644 index 00000000000..2c74b9a02ac Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor.class new file mode 100644 index 00000000000..8ed9ca7328d Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$1Visitor.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$ActualSignature.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$ActualSignature.class new file mode 100644 index 00000000000..53c99940179 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$ActualSignature.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$Expectation.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$Expectation.class new file mode 100644 index 00000000000..466f336e4fa Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest$Expectation.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest.class new file mode 100644 index 00000000000..d6a6e47cb89 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/compiler/WriteSignatureTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/lang/psi/JetPsiUtilTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/lang/psi/JetPsiUtilTest.class new file mode 100644 index 00000000000..8dcf2ee95f9 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/lang/psi/JetPsiUtilTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetCodeConformanceTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetCodeConformanceTest.class new file mode 100644 index 00000000000..27dc1e06f19 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetCodeConformanceTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetParsingTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetParsingTest$1.class new file mode 100644 index 00000000000..7c7bb9aaae2 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetParsingTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetParsingTest$2.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetParsingTest$2.class new file mode 100644 index 00000000000..917d73b41c0 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetParsingTest$2.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetParsingTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetParsingTest.class new file mode 100644 index 00000000000..8432df42432 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/parsing/JetParsingTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExpectedResolveData$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExpectedResolveData$1.class new file mode 100644 index 00000000000..b0eb9ba89da Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExpectedResolveData$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExpectedResolveData$Position.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExpectedResolveData$Position.class new file mode 100644 index 00000000000..48116c83f11 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExpectedResolveData$Position.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExpectedResolveData.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExpectedResolveData.class new file mode 100644 index 00000000000..4fbfc2b73d4 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExpectedResolveData.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExtensibleResolveTestCase$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExtensibleResolveTestCase$1.class new file mode 100644 index 00000000000..4e274341bc1 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExtensibleResolveTestCase$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExtensibleResolveTestCase.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExtensibleResolveTestCase.class new file mode 100644 index 00000000000..c473e48433e Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/ExtensibleResolveTestCase.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/JetResolveTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/JetResolveTest$1.class new file mode 100644 index 00000000000..58604d2923a Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/JetResolveTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/JetResolveTest$2.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/JetResolveTest$2.class new file mode 100644 index 00000000000..5f7494cc843 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/JetResolveTest$2.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/JetResolveTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/JetResolveTest.class new file mode 100644 index 00000000000..582aec89388 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/resolve/JetResolveTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/runtime/JetNpeTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/runtime/JetNpeTest.class new file mode 100644 index 00000000000..710935f0543 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/runtime/JetNpeTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest$JetDefaultModalityModifiersTestCase.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest$JetDefaultModalityModifiersTestCase.class new file mode 100644 index 00000000000..209b5fb9b81 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest$JetDefaultModalityModifiersTestCase.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.class new file mode 100644 index 00000000000..0a9e4efa058 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetOverloadTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetOverloadTest.class new file mode 100644 index 00000000000..61ed04b42f0 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetOverloadTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetOverridingTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetOverridingTest.class new file mode 100644 index 00000000000..0db7a668d6f Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetOverridingTest.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$1.class new file mode 100644 index 00000000000..da9e2af5d72 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$ClassDefinitions$1.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$ClassDefinitions$1.class new file mode 100644 index 00000000000..5a51f2c4e28 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$ClassDefinitions$1.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$ClassDefinitions$2.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$ClassDefinitions$2.class new file mode 100644 index 00000000000..a8e3c457455 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$ClassDefinitions$2.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$ClassDefinitions.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$ClassDefinitions.class new file mode 100644 index 00000000000..15def5c44d4 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest$ClassDefinitions.class differ diff --git a/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest.class b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest.class new file mode 100644 index 00000000000..6748e849a65 Binary files /dev/null and b/k2js/out/test/compiler-tests/org/jetbrains/jet/types/JetTypeCheckerTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/AbstractExpressionTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/AbstractExpressionTest.class new file mode 100644 index 00000000000..4cb446e4fcc Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/AbstractExpressionTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ArrayListTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ArrayListTest.class new file mode 100644 index 00000000000..b5275ff20f3 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ArrayListTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/BaseTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/BaseTest.class new file mode 100644 index 00000000000..f7aacc8065e Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/BaseTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/BasicClassTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/BasicClassTest.class new file mode 100644 index 00000000000..2f60336e4dd Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/BasicClassTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ClassInheritanceTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ClassInheritanceTest.class new file mode 100644 index 00000000000..93b0de01ed2 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ClassInheritanceTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ConditionalTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ConditionalTest.class new file mode 100644 index 00000000000..e4836cdafbe Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ConditionalTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExampleTestSuite$1.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExampleTestSuite$1.class new file mode 100644 index 00000000000..198174d0ebd Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExampleTestSuite$1.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExampleTestSuite.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExampleTestSuite.class new file mode 100644 index 00000000000..6c6f310cf51 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExampleTestSuite.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExtensionFunctionTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExtensionFunctionTest.class new file mode 100644 index 00000000000..5ed0193b3ea Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExtensionFunctionTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExtensionPropertyTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExtensionPropertyTest.class new file mode 100644 index 00000000000..ae2efb7b08e Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ExtensionPropertyTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ForTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ForTest.class new file mode 100644 index 00000000000..bb2f61f93cf Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ForTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/FunctionTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/FunctionTest.class new file mode 100644 index 00000000000..f6773db70e6 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/FunctionTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/JavaClassesTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/JavaClassesTest.class new file mode 100644 index 00000000000..60565244cc6 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/JavaClassesTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/KotlinLibTest$1.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/KotlinLibTest$1.class new file mode 100644 index 00000000000..e84986fcd7a Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/KotlinLibTest$1.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/KotlinLibTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/KotlinLibTest.class new file mode 100644 index 00000000000..f5adedec1cb Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/KotlinLibTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/MiscTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/MiscTest.class new file mode 100644 index 00000000000..b58e030532e Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/MiscTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/MultiFileTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/MultiFileTest.class new file mode 100644 index 00000000000..50cd836d0a2 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/MultiFileTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/MultiNamespaceTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/MultiNamespaceTest.class new file mode 100644 index 00000000000..a6ee234328f Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/MultiNamespaceTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/NameClashesTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/NameClashesTest.class new file mode 100644 index 00000000000..d5b089fedcd Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/NameClashesTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ObjectTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ObjectTest.class new file mode 100644 index 00000000000..671b58a1584 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/ObjectTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/OperatorOverloadingTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/OperatorOverloadingTest.class new file mode 100644 index 00000000000..af15b9263f4 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/OperatorOverloadingTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/PatternMatchingTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/PatternMatchingTest.class new file mode 100644 index 00000000000..1d03d2b21af Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/PatternMatchingTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/PropertyAccessTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/PropertyAccessTest.class new file mode 100644 index 00000000000..32d55e0680a Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/PropertyAccessTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RTTITest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RTTITest.class new file mode 100644 index 00000000000..16fd7d3126a Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RTTITest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RangeTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RangeTest.class new file mode 100644 index 00000000000..b77a0bfdfc1 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RangeTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoFunctionResultChecker.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoFunctionResultChecker.class new file mode 100644 index 00000000000..8921a012972 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoFunctionResultChecker.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoPropertyTypesChecker.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoPropertyTypesChecker.class new file mode 100644 index 00000000000..1021d7d81f4 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoPropertyTypesChecker.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoResultChecker.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoResultChecker.class new file mode 100644 index 00000000000..991a6de63e1 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoResultChecker.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoSystemOutputChecker.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoSystemOutputChecker.class new file mode 100644 index 00000000000..d00410e8f59 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoSystemOutputChecker.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoUtils.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoUtils.class new file mode 100644 index 00000000000..b218d3cfd54 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/RhinoUtils.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/SimpleTestSuite$1.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/SimpleTestSuite$1.class new file mode 100644 index 00000000000..de27cff1635 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/SimpleTestSuite$1.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/SimpleTestSuite.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/SimpleTestSuite.class new file mode 100644 index 00000000000..a0b3e39142a Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/SimpleTestSuite.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/StandardClassesTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/StandardClassesTest.class new file mode 100644 index 00000000000..e7c6d7f11d9 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/StandardClassesTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/StringTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/StringTest.class new file mode 100644 index 00000000000..ffd7a1a2b51 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/StringTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite$1.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite$1.class new file mode 100644 index 00000000000..c7bdac391bf Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite$1.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite$2.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite$2.class new file mode 100644 index 00000000000..0cf76801ad7 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite$2.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite$SingleFileTester.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite$SingleFileTester.class new file mode 100644 index 00000000000..c5b4b2ec24a Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite$SingleFileTester.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite.class new file mode 100644 index 00000000000..8906648b535 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/Suite.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TraitTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TraitTest.class new file mode 100644 index 00000000000..4299b66a4c6 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TraitTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslationTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslationTest.class new file mode 100644 index 00000000000..bc7fef386df Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslationTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$1.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$1.class new file mode 100644 index 00000000000..b48b1935344 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$1.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$2.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$2.class new file mode 100644 index 00000000000..9f8d58ea61d Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$2.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$3.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$3.class new file mode 100644 index 00000000000..3d7af1d5936 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$3.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$4.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$4.class new file mode 100644 index 00000000000..246bc30329f Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$4.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$NamedTestFactory.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$NamedTestFactory.class new file mode 100644 index 00000000000..9427573a389 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder$NamedTestFactory.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder.class new file mode 100644 index 00000000000..1f789cf25e3 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TranslatorTestCaseBuilder.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TupleTest.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TupleTest.class new file mode 100644 index 00000000000..a78f38ea2ac Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/TupleTest.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/WebDemoExamples1Test.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/WebDemoExamples1Test.class new file mode 100644 index 00000000000..ee937e6b5db Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/WebDemoExamples1Test.class differ diff --git a/k2js/out/test/translatorTests/org/jetbrains/k2js/test/WebDemoExamples2Test.class b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/WebDemoExamples2Test.class new file mode 100644 index 00000000000..823b8196544 Binary files /dev/null and b/k2js/out/test/translatorTests/org/jetbrains/k2js/test/WebDemoExamples2Test.class differ diff --git a/k2js/translator/testFiles/class/out/classInstantiation.js b/k2js/translator/testFiles/class/out/classInstantiation.js new file mode 100644 index 00000000000..dd262ccec77 --- /dev/null +++ b/k2js/translator/testFiles/class/out/classInstantiation.js @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var Test = Kotlin.Class.create({initialize:function(){ + } + }); + return {Test_0:Test}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var test = new foo.Test_0; + return true; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/class/out/classWithoutNamespace.js b/k2js/translator/testFiles/class/out/classWithoutNamespace.js new file mode 100644 index 00000000000..d15ad6a889c --- /dev/null +++ b/k2js/translator/testFiles/class/out/classWithoutNamespace.js @@ -0,0 +1,26 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(a){ + this.$a = a; + { + this.$a = 3; + } + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {A:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new Anonymous.A(1)).get_a() == 3; + } +} +}, {A:classes.A}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/class/out/complexExpressionAsConstructorParameter.js b/k2js/translator/testFiles/class/out/complexExpressionAsConstructorParameter.js new file mode 100644 index 00000000000..2110aec74d3 --- /dev/null +++ b/k2js/translator/testFiles/class/out/complexExpressionAsConstructorParameter.js @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var Test = Kotlin.Class.create({initialize:function(a, b){ + this.$c = a; + this.$d = b; + } + , get_c:function(){ + return this.$c; + } + , get_d:function(){ + return this.$d; + } + }); + return {Test_0:Test}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var test = new foo.Test_0(1 + 6 * 3, 10 % 2); + return test.get_c() == 19 && test.get_d() == 0; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/class/out/constructorWithParameter.js b/k2js/translator/testFiles/class/out/constructorWithParameter.js new file mode 100644 index 00000000000..21bbff908d6 --- /dev/null +++ b/k2js/translator/testFiles/class/out/constructorWithParameter.js @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var Test = Kotlin.Class.create({initialize:function(a){ + this.$b = a; + } + , get_b:function(){ + return this.$b; + } + }); + return {Test_0:Test}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var test = new foo.Test_0(1); + return test.get_b() == 1; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/class/out/constructorWithPropertiesAsParameters.js b/k2js/translator/testFiles/class/out/constructorWithPropertiesAsParameters.js new file mode 100644 index 00000000000..6cfad6ef0d1 --- /dev/null +++ b/k2js/translator/testFiles/class/out/constructorWithPropertiesAsParameters.js @@ -0,0 +1,51 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var A = Kotlin.Class.create({initialize:function(b, a){ + this.$b = b; + this.$a = a; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {A_0:A}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var c = new foo.A_0(1, '1'); + c.set_b(2); + c.set_a('2'); + return c.get_b() == 2 && c.get_a() == '2'; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/class/out/incrementProperty.js b/k2js/translator/testFiles/class/out/incrementProperty.js new file mode 100644 index 00000000000..4d85dc808ed --- /dev/null +++ b/k2js/translator/testFiles/class/out/incrementProperty.js @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var Slot = Kotlin.Class.create({initialize:function(){ + this.$vitality = 10000; + } + , get_vitality:function(){ + return this.$vitality; + } + , set_vitality:function(tmp$0){ + this.$vitality = tmp$0; + } + , increaseVitality:function(delta){ + { + this.set_vitality(this.get_vitality() + delta); + if (this.get_vitality() > 65535) + this.set_vitality(65535); + } + } + }); + return {Slot_0:Slot}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var s = new foo.Slot_0; + s.increaseVitality(1000); + if (s.get_vitality() == 11000) + return 'OK'; + else + return 'fail'; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/class/out/methodDeclarationAndCall.js b/k2js/translator/testFiles/class/out/methodDeclarationAndCall.js new file mode 100644 index 00000000000..15b23e7a16f --- /dev/null +++ b/k2js/translator/testFiles/class/out/methodDeclarationAndCall.js @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var Test = Kotlin.Class.create({initialize:function(){ + } + , method:function(){ + { + return true; + } + } + }); + return {Test_0:Test}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var test = new foo.Test_0; + return test.method(); + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/class/out/propertiesAsParametersInitialized.js b/k2js/translator/testFiles/class/out/propertiesAsParametersInitialized.js new file mode 100644 index 00000000000..0463524396e --- /dev/null +++ b/k2js/translator/testFiles/class/out/propertiesAsParametersInitialized.js @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var A = Kotlin.Class.create({initialize:function(b, a){ + this.$b = b; + this.$a = a; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {A_0:A}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var c = new foo.A_0(2, '2'); + return c.get_b() == 2 && c.get_a() == '2'; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/class/out/propertyAccess.js b/k2js/translator/testFiles/class/out/propertyAccess.js new file mode 100644 index 00000000000..fff3a97d69c --- /dev/null +++ b/k2js/translator/testFiles/class/out/propertyAccess.js @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var Test = Kotlin.Class.create({initialize:function(){ + this.$p = true; + } + , get_p:function(){ + return this.$p; + } + }); + return {Test_0:Test}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + return (new foo.Test_0).get_p(); + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/class/out/simpleInitializer.js b/k2js/translator/testFiles/class/out/simpleInitializer.js new file mode 100644 index 00000000000..7eba4fc61ab --- /dev/null +++ b/k2js/translator/testFiles/class/out/simpleInitializer.js @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var Test = Kotlin.Class.create({initialize:function(){ + { + this.$a = 3; + } + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {Test_0:Test}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + return (new foo.Test_0).get_a() == 3; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/examples/out/KT-921.js b/k2js/translator/testFiles/examples/out/KT-921.js new file mode 100644 index 00000000000..f4261476a01 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/KT-921.js @@ -0,0 +1,104 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + classes = function(){ + var Viewable = Kotlin.Class.create({initialize:function(){ + this.$items = new Kotlin.ArrayList; + } + , get_items:function(){ + return this.$items; + } + , add:function(item_0){ + this.get_items().add(item_0); + } + , remove:function(item_0){ + this.get_items().remove(item_0); + } + , view:function(lifetime, viewer){ + { + tmp$0 = this.get_items().iterator(); + while (tmp$0.hasNext()) { + item = tmp$0.next(); + { + viewer(lifetime, item); + } + } + } + } + }); + var Lifetime = Kotlin.Class.create({initialize:function(){ + this.$attached = new Kotlin.ArrayList; + } + , get_attached:function(){ + return this.$attached; + } + , attach:function(action){ + this.get_attached().add(action); + } + , close_0:function(){ + { + tmp$0 = this.get_attached().iterator(); + while (tmp$0.hasNext()) { + x = tmp$0.next(); + { + x(); + } + } + } + this.get_attached().clear(); + } + }); + return {Lifetime_0:Lifetime, Viewable_0:Viewable}; + } + (); + Anonymous = Kotlin.Namespace.create({initialize:function(){ + } + , lifetime_0:function(body){ + var l = new Anonymous.Lifetime_0; + body(l); + l.close_0(); + } + , Dump:function(items){ + { + tmp$0 = items.iterator(); + while (tmp$0.hasNext()) { + item = tmp$0.next(); + { + Kotlin.System.out() != null?Kotlin.System.out().print(Kotlin.toString(item) + ', '):null; + } + } + } + Kotlin.System.out() != null?Kotlin.System.out().println():null; + } + , main:function(args){ + var v = new Anonymous.Viewable_0; + var x = new Kotlin.ArrayList; + v.add(1); + v.add(2); + Anonymous.lifetime_0((tmp$0_0 = this , function(it){ + return v.view(it, (tmp$0 = this , function(itemLifetime, item){ + x.add(item); + Anonymous.Dump(x); + return itemLifetime.attach(); + } + )); + } + )); + } + }, classes); + Anonymous.initialize(); +} diff --git a/k2js/translator/testFiles/examples/out/closureWithParameter.js b/k2js/translator/testFiles/examples/out/closureWithParameter.js new file mode 100644 index 00000000000..3fb2e2e509d --- /dev/null +++ b/k2js/translator/testFiles/examples/out/closureWithParameter.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return Anonymous.apply('OK', function(arg){ + { + return arg; + } + } + ); + } +} +, apply:function(arg, f){ + { + return f(arg); + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/closureWithParameterAndBoxing.js b/k2js/translator/testFiles/examples/out/closureWithParameterAndBoxing.js new file mode 100644 index 00000000000..cd1791d1d3e --- /dev/null +++ b/k2js/translator/testFiles/examples/out/closureWithParameterAndBoxing.js @@ -0,0 +1,28 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + if (Anonymous.apply(5, function(arg){ + { + return arg + 13; + } + } + ) == 18) + tmp$0 = 'OK'; + else + tmp$0 = 'fail'; + return tmp$0; + } +} +, apply:function(arg, f){ + { + return f(arg); + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/diamondInheritance.js b/k2js/translator/testFiles/examples/out/diamondInheritance.js new file mode 100644 index 00000000000..54b0c51ee46 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/diamondInheritance.js @@ -0,0 +1,50 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$v = 0; + } + , get_v:function(){ + return this.$v; + } + , set_v:function(tmp$0){ + this.$v = tmp$0; + } + }); + var tmp$1 = Kotlin.Trait.create(tmp$0, {}); + var tmp$2 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + } + }); + var tmp$3 = Kotlin.Class.create(tmp$2, tmp$1, {initialize:function(){ + this.super_init(); + } + }); + return {Right:tmp$1, Left:tmp$2, D:tmp$3, Base:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, vl:function(l){ + { + return l.get_v(); + } +} +, vr:function(r){ + { + return r.get_v(); + } +} +, box:function(){ + { + var d = new Anonymous.D; + d.set_v(42); + if (d.get_v() != 42) + return 'Fail #1'; + if (Anonymous.vl(d) != 42) + return 'Fail #2'; + if (Anonymous.vr(d) != 42) + return 'Fail #3'; + return 'OK'; + } +} +}, {Base:classes.Base, Left:classes.Left, Right:classes.Right, D:classes.D}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/doubleEnclosedLocalVariable.js b/k2js/translator/testFiles/examples/out/doubleEnclosedLocalVariable.js new file mode 100644 index 00000000000..6d8e80a38b9 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/doubleEnclosedLocalVariable.js @@ -0,0 +1,35 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var cl = 39; + if (Anonymous.sum(200, function(){ + { + var ff = function(){ + { + return cl; + } + } + ; + return ff(); + } + } + ) == 239) + tmp$0 = 'OK'; + else + tmp$0 = 'FAIL'; + return tmp$0; + } +} +, sum:function(arg, f){ + { + return arg + f(); + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/enclosingLocalVariable.js b/k2js/translator/testFiles/examples/out/enclosingLocalVariable.js new file mode 100644 index 00000000000..c97a6e06d41 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/enclosingLocalVariable.js @@ -0,0 +1,41 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var cl = 39; + if (Anonymous.sum(200, function(){ + { + var m = function(){ + { + var r = function(){ + { + return cl; + } + } + ; + return r(); + } + } + ; + return m(); + } + } + ) == 239) + tmp$0 = 'OK'; + else + tmp$0 = 'FAIL'; + return tmp$0; + } +} +, sum:function(arg, f){ + { + return arg + f(); + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/enclosingThis.js b/k2js/translator/testFiles/examples/out/enclosingThis.js new file mode 100644 index 00000000000..1fd99f7521c --- /dev/null +++ b/k2js/translator/testFiles/examples/out/enclosingThis.js @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var Point_0 = Kotlin.Class.create({initialize:function(x, y){ + this.$x = x; + this.$y = y; + } + , get_x:function(){ + return this.$x; + } + , get_y:function(){ + return this.$y; + } + , mul:function(){ + { + var tmp$0; + return tmp$0 = this , function(scalar){ + { + return new Anonymous.Point(tmp$0.get_x() * scalar, tmp$0.get_y() * scalar); + } + } + ; + } + } + }); + return {Point:Point_0}; + } + (); + var Anonymous = Kotlin.Namespace.create({initialize:function(){ + Anonymous.$m = (new Anonymous.Point(2, 3)).mul(); + } + , get_m:function(){ + return Anonymous.$m; + } + , box:function(){ + { + var answer = Anonymous.get_m()(5); + return answer.get_x() == 10 && answer.get_y() == 15?'OK':'FAIL'; + } + } + }, classes); + Anonymous.initialize(); +} diff --git a/k2js/translator/testFiles/examples/out/extensionClosure.js b/k2js/translator/testFiles/examples/out/extensionClosure.js new file mode 100644 index 00000000000..f49da63c02d --- /dev/null +++ b/k2js/translator/testFiles/examples/out/extensionClosure.js @@ -0,0 +1,40 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(x, y){ + this.$x = x; + this.$y = y; + } + , get_x:function(){ + return this.$x; + } + , get_y:function(){ + return this.$y; + } + }); + return {Point:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var answer = Anonymous.apply(new Anonymous.Point(3, 5), function(scalar){ + { + return new Anonymous.Point(this.get_x() * scalar, this.get_y() * scalar); + } + } + ); + if (answer.get_x() == 6 && answer.get_y() == 10) + tmp$0 = 'OK'; + else + tmp$0 = 'FAIL'; + return tmp$0; + } +} +, apply:function(arg, f){ + { + return f.call(arg, 2); + } +} +}, {Point:classes.Point}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/funDelegation.js b/k2js/translator/testFiles/examples/out/funDelegation.js new file mode 100644 index 00000000000..256a85c899f --- /dev/null +++ b/k2js/translator/testFiles/examples/out/funDelegation.js @@ -0,0 +1,41 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({}); + var tmp$1 = Kotlin.Class.create({initialize:function(){ + } + , n_0:function(n){ + { + return n + 1; + } + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, tmp$0, {initialize:function(){ + this.super_init(); + } + }); + var tmp$3 = Kotlin.Class.create(tmp$1, tmp$0, {initialize:function(){ + this.super_init(); + } + }); + return {Base:tmp$1, Derived2:tmp$2, Derived1:tmp$3, Abstract:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, test:function(s){ + { + return s.n_0(238) == 239; + } +} +, box:function(){ + { + if (!Anonymous.test(new Anonymous.Base)) + return 'Fail #1'; + if (!Anonymous.test(new Anonymous.Derived1)) + return 'Fail #2'; + if (!Anonymous.test(new Anonymous.Derived2)) + return 'Fail #3'; + return 'OK'; + } +} +}, {Base:classes.Base, Abstract:classes.Abstract, Derived1:classes.Derived1, Derived2:classes.Derived2}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/generic.js b/k2js/translator/testFiles/examples/out/generic.js new file mode 100644 index 00000000000..89c902fe806 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/generic.js @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var Anonymous = Kotlin.Namespace.create({initialize:function(){ + } + , findAll:function(receiver, predicate){ + { + var tmp$0; + var result = new Kotlin.ArrayList(0); + { + tmp$0 = this.iterator(); + while (tmp$0.hasNext()) { + var t = tmp$0.next(); + { + if (predicate(t)) + result.add(t); + } + } + } + return result; + } + } + , box:function(){ + { + var list = new Kotlin.ArrayList(0); + list.add(2); + list.add(3); + list.add(5); + var m = list.Anonymous.findAll(list, function(name_0){ + { + return name_0 < 4; + } + } + ); + return m.size() == 2?'OK':'fail'; + } + } + }, classes); + Anonymous.initialize(); +} diff --git a/k2js/translator/testFiles/examples/out/incrementProperty.js b/k2js/translator/testFiles/examples/out/incrementProperty.js new file mode 100644 index 00000000000..a4365ed3ba1 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/incrementProperty.js @@ -0,0 +1,35 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$vitality = 10000; + } + , get_vitality:function(){ + return this.$vitality; + } + , set_vitality:function(tmp$0){ + this.$vitality = tmp$0; + } + , increaseVitality:function(delta){ + { + this.set_vitality(this.get_vitality() + delta); + if (this.get_vitality() > 65535) + this.set_vitality(65535); + } + } + }); + return {Slot:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var s = new Anonymous.Slot; + s.increaseVitality(1000); + if (s.get_vitality() == 11000) + return 'OK'; + else + return 'fail'; + } +} +}, {Slot:classes.Slot}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/inheritedMethod.js b/k2js/translator/testFiles/examples/out/inheritedMethod.js new file mode 100644 index 00000000000..d7760fa7097 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/inheritedMethod.js @@ -0,0 +1,37 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , xyzzy:function(){ + { + return 'xyzzy'; + } + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + } + , test:function(){ + { + return this.xyzzy(); + } + } + }); + return {Bar:tmp$1, Foo:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var bar = new Anonymous.Bar; + var f = bar.test(); + if (f == 'xyzzy') + tmp$0 = 'OK'; + else + tmp$0 = 'fail'; + return tmp$0; + } +} +}, {Foo:classes.Foo, Bar:classes.Bar}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/initializerBlock.js b/k2js/translator/testFiles/examples/out/initializerBlock.js new file mode 100644 index 00000000000..b6e7745ddf5 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/initializerBlock.js @@ -0,0 +1,28 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + { + this.$f = 610; + } + } + , get_f:function(){ + return this.$f; + } + , set_f:function(tmp$0){ + this.$f = tmp$0; + } + }); + return {C:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new Anonymous.C; + if (c.get_f() != 610) + return 'fail'; + return 'OK'; + } +} +}, {C:classes.C}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/initializerBlockDImpl.js b/k2js/translator/testFiles/examples/out/initializerBlockDImpl.js new file mode 100644 index 00000000000..3d204758755 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/initializerBlockDImpl.js @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + classes = function(){ + var World = Kotlin.Class.create({initialize:function(){ + this.$items = new Kotlin.ArrayList; + this.$foo = new this.Item; + } + , get_items:function(){ + return this.$items; + } + , get_foo:function(){ + return this.$foo; + } + }); + return {World:World}; + } + (); + Anonymous = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + var w = new Anonymous.World; + if (w.get_items().size() !== 1) + return 'fail'; + return 'OK'; + } + }, classes); + Anonymous.initialize(); +} diff --git a/k2js/translator/testFiles/examples/out/jquery.js b/k2js/translator/testFiles/examples/out/jquery.js new file mode 100644 index 00000000000..8e19dfc32ed --- /dev/null +++ b/k2js/translator/testFiles/examples/out/jquery.js @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var Anonymous = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var aa = Kotlin.jQuery('a').attr('a'); + return 'OK'; + } + } + }, classes); + Anonymous.initialize(); +} diff --git a/k2js/translator/testFiles/examples/out/kt242.js b/k2js/translator/testFiles/examples/out/kt242.js new file mode 100644 index 00000000000..b3b19087add --- /dev/null +++ b/k2js/translator/testFiles/examples/out/kt242.js @@ -0,0 +1,32 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var i = 7; + var j = null; + var k = 7; + if (i == 7) { + } + if (7 == i) { + } + if (j == 7) { + } + if (7 == j) { + } + if (i == k) { + } + if (k == i) { + } + if (j == k) { + } + if (k == j) { + } + return 'OK'; + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/kt248.js b/k2js/translator/testFiles/examples/out/kt248.js new file mode 100644 index 00000000000..9fa7468f699 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/kt248.js @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + classes = function(){ + return {}; + } + (); + Anonymous = Namespace.create({initialize:function(){ + } + , box:function(){ + var b = true; + var i = 1; + var j = 1; + var s = 's'; + return 'OK'; + } + }, classes); + Anonymous.initialize(); +} diff --git a/k2js/translator/testFiles/examples/out/kt446.js b/k2js/translator/testFiles/examples/out/kt446.js new file mode 100644 index 00000000000..2cf69d1b63c --- /dev/null +++ b/k2js/translator/testFiles/examples/out/kt446.js @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + classes = function(){ + return {}; + } + (); + Anonymous = Namespace.create({initialize:function(){ + } + , box:function(){ + var s = 's'; + s += 1; + return s === 's1'?'OK':'fail'; + } + }, classes); + Anonymous.initialize(); +} diff --git a/k2js/translator/testFiles/examples/out/newInstanceDefaultConstructor.js b/k2js/translator/testFiles/examples/out/newInstanceDefaultConstructor.js new file mode 100644 index 00000000000..d4ed4fcf556 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/newInstanceDefaultConstructor.js @@ -0,0 +1,25 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , foo:function(){ + { + return 610; + } + } + }); + return {SimpleClass:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new Anonymous.SimpleClass; + if (c.foo() == 610) { + return 'OK'; + } + return 'FAIL'; + } +} +}, {SimpleClass:classes.SimpleClass}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/overloadBinaryOperator.js b/k2js/translator/testFiles/examples/out/overloadBinaryOperator.js new file mode 100644 index 00000000000..5f488407a1c --- /dev/null +++ b/k2js/translator/testFiles/examples/out/overloadBinaryOperator.js @@ -0,0 +1,43 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$contents = new Kotlin.ArrayList; + } + , get_contents:function(){ + return this.$contents; + } + , add:function(item){ + { + this.get_contents().add(item); + } + } + , plus:function(b){ + { + var result = new Anonymous.ArrayWrapper; + result.get_contents().addAll(this.get_contents()); + result.get_contents().addAll(b.get_contents()); + return result; + } + } + }); + return {ArrayWrapper:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var v1 = new Anonymous.ArrayWrapper; + var v2 = new Anonymous.ArrayWrapper; + v1.add('foo'); + v2.add('bar'); + var v3 = v1.plus(v2); + if (v3.get_contents().size() == 2) + tmp$0 = 'OK'; + else + tmp$0 = 'fail'; + return tmp$0; + } +} +}, {ArrayWrapper:classes.ArrayWrapper}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/overloadPlusAssignReturn.js b/k2js/translator/testFiles/examples/out/overloadPlusAssignReturn.js new file mode 100644 index 00000000000..eaaa7e822bc --- /dev/null +++ b/k2js/translator/testFiles/examples/out/overloadPlusAssignReturn.js @@ -0,0 +1,46 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$contents = new Kotlin.ArrayList; + } + , get_contents:function(){ + return this.$contents; + } + , add:function(item){ + { + this.get_contents().add(item); + } + } + , plusAssign:function(rhs){ + { + this.get_contents().addAll(rhs.get_contents()); + } + } + , get:function(index){ + { + return this.get_contents().get(index); + } + } + }); + return {ArrayWrapper:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var v1 = new Anonymous.ArrayWrapper; + var v2 = new Anonymous.ArrayWrapper; + v1.add('foo'); + var v3 = v1; + v2.add('bar'); + v1.plusAssign(v2); + if (v1.get_contents().size() == 2 && v3.get_contents().size() == 2) + tmp$0 = 'OK'; + else + tmp$0 = 'fail'; + return tmp$0; + } +} +}, {ArrayWrapper:classes.ArrayWrapper}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/overloadPlusToPlusAssign.js b/k2js/translator/testFiles/examples/out/overloadPlusToPlusAssign.js new file mode 100644 index 00000000000..cab890a4d6d --- /dev/null +++ b/k2js/translator/testFiles/examples/out/overloadPlusToPlusAssign.js @@ -0,0 +1,49 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$contents = new Kotlin.ArrayList; + } + , get_contents:function(){ + return this.$contents; + } + , add:function(item){ + { + this.get_contents().add(item); + } + } + , plus:function(rhs){ + { + var result = new Anonymous.ArrayWrapper; + result.get_contents().addAll(this.get_contents()); + result.get_contents().addAll(rhs.get_contents()); + return result; + } + } + , get:function(index){ + { + return this.get_contents().get(index); + } + } + }); + return {ArrayWrapper:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var v1 = new Anonymous.ArrayWrapper; + var v2 = new Anonymous.ArrayWrapper; + v1.add('foo'); + var v3 = v1; + v2.add('bar'); + v1 = v1.plus(v2); + if (v1.get_contents().size() == 2 && v3.get_contents().size() == 1) + tmp$0 = 'OK'; + else + tmp$0 = 'fail'; + return tmp$0; + } +} +}, {ArrayWrapper:classes.ArrayWrapper}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/overloadUnaryOperator.js b/k2js/translator/testFiles/examples/out/overloadUnaryOperator.js new file mode 100644 index 00000000000..d34c9c395c9 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/overloadUnaryOperator.js @@ -0,0 +1,57 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$contents = new Kotlin.ArrayList; + } + , get_contents:function(){ + return this.$contents; + } + , add:function(item){ + { + this.get_contents().add(item); + } + } + , minus:function(){ + { + var tmp$0; + var result = new Anonymous.ArrayWrapper; + result.get_contents().addAll(this.get_contents()); + var i = this.get_contents().size(); + { + tmp$0 = this.get_contents().iterator(); + while (tmp$0.hasNext()) { + var a = tmp$0.next(); + { + result.get_contents().set(--i, a); + } + } + } + return result; + } + } + , get:function(index){ + { + return this.get_contents().get(index); + } + } + }); + return {ArrayWrapper:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var v1 = new Anonymous.ArrayWrapper; + v1.add('foo'); + v1.add('bar'); + var v2 = v1.minus(); + if (v2.get(0) == 'bar' && v2.get(1) == 'foo') + tmp$0 = 'OK'; + else + tmp$0 = 'fail'; + return tmp$0; + } +} +}, {ArrayWrapper:classes.ArrayWrapper}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/propertyDelegation.js b/k2js/translator/testFiles/examples/out/propertyDelegation.js new file mode 100644 index 00000000000..ad0ee0ddbd9 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/propertyDelegation.js @@ -0,0 +1,68 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({}); + var tmp$1 = Kotlin.Class.create({initialize:function(){ + this.$plain = 239; + this.$readwrite = 0; + } + , get_plain:function(){ + return this.$plain; + } + , get_read:function(){ + { + return 239; + } + } + , get_readwrite:function(){ + { + return this.$readwrite + 1; + } + } + , set_readwrite:function(n){ + { + this.$readwrite = n; + } + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, tmp$0, {initialize:function(){ + this.super_init(); + } + }); + var tmp$3 = Kotlin.Class.create(tmp$1, tmp$0, {initialize:function(){ + this.super_init(); + } + }); + return {Base:tmp$1, Derived2:tmp$2, Derived1:tmp$3, Abstract:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, code:function(s){ + { + if (s.get_plain() != 239) + return 1; + if (s.get_read() != 239) + return 2; + s.set_readwrite(238); + if (s.get_readwrite() != 239) + return 3; + return 0; + } +} +, test:function(s){ + { + return Anonymous.code(s) == 0; + } +} +, box:function(){ + { + if (!Anonymous.test(new Anonymous.Base)) + return 'Fail #1'; + if (!Anonymous.test(new Anonymous.Derived1)) + return 'Fail #2'; + if (!Anonymous.test(new Anonymous.Derived2)) + return 'Fail #3'; + return 'OK'; + } +} +}, {Base:classes.Base, Abstract:classes.Abstract, Derived1:classes.Derived1, Derived2:classes.Derived2}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/rightHandOverride.js b/k2js/translator/testFiles/examples/out/rightHandOverride.js new file mode 100644 index 00000000000..26fdddc2654 --- /dev/null +++ b/k2js/translator/testFiles/examples/out/rightHandOverride.js @@ -0,0 +1,37 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , f:function(){ + { + return 42; + } + } + }); + var tmp$1 = Kotlin.Trait.create({}); + var tmp$2 = Kotlin.Class.create(tmp$0, tmp$1, {initialize:function(){ + this.super_init(); + } + , f:function(){ + { + return 239; + } + } + }); + return {Left:tmp$1, D:tmp$2, Right:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var r = new Anonymous.Right; + var d = new Anonymous.D; + if (r.f() != 42) + return 'Fail #1'; + if (d.f() != 239) + return 'Fail #2'; + return 'OK'; + } +} +}, {Left:classes.Left, Right:classes.Right, D:classes.D}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/simplestClosure.js b/k2js/translator/testFiles/examples/out/simplestClosure.js new file mode 100644 index 00000000000..d0d632f712e --- /dev/null +++ b/k2js/translator/testFiles/examples/out/simplestClosure.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return Anonymous.invoker(function(){ + { + return 'OK'; + } + } + ); + } +} +, invoker:function(gen){ + { + return gen(); + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/examples/out/simplestClosureAndBoxing.js b/k2js/translator/testFiles/examples/out/simplestClosureAndBoxing.js new file mode 100644 index 00000000000..ddfb2abdd0e --- /dev/null +++ b/k2js/translator/testFiles/examples/out/simplestClosureAndBoxing.js @@ -0,0 +1,28 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + if (Anonymous.int_invoker(function(){ + { + return 7; + } + } + ) == 7) + tmp$0 = 'OK'; + else + tmp$0 = 'fail'; + return tmp$0; + } +} +, int_invoker:function(gen){ + { + return gen(); + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/expression/conditional/out/elseif.js b/k2js/translator/testFiles/expression/conditional/out/elseif.js new file mode 100644 index 00000000000..fc777c6cc98 --- /dev/null +++ b/k2js/translator/testFiles/expression/conditional/out/elseif.js @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var a = 2; + var b = 3; + var c = 4; + if (a < 2) { + return a; + } + else if (a > 2) { + return b; + } + else if (a == c) { + return c; + } + else { + return 5; + } + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/conditional/out/if.js b/k2js/translator/testFiles/expression/conditional/out/if.js new file mode 100644 index 00000000000..1e7f752385a --- /dev/null +++ b/k2js/translator/testFiles/expression/conditional/out/if.js @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var a = 2; + var b = 3; + var c = 4; + if (a < 2) { + return a; + } + if (a > 2) { + return b; + } + if (a == c) { + return c; + } + else { + return 5; + } + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/conditional/out/ifAsExpressionWithThrow.js b/k2js/translator/testFiles/expression/conditional/out/ifAsExpressionWithThrow.js new file mode 100644 index 00000000000..fb918e77094 --- /dev/null +++ b/k2js/translator/testFiles/expression/conditional/out/ifAsExpressionWithThrow.js @@ -0,0 +1,18 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + var tmp$0; + if (true) + throw new Kotlin.Exception; + else + tmp$0 = false; + { + return tmp$0; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/conditional/out/ifElseAsExpression.js b/k2js/translator/testFiles/expression/conditional/out/ifElseAsExpression.js new file mode 100644 index 00000000000..ade1f8928b6 --- /dev/null +++ b/k2js/translator/testFiles/expression/conditional/out/ifElseAsExpression.js @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var tmp$0; + var a = 2; + if (a == 2) + tmp$0 = true; + else + tmp$0 = false; + return tmp$0; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/for/out/forIteratesOverArray.js b/k2js/translator/testFiles/expression/for/out/forIteratesOverArray.js new file mode 100644 index 00000000000..b9b88e76207 --- /dev/null +++ b/k2js/translator/testFiles/expression/for/out/forIteratesOverArray.js @@ -0,0 +1,36 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $a1 = Kotlin.nullArray(10); +} +, get_a1:function(){ + return $a1; +} +, box:function(){ + { + var tmp$0; + var c = 0; + var d = 0; + foo.get_a1()[3] = 3; + foo.get_a1()[5] = 5; + { + tmp$0 = Kotlin.arrayIterator(foo.get_a1()); + while (tmp$0.hasNext()) { + var a = tmp$0.next(); + { + if (a != null) { + c += 1; + } + else { + d += 1; + } + } + } + } + return c == 2 && d == 8; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/for/out/forOnEmptyArray.js b/k2js/translator/testFiles/expression/for/out/forOnEmptyArray.js new file mode 100644 index 00000000000..238a9adac77 --- /dev/null +++ b/k2js/translator/testFiles/expression/for/out/forOnEmptyArray.js @@ -0,0 +1,27 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $a1 = Kotlin.nullArray(0); +} +, get_a1:function(){ + return $a1; +} +, box:function(){ + { + var tmp$0; + { + tmp$0 = Kotlin.arrayIterator(foo.get_a1()); + while (tmp$0.hasNext()) { + var a = tmp$0.next(); + { + return false; + } + } + } + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/KT-921.js b/k2js/translator/testFiles/expression/function/out/KT-921.js new file mode 100644 index 00000000000..d1e2f1d2dbf --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/KT-921.js @@ -0,0 +1,115 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$items = new Kotlin.ArrayList; + } + , get_items:function(){ + return this.$items; + } + , add:function(item){ + { + this.get_items().add(item); + } + } + , remove:function(item){ + { + this.get_items().remove(item); + } + } + , view:function(lifetime, viewer){ + { + var tmp$0; + { + tmp$0 = this.get_items().iterator(); + while (tmp$0.hasNext()) { + var item = tmp$0.next(); + { + viewer(lifetime, item); + } + } + } + } + } + }); + var tmp$1 = Kotlin.Class.create({initialize:function(){ + this.$attached = new Kotlin.ArrayList; + } + , get_attached:function(){ + return this.$attached; + } + , attach:function(action){ + { + this.get_attached().add(action); + } + } + , close_0:function(){ + { + var tmp$0; + { + tmp$0 = this.get_attached().iterator(); + while (tmp$0.hasNext()) { + var x = tmp$0.next(); + { + x(); + } + } + } + this.get_attached().clear(); + } + } + }); + return {Lifetime:tmp$1, Viewable:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, lifetime:function(body){ + { + var l = new Anonymous.Lifetime; + body(l); + l.close_0(); + } +} +, Dump:function(items){ + { + var tmp$0; + { + tmp$0 = items.iterator(); + while (tmp$0.hasNext()) { + var item = tmp$0.next(); + { + Kotlin.print(jet.toString(item) + ', '); + } + } + } + Kotlin.println(); + } +} +, main:function(args){ + { + var v = new Anonymous.Viewable; + var x = new Kotlin.ArrayList; + v.add(1); + v.add(2); + Anonymous.lifetime(function(it){ + { + v.view(it, function(itemLifetime, item){ + { + x.add(item); + Anonymous.Dump(x); + itemLifetime.attach(function(){ + { + x.remove(item); + Anonymous.Dump(x); + } + } + ); + } + } + ); + } + } + ); + } +} +}, {Lifetime:classes.Lifetime, Viewable:classes.Viewable}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/adderClosure.js b/k2js/translator/testFiles/expression/function/out/adderClosure.js new file mode 100644 index 00000000000..5c66dfd3ca8 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/adderClosure.js @@ -0,0 +1,22 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var sum = 0; + var adder = function(a){ + { + sum += a; + } + } + ; + adder(3); + adder(2); + return sum == 5; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/closureWithParameter.js b/k2js/translator/testFiles/expression/function/out/closureWithParameter.js new file mode 100644 index 00000000000..d00213404f4 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/closureWithParameter.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return foo.apply('OK', function(arg){ + { + return arg; + } + } + ); + } +} +, apply:function(arg, f){ + { + return f(arg); + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/closureWithParameterAndBoxing.js b/k2js/translator/testFiles/expression/function/out/closureWithParameterAndBoxing.js new file mode 100644 index 00000000000..7688c70ab67 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/closureWithParameterAndBoxing.js @@ -0,0 +1,28 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + if (foo.apply(5, function(arg){ + { + return arg + 13; + } + } + ) == 18) + tmp$0 = 'OK'; + else + tmp$0 = 'fail'; + return tmp$0; + } +} +, apply:function(arg, f){ + { + return f(arg); + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/defaultParameters.js b/k2js/translator/testFiles/expression/function/out/defaultParameters.js new file mode 100644 index 00000000000..2b08a8210e6 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/defaultParameters.js @@ -0,0 +1,26 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, f:function(a, b){ + { + return a + b; + } +} +, box:function(){ + { + if (foo.f(1, 2) != 3) + return false; + if (foo.f(1, 3) != 4) + return false; + if (foo.f(3, 3) != 6) + return false; + if (foo.f(2, 3) != 5) + return false; + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/enclosingThis.js b/k2js/translator/testFiles/expression/function/out/enclosingThis.js new file mode 100644 index 00000000000..3c2c756ba2d --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/enclosingThis.js @@ -0,0 +1,45 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(x, y){ + this.$x = x; + this.$y = y; + } + , get_x:function(){ + return this.$x; + } + , get_y:function(){ + return this.$y; + } + , mul:function(){ + { + var tmp$0; + return tmp$0 = this , function(scalar){ + { + return new Anonymous.Point(tmp$0.get_x() * scalar, tmp$0.get_y() * scalar); + } + } + ; + } + } + }); + return {Point:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ + $m = (new Anonymous.Point(2, 3)).mul(); +} +, get_m:function(){ + return $m; +} +, box:function(){ + { + var tmp$0; + var answer = Anonymous.get_m()(5); + if (answer.get_x() == 10 && answer.get_y() == 15) + tmp$0 = 'OK'; + else + tmp$0 = 'FAIL'; + return tmp$0; + } +} +}, {Point:classes.Point}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/expressionAsFunction.js b/k2js/translator/testFiles/expression/function/out/expressionAsFunction.js new file mode 100644 index 00000000000..e21ec08d719 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/expressionAsFunction.js @@ -0,0 +1,88 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $d = function(a){ + { + return a + 1; + } + } + ; + $p = function(a){ + { + return a * 3; + } + } + ; + $list = new Kotlin.ArrayList; +} +, get_d:function(){ + return $d; +} +, get_p:function(){ + return $p; +} +, get_list:function(){ + return $list; +} +, chain:function(start){ + { + var tmp$0; + var res = start; + { + tmp$0 = foo.get_list().iterator(); + while (tmp$0.hasNext()) { + var func = tmp$0.next(); + { + res = func(res); + } + } + } + return res; + } +} +, box:function(){ + { + if (foo.chain(0) != 0) { + return false; + } + foo.get_list().add(foo.get_d()); + if (foo.get_list().get(0)(0) != 1) { + return false; + } + foo.get_list().add(foo.get_p()); + if (foo.get_list().get(1)(10) != 30) { + return false; + } + if (foo.chain(0) != 3) { + return false; + } + foo.get_list().add(function(it){ + { + return it * it; + } + } + ); + foo.get_list().add(function(it){ + { + return it - 100; + } + } + ); + if (foo.chain(2) != -19) { + return false; + } + if (function(a){ + { + return a * a; + } + } + (3) != 9) { + return false; + } + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/functionInsideFunction.js b/k2js/translator/testFiles/expression/function/out/functionInsideFunction.js new file mode 100644 index 00000000000..e96efde42e6 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/functionInsideFunction.js @@ -0,0 +1,37 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + function f(){ + { + return 3; + } + } + + return f() + f() == 6 && foo.b() == 24; + } +} +, b:function(){ + { + function a(){ + { + function c(){ + { + return 4; + } + } + + return c() * 3; + } + } + + var a$0 = 2; + return a() * a$0; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/functionLiteral.js b/k2js/translator/testFiles/expression/function/out/functionLiteral.js new file mode 100644 index 00000000000..b72884eedca --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/functionLiteral.js @@ -0,0 +1,21 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var sum = 0; + var addFive = function(a){ + { + return a + 5; + } + } + ; + sum = addFive(sum); + return sum == 5; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/functionLiteralAsLastParameter.js b/k2js/translator/testFiles/expression/function/out/functionLiteralAsLastParameter.js new file mode 100644 index 00000000000..7a455995c5a --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/functionLiteralAsLastParameter.js @@ -0,0 +1,32 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, f:function(a){ + { + return a(1); + } +} +, box:function(){ + { + if (foo.f(function(it){ + { + return it + 2; + } + } + ) != 3) + return false; + if (foo.f(function(a){ + { + return a * 300; + } + } + ) != 300) + return false; + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/functionLiteralAsParameter.js b/k2js/translator/testFiles/expression/function/out/functionLiteralAsParameter.js new file mode 100644 index 00000000000..8d97ec5fb70 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/functionLiteralAsParameter.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, apply:function(f, t){ + { + return f(t); + } +} +, box:function(){ + { + return foo.apply(function(a){ + { + return a + 5; + } + } + , 3) == 8; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/functionUsedBeforeDeclaration.js b/k2js/translator/testFiles/expression/function/out/functionUsedBeforeDeclaration.js new file mode 100644 index 00000000000..b34d6e96aac --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/functionUsedBeforeDeclaration.js @@ -0,0 +1,18 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return foo.f(); + } +} +, f:function(){ + { + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/functionWithTwoParametersCall.js b/k2js/translator/testFiles/expression/function/out/functionWithTwoParametersCall.js new file mode 100644 index 00000000000..73a04aaf12e --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/functionWithTwoParametersCall.js @@ -0,0 +1,18 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, sum:function(param1, param2){ + { + return param1 + param2; + } +} +, box:function(){ + { + return foo.sum(1, 5) == 6; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/implicitItParameter.js b/k2js/translator/testFiles/expression/function/out/implicitItParameter.js new file mode 100644 index 00000000000..12f0b1da6e8 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/implicitItParameter.js @@ -0,0 +1,37 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, test:function(f, p){ + { + return f(p); + } +} +, box:function(){ + { + if (!foo.test(function(it){ + { + return it + 1 == 2; + } + } + , 1)) + return false; + if (!foo.test(function(it){ + { + return it > 1; + } + } + , 3)) + return false; + return foo.test(function(it){ + { + return it < 1 == false; + } + } + , 1); + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/loopClosure.js b/k2js/translator/testFiles/expression/function/out/loopClosure.js new file mode 100644 index 00000000000..de725a25368 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/loopClosure.js @@ -0,0 +1,34 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $b = 0; +} +, get_b:function(){ + return $b; +} +, set_b:function(tmp$0){ + $b = tmp$0; +} +, loop:function(times){ + { + while (times > 0) { + var u = function(value){ + { + foo.set_b(foo.get_b() + 1); + } + } + ; + u(times--); + } + } +} +, box:function(){ + { + foo.loop(5); + return foo.get_b() == 5; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/namedArguments.js b/k2js/translator/testFiles/expression/function/out/namedArguments.js new file mode 100644 index 00000000000..e33cccbd6c0 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/namedArguments.js @@ -0,0 +1,27 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, test:function(x, y){ + { + return y - x; + } +} +, box:function(){ + { + if (foo.test(1, 2) != 1) { + return false; + } + if (foo.test(1, 2) != 1) { + return false; + } + if (foo.test(1, 2) != 1) { + return false; + } + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/function/out/vararg.js b/k2js/translator/testFiles/expression/function/out/vararg.js new file mode 100644 index 00000000000..3e93b7088b6 --- /dev/null +++ b/k2js/translator/testFiles/expression/function/out/vararg.js @@ -0,0 +1,34 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, testSize:function(expectedSize, i){ + { + return i.length == expectedSize; + } +} +, testSum:function(expectedSum, i){ + { + var tmp$0; + var sum = 0; + { + tmp$0 = Kotlin.arrayIterator(i); + while (tmp$0.hasNext()) { + var j = tmp$0.next(); + { + sum += j; + } + } + } + return expectedSum == sum; + } +} +, box:function(){ + { + return foo.testSize(0, []) && foo.testSum(0, []) && foo.testSize(3, [1, 1, 1]) && foo.testSum(3, [1, 1, 1]) && foo.testSize(6, [1, 1, 1, 2, 3, 4]) && foo.testSum(30, [10, 20, 0]); + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/misc/out/KT-962.js b/k2js/translator/testFiles/expression/misc/out/KT-962.js new file mode 100644 index 00000000000..c854c5d32be --- /dev/null +++ b/k2js/translator/testFiles/expression/misc/out/KT-962.js @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var Anonymous = Kotlin.Namespace.create({initialize:function(){ + } + , stdout:function(){ + { + var tmp$0; + tmp$0 = Kotlin.System.out() , tmp$0 != null?tmp$0.println('stdout'):null; + return Kotlin.System.out(); + } + } + , main:function(args){ + { + var tmp$0; + tmp$0 = Anonymous.stdout() , tmp$0 != null?tmp$0.println('Hello, world!'):null; + } + } + }, classes); + Anonymous.initialize(); +} diff --git a/k2js/translator/testFiles/expression/misc/out/intRange.js b/k2js/translator/testFiles/expression/misc/out/intRange.js new file mode 100644 index 00000000000..1c3a79a9e7f --- /dev/null +++ b/k2js/translator/testFiles/expression/misc/out/intRange.js @@ -0,0 +1,207 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(start, size, reversed){ + this.$start = start; + this.$size = size; + this.$reversed = reversed; + } + , get_start:function(){ + return this.$start; + } + , get_size:function(){ + return this.$size; + } + , get_reversed:function(){ + return this.$reversed; + } + , get_end:function(){ + var tmp$0; + if (this.get_reversed()) + tmp$0 = this.get_start() - this.get_size() + 1; + else + tmp$0 = this.get_start() + this.get_size() - 1; + { + return tmp$0; + } + } + , contains:function(number){ + { + if (this.get_reversed()) { + return number <= this.get_start() && number > this.get_start() - this.get_size(); + } + else { + return number >= this.get_start() && number < this.get_start() + this.get_size(); + } + } + } + , iterator:function(){ + { + return new foo.RangeIterator(this.get_start(), this.get_size(), this.get_reversed()); + } + } + }); + var tmp$1 = Kotlin.Class.create({initialize:function(start, count, reversed){ + this.$start = start; + this.$count = count; + this.$reversed = reversed; + this.$i = this.get_start(); + } + , get_start:function(){ + return this.$start; + } + , get_count:function(){ + return this.$count; + } + , set_count:function(tmp$0){ + this.$count = tmp$0; + } + , get_reversed:function(){ + return this.$reversed; + } + , get_i:function(){ + return this.$i; + } + , set_i:function(tmp$0){ + this.$i = tmp$0; + } + , next:function(){ + { + this.set_count(this.get_count() - 1); + if (this.get_reversed()) { + this.set_i(this.get_i() - 1); + return this.get_i() + 1; + } + else { + this.set_i(this.get_i() + 1); + return this.get_i() - 1; + } + } + } + , hasNext:function(){ + { + return this.get_count() > 0; + } + } + }); + return {RangeIterator:tmp$1, NumberRange:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return foo.testRange() && foo.testReversedRange(); + } +} +, testRange:function(){ + { + var tmp$1; + var tmp$0; + var oneToFive = new foo.NumberRange(1, 4, false); + if (oneToFive.contains(5)) + return false; + if (oneToFive.contains(0)) + return false; + if (oneToFive.contains(-100)) + return false; + if (oneToFive.contains(10)) + return false; + if (!oneToFive.contains(1)) + return false; + if (!oneToFive.contains(2)) + return false; + if (!oneToFive.contains(3)) + return false; + if (!oneToFive.contains(4)) + return false; + if (!(oneToFive.get_start() == 1)) + return false; + if (!(oneToFive.get_size() == 4)) + return false; + if (!(oneToFive.get_end() == 4)) + return false; + var sum = 0; + { + tmp$0 = oneToFive.iterator(); + while (tmp$0.hasNext()) { + var i = tmp$0.next(); + { + sum += i; + } + } + } + { + tmp$1 = oneToFive.iterator(); + while (tmp$1.hasNext()) { + var i$0 = tmp$1.next(); + { + Kotlin.print(i$0); + } + } + } + if (sum != 10) + return false; + return true; + } +} +, testReversedRange:function(){ + { + var tmp$1; + var tmp$0; + Kotlin.println('Testing reversed range.'); + var tenToFive = new foo.NumberRange(10, 5, true); + if (tenToFive.contains(5)) + return false; + if (tenToFive.contains(11)) + return false; + if (tenToFive.contains(-100)) + return false; + if (tenToFive.contains(1000)) + return false; + if (!tenToFive.contains(6)) + return false; + if (!tenToFive.contains(7)) + return false; + if (!tenToFive.contains(8)) + return false; + if (!tenToFive.contains(9)) + return false; + if (!tenToFive.contains(10)) + return false; + if (!(tenToFive.get_start() == 10)) + return false; + if (!(tenToFive.get_size() == 5)) + return false; + if (!(tenToFive.get_end() == 6)) + return false; + { + tmp$0 = tenToFive.iterator(); + while (tmp$0.hasNext()) { + var i = tmp$0.next(); + { + Kotlin.println(i); + } + } + } + var sum = 0; + { + tmp$1 = tenToFive.iterator(); + while (tmp$1.hasNext()) { + var i$0 = tmp$1.next(); + { + sum += i$0; + } + } + } + if (sum != 40) { + return false; + } + return true; + } +} +, main:function(args){ + { + Kotlin.println(foo.box()); + } +} +}, {RangeIterator:classes.RangeIterator, NumberRange:classes.NumberRange}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/misc/out/jquery.js b/k2js/translator/testFiles/expression/misc/out/jquery.js new file mode 100644 index 00000000000..7a0538dc529 --- /dev/null +++ b/k2js/translator/testFiles/expression/misc/out/jquery.js @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var aa = jQuery('a').attr('a'); + return 'OK'; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/misc/out/localProperty.js b/k2js/translator/testFiles/expression/misc/out/localProperty.js new file mode 100644 index 00000000000..c5aa34d8228 --- /dev/null +++ b/k2js/translator/testFiles/expression/misc/out/localProperty.js @@ -0,0 +1,24 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $y = 3; +} +, get_y:function(){ + return $y; +} +, f:function(a){ + { + var x = 42; + var y = 50; + return y; + } +} +, box:function(){ + { + return foo.f(foo.get_y()); + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/misc/out/safecallComputesExpressionOnlyOnce.js b/k2js/translator/testFiles/expression/misc/out/safecallComputesExpressionOnlyOnce.js new file mode 100644 index 00000000000..7d667c4bb05 --- /dev/null +++ b/k2js/translator/testFiles/expression/misc/out/safecallComputesExpressionOnlyOnce.js @@ -0,0 +1,35 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $i = 0; +} +, get_i:function(){ + return $i; +} +, set_i:function(tmp$0){ + $i = tmp$0; +} +, test:function(){ + var tmp$1; + var tmp$0; + { + return tmp$0 = foo.get_i() , (tmp$1 = tmp$0 , (foo.set_i(tmp$0 + 1) , tmp$1)); + } +} +, box:function(){ + { + if (foo.get_i() != 0) + return false; + foo.test() + 1; + if (foo.get_i() != 1) + return false; + foo.test() - 2; + if (foo.get_i() != 2) + return false; + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/string/out/intInTemplate.js b/k2js/translator/testFiles/expression/string/out/intInTemplate.js new file mode 100644 index 00000000000..d4a6ec6d4a6 --- /dev/null +++ b/k2js/translator/testFiles/expression/string/out/intInTemplate.js @@ -0,0 +1,14 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var number = 3; + return 'my age is ' + number; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/string/out/multipleExpressionsInTemplate.js b/k2js/translator/testFiles/expression/string/out/multipleExpressionsInTemplate.js new file mode 100644 index 00000000000..26e4ccee4cb --- /dev/null +++ b/k2js/translator/testFiles/expression/string/out/multipleExpressionsInTemplate.js @@ -0,0 +1,15 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var right = 2; + var left = 3; + return 'left = ' + left + '\n' + 'right = ' + right + '\n' + 'sum = ' + (left + right) + '\n'; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/string/out/objectToStringCallInTemplate.js b/k2js/translator/testFiles/expression/string/out/objectToStringCallInTemplate.js new file mode 100644 index 00000000000..5b910f020ef --- /dev/null +++ b/k2js/translator/testFiles/expression/string/out/objectToStringCallInTemplate.js @@ -0,0 +1,36 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(i){ + this.$i = i; + } + , get_i:function(){ + return this.$i; + } + , set_i:function(tmp$0){ + this.$i = tmp$0; + } + , toString:function(){ + { + return 'a' + this.get_i(); + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var p = new foo.A(2); + var n = new foo.A(1); + if (p + n != 'a2a1') { + return false; + } + if (new foo.A(10) != 'a10') { + return false; + } + return true; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/string/out/stringAssignment.js b/k2js/translator/testFiles/expression/string/out/stringAssignment.js new file mode 100644 index 00000000000..c17668a8230 --- /dev/null +++ b/k2js/translator/testFiles/expression/string/out/stringAssignment.js @@ -0,0 +1,16 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = 'bar'; + var b = 'foo'; + b = a; + return b == 'bar'; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/string/out/stringConstant.js b/k2js/translator/testFiles/expression/string/out/stringConstant.js new file mode 100644 index 00000000000..0d120ddcdbb --- /dev/null +++ b/k2js/translator/testFiles/expression/string/out/stringConstant.js @@ -0,0 +1,14 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = 'String'; + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/string/out/stringInTemplate.js b/k2js/translator/testFiles/expression/string/out/stringInTemplate.js new file mode 100644 index 00000000000..3a33350c76f --- /dev/null +++ b/k2js/translator/testFiles/expression/string/out/stringInTemplate.js @@ -0,0 +1,14 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var name_0 = 'Hello'; + return 'o' + name_0 + 'o'; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/expression/while/out/breakDoWhile.js b/k2js/translator/testFiles/expression/while/out/breakDoWhile.js new file mode 100644 index 00000000000..18229a1623f --- /dev/null +++ b/k2js/translator/testFiles/expression/while/out/breakDoWhile.js @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var i = 0; + do { + if (i == 3) { + break; + } + ++i; + } + while (i < 100); + return i == 3; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/while/out/breakWhile.js b/k2js/translator/testFiles/expression/while/out/breakWhile.js new file mode 100644 index 00000000000..37857b175bb --- /dev/null +++ b/k2js/translator/testFiles/expression/while/out/breakWhile.js @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var i = 0; + while (i < 100) { + if (i == 3) { + break; + } + ++i; + } + return i == 3; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/while/out/continueDoWhile.js b/k2js/translator/testFiles/expression/while/out/continueDoWhile.js new file mode 100644 index 00000000000..d696274a49a --- /dev/null +++ b/k2js/translator/testFiles/expression/while/out/continueDoWhile.js @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var i = 0; + var b = true; + do { + ++i; + if (i >= 1) { + continue; + } + b = false; + } + while (i < 100); + return b; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/while/out/continueWhile.js b/k2js/translator/testFiles/expression/while/out/continueWhile.js new file mode 100644 index 00000000000..4c9a9c699bb --- /dev/null +++ b/k2js/translator/testFiles/expression/while/out/continueWhile.js @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var i = 0; + var b = true; + while (i < 100) { + ++i; + if (i >= 1) { + continue; + } + b = false; + } + return b; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/while/out/doWhile.js b/k2js/translator/testFiles/expression/while/out/doWhile.js new file mode 100644 index 00000000000..61ef47b9aea --- /dev/null +++ b/k2js/translator/testFiles/expression/while/out/doWhile.js @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var a = 50; + var b = 0; + var c = 0; + do { + b = b + 1; + c = c + 2; + } + while (b < a); + if (c == 100) { + return true; + } + return false; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/while/out/doWhile2.js b/k2js/translator/testFiles/expression/while/out/doWhile2.js new file mode 100644 index 00000000000..a426d57c782 --- /dev/null +++ b/k2js/translator/testFiles/expression/while/out/doWhile2.js @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var x = 2; + do { + x = 1; + } + while (3 < 2); + if (x == 1) { + return true; + } + return false; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/while/out/while.js b/k2js/translator/testFiles/expression/while/out/while.js new file mode 100644 index 00000000000..c111cd03236 --- /dev/null +++ b/k2js/translator/testFiles/expression/while/out/while.js @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var a = 50; + var b = 0; + var c = 0; + while (b < a) { + b = b + 1; + c = c + 2; + } + if (c == 100) { + return true; + } + return false; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/expression/while/out/while2.js b/k2js/translator/testFiles/expression/while/out/while2.js new file mode 100644 index 00000000000..15d1c8416ea --- /dev/null +++ b/k2js/translator/testFiles/expression/while/out/while2.js @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + while (2 < 1) { + return false; + } + return true; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/extensionFunction/out/extensionFunctionOnExpression.js b/k2js/translator/testFiles/extensionFunction/out/extensionFunctionOnExpression.js new file mode 100644 index 00000000000..2c0f1cc737b --- /dev/null +++ b/k2js/translator/testFiles/extensionFunction/out/extensionFunctionOnExpression.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, same:function(receiver){ + { + return receiver; + } +} +, quadruple:function(receiver){ + { + return foo.same(receiver) * 4; + } +} +, box:function(){ + { + return foo.quadruple(3 + 4) == 28; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionFunction/out/extensionInsideFunctionLiteral.js b/k2js/translator/testFiles/extensionFunction/out/extensionInsideFunctionLiteral.js new file mode 100644 index 00000000000..3a47cebd385 --- /dev/null +++ b/k2js/translator/testFiles/extensionFunction/out/extensionInsideFunctionLiteral.js @@ -0,0 +1,48 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$m = 0; + } + , get_m:function(){ + return this.$m; + } + , set_m:function(tmp$0){ + this.$m = tmp$0; + } + , eval_0:function(){ + { + var tmp$0_0; + var d = (tmp$0_0 = this , function(){ + { + var tmp$0; + var c = (tmp$0 = tmp$0_0 , function(){ + { + return this + 3; + } + } + ); + tmp$0_0.set_m(tmp$0_0.get_m() + c.call(3)); + } + } + ); + d(); + } + } + }); + return {M:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = new foo.M; + if (a.get_m() != 0) + return false; + a.eval_0(); + if (a.get_m() != 6) + return false; + return true; + } +} +}, {M:classes.M}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionFunction/out/extensionLiteralPassedToFunction.js b/k2js/translator/testFiles/extensionFunction/out/extensionLiteralPassedToFunction.js new file mode 100644 index 00000000000..467922f84a1 --- /dev/null +++ b/k2js/translator/testFiles/extensionFunction/out/extensionLiteralPassedToFunction.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, apply:function(i, f){ + { + return f.call(i, 1); + } +} +, box:function(){ + { + return foo.apply(1, function(i){ + { + return i + this; + } + } + ) == 2; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionFunction/out/extensionUsedInsideClass.js b/k2js/translator/testFiles/extensionFunction/out/extensionUsedInsideClass.js new file mode 100644 index 00000000000..f7f08128740 --- /dev/null +++ b/k2js/translator/testFiles/extensionFunction/out/extensionUsedInsideClass.js @@ -0,0 +1,35 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(a){ + this.$a = a; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + , eval_0:function(){ + { + return foo.f(this); + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, f:function(receiver){ + { + receiver.set_a(3); + return 10; + } +} +, box:function(){ + { + var a = new foo.A(4); + return a.eval_0() == 10 && a.get_a() == 3; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionFunction/out/extensionWithImplicitReceiver.js b/k2js/translator/testFiles/extensionFunction/out/extensionWithImplicitReceiver.js new file mode 100644 index 00000000000..72374531371 --- /dev/null +++ b/k2js/translator/testFiles/extensionFunction/out/extensionWithImplicitReceiver.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, same:function(receiver){ + { + return receiver; + } +} +, quadruple:function(receiver){ + { + return foo.same(receiver) * 4; + } +} +, box:function(){ + { + return foo.quadruple(3) == 12; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionFunction/out/generic.js b/k2js/translator/testFiles/extensionFunction/out/generic.js new file mode 100644 index 00000000000..97d87242fa1 --- /dev/null +++ b/k2js/translator/testFiles/extensionFunction/out/generic.js @@ -0,0 +1,45 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, findAll:function(receiver, predicate){ + { + var tmp$0; + var result = new Kotlin.ArrayList; + { + tmp$0 = receiver.iterator(); + while (tmp$0.hasNext()) { + var t = tmp$0.next(); + { + if (predicate(t)) + result.add(t); + } + } + } + return result; + } +} +, box:function(){ + { + var tmp$0; + var list = new Kotlin.ArrayList; + list.add(2); + list.add(3); + list.add(5); + var m = foo.findAll(list, function(name_0){ + { + return name_0 < 4; + } + } + ); + if (m.size() == 2) + tmp$0 = 'OK'; + else + tmp$0 = 'fail'; + return tmp$0; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionFunction/out/intExtension.js b/k2js/translator/testFiles/extensionFunction/out/intExtension.js new file mode 100644 index 00000000000..c69a2a70d73 --- /dev/null +++ b/k2js/translator/testFiles/extensionFunction/out/intExtension.js @@ -0,0 +1,18 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, quadruple:function(receiver){ + { + return receiver * 4; + } +} +, box:function(){ + { + return foo.quadruple(3) == 12; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionFunction/out/virtualExtension.js b/k2js/translator/testFiles/extensionFunction/out/virtualExtension.js new file mode 100644 index 00000000000..085459763ef --- /dev/null +++ b/k2js/translator/testFiles/extensionFunction/out/virtualExtension.js @@ -0,0 +1,34 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(a){ + this.$a = a; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + , modify:function(receiver){ + { + return receiver * 3; + } + } + , eval_0:function(){ + { + return this.modify(this.get_a()); + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = new foo.A(4); + return a.eval_0() == 12; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionFunction/out/virtualExtensionOverride.js b/k2js/translator/testFiles/extensionFunction/out/virtualExtensionOverride.js new file mode 100644 index 00000000000..74c14aaf434 --- /dev/null +++ b/k2js/translator/testFiles/extensionFunction/out/virtualExtensionOverride.js @@ -0,0 +1,42 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(a){ + this.$a = a; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + , modify:function(receiver){ + { + return receiver * 3; + } + } + , eval_0:function(){ + { + return this.modify(this.get_a()); + } + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(a){ + this.super_init(a); + } + , modify:function(receiver){ + { + return receiver - 2; + } + } + }); + return {B:tmp$1, A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A(4)).eval_0() == 12 && (new foo.A(2)).eval_0() == 6 && (new foo.B(3)).eval_0() == 1; + } +} +}, {A:classes.A, B:classes.B}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionProperty/out/absExtension.js b/k2js/translator/testFiles/extensionProperty/out/absExtension.js new file mode 100644 index 00000000000..eb23945f0ad --- /dev/null +++ b/k2js/translator/testFiles/extensionProperty/out/absExtension.js @@ -0,0 +1,27 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, get_abs:function(receiver){ + var tmp$0; + if (receiver > 0) + tmp$0 = receiver; + else + tmp$0 = -receiver; + { + return tmp$0; + } +} +, box:function(){ + { + if (foo.get_abs(4) != 4) + return false; + if (foo.get_abs(-5.2) != 5.2) + return false; + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionProperty/out/propertyWithGetterAndSetter.js b/k2js/translator/testFiles/extensionProperty/out/propertyWithGetterAndSetter.js new file mode 100644 index 00000000000..38995e1f78c --- /dev/null +++ b/k2js/translator/testFiles/extensionProperty/out/propertyWithGetterAndSetter.js @@ -0,0 +1,46 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$a = 0; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, get_b:function(receiver){ + { + return receiver.get_a() * 3; + } +} +, set_b:function(receiver, c){ + { + receiver.set_a(c - 1); + } +} +, box:function(){ + { + var c = new foo.Test; + if (c.get_a() != 0) + return false; + if (foo.get_b(c) != 0) + return false; + c.set_a(3); + if (foo.get_b(c) != 9) + return false; + foo.set_b(c, 10); + if (c.get_a() != 9) + return false; + if (foo.get_b(c) != 27) + return false; + return true; + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/extensionProperty/out/simplePropertyWithGetter.js b/k2js/translator/testFiles/extensionProperty/out/simplePropertyWithGetter.js new file mode 100644 index 00000000000..45e40284c0e --- /dev/null +++ b/k2js/translator/testFiles/extensionProperty/out/simplePropertyWithGetter.js @@ -0,0 +1,33 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, get_size:function(receiver){ + { + return receiver.length; + } +} +, get_quadruple:function(receiver){ + { + return receiver * 4; + } +} +, box:function(){ + { + if (foo.get_size('1') != 1) + return false; + if (foo.get_size('11') != 2) + return false; + if (foo.get_size('121' + '123') != 6) + return false; + if (foo.get_quadruple(1) != 4) + return false; + if (foo.get_quadruple(0) != 0) + return false; + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/inheritance/out/baseClassDefinedAfterDerived.js b/k2js/translator/testFiles/inheritance/out/baseClassDefinedAfterDerived.js new file mode 100644 index 00000000000..77c6e4b59b4 --- /dev/null +++ b/k2js/translator/testFiles/inheritance/out/baseClassDefinedAfterDerived.js @@ -0,0 +1,24 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$a = 3; + } + , get_a:function(){ + return this.$a; + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + } + }); + return {A:tmp$1, B:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A).get_a() == 3; + } +} +}, {A:classes.A, B:classes.B}); +foo.initialize(); diff --git a/k2js/translator/testFiles/inheritance/out/complexInitializationOrder.js b/k2js/translator/testFiles/inheritance/out/complexInitializationOrder.js new file mode 100644 index 00000000000..93e751ab101 --- /dev/null +++ b/k2js/translator/testFiles/inheritance/out/complexInitializationOrder.js @@ -0,0 +1,54 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$order = ''; + { + this.set_order(this.get_order() + 'A'); + } + } + , get_order:function(){ + return this.$order; + } + , set_order:function(tmp$0){ + this.$order = tmp$0; + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'E'); + } + } + }); + var tmp$2 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'B'); + } + } + }); + var tmp$3 = Kotlin.Class.create(tmp$2, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'D'); + } + } + }); + var tmp$4 = Kotlin.Class.create(tmp$2, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'C'); + } + } + }); + return {E:tmp$1, B:tmp$2, D:tmp$3, C:tmp$4, A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.C).get_order() == 'ABC' && (new foo.D).get_order() == 'ABD' && (new foo.E).get_order() == 'AE'; + } +} +}, {A:classes.A, B:classes.B, C:classes.C, D:classes.D, E:classes.E}); +foo.initialize(); diff --git a/k2js/translator/testFiles/inheritance/out/definitionOrder.js b/k2js/translator/testFiles/inheritance/out/definitionOrder.js new file mode 100644 index 00000000000..c36bbed8040 --- /dev/null +++ b/k2js/translator/testFiles/inheritance/out/definitionOrder.js @@ -0,0 +1,54 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$order = ''; + { + this.set_order(this.get_order() + 'A'); + } + } + , get_order:function(){ + return this.$order; + } + , set_order:function(tmp$0){ + this.$order = tmp$0; + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'B'); + } + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'D'); + } + } + }); + var tmp$3 = Kotlin.Class.create(tmp$1, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'C'); + } + } + }); + var tmp$4 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'E'); + } + } + }); + return {B:tmp$1, D:tmp$2, C:tmp$3, E:tmp$4, A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.C).get_order() == 'ABC' && (new foo.D).get_order() == 'ABD' && (new foo.E).get_order() == 'AE'; + } +} +}, {C:classes.C, D:classes.D, E:classes.E, B:classes.B, A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/inheritance/out/initializationOrder.js b/k2js/translator/testFiles/inheritance/out/initializationOrder.js new file mode 100644 index 00000000000..ce6de580d08 --- /dev/null +++ b/k2js/translator/testFiles/inheritance/out/initializationOrder.js @@ -0,0 +1,40 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$order = ''; + { + this.set_order(this.get_order() + 'A'); + } + } + , get_order:function(){ + return this.$order; + } + , set_order:function(tmp$0){ + this.$order = tmp$0; + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'B'); + } + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'C'); + } + } + }); + return {B:tmp$1, C:tmp$2, A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.C).get_order() == 'ABC' && (new foo.B).get_order() == 'AB' && (new foo.A).get_order() == 'A'; + } +} +}, {A:classes.A, B:classes.B, C:classes.C}); +foo.initialize(); diff --git a/k2js/translator/testFiles/inheritance/out/initializersOfBasicClassExecute.js b/k2js/translator/testFiles/inheritance/out/initializersOfBasicClassExecute.js new file mode 100644 index 00000000000..899a039ffd5 --- /dev/null +++ b/k2js/translator/testFiles/inheritance/out/initializersOfBasicClassExecute.js @@ -0,0 +1,27 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$a = 3; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + } + }); + return {B:tmp$1, A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.B).get_a(); + } +} +}, {A:classes.A, B:classes.B}); +foo.initialize(); diff --git a/k2js/translator/testFiles/inheritance/out/methodOverride.js b/k2js/translator/testFiles/inheritance/out/methodOverride.js new file mode 100644 index 00000000000..54747099ea3 --- /dev/null +++ b/k2js/translator/testFiles/inheritance/out/methodOverride.js @@ -0,0 +1,33 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , f:function(){ + { + return 'C f'; + } + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + } + , f:function(){ + { + return 'D f'; + } + } + }); + return {D:tmp$1, C:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var d = new foo.D; + if (d.f() != 'D f') + return false; + return true; + } +} +}, {C:classes.C, D:classes.D}); +foo.initialize(); diff --git a/k2js/translator/testFiles/inheritance/out/valuePassedToAncestorConstructor.js b/k2js/translator/testFiles/inheritance/out/valuePassedToAncestorConstructor.js new file mode 100644 index 00000000000..7873730c237 --- /dev/null +++ b/k2js/translator/testFiles/inheritance/out/valuePassedToAncestorConstructor.js @@ -0,0 +1,24 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(a){ + this.$b = a; + } + , get_b:function(){ + return this.$b; + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(c){ + this.super_init(c + 2); + } + }); + return {D:tmp$1, C:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.D(0)).get_b() == 2; + } +} +}, {C:classes.C, D:classes.D}); +foo.initialize(); diff --git a/k2js/translator/testFiles/java/arrayList/out/access.js b/k2js/translator/testFiles/java/arrayList/out/access.js new file mode 100644 index 00000000000..85c2a166920 --- /dev/null +++ b/k2js/translator/testFiles/java/arrayList/out/access.js @@ -0,0 +1,16 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = new Kotlin.ArrayList; + a.add(1); + a.add(2); + return a.size() == 2 && a.get(1) == 2 && a.get(0) == 1; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/java/arrayList/out/arrayAccess.js b/k2js/translator/testFiles/java/arrayList/out/arrayAccess.js new file mode 100644 index 00000000000..e5a5a5732f7 --- /dev/null +++ b/k2js/translator/testFiles/java/arrayList/out/arrayAccess.js @@ -0,0 +1,17 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = new Kotlin.ArrayList; + a.add(1); + a.add(2); + a.set(1, 100); + return a.size() == 2 && a.get(1) == 100 && a.get(0) == 1; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/java/arrayList/out/emptyList.js b/k2js/translator/testFiles/java/arrayList/out/emptyList.js new file mode 100644 index 00000000000..30442c2b01a --- /dev/null +++ b/k2js/translator/testFiles/java/arrayList/out/emptyList.js @@ -0,0 +1,14 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = new Kotlin.ArrayList; + return a.size() == 0; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/java/arrayList/out/indexOOB.js b/k2js/translator/testFiles/java/arrayList/out/indexOOB.js new file mode 100644 index 00000000000..ce2033fffc9 --- /dev/null +++ b/k2js/translator/testFiles/java/arrayList/out/indexOOB.js @@ -0,0 +1,18 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var arr = new Kotlin.ArrayList; + var i = 0; + while (i++ < 10) { + arr.add(i); + } + return arr.get(10) == 11; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/java/arrayList/out/isEmpty.js b/k2js/translator/testFiles/java/arrayList/out/isEmpty.js new file mode 100644 index 00000000000..b9aeef72c37 --- /dev/null +++ b/k2js/translator/testFiles/java/arrayList/out/isEmpty.js @@ -0,0 +1,15 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = new Kotlin.ArrayList; + a.add(3); + return !a.isEmpty() && (new Kotlin.ArrayList).isEmpty(); + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/java/arrayList/out/iterate.js b/k2js/translator/testFiles/java/arrayList/out/iterate.js new file mode 100644 index 00000000000..95a829d963c --- /dev/null +++ b/k2js/translator/testFiles/java/arrayList/out/iterate.js @@ -0,0 +1,29 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var i = 0; + var arr = new Kotlin.ArrayList; + while (i++ < 10) { + arr.add(i); + } + var sum = 0; + { + tmp$0 = arr.iterator(); + while (tmp$0.hasNext()) { + var a = tmp$0.next(); + { + sum += a; + } + } + } + return sum == 55 && arr.size() == 10; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/java/arrayList/out/remove.js b/k2js/translator/testFiles/java/arrayList/out/remove.js new file mode 100644 index 00000000000..f2a8ff85833 --- /dev/null +++ b/k2js/translator/testFiles/java/arrayList/out/remove.js @@ -0,0 +1,30 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var i = 0; + var arr = new Kotlin.ArrayList; + while (i++ < 10) { + arr.add(i); + } + arr.remove(2); + var sum = 0; + { + tmp$0 = arr.iterator(); + while (tmp$0.hasNext()) { + var a = tmp$0.next(); + { + sum += a; + } + } + } + return sum == 52 && arr.get(1) == 2 && arr.get(2) == 4 && arr.get(3) == 5 && arr.get(4) == 6 && arr.get(8) == 10; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/multiFile/out/classesInheritedFromOtherFile.js b/k2js/translator/testFiles/multiFile/out/classesInheritedFromOtherFile.js new file mode 100644 index 00000000000..124841c684e --- /dev/null +++ b/k2js/translator/testFiles/multiFile/out/classesInheritedFromOtherFile.js @@ -0,0 +1,39 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , f:function(){ + { + return 3; + } + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + } + , f:function(){ + { + return 4; + } + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, {initialize:function(){ + this.super_init(); + } + , f:function(){ + { + return 5; + } + } + }); + return {B:tmp$1, C:tmp$2, A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A).f() == 3 && (new foo.B).f() == 4 && (new foo.C).f() == 5; + } +} +}, {A:classes.A, C:classes.C, B:classes.B}); +foo.initialize(); diff --git a/k2js/translator/testFiles/multiFile/out/functionsVisibleFromOtherFile.js b/k2js/translator/testFiles/multiFile/out/functionsVisibleFromOtherFile.js new file mode 100644 index 00000000000..5ac79b91c17 --- /dev/null +++ b/k2js/translator/testFiles/multiFile/out/functionsVisibleFromOtherFile.js @@ -0,0 +1,18 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, f:function(){ + { + return 3; + } +} +, box:function(){ + { + return foo.f() == 3; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/multiNamespace/out/classesInheritedFromOtherNamespace.js b/k2js/translator/testFiles/multiNamespace/out/classesInheritedFromOtherNamespace.js new file mode 100644 index 00000000000..aa747f4705c --- /dev/null +++ b/k2js/translator/testFiles/multiNamespace/out/classesInheritedFromOtherNamespace.js @@ -0,0 +1,43 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , f:function(){ + { + return 3; + } + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + } + , f:function(){ + { + return 4; + } + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, {initialize:function(){ + this.super_init(); + } + , f:function(){ + { + return 5; + } + } + }); + return {B:tmp$1, C:tmp$2, A:tmp$0}; +} +(); +var bar = Kotlin.Namespace.create({initialize:function(){ +} +}, {B:classes.B}); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A).f() == 3 && (new bar.B).f() == 4 && (new foo.C).f() == 5; + } +} +}, {A:classes.A, C:classes.C}); +bar.initialize(); +foo.initialize(); diff --git a/k2js/translator/testFiles/multiNamespace/out/functionsVisibleFromOtherNamespace.js b/k2js/translator/testFiles/multiNamespace/out/functionsVisibleFromOtherNamespace.js new file mode 100644 index 00000000000..8c8e2df3872 --- /dev/null +++ b/k2js/translator/testFiles/multiNamespace/out/functionsVisibleFromOtherNamespace.js @@ -0,0 +1,22 @@ +var classes = function(){ + return {}; +} +(); +var bar = Kotlin.Namespace.create({initialize:function(){ +} +, f:function(){ + { + return 3; + } +} +}, {}); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return bar.f() == 3; + } +} +}, {}); +bar.initialize(); +foo.initialize(); diff --git a/k2js/translator/testFiles/nameClashes/out/methodOverload.js b/k2js/translator/testFiles/nameClashes/out/methodOverload.js new file mode 100644 index 00000000000..f972f0f2339 --- /dev/null +++ b/k2js/translator/testFiles/nameClashes/out/methodOverload.js @@ -0,0 +1,44 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , eval_0:function(){ + { + return 3; + } + } + , eval$0:function(a){ + { + return 4; + } + } + , eval$1:function(a){ + { + return 5; + } + } + , eval$2:function(a, b){ + { + return 6; + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + if ((new foo.A).eval_0() != 3) + return false; + if ((new foo.A).eval$0(2) != 4) + return false; + if ((new foo.A).eval$1('3') != 5) + return false; + if ((new foo.A).eval$2('a', 3) != 6) + return false; + return true; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/object/out/objectDeclaration.js b/k2js/translator/testFiles/object/out/objectDeclaration.js new file mode 100644 index 00000000000..e16d8d0e494 --- /dev/null +++ b/k2js/translator/testFiles/object/out/objectDeclaration.js @@ -0,0 +1,41 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $test = Kotlin.object.create({initialize:function(){ + this.$c = 2; + this.$b = 1; + } + , get_c:function(){ + return this.$c; + } + , set_c:function(tmp$0){ + this.$c = tmp$0; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + }); +} +, get_test:function(){ + return $test; +} +, box:function(){ + { + if (foo.get_test().get_c() != 2) + return false; + if (foo.get_test().get_b() != 1) + return false; + foo.get_test().set_c(foo.get_test().get_c() + 10); + if (foo.get_test().get_c() != 12) { + return false; + } + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/object/out/objectInMethod.js b/k2js/translator/testFiles/object/out/objectInMethod.js new file mode 100644 index 00000000000..5a46d78784d --- /dev/null +++ b/k2js/translator/testFiles/object/out/objectInMethod.js @@ -0,0 +1,35 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , f:function(){ + { + var t = Kotlin.object.create({initialize:function(){ + this.$c = true; + } + , get_c:function(){ + return this.$c; + } + }); + var z = Kotlin.object.create({initialize:function(){ + this.$c = true; + } + , get_c:function(){ + return this.$c; + } + }); + return t.get_c() && z.get_c(); + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A).f(); + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/object/out/objectWithMethods.js b/k2js/translator/testFiles/object/out/objectWithMethods.js new file mode 100644 index 00000000000..b3c2c9631ec --- /dev/null +++ b/k2js/translator/testFiles/object/out/objectWithMethods.js @@ -0,0 +1,35 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $a = Kotlin.object.create({initialize:function(){ + } + , c:function(){ + { + return 3; + } + } + , b:function(){ + { + return 2; + } + } + }); +} +, get_a:function(){ + return $a; +} +, box:function(){ + { + if (foo.get_a().c() != 3) { + return false; + } + if (foo.get_a().b() != 2) { + return false; + } + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/binaryDivOverload.js b/k2js/translator/testFiles/operatorOverloading/out/binaryDivOverload.js new file mode 100644 index 00000000000..00416f9f4a1 --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/binaryDivOverload.js @@ -0,0 +1,21 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , div:function(other){ + { + return 'hooray'; + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A).div(new foo.A) == 'hooray'; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/compareTo.js b/k2js/translator/testFiles/operatorOverloading/out/compareTo.js new file mode 100644 index 00000000000..f24bc38db30 --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/compareTo.js @@ -0,0 +1,28 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(t){ + this.$i = t; + } + , get_i:function(){ + return this.$i; + } + , set_i:function(tmp$0){ + this.$i = tmp$0; + } + , compareTo:function(other){ + { + return this.get_i() - other.get_i(); + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A(3)).compareTo(new foo.A(2)) > 0 && (new foo.A(2)).compareTo(new foo.A(2)) >= 0 && (new foo.A(1)).compareTo(new foo.A(0)) >= 0 && (new foo.A(2)).compareTo(new foo.A(2)) <= 0 && (new foo.A(3)).compareTo(new foo.A(4)) <= 0 && (new foo.A(0)).compareTo(new foo.A(100)) < 0; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/notOverload.js b/k2js/translator/testFiles/operatorOverloading/out/notOverload.js new file mode 100644 index 00000000000..bbd924a0dde --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/notOverload.js @@ -0,0 +1,21 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , not:function(){ + { + return 'hooray'; + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A).not() == 'hooray'; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.js b/k2js/translator/testFiles/operatorOverloading/out/operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.js new file mode 100644 index 00000000000..65c1894c232 --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.js @@ -0,0 +1,62 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$gc = 0; + this.$sc = 0; + this.$b = new foo.MyInt(0); + } + , get_gc:function(){ + return this.$gc; + } + , set_gc:function(tmp$0){ + this.$gc = tmp$0; + } + , get_sc:function(){ + return this.$sc; + } + , set_sc:function(tmp$0){ + this.$sc = tmp$0; + } + , get_b:function(){ + { + this.set_gc(this.get_gc() + 1); + return this.$b; + } + } + , set_b:function(a){ + { + this.set_sc(this.get_sc() + 1); + } + } + }); + var tmp$1 = Kotlin.Class.create({initialize:function(i){ + this.$b = i; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , inc:function(){ + { + this.set_b(this.get_b() + 1); + return this; + } + } + }); + return {MyInt:tmp$1, A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$1; + var tmp$0; + var t = new foo.A; + var d = (tmp$0 = t.get_b() , (tmp$1 = tmp$0 , (t.set_b(tmp$0.inc()) , tmp$1))); + return t.get_sc() == 1 && t.get_gc() == 1; + } +} +}, {MyInt:classes.MyInt, A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/overloadPlusAssignArrayList.js b/k2js/translator/testFiles/operatorOverloading/out/overloadPlusAssignArrayList.js new file mode 100644 index 00000000000..7274e35e0f6 --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/overloadPlusAssignArrayList.js @@ -0,0 +1,45 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$contents = new Kotlin.ArrayList; + } + , get_contents:function(){ + return this.$contents; + } + , add:function(item){ + { + this.get_contents().add(item); + } + } + , plusAssign:function(rhs){ + { + this.get_contents().addAll(rhs.get_contents()); + } + } + , get:function(index){ + { + return this.get_contents().get(index); + } + } + }); + return {ArrayWrapper:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var v1 = new foo.ArrayWrapper; + var v2 = new foo.ArrayWrapper; + v1.add('foo'); + v2.add('bar'); + v1.plusAssign(v2); + if (v1.get_contents().size() == 2) + tmp$0 = 'OK'; + else + tmp$0 = 'fail'; + return tmp$0; + } +} +}, {ArrayWrapper:classes.ArrayWrapper}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/overloadedCallOnProperty.js b/k2js/translator/testFiles/operatorOverloading/out/overloadedCallOnProperty.js new file mode 100644 index 00000000000..ebdd7877c84 --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/overloadedCallOnProperty.js @@ -0,0 +1,40 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$b = 0; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , inc:function(){ + { + var res = new foo.MyInt; + res.set_b(this.get_b()); + res.set_b(res.get_b() + 1); + return res; + } + } + }); + return {MyInt:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $a = new foo.MyInt; +} +, get_a:function(){ + return $a; +} +, set_a:function(tmp$0){ + $a = tmp$0; +} +, box:function(){ + { + foo.set_a(foo.get_a().inc()); + foo.set_a(foo.get_a().inc()); + return foo.get_a().get_b() == 2; + } +} +}, {MyInt:classes.MyInt}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/plusAndMinusAsAnExpression.js b/k2js/translator/testFiles/operatorOverloading/out/plusAndMinusAsAnExpression.js new file mode 100644 index 00000000000..44ffaff5163 --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/plusAndMinusAsAnExpression.js @@ -0,0 +1,27 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , plus:function(){ + { + return 'hooray'; + } + } + , minus:function(){ + { + return 'not really'; + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new foo.A; + return c.plus() + c.minus() == 'hooraynot really'; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/plusAssignNoReassign.js b/k2js/translator/testFiles/operatorOverloading/out/plusAssignNoReassign.js new file mode 100644 index 00000000000..0a79624f16c --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/plusAssignNoReassign.js @@ -0,0 +1,31 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$message = ''; + } + , get_message:function(){ + return this.$message; + } + , set_message:function(tmp$0){ + this.$message = tmp$0; + } + , plusAssign:function(other){ + { + this.set_message(this.get_message() + '!'); + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new foo.A; + c.plusAssign(new foo.A); + c.plusAssign(new foo.A); + return c.get_message() == '!!'; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/plusAssignReassign.js b/k2js/translator/testFiles/operatorOverloading/out/plusAssignReassign.js new file mode 100644 index 00000000000..e144960088d --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/plusAssignReassign.js @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var A = Kotlin.Class.create({initialize:function(i){ + this.$a = i; + } + , get_a:function(){ + return this.$a; + } + , plusAssign:function(other){ + { + return new foo.A_0(this.get_a() + other.get_a()); + } + } + }); + return {A_0:A}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var c = new foo.A_0(2); + var d = c; + c = c.plusAssign(new foo.A_0(3)); + return c.get_a() == 5 && d.get_a() == 2 && d != c; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/operatorOverloading/out/plusOverload.js b/k2js/translator/testFiles/operatorOverloading/out/plusOverload.js new file mode 100644 index 00000000000..c065e779805 --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/plusOverload.js @@ -0,0 +1,25 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(a){ + this.$value = a; + } + , get_value:function(){ + return this.$value; + } + , plus:function(other){ + { + return new foo.myInt(this.get_value() + other.get_value()); + } + } + }); + return {myInt:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.myInt(3)).plus(new foo.myInt(5)).get_value() == 8; + } +} +}, {myInt:classes.myInt}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/postfixIncOverload.js b/k2js/translator/testFiles/operatorOverloading/out/postfixIncOverload.js new file mode 100644 index 00000000000..0240d8d94da --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/postfixIncOverload.js @@ -0,0 +1,32 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$b = 0; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , inc:function(){ + { + var res = new foo.MyInt; + res.set_b(res.get_b() + 1); + return res; + } + } + }); + return {MyInt:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new foo.MyInt; + c = c.inc(); + return c.get_b() == 1; + } +} +}, {MyInt:classes.MyInt}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/postfixOnProperty.js b/k2js/translator/testFiles/operatorOverloading/out/postfixOnProperty.js new file mode 100644 index 00000000000..fb5239c752a --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/postfixOnProperty.js @@ -0,0 +1,39 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$b = 0; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , inc:function(){ + { + this.set_b(this.get_b() + 1); + return this; + } + } + }); + return {MyInt:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $a = new foo.MyInt; +} +, get_a:function(){ + return $a; +} +, set_a:function(tmp$0){ + $a = tmp$0; +} +, box:function(){ + { + var tmp$1; + var tmp$0; + var d = (tmp$0 = foo.get_a() , (tmp$1 = tmp$0 , (foo.set_a(tmp$0.inc()) , tmp$1))); + return foo.get_a().get_b() == 1 && d.get_b() == 1; + } +} +}, {MyInt:classes.MyInt}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/prefixDecOverload.js b/k2js/translator/testFiles/operatorOverloading/out/prefixDecOverload.js new file mode 100644 index 00000000000..5da0b86f62b --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/prefixDecOverload.js @@ -0,0 +1,32 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$b = 0; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , dec:function(){ + { + var res = new foo.MyInt; + res.set_b(res.get_b() + 1); + return res; + } + } + }); + return {MyInt:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new foo.MyInt; + c = c.dec(); + return c.get_b() == 1; + } +} +}, {MyInt:classes.MyInt}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/prefixIncReturnsCorrectValue.js b/k2js/translator/testFiles/operatorOverloading/out/prefixIncReturnsCorrectValue.js new file mode 100644 index 00000000000..0e93cde9f2f --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/prefixIncReturnsCorrectValue.js @@ -0,0 +1,31 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$b = 0; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , dec:function(){ + { + this.set_b(this.get_b() + 1); + return this; + } + } + }); + return {MyInt:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new foo.MyInt; + var d = c = c.dec(); + return c.get_b() == 1; + } +} +}, {MyInt:classes.MyInt}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/unaryOnIntProperty.js b/k2js/translator/testFiles/operatorOverloading/out/unaryOnIntProperty.js new file mode 100644 index 00000000000..b18b23064f2 --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/unaryOnIntProperty.js @@ -0,0 +1,33 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(i){ + this.$b = i; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , inc:function(){ + { + var tmp$1; + var tmp$0; + this.set_b((tmp$0 = this.get_b() , (tmp$1 = tmp$0 , (this.set_b(tmp$0 + 1) , tmp$1)))); + return this; + } + } + }); + return {MyInt:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var t = new foo.MyInt(0); + t = t.inc(); + return t.get_b() == 0; + } +} +}, {MyInt:classes.MyInt}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/unaryOnIntProperty2.js b/k2js/translator/testFiles/operatorOverloading/out/unaryOnIntProperty2.js new file mode 100644 index 00000000000..e29c7abcd53 --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/unaryOnIntProperty2.js @@ -0,0 +1,31 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(i){ + this.$b = i; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , inc:function(){ + { + this.set_b(this.get_b() + 1); + return this; + } + } + }); + return {MyInt:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var t = new foo.MyInt(0); + t = t.inc(); + return t.get_b() == 1; + } +} +}, {MyInt:classes.MyInt}); +foo.initialize(); diff --git a/k2js/translator/testFiles/operatorOverloading/out/usingModInCaseModAssignNotAvailable.js b/k2js/translator/testFiles/operatorOverloading/out/usingModInCaseModAssignNotAvailable.js new file mode 100644 index 00000000000..5a15936649f --- /dev/null +++ b/k2js/translator/testFiles/operatorOverloading/out/usingModInCaseModAssignNotAvailable.js @@ -0,0 +1,31 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$p = 'yeah'; + } + , get_p:function(){ + return this.$p; + } + , set_p:function(tmp$0){ + this.$p = tmp$0; + } + , mod:function(other){ + { + return new foo.A; + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new foo.A; + var d = c; + c = c.mod(new foo.A); + return c != d && c.get_p() == 'yeah'; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/patternMatching/out/matchNullableType.js b/k2js/translator/testFiles/patternMatching/out/matchNullableType.js new file mode 100644 index 00000000000..9ee8d54edfb --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/matchNullableType.js @@ -0,0 +1,28 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$1; + var tmp$0; + var a = null; + for (tmp$0 = 0; tmp$0 < 2; ++tmp$0) { + if (tmp$0 == 0) + if (a == null || Kotlin.isType(a, foo.A)) { + return true; + break; + } + if (tmp$0 == 1) + return false; + } + tmp$1; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/patternMatching/out/multipleCases.js b/k2js/translator/testFiles/patternMatching/out/multipleCases.js new file mode 100644 index 00000000000..8f430ce7f24 --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/multipleCases.js @@ -0,0 +1,42 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$3; + var tmp$2; + var tmp$1; + var tmp$0; + var c = 3; + var d = 5; + var z = 0; + for (tmp$0 = 0; tmp$0 < 2; ++tmp$0) { + if (tmp$0 == 0) + if (c == 5 || c == 3) { + tmp$1 = z++; + break; + } + if (tmp$0 == 1) { + tmp$1 = z = -1000; + } + } + tmp$1; + for (tmp$2 = 0; tmp$2 < 2; ++tmp$2) { + if (tmp$2 == 0) + if (d == 5 || d == 3) { + tmp$3 = z++; + break; + } + if (tmp$2 == 1) { + tmp$3 = z = -1000; + } + } + tmp$3; + return z; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/patternMatching/out/whenAsExpression.js b/k2js/translator/testFiles/patternMatching/out/whenAsExpression.js new file mode 100644 index 00000000000..eb5e00cc30c --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenAsExpression.js @@ -0,0 +1,29 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$1; + var tmp$0; + for (tmp$0 = 0; tmp$0 < 3; ++tmp$0) { + if (tmp$0 == 0) + if (1 == 2) { + tmp$1 = 3; + break; + } + if (tmp$0 == 1) + if (1 == 1) { + tmp$1 = 1; + break; + } + if (tmp$0 == 2) + tmp$1 = 5; + } + return tmp$1 == 1; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/patternMatching/out/whenAsExpressionWithThrow.js b/k2js/translator/testFiles/patternMatching/out/whenAsExpressionWithThrow.js new file mode 100644 index 00000000000..d286fc3bc0d --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenAsExpressionWithThrow.js @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + return {}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var tmp$1; + var tmp$0; + for (tmp$0 = 0; tmp$0 < 3; ++tmp$0) { + if (tmp$0 == 0) + if (1 == 3) { + { + tmp$1 = 3; + } + break; + } + if (tmp$0 == 1) + if (1 == 1) { + { + throw new Kotlin.Exception; + } + break; + } + if (tmp$0 == 2) { + return false; + } + } + tmp$1; + return false; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/patternMatching/out/whenConditionMethodCall.js b/k2js/translator/testFiles/patternMatching/out/whenConditionMethodCall.js new file mode 100644 index 00000000000..84fcd78a049 --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenConditionMethodCall.js @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + classes = function(){ + var A = Class.create({initialize:function(){ + } + , p:function(){ + return true; + } + }); + return {A:A}; + } + (); + foo = Namespace.create({initialize:function(){ + } + , box:function(){ + var a = 0; + for (var tmp$0 = 0; tmp$0 < 4; ++tmp$0) { + if (tmp$0 == 0) + if ((new foo.A).p() === true) { + a--; + break; + } + if (tmp$0 == 1) + if (new foo.A === null || isType(new foo.A, foo.A)) { + a++; + break; + } + if (tmp$0 == 2) + if (isType(new foo.A, foo.A)) { + a++; + break; + } + if (tmp$0 == 3) + a++; + } + return a === -1; + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/patternMatching/out/whenConditionPropertyAccess.js b/k2js/translator/testFiles/patternMatching/out/whenConditionPropertyAccess.js new file mode 100644 index 00000000000..4858fe61cf2 --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenConditionPropertyAccess.js @@ -0,0 +1,64 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + classes = function(){ + var A = Class.create({initialize:function(){ + this.$pp = true; + } + , get_pp:function(){ + return this.$pp; + } + , p:function(){ + return true; + } + }); + return {A:A}; + } + (); + foo = Namespace.create({initialize:function(){ + } + , box:function(){ + var a = 0; + for (var tmp$0 = 0; tmp$0 < 5; ++tmp$0) { + if (tmp$0 == 0) + if ((new foo.A).get_pp() === true) { + a -= 2; + break; + } + if (tmp$0 == 1) + if ((new foo.A).p() === true) { + a--; + break; + } + if (tmp$0 == 2) + if (new foo.A === null || isType(new foo.A, foo.A)) { + a++; + break; + } + if (tmp$0 == 3) + if (isType(new foo.A, foo.A)) { + a++; + break; + } + if (tmp$0 == 4) + a++; + } + return a === -2; + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/patternMatching/out/whenExecutesOnlyOnce.js b/k2js/translator/testFiles/patternMatching/out/whenExecutesOnlyOnce.js new file mode 100644 index 00000000000..423d3d264e7 --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenExecutesOnlyOnce.js @@ -0,0 +1,34 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$1; + var tmp$0; + var a = 0; + for (tmp$0 = 0; tmp$0 < 3; ++tmp$0) { + if (tmp$0 == 0) + if (Kotlin.isType(new foo.A, foo.A)) { + tmp$1 = a++; + break; + } + if (tmp$0 == 1) + if (Kotlin.isType(new foo.A, foo.A)) { + tmp$1 = a++; + break; + } + if (tmp$0 == 2) + tmp$1 = a++; + } + tmp$1; + return a == 1; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/patternMatching/out/whenNotType.js b/k2js/translator/testFiles/patternMatching/out/whenNotType.js new file mode 100644 index 00000000000..9e262be4d5e --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenNotType.js @@ -0,0 +1,27 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$1; + var tmp$0; + for (tmp$0 = 0; tmp$0 < 2; ++tmp$0) { + if (tmp$0 == 0) + if (!Kotlin.isType(new foo.A, foo.A)) { + return false; + break; + } + if (tmp$0 == 1) + return true; + } + tmp$1; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/patternMatching/out/whenNotValue.js b/k2js/translator/testFiles/patternMatching/out/whenNotValue.js new file mode 100644 index 00000000000..456630e5ae0 --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenNotValue.js @@ -0,0 +1,36 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$1; + var tmp$0; + var a = 4; + for (tmp$0 = 0; tmp$0 < 3; ++tmp$0) { + if (tmp$0 == 0) + if (!(a == 3)) { + { + tmp$1 = a = 10; + } + break; + } + if (tmp$0 == 1) + if (!(a == 4)) { + { + tmp$1 = a = 20; + } + break; + } + if (tmp$0 == 2) { + tmp$1 = a = 30; + } + } + tmp$1; + return a == 10; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/patternMatching/out/whenType.js b/k2js/translator/testFiles/patternMatching/out/whenType.js new file mode 100644 index 00000000000..7eb531d6102 --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenType.js @@ -0,0 +1,27 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$1; + var tmp$0; + for (tmp$0 = 0; tmp$0 < 2; ++tmp$0) { + if (tmp$0 == 0) + if (Kotlin.isType(new foo.A, foo.A)) { + return true; + break; + } + if (tmp$0 == 1) + return false; + } + tmp$1; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/patternMatching/out/whenValue.js b/k2js/translator/testFiles/patternMatching/out/whenValue.js new file mode 100644 index 00000000000..05092651f1e --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenValue.js @@ -0,0 +1,36 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$1; + var tmp$0; + var a = 4; + for (tmp$0 = 0; tmp$0 < 3; ++tmp$0) { + if (tmp$0 == 0) + if (a == 3) { + { + tmp$1 = a = 10; + } + break; + } + if (tmp$0 == 1) + if (a == 4) { + { + tmp$1 = a = 20; + } + break; + } + if (tmp$0 == 2) { + tmp$1 = a = 30; + } + } + tmp$1; + return a == 20; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/patternMatching/out/whenValueOrType.js b/k2js/translator/testFiles/patternMatching/out/whenValueOrType.js new file mode 100644 index 00000000000..bbb327f4aa9 --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenValueOrType.js @@ -0,0 +1,61 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + }); + var tmp$1 = Kotlin.Class.create({initialize:function(){ + } + }); + return {A:tmp$1, B:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$3; + var tmp$2; + var tmp$1; + var tmp$0; + var c = 0; + var a = new foo.A; + var b = null; + for (tmp$0 = 0; tmp$0 < 4; ++tmp$0) { + if (tmp$0 == 0) + if (a == null) { + tmp$1 = c = 10; + break; + } + if (tmp$0 == 1) + if (Kotlin.isType(a, foo.B)) { + tmp$1 = c = 10000; + break; + } + if (tmp$0 == 2) + if (Kotlin.isType(a, foo.A)) { + tmp$1 = c = 20; + break; + } + if (tmp$0 == 3) + tmp$1 = c = 1000; + } + tmp$1; + for (tmp$2 = 0; tmp$2 < 3; ++tmp$2) { + if (tmp$2 == 0) + if (b == null) { + tmp$3 = c += 5; + break; + } + if (tmp$2 == 1) + if (Kotlin.isType(b, foo.B)) { + tmp$3 = c += 100; + break; + } + if (tmp$2 == 2) + tmp$3 = c = 1000; + } + tmp$3; + return c == 25; + } +} +}, {A:classes.A, B:classes.B}); +foo.initialize(); diff --git a/k2js/translator/testFiles/patternMatching/out/whenWithIf.js b/k2js/translator/testFiles/patternMatching/out/whenWithIf.js new file mode 100644 index 00000000000..ee6705ac2f2 --- /dev/null +++ b/k2js/translator/testFiles/patternMatching/out/whenWithIf.js @@ -0,0 +1,65 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$5; + var tmp$4; + var tmp$3; + var tmp$2; + var tmp$1; + var tmp$0; + for (tmp$0 = 0; tmp$0 < 3; ++tmp$0) { + if (tmp$0 == 0) + if (3 == 3) { + tmp$1 = 1; + break; + } + if (tmp$0 == 1) + if (3 == 2) { + tmp$1 = 100; + break; + } + if (tmp$0 == 2) + tmp$1 = 100; + } + for (tmp$2 = 0; tmp$2 < 2; ++tmp$2) { + if (tmp$2 == 0) + if (2 == 1) { + tmp$3 = 100; + break; + } + if (tmp$2 == 1) + tmp$3 = 1; + } + for (tmp$4 = 0; tmp$4 < 3; ++tmp$4) { + if (tmp$4 == 0) + if (0 == 1) { + if (true) + tmp$5 = 100; + else + tmp$5 = 100; + break; + } + if (tmp$4 == 1) + if (0 == 0) { + if (false) { + tmp$5 = 100; + } + else { + tmp$5 = 1; + } + break; + } + if (tmp$4 == 2) + tmp$5 = 100; + } + var c = tmp$1 + tmp$3 + tmp$5; + return c == 3; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/accessToInstanceProperty.js b/k2js/translator/testFiles/propertyAccess/out/accessToInstanceProperty.js new file mode 100644 index 00000000000..8d9b2bc3f7b --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/accessToInstanceProperty.js @@ -0,0 +1,25 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$a = 100; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var test = new foo.Test; + test.set_a(1); + return 1 == test.get_a(); + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/classUsesNamespaceProperties.js b/k2js/translator/testFiles/propertyAccess/out/classUsesNamespaceProperties.js new file mode 100644 index 00000000000..c3da7fdc841 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/classUsesNamespaceProperties.js @@ -0,0 +1,29 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + { + foo.set_a(foo.get_a() + 1); + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $a = 0; +} +, get_a:function(){ + return $a; +} +, set_a:function(tmp$0){ + $a = tmp$0; +} +, box:function(){ + { + var c = new foo.A; + c = new foo.A; + c = new foo.A; + return foo.get_a() == 3; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/customGetter.js b/k2js/translator/testFiles/propertyAccess/out/customGetter.js new file mode 100644 index 00000000000..f263f55a827 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/customGetter.js @@ -0,0 +1,22 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , get_a:function(){ + { + return 5; + } + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var test = new foo.Test; + return test.get_a() == 5; + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/customSetter.js b/k2js/translator/testFiles/propertyAccess/out/customSetter.js new file mode 100644 index 00000000000..e5a5269326c --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/customSetter.js @@ -0,0 +1,27 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$a = 5; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(b){ + { + this.$a = 3; + } + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var test = new foo.Test; + test.set_a(5); + return test.get_a() == 3; + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/extensionLiteralSafeCall.js b/k2js/translator/testFiles/propertyAccess/out/extensionLiteralSafeCall.js new file mode 100644 index 00000000000..e3ecd4951ad --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/extensionLiteralSafeCall.js @@ -0,0 +1,34 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, f:function(a, b){ + var tmp$0; + { + return tmp$0 = a , tmp$0 != null?b.call(tmp$0, 2):null; + } +} +, box:function(){ + { + var c1 = foo.f(null, function(it){ + { + return it + this; + } + } + ) != null; + if (c1) + return false; + if (foo.f(3, function(it){ + { + return it + this; + } + } + ) != 5) + return false; + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/namespaceCustomAccessors.js b/k2js/translator/testFiles/propertyAccess/out/namespaceCustomAccessors.js new file mode 100644 index 00000000000..525a9937690 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/namespaceCustomAccessors.js @@ -0,0 +1,22 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, get_a:function(){ + { + return 5; + } +} +, set_a:function(b){ + { + } +} +, box:function(){ + { + return foo.get_a() == 5; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/namespacePropertyInitializer.js b/k2js/translator/testFiles/propertyAccess/out/namespacePropertyInitializer.js new file mode 100644 index 00000000000..5757786ea89 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/namespacePropertyInitializer.js @@ -0,0 +1,17 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $b = 3; +} +, get_b:function(){ + return $b; +} +, box:function(){ + { + return foo.get_b() == 3; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/namespacePropertySet.js b/k2js/translator/testFiles/propertyAccess/out/namespacePropertySet.js new file mode 100644 index 00000000000..40a57762c52 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/namespacePropertySet.js @@ -0,0 +1,21 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $b = 3; +} +, get_b:function(){ + return $b; +} +, set_b:function(tmp$0){ + $b = tmp$0; +} +, box:function(){ + { + foo.set_b(2); + return foo.get_b() == 2; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/safeAccess.js b/k2js/translator/testFiles/propertyAccess/out/safeAccess.js new file mode 100644 index 00000000000..43d695ee0a9 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/safeAccess.js @@ -0,0 +1,38 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$c = 3; + } + , get_c:function(){ + return this.$c; + } + , set_c:function(tmp$0){ + this.$c = tmp$0; + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$5; + var tmp$4; + var tmp$3; + var tmp$2; + var tmp$1; + var tmp$0; + var a1 = new foo.A; + var a2 = null; + tmp$0 = a1 , tmp$0 != null?tmp$0.set_c(4):null; + tmp$1 = a2 , tmp$1 != null?tmp$1.set_c(5):null; + if ((tmp$2 = a1 , tmp$2 != null?tmp$2.get_c():null) != 4) { + return false; + } + a2 = a1; + tmp$3 = a2 , tmp$3 != null?tmp$3.set_c(5):null; + return (tmp$4 = a2 , tmp$4 != null?tmp$4.get_c():null) == 5 && (tmp$5 = a1 , tmp$5 != null?tmp$5.get_c():null) == 5; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/safeCall.js b/k2js/translator/testFiles/propertyAccess/out/safeCall.js new file mode 100644 index 00000000000..da735328d70 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/safeCall.js @@ -0,0 +1,23 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , doSomething:function(){ + { + } + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var a = null; + tmp$0 = a , tmp$0 != null?tmp$0.doSomething():null; + return true; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/safeCallReturnsNullIfFails.js b/k2js/translator/testFiles/propertyAccess/out/safeCallReturnsNullIfFails.js new file mode 100644 index 00000000000..648f74bec77 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/safeCallReturnsNullIfFails.js @@ -0,0 +1,22 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$x = 4; + } + , get_x:function(){ + return this.$x; + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var a = null; + return (tmp$0 = a , tmp$0 != null?tmp$0.get_x():null) == null; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/safeExtensionFunctionCall.js b/k2js/translator/testFiles/propertyAccess/out/safeExtensionFunctionCall.js new file mode 100644 index 00000000000..569d3798417 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/safeExtensionFunctionCall.js @@ -0,0 +1,59 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$c = 3; + } + , get_c:function(){ + return this.$c; + } + , set_c:function(tmp$0){ + this.$c = tmp$0; + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, i:function(receiver){ + { + receiver.set_c(receiver.get_c() + 1); + return receiver.get_c(); + } +} +, box:function(){ + { + var tmp$7; + var tmp$6; + var tmp$5; + var tmp$4; + var tmp$3; + var tmp$2; + var tmp$1; + var tmp$0; + var a1 = new foo.A; + var a2 = null; + if ((tmp$0 = a1 , tmp$0 != null?foo.i(tmp$0):null) != 4) { + return '1'; + } + if ((tmp$1 = a1 , tmp$1 != null?tmp$1.get_c():null) != 4) { + return '2'; + } + if ((tmp$2 = a2 , tmp$2 != null?tmp$2.get_c():null) != null) { + return '3'; + } + tmp$3 = a2 , tmp$3 != null?foo.i(tmp$3):null; + if ((tmp$4 = a1 , tmp$4 != null?tmp$4.get_c():null) != 4) { + return '4'; + } + a2 = a1; + if ((tmp$5 = a2 , tmp$5 != null?foo.i(tmp$5):null) != 5) { + return '5'; + } + if ((tmp$6 = a2 , tmp$6 != null?foo.i(tmp$6):null) != 6 || (tmp$7 = a1 , tmp$7 != null?tmp$7.get_c():null) != 6) { + return '6'; + } + return 'OK'; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/setter.js b/k2js/translator/testFiles/propertyAccess/out/setter.js new file mode 100644 index 00000000000..0cb88d5af83 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/setter.js @@ -0,0 +1,26 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$a = 1; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, f:function(){ + { + var a = new foo.Test; + var b = new foo.Test; + b.set_a(100); + return b.get_a() - a.get_a(); + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/propertyAccess/out/twoClassesWithProperties.js b/k2js/translator/testFiles/propertyAccess/out/twoClassesWithProperties.js new file mode 100644 index 00000000000..68855d8b249 --- /dev/null +++ b/k2js/translator/testFiles/propertyAccess/out/twoClassesWithProperties.js @@ -0,0 +1,27 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$b = 2; + } + , get_b:function(){ + return this.$b; + } + }); + var tmp$1 = Kotlin.Class.create({initialize:function(){ + this.$a = 1; + } + , get_a:function(){ + return this.$a; + } + }); + return {A:tmp$1, B:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A).get_a() == 1 && (new foo.B).get_b() == 2; + } +} +}, {A:classes.A, B:classes.B}); +foo.initialize(); diff --git a/k2js/translator/testFiles/range/out/explicitRange.js b/k2js/translator/testFiles/range/out/explicitRange.js new file mode 100644 index 00000000000..f8b1ce2d2f3 --- /dev/null +++ b/k2js/translator/testFiles/range/out/explicitRange.js @@ -0,0 +1,64 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$1; + var tmp$0; + var oneToFive = new Kotlin.NumberRange(1, 4); + if (oneToFive.contains(5)) + return false; + if (oneToFive.contains(0)) + return false; + if (oneToFive.contains(-100)) + return false; + if (oneToFive.contains(10)) + return false; + if (!oneToFive.contains(1)) + return false; + if (!oneToFive.contains(2)) + return false; + if (!oneToFive.contains(3)) + return false; + if (!oneToFive.contains(4)) + return false; + if (!(oneToFive.get_start() == 1)) + return false; + if (!(oneToFive.get_size() == 4)) + return false; + if (!(oneToFive.get_end() == 4)) + return false; + var sum = 0; + { + tmp$0 = oneToFive.iterator(); + while (tmp$0.hasNext()) { + var i = tmp$0.next(); + { + sum += i; + } + } + } + { + tmp$1 = oneToFive.iterator(); + while (tmp$1.hasNext()) { + var i$0 = tmp$1.next(); + { + Kotlin.print(i$0); + } + } + } + if (sum != 10) + return false; + return true; + } +} +, main:function(){ + { + foo.box(); + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/range/out/intInRange.js b/k2js/translator/testFiles/range/out/intInRange.js new file mode 100644 index 00000000000..cd95b4c3ae4 --- /dev/null +++ b/k2js/translator/testFiles/range/out/intInRange.js @@ -0,0 +1,28 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + if ((new Kotlin.NumberRange(-2, 0 - -2 + 1, false)).contains(1)) + return false; + if ((new Kotlin.NumberRange(-10, -4 - -10 + 1, false)).contains(1)) + return false; + if (!(new Kotlin.NumberRange(0, 2 - 0 + 1, false)).contains(1)) + return false; + if (!(new Kotlin.NumberRange(1, 2 - 1 + 1, false)).contains(1)) + return false; + if (!(new Kotlin.NumberRange(-2, 5 - -2 + 1, false)).contains(1)) + return false; + return true; + } +} +, main:function(){ + { + foo.box(); + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/range/out/rangeSugarSyntax.js b/k2js/translator/testFiles/range/out/rangeSugarSyntax.js new file mode 100644 index 00000000000..82a33ddf974 --- /dev/null +++ b/k2js/translator/testFiles/range/out/rangeSugarSyntax.js @@ -0,0 +1,64 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$1; + var tmp$0; + var oneToFive = new Kotlin.NumberRange(1, 5 - 1 + 1, false); + if (!oneToFive.contains(5)) + return false; + if (oneToFive.contains(0)) + return false; + if (oneToFive.contains(-100)) + return false; + if (oneToFive.contains(10)) + return false; + if (!oneToFive.contains(1)) + return false; + if (!oneToFive.contains(2)) + return false; + if (!oneToFive.contains(3)) + return false; + if (!oneToFive.contains(4)) + return false; + if (!(oneToFive.get_start() == 1)) + return false; + if (!(oneToFive.get_size() == 5)) + return false; + if (!(oneToFive.get_end() == 5)) + return false; + var sum = 0; + { + tmp$0 = oneToFive.iterator(); + while (tmp$0.hasNext()) { + var i = tmp$0.next(); + { + sum += i; + } + } + } + { + tmp$1 = oneToFive.iterator(); + while (tmp$1.hasNext()) { + var i$0 = tmp$1.next(); + { + Kotlin.print(i$0); + } + } + } + if (sum != 15) + return false; + return true; + } +} +, main:function(){ + { + foo.box(); + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/rtti/out/isSameClass.js b/k2js/translator/testFiles/rtti/out/isSameClass.js new file mode 100644 index 00000000000..49e783c2e09 --- /dev/null +++ b/k2js/translator/testFiles/rtti/out/isSameClass.js @@ -0,0 +1,16 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return Kotlin.isType(new foo.A, foo.A); + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/rtti/out/notIsOtherClass.js b/k2js/translator/testFiles/rtti/out/notIsOtherClass.js new file mode 100644 index 00000000000..efef11b862a --- /dev/null +++ b/k2js/translator/testFiles/rtti/out/notIsOtherClass.js @@ -0,0 +1,20 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.super_init(); + } + }); + return {B:tmp$1, A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return !Kotlin.isType(new foo.A, foo.B); + } +} +}, {A:classes.A, B:classes.B}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/assign.js b/k2js/translator/testFiles/simple/out/assign.js new file mode 100644 index 00000000000..416787d1404 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/assign.js @@ -0,0 +1,20 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, f:function(){ + { + var x = 1; + x = x + 1; + return x; + } +} +, box:function(){ + { + return foo.f() == 2; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/breakDoWhile.js b/k2js/translator/testFiles/simple/out/breakDoWhile.js new file mode 100644 index 00000000000..56b982aaab4 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/breakDoWhile.js @@ -0,0 +1,21 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var i = 0; + do { + if (i == 3) { + break; + } + ++i; + } + while (i < 100); + return i == 3; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/breakWhile.js b/k2js/translator/testFiles/simple/out/breakWhile.js new file mode 100644 index 00000000000..213bc236cf6 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/breakWhile.js @@ -0,0 +1,20 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var i = 0; + while (i < 100) { + if (i == 3) { + break; + } + ++i; + } + return i == 3; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/classInstantiation.js b/k2js/translator/testFiles/simple/out/classInstantiation.js new file mode 100644 index 00000000000..f9ebcc419bb --- /dev/null +++ b/k2js/translator/testFiles/simple/out/classInstantiation.js @@ -0,0 +1,17 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var test = new foo.Test; + return true; + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/classWithoutNamespace.js b/k2js/translator/testFiles/simple/out/classWithoutNamespace.js new file mode 100644 index 00000000000..242b1592988 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/classWithoutNamespace.js @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var A = Kotlin.Class.create({initialize:function(a){ + this.$a = a; + { + this.$a = 3; + } + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {A_0:A}; + } + (); + var Anonymous = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + return (new Anonymous.A_0(1)).get_a() == 3; + } + } + }, classes); + Anonymous.initialize(); +} diff --git a/k2js/translator/testFiles/simple/out/comparison.js b/k2js/translator/testFiles/simple/out/comparison.js new file mode 100644 index 00000000000..fd337227ea2 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/comparison.js @@ -0,0 +1,16 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = 2; + var b = 3; + var c = 4; + return a < c; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/complexExpressionAsConstructorParameter.js b/k2js/translator/testFiles/simple/out/complexExpressionAsConstructorParameter.js new file mode 100644 index 00000000000..909a229c79a --- /dev/null +++ b/k2js/translator/testFiles/simple/out/complexExpressionAsConstructorParameter.js @@ -0,0 +1,25 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(a, b){ + this.$c = a; + this.$d = b; + } + , get_c:function(){ + return this.$c; + } + , get_d:function(){ + return this.$d; + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var test = new foo.Test(1 + 6 * 3, 10 % 2); + return test.get_c() == 19 && test.get_d() == 0; + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/constructorWithParameter.js b/k2js/translator/testFiles/simple/out/constructorWithParameter.js new file mode 100644 index 00000000000..d0c99147507 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/constructorWithParameter.js @@ -0,0 +1,21 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(a){ + this.$b = a; + } + , get_b:function(){ + return this.$b; + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var test = new foo.Test(1); + return test.get_b() == 1; + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/constructorWithPropertiesAsParameters.js b/k2js/translator/testFiles/simple/out/constructorWithPropertiesAsParameters.js new file mode 100644 index 00000000000..e51d0aca80a --- /dev/null +++ b/k2js/translator/testFiles/simple/out/constructorWithPropertiesAsParameters.js @@ -0,0 +1,33 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(b, a){ + this.$b = b; + this.$a = a; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new foo.A(1, '1'); + c.set_b(2); + c.set_a('2'); + return c.get_b() == 2 && c.get_a() == '2'; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/continueDoWhile.js b/k2js/translator/testFiles/simple/out/continueDoWhile.js new file mode 100644 index 00000000000..abdae966bc8 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/continueDoWhile.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var i = 0; + var b = true; + do { + ++i; + if (i >= 1) { + continue; + } + b = false; + } + while (i < 100); + return b; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/continueWhile.js b/k2js/translator/testFiles/simple/out/continueWhile.js new file mode 100644 index 00000000000..ca15d004494 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/continueWhile.js @@ -0,0 +1,22 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var i = 0; + var b = true; + while (i < 100) { + ++i; + if (i >= 1) { + continue; + } + b = false; + } + return b; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/doWhile.js b/k2js/translator/testFiles/simple/out/doWhile.js new file mode 100644 index 00000000000..da5e41fac0a --- /dev/null +++ b/k2js/translator/testFiles/simple/out/doWhile.js @@ -0,0 +1,24 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = 50; + var b = 0; + var c = 0; + do { + b = b + 1; + c = c + 2; + } + while (b < a); + if (c == 100) { + return true; + } + return false; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/doWhile2.js b/k2js/translator/testFiles/simple/out/doWhile2.js new file mode 100644 index 00000000000..578bae85dc5 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/doWhile2.js @@ -0,0 +1,21 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var x = 2; + do { + x = 1; + } + while (3 < 2); + if (x == 1) { + return true; + } + return false; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/elseif.js b/k2js/translator/testFiles/simple/out/elseif.js new file mode 100644 index 00000000000..73f3b1767b8 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/elseif.js @@ -0,0 +1,32 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, bor:function(){ + { + var a = 2; + var b = 3; + var c = 4; + if (a < 2) { + return a; + } + else if (a > 2) { + return b; + } + else if (a == c) { + return c; + } + else { + return 5; + } + } +} +, box:function(){ + { + return foo.bor() == 5; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/if.js b/k2js/translator/testFiles/simple/out/if.js new file mode 100644 index 00000000000..b8dff315748 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/if.js @@ -0,0 +1,32 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, bol:function(){ + { + var a = 2; + var b = 3; + var c = 4; + if (a < 2) { + return a; + } + if (a > 2) { + return b; + } + if (a == c) { + return c; + } + else { + return 5; + } + } +} +, box:function(){ + { + return foo.bol() == 5; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/ifElseAsExpression.js b/k2js/translator/testFiles/simple/out/ifElseAsExpression.js new file mode 100644 index 00000000000..63d360dbe96 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/ifElseAsExpression.js @@ -0,0 +1,19 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var tmp$0; + var a = 2; + if (a == 2) + tmp$0 = true; + else + tmp$0 = false; + return tmp$0; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/incrementProperty.js b/k2js/translator/testFiles/simple/out/incrementProperty.js new file mode 100644 index 00000000000..4d85dc808ed --- /dev/null +++ b/k2js/translator/testFiles/simple/out/incrementProperty.js @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var Slot = Kotlin.Class.create({initialize:function(){ + this.$vitality = 10000; + } + , get_vitality:function(){ + return this.$vitality; + } + , set_vitality:function(tmp$0){ + this.$vitality = tmp$0; + } + , increaseVitality:function(delta){ + { + this.set_vitality(this.get_vitality() + delta); + if (this.get_vitality() > 65535) + this.set_vitality(65535); + } + } + }); + return {Slot_0:Slot}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , box:function(){ + { + var s = new foo.Slot_0; + s.increaseVitality(1000); + if (s.get_vitality() == 11000) + return 'OK'; + else + return 'fail'; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/simple/out/methodDeclarationAndCall.js b/k2js/translator/testFiles/simple/out/methodDeclarationAndCall.js new file mode 100644 index 00000000000..353a88b0c12 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/methodDeclarationAndCall.js @@ -0,0 +1,22 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + , method:function(){ + { + return true; + } + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var test = new foo.Test; + return test.method(); + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/minusAssignOnProperty.js b/k2js/translator/testFiles/simple/out/minusAssignOnProperty.js new file mode 100644 index 00000000000..97e3dffbce7 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/minusAssignOnProperty.js @@ -0,0 +1,21 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $a = 3; +} +, get_a:function(){ + return $a; +} +, set_a:function(tmp$0){ + $a = tmp$0; +} +, box:function(){ + { + foo.set_a(foo.get_a() - 10); + return foo.get_a() == -7; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/notBoolean.js b/k2js/translator/testFiles/simple/out/notBoolean.js new file mode 100644 index 00000000000..a934a99a47c --- /dev/null +++ b/k2js/translator/testFiles/simple/out/notBoolean.js @@ -0,0 +1,13 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return !false; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/plusAssign.js b/k2js/translator/testFiles/simple/out/plusAssign.js new file mode 100644 index 00000000000..83578625982 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/plusAssign.js @@ -0,0 +1,15 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = 3; + a += 3; + return a == 6; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/positiveAndNegativeNumbers.js b/k2js/translator/testFiles/simple/out/positiveAndNegativeNumbers.js new file mode 100644 index 00000000000..16bf1868b08 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/positiveAndNegativeNumbers.js @@ -0,0 +1,15 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var b = -3; + var c = +3; + return c - b == 6; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/postfixIntOperations.js b/k2js/translator/testFiles/simple/out/postfixIntOperations.js new file mode 100644 index 00000000000..2f52c957222 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/postfixIntOperations.js @@ -0,0 +1,17 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = 3; + var b = a++; + a--; + a--; + return a++ == 2 && b == 3; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/prefixIntOperations.js b/k2js/translator/testFiles/simple/out/prefixIntOperations.js new file mode 100644 index 00000000000..8f87479021c --- /dev/null +++ b/k2js/translator/testFiles/simple/out/prefixIntOperations.js @@ -0,0 +1,17 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = 3; + var b = ++a; + --a; + --a; + return --a == 1 && b == 4; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/propertiesAsParametersInitialized.js b/k2js/translator/testFiles/simple/out/propertiesAsParametersInitialized.js new file mode 100644 index 00000000000..3f128259e5e --- /dev/null +++ b/k2js/translator/testFiles/simple/out/propertiesAsParametersInitialized.js @@ -0,0 +1,31 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(b, a){ + this.$b = b; + this.$a = a; + } + , get_b:function(){ + return this.$b; + } + , set_b:function(tmp$0){ + this.$b = tmp$0; + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new foo.A(2, '2'); + return c.get_b() == 2 && c.get_a() == '2'; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/propertyAccess.js b/k2js/translator/testFiles/simple/out/propertyAccess.js new file mode 100644 index 00000000000..dc7a1bc3821 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/propertyAccess.js @@ -0,0 +1,20 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + this.$p = true; + } + , get_p:function(){ + return this.$p; + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.Test).get_p(); + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/simpleInitializer.js b/k2js/translator/testFiles/simple/out/simpleInitializer.js new file mode 100644 index 00000000000..2091bb6a518 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/simpleInitializer.js @@ -0,0 +1,25 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + { + this.$a = 3; + } + } + , get_a:function(){ + return this.$a; + } + , set_a:function(tmp$0){ + this.$a = tmp$0; + } + }); + return {Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.Test).get_a() == 3; + } +} +}, {Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/while.js b/k2js/translator/testFiles/simple/out/while.js new file mode 100644 index 00000000000..14cdde6050e --- /dev/null +++ b/k2js/translator/testFiles/simple/out/while.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = 50; + var b = 0; + var c = 0; + while (b < a) { + b = b + 1; + c = c + 2; + } + if (c == 100) { + return true; + } + return false; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/simple/out/while2.js b/k2js/translator/testFiles/simple/out/while2.js new file mode 100644 index 00000000000..7a5a2ec03a5 --- /dev/null +++ b/k2js/translator/testFiles/simple/out/while2.js @@ -0,0 +1,16 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + while (2 < 1) { + return false; + } + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/standardClasses/out/array.js b/k2js/translator/testFiles/standardClasses/out/array.js new file mode 100644 index 00000000000..e68d18c7ed5 --- /dev/null +++ b/k2js/translator/testFiles/standardClasses/out/array.js @@ -0,0 +1,15 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = Kotlin.nullArray(2); + a[1] = 2; + return a[1] == 2; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/standardClasses/out/arrayAccess.js b/k2js/translator/testFiles/standardClasses/out/arrayAccess.js new file mode 100644 index 00000000000..7abaf28ce59 --- /dev/null +++ b/k2js/translator/testFiles/standardClasses/out/arrayAccess.js @@ -0,0 +1,16 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = Kotlin.nullArray(4); + a[1] = 2; + a[2] = 3; + return a[1] == 2 && a[2] == 3; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/standardClasses/out/arrayFunctionConstructor.js b/k2js/translator/testFiles/standardClasses/out/arrayFunctionConstructor.js new file mode 100644 index 00000000000..614d109a2a2 --- /dev/null +++ b/k2js/translator/testFiles/standardClasses/out/arrayFunctionConstructor.js @@ -0,0 +1,26 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $f = function(i){ + { + return i + 1; + } + } + ; + $a = Kotlin.arrayFromFun(3, foo.get_f()); +} +, get_f:function(){ + return $f; +} +, get_a:function(){ + return $a; +} +, box:function(){ + { + return foo.get_a()[0] == 1 && foo.get_a()[2] == 3 && foo.get_a()[1] == 2; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/standardClasses/out/arrayIsFilledWithNulls.js b/k2js/translator/testFiles/standardClasses/out/arrayIsFilledWithNulls.js new file mode 100644 index 00000000000..9610d162169 --- /dev/null +++ b/k2js/translator/testFiles/standardClasses/out/arrayIsFilledWithNulls.js @@ -0,0 +1,17 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $a = Kotlin.nullArray(3); +} +, get_a:function(){ + return $a; +} +, box:function(){ + { + return foo.get_a()[0] == null && foo.get_a()[1] == null && foo.get_a()[2] == null; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/standardClasses/out/arraySize.js b/k2js/translator/testFiles/standardClasses/out/arraySize.js new file mode 100644 index 00000000000..7bc3ad15e1f --- /dev/null +++ b/k2js/translator/testFiles/standardClasses/out/arraySize.js @@ -0,0 +1,24 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + }); + return {A:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $a1 = Kotlin.nullArray(3); + $a2 = Kotlin.nullArray(2); +} +, get_a1:function(){ + return $a1; +} +, get_a2:function(){ + return $a2; +} +, box:function(){ + { + return foo.get_a1().length == 3 && foo.get_a2().length == 2; + } +} +}, {A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/standardClasses/out/arrayThrowsExceptionOnOOBaccess.js b/k2js/translator/testFiles/standardClasses/out/arrayThrowsExceptionOnOOBaccess.js new file mode 100644 index 00000000000..b4163175e13 --- /dev/null +++ b/k2js/translator/testFiles/standardClasses/out/arrayThrowsExceptionOnOOBaccess.js @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var A_0 = Kotlin.Class.create({initialize:function(){ + } + }); + return {A:A_0}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + foo.$a1 = Kotlin.nullArray(3); + foo.$a2 = Kotlin.nullArray(2); + } + , get_a1:function(){ + return foo.$a1; + } + , get_a2:function(){ + return foo.$a2; + } + , box:function(){ + { + return foo.get_a1()[4] == null; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/standardClasses/out/arraysIterator.js b/k2js/translator/testFiles/standardClasses/out/arraysIterator.js new file mode 100644 index 00000000000..888dff625fa --- /dev/null +++ b/k2js/translator/testFiles/standardClasses/out/arraysIterator.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ + $a1 = Kotlin.arrayFromFun(3, function(i){ + { + return i; + } + } + ); +} +, get_a1:function(){ + return $a1; +} +, box:function(){ + { + var i = Kotlin.arrayIterator(foo.get_a1()); + return i.get_hasNext() == true && i.next() == 0 && i.get_hasNext() == true && i.next() == 1 && i.get_hasNext() == true && i.next() == 2 && i.get_hasNext() == false; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/stdlib/out/Filter.js b/k2js/translator/testFiles/stdlib/out/Filter.js new file mode 100644 index 00000000000..ca21a4ddd59 --- /dev/null +++ b/k2js/translator/testFiles/stdlib/out/Filter.js @@ -0,0 +1,112 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + var classes = function(){ + var FilterIterator_0 = Kotlin.Class.create(Kotlin.ArrayIterator, {initialize:function(original, filter_0){ + this.$original = original; + this.$filter = filter_0; + this.$state = 0; + this.$nextElement = null; + } + , get_original:function(){ + return this.$original; + } + , get_filter:function(){ + return this.$filter; + } + , get_state:function(){ + return this.$state; + } + , set_state:function(tmp$0){ + this.$state = tmp$0; + } + , get_nextElement:function(){ + return this.$nextElement; + } + , set_nextElement:function(tmp$0){ + this.$nextElement = tmp$0; + } + , get_hasNext:function(){ + { + var tmp$1; + var tmp$0; + if (this.get_state() == 1) { + return true; + } + tmp$0; + if (this.get_state() == 2) { + return false; + } + tmp$1; + while (this.get_original().get_hasNext()) { + var tmp$2; + var candidate = this.get_original().next(); + if (this.get_filter()(candidate)) { + this.set_nextElement(candidate); + this.set_state(1); + return true; + } + tmp$2; + } + this.set_state(2); + return false; + } + } + , next:function(){ + { + var res = this.get_nextElement(); + this.set_nextElement(null); + this.set_state(0); + return res; + } + } + }); + var NoSuchElementException_0 = Kotlin.Class.create(Kotlin.Exception, {initialize:function(){ + this.super_init(); + } + }); + return {NoSuchElementException:NoSuchElementException_0, FilterIterator:FilterIterator_0}; + } + (); + var foo = Kotlin.Namespace.create({initialize:function(){ + } + , filter:function(receiver, f){ + { + return new foo.FilterIterator(receiver, f); + } + } + , filterTo:function(receiver, container, filter){ + { + var tmp$0; + { + tmp$0 = receiver.iterator(); + while (tmp$0.hasNext()) { + var element = tmp$0.next(); + { + var tmp$1; + if (filter(element)) + tmp$1 = container.add(element); + tmp$1; + } + } + } + return container; + } + } + }, classes); + foo.initialize(); +} diff --git a/k2js/translator/testFiles/trait/out/classDerivesFromClassAndTrait.js b/k2js/translator/testFiles/trait/out/classDerivesFromClassAndTrait.js new file mode 100644 index 00000000000..ffaf47a86f1 --- /dev/null +++ b/k2js/translator/testFiles/trait/out/classDerivesFromClassAndTrait.js @@ -0,0 +1,35 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({addFoo:function(s){ + { + return s + 'FOO'; + } + } + }); + var tmp$1 = Kotlin.Class.create({initialize:function(){ + this.$value = 'BAR'; + } + , get_value:function(){ + return this.$value; + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, tmp$0, {initialize:function(){ + this.super_init(); + } + , eval_0:function(){ + { + return this.addFoo(this.get_value()); + } + } + }); + return {A:tmp$1, B:tmp$2, Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.B).eval_0() == 'BARFOO'; + } +} +}, {A:classes.A, Test:classes.Test, B:classes.B}); +foo.initialize(); diff --git a/k2js/translator/testFiles/trait/out/classDerivesFromTraitAndClass.js b/k2js/translator/testFiles/trait/out/classDerivesFromTraitAndClass.js new file mode 100644 index 00000000000..ffaf47a86f1 --- /dev/null +++ b/k2js/translator/testFiles/trait/out/classDerivesFromTraitAndClass.js @@ -0,0 +1,35 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({addFoo:function(s){ + { + return s + 'FOO'; + } + } + }); + var tmp$1 = Kotlin.Class.create({initialize:function(){ + this.$value = 'BAR'; + } + , get_value:function(){ + return this.$value; + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, tmp$0, {initialize:function(){ + this.super_init(); + } + , eval_0:function(){ + { + return this.addFoo(this.get_value()); + } + } + }); + return {A:tmp$1, B:tmp$2, Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.B).eval_0() == 'BARFOO'; + } +} +}, {A:classes.A, Test:classes.Test, B:classes.B}); +foo.initialize(); diff --git a/k2js/translator/testFiles/trait/out/definitionOrder.js b/k2js/translator/testFiles/trait/out/definitionOrder.js new file mode 100644 index 00000000000..4a4195af228 --- /dev/null +++ b/k2js/translator/testFiles/trait/out/definitionOrder.js @@ -0,0 +1,60 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({bar:function(){ + { + return 'F'; + } + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.$order = ''; + { + this.set_order(this.get_order() + 'A'); + } + } + , get_order:function(){ + return this.$order; + } + , set_order:function(tmp$0){ + this.$order = tmp$0; + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, tmp$0, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'B'); + } + } + }); + var tmp$3 = Kotlin.Class.create(tmp$2, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'D'); + } + } + }); + var tmp$4 = Kotlin.Class.create(tmp$2, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'C'); + } + } + }); + var tmp$5 = Kotlin.Class.create(tmp$1, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'E'); + } + } + }); + return {E:tmp$5, A:tmp$1, B:tmp$2, D:tmp$3, C:tmp$4, F:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.C).get_order() == 'ABC' && (new foo.D).get_order() == 'ABD' && (new foo.E).get_order() == 'AE' && (new foo.C).bar() == 'F' && (new foo.A).bar() == 'F'; + } +} +}, {C:classes.C, D:classes.D, E:classes.E, B:classes.B, A:classes.A, F:classes.F}); +foo.initialize(); diff --git a/k2js/translator/testFiles/trait/out/example.js b/k2js/translator/testFiles/trait/out/example.js new file mode 100644 index 00000000000..702a021cb6b --- /dev/null +++ b/k2js/translator/testFiles/trait/out/example.js @@ -0,0 +1,23 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({get:function(index){ + { + return null; + } + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + } + }); + return {SmartArrayList:tmp$1, AL:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var c = new foo.SmartArrayList; + return null == c.get(0); + } +} +}, {AL:classes.AL, SmartArrayList:classes.SmartArrayList}); +foo.initialize(); diff --git a/k2js/translator/testFiles/trait/out/funDelegation.js b/k2js/translator/testFiles/trait/out/funDelegation.js new file mode 100644 index 00000000000..e9934a9c8cb --- /dev/null +++ b/k2js/translator/testFiles/trait/out/funDelegation.js @@ -0,0 +1,41 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({}); + var tmp$1 = Kotlin.Class.create({initialize:function(){ + } + , n_0:function(n){ + { + return n + 1; + } + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, tmp$0, {initialize:function(){ + this.super_init(); + } + }); + var tmp$3 = Kotlin.Class.create(tmp$1, tmp$0, {initialize:function(){ + this.super_init(); + } + }); + return {Base:tmp$1, Derived2:tmp$2, Derived1:tmp$3, Abstract:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, test:function(s){ + { + return s.n_0(238) == 239; + } +} +, box:function(){ + { + if (!foo.test(new foo.Base)) + return 'Fail #1'; + if (!foo.test(new foo.Derived1)) + return 'Fail #2'; + if (!foo.test(new foo.Derived2)) + return 'Fail #3'; + return 'OK'; + } +} +}, {Base:classes.Base, Abstract:classes.Abstract, Derived1:classes.Derived1, Derived2:classes.Derived2}); +foo.initialize(); diff --git a/k2js/translator/testFiles/trait/out/traitAddsFunctionsToClass.js b/k2js/translator/testFiles/trait/out/traitAddsFunctionsToClass.js new file mode 100644 index 00000000000..e870e397b35 --- /dev/null +++ b/k2js/translator/testFiles/trait/out/traitAddsFunctionsToClass.js @@ -0,0 +1,36 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({addFoo:function(s){ + { + return s + 'FOO'; + } + } + , addBar:function(s){ + { + return s + 'BAR'; + } + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(){ + this.$string = 'TEST'; + } + , get_string:function(){ + return this.$string; + } + , value:function(){ + { + return this.addBar(this.addFoo(this.get_string())); + } + } + }); + return {A:tmp$1, Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A).value() == 'TESTFOOBAR'; + } +} +}, {Test:classes.Test, A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/trait/out/traitCompiles.js b/k2js/translator/testFiles/trait/out/traitCompiles.js new file mode 100644 index 00000000000..47746920a24 --- /dev/null +++ b/k2js/translator/testFiles/trait/out/traitCompiles.js @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +foo = {}; +(function(foo){ + foo.Test = {addFoo:function(s){ + return s + 'FOO'; + } + }; + foo.box = function(){ + return true; + } + ; +} +(foo)); diff --git a/k2js/translator/testFiles/trait/out/traitExtendsTrait.js b/k2js/translator/testFiles/trait/out/traitExtendsTrait.js new file mode 100644 index 00000000000..c496e4c9d35 --- /dev/null +++ b/k2js/translator/testFiles/trait/out/traitExtendsTrait.js @@ -0,0 +1,33 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({addFoo:function(s){ + { + return s + 'FOO'; + } + } + }); + var tmp$1 = Kotlin.Trait.create(tmp$0, {hooray:function(){ + { + return 'hooray'; + } + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, {initialize:function(){ + } + , eval_0:function(){ + { + return this.addFoo(this.hooray()); + } + } + }); + return {ExtendedTest:tmp$1, A:tmp$2, Test:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.A).eval_0() == 'hoorayFOO'; + } +} +}, {Test:classes.Test, ExtendedTest:classes.ExtendedTest, A:classes.A}); +foo.initialize(); diff --git a/k2js/translator/testFiles/trait/out/traitExtendsTwoTraits.js b/k2js/translator/testFiles/trait/out/traitExtendsTwoTraits.js new file mode 100644 index 00000000000..2f89a3707a9 --- /dev/null +++ b/k2js/translator/testFiles/trait/out/traitExtendsTwoTraits.js @@ -0,0 +1,34 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({hooray:function(){ + { + return 'hooray'; + } + } + }); + var tmp$1 = Kotlin.Trait.create({addFoo:function(s){ + { + return s + 'FOO'; + } + } + }); + var tmp$2 = Kotlin.Trait.create(tmp$1, tmp$0, {}); + var tmp$3 = Kotlin.Class.create(tmp$2, {initialize:function(){ + } + , eval_0:function(){ + { + return this.addFoo(this.hooray()); + } + } + }); + return {A:tmp$1, AD:tmp$2, Test:tmp$3, B:tmp$0}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + return (new foo.Test).eval_0() == 'hoorayFOO'; + } +} +}, {A:classes.A, B:classes.B, AD:classes.AD, Test:classes.Test}); +foo.initialize(); diff --git a/k2js/translator/testFiles/tuple/out/multipleMembers.js b/k2js/translator/testFiles/tuple/out/multipleMembers.js new file mode 100644 index 00000000000..529c4a88207 --- /dev/null +++ b/k2js/translator/testFiles/tuple/out/multipleMembers.js @@ -0,0 +1,32 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + if ([1, 2, 3][0] != 1) + return false; + if (['a', 'b'][1] != 'b') + return false; + var x = ['1', 2, '3', 4, '5', 6]; + if (x[0] != '1') + return false; + if (x[1] != 2) + return false; + if (x[1] != 2) + return false; + if (x[5] != 6) + return false; + if (x[4] != '5') + return false; + if (x[2] != '3') + return false; + if ([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1][20] != 1) + return false; + return true; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/tuple/out/twoElements.js b/k2js/translator/testFiles/tuple/out/twoElements.js new file mode 100644 index 00000000000..1b26229d993 --- /dev/null +++ b/k2js/translator/testFiles/tuple/out/twoElements.js @@ -0,0 +1,14 @@ +var classes = function(){ + return {}; +} +(); +var foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + { + var a = [1, 2]; + return a[0] == 1 && a[1] == 2; + } +} +}, {}); +foo.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples1/out/forLoop.js b/k2js/translator/testFiles/webDemoExamples1/out/forLoop.js new file mode 100644 index 00000000000..39a2a383097 --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples1/out/forLoop.js @@ -0,0 +1,33 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + var tmp$1; + var tmp$0; + { + tmp$0 = Kotlin.arrayIterator(args); + while (tmp$0.hasNext()) { + var arg = tmp$0.next(); + { + Kotlin.println(arg); + } + } + } + Kotlin.println(); + { + tmp$1 = Kotlin.arrayIndices(args).iterator(); + while (tmp$1.hasNext()) { + var i = tmp$1.next(); + { + Kotlin.println(args[i]); + } + } + } + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples1/out/ifAsExpression.js b/k2js/translator/testFiles/webDemoExamples1/out/ifAsExpression.js new file mode 100644 index 00000000000..49eb815c788 --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples1/out/ifAsExpression.js @@ -0,0 +1,23 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + Kotlin.println(Anonymous.max(Kotlin.parseInt(args[0]), Kotlin.parseInt(args[1]))); + } +} +, max:function(a, b){ + var tmp$0; + if (a > b) + tmp$0 = a; + else + tmp$0 = b; + { + return tmp$0; + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples1/out/isCheck.js b/k2js/translator/testFiles/webDemoExamples1/out/isCheck.js new file mode 100644 index 00000000000..44a9c6bbb3e --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples1/out/isCheck.js @@ -0,0 +1,21 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + Kotlin.println(Anonymous.getStringLength('aaa')); + Kotlin.println(Anonymous.getStringLength(1)); + } +} +, getStringLength:function(obj){ + { + if (typeof obj == 'string') + return obj.length; + return null; + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples1/out/multiLanguageHello.js b/k2js/translator/testFiles/webDemoExamples1/out/multiLanguageHello.js new file mode 100644 index 00000000000..e25cab11cc3 --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples1/out/multiLanguageHello.js @@ -0,0 +1,40 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + var tmp$2; + var tmp$1; + var tmp$0; + if (args.length == 0) + tmp$0 = 'EN'; + else + tmp$0 = args[0]; + var language = tmp$0; + for (tmp$1 = 0; tmp$1 < 4; ++tmp$1) { + if (tmp$1 == 0) + if (language == 'EN') { + tmp$2 = 'Hello!'; + break; + } + if (tmp$1 == 1) + if (language == 'FR') { + tmp$2 = 'Salut!'; + break; + } + if (tmp$1 == 2) + if (language == 'IT') { + tmp$2 = 'Ciao!'; + break; + } + if (tmp$1 == 3) + tmp$2 = "Sorry, I can't greet you in " + language + ' yet'; + } + Kotlin.println(tmp$2); + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples1/out/nullChecks.js b/k2js/translator/testFiles/webDemoExamples1/out/nullChecks.js new file mode 100644 index 00000000000..744e68cf888 --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples1/out/nullChecks.js @@ -0,0 +1,33 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, myParseInt:function(str){ + { + try { + return Kotlin.parseInt(str); + } + catch (e) { + Kotlin.println("One of argument isn't Int"); + } + return null; + } +} +, main:function(args){ + { + if (args.length < 2) { + Kotlin.print('No number supplied'); + } + else { + var x = Anonymous.myParseInt(args[0]); + var y = Anonymous.myParseInt(args[1]); + if (x != null && y != null) { + Kotlin.print(x * y); + } + } + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples1/out/objectOrientedHello.js b/k2js/translator/testFiles/webDemoExamples1/out/objectOrientedHello.js new file mode 100644 index 00000000000..a2c79e7134a --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples1/out/objectOrientedHello.js @@ -0,0 +1,25 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(name_0){ + this.$name = name_0; + } + , get_name:function(){ + return this.$name; + } + , greet:function(){ + { + Kotlin.println('Hello, ' + this.get_name() + '!'); + } + } + }); + return {Greeter:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + (new Anonymous.Greeter(args[0])).greet(); + } +} +}, {Greeter:classes.Greeter}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples1/out/patternMatching.js b/k2js/translator/testFiles/webDemoExamples1/out/patternMatching.js new file mode 100644 index 00000000000..804b0e427c1 --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples1/out/patternMatching.js @@ -0,0 +1,45 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(){ + } + }); + return {MyClass:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + Anonymous.cases('Hello'); + Anonymous.cases(1); + Anonymous.cases(new Anonymous.MyClass); + Anonymous.cases('hello'); + } +} +, cases:function(obj){ + { + var tmp$1; + var tmp$0; + for (tmp$0 = 0; tmp$0 < 4; ++tmp$0) { + if (tmp$0 == 0) + if (obj == 1) { + tmp$1 = Kotlin.println('One'); + break; + } + if (tmp$0 == 1) + if (obj == 'Hello') { + tmp$1 = Kotlin.println('Greeting'); + break; + } + if (tmp$0 == 2) + if (!(typeof obj == 'string')) { + tmp$1 = Kotlin.println('Not a string'); + break; + } + if (tmp$0 == 3) + tmp$1 = Kotlin.println('Unknown'); + } + tmp$1; + } +} +}, {MyClass:classes.MyClass}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples1/out/printArg.js b/k2js/translator/testFiles/webDemoExamples1/out/printArg.js new file mode 100644 index 00000000000..1d4bb0c45ef --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples1/out/printArg.js @@ -0,0 +1,13 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + Kotlin.print(args[0]); + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples1/out/ranges.js b/k2js/translator/testFiles/webDemoExamples1/out/ranges.js new file mode 100644 index 00000000000..63df3d145d7 --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples1/out/ranges.js @@ -0,0 +1,39 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + var tmp$0; + var x = Kotlin.parseInt(args[0]); + var y = 10; + if ((new Kotlin.NumberRange(1, y - 1 - 1 + 1, false)).contains(x)) + Kotlin.println('OK'); + { + tmp$0 = (new Kotlin.NumberRange(1, 5 - 1 + 1, false)).iterator(); + while (tmp$0.hasNext()) { + var a = tmp$0.next(); + { + Kotlin.print(' ' + a); + } + } + } + Kotlin.println(); + var array = new Kotlin.ArrayList; + array.add('aaa'); + array.add('bbb'); + array.add('ccc'); + if (!(new Kotlin.NumberRange(0, array.size() - 0 + 1, false)).contains(x)) + Kotlin.println('Out: array has only ' + array.size() + ' elements. x = ' + x); + if (array.contains('aaa')) + Kotlin.println('Yes: array contains aaa'); + if (array.contains('ddd')) + Kotlin.println('Yes: array contains ddd'); + else + Kotlin.println("No: array doesn't contains ddd"); + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples1/out/whileLoop.js b/k2js/translator/testFiles/webDemoExamples1/out/whileLoop.js new file mode 100644 index 00000000000..8b6b3a7f076 --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples1/out/whileLoop.js @@ -0,0 +1,15 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + var i = 0; + while (i < args.length) + Kotlin.println(args[i++]); + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples2/out/bottles.js b/k2js/translator/testFiles/webDemoExamples2/out/bottles.js new file mode 100644 index 00000000000..b64617b2e03 --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples2/out/bottles.js @@ -0,0 +1,67 @@ +var classes = function(){ + return {}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + if (Anonymous.isEmpty(args)) { + Anonymous.printBottles(99); + } + else { + var bottles = Kotlin.parseInt(args[0]); + if (bottles != null) { + Anonymous.printBottles(bottles); + } + else { + Kotlin.println("You have passed '" + args[0] + "' as a number of bottles, " + 'but it is not a valid integral number'); + } + } + } +} +, printBottles:function(bottleCount){ + { + if (bottleCount <= 0) { + Kotlin.println('No bottles - no song'); + return; + } + Kotlin.println('The ' + '"' + Anonymous.bottlesOfBeer_0(bottleCount) + '"' + ' song' + '\n'); + var bottles = bottleCount; + while (bottles > 0) { + var bottlesOfBeer = Anonymous.bottlesOfBeer_0(bottles); + Kotlin.print(bottlesOfBeer + ' on the wall, ' + bottlesOfBeer + '.' + '\n' + 'Take one down, pass it around, '); + bottles--; + Kotlin.println(Anonymous.bottlesOfBeer_0(bottles) + ' on the wall.' + '\n'); + } + Kotlin.println('No more bottles of beer on the wall, no more bottles of beer.\n' + ('Go to the store and buy some more, ' + Anonymous.bottlesOfBeer_0(bottleCount) + ' on the wall.')); + } +} +, bottlesOfBeer_0:function(count){ + var tmp$1; + var tmp$0; + for (tmp$0 = 0; tmp$0 < 3; ++tmp$0) { + if (tmp$0 == 0) + if (count == 0) { + tmp$1 = 'no more bottles'; + break; + } + if (tmp$0 == 1) + if (count == 1) { + tmp$1 = '1 bottle'; + break; + } + if (tmp$0 == 2) + tmp$1 = count + ' bottles'; + } + { + return tmp$1 + ' of beer'; + } +} +, isEmpty:function(receiver){ + { + return receiver.length == 0; + } +} +}, {}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples2/out/builder.js b/k2js/translator/testFiles/webDemoExamples2/out/builder.js new file mode 100644 index 00000000000..8ff565ef968 --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples2/out/builder.js @@ -0,0 +1,301 @@ +var classes = function(){ + var tmp$0 = Kotlin.Trait.create({render:function(builder, indent){ + } + , toString:function(){ + { + var builder = new Kotlin.StringBuilder; + this.render(builder, ''); + return builder.toString(); + } + } + }); + var tmp$1 = Kotlin.Class.create(tmp$0, {initialize:function(name_0){ + this.$name = name_0; + this.$children = new Kotlin.ArrayList; + this.$attributes = new Kotlin.HashMap; + } + , get_name:function(){ + return this.$name; + } + , get_children:function(){ + return this.$children; + } + , get_attributes:function(){ + return this.$attributes; + } + , initTag:function(tag, init){ + { + init.call(tag); + this.get_children().add(tag); + return tag; + } + } + , render:function(builder, indent){ + { + var tmp$0; + builder.append(indent + '<' + this.get_name() + this.renderAttributes() + '>' + '\n'); + { + tmp$0 = this.get_children().iterator(); + while (tmp$0.hasNext()) { + var c = tmp$0.next(); + { + c.render(builder, indent + ' '); + } + } + } + builder.append(indent + '<\/' + this.get_name() + '>' + '\n'); + } + } + , renderAttributes:function(){ + { + var tmp$0; + var builder = new Kotlin.StringBuilder; + { + tmp$0 = this.get_attributes().keySet().iterator(); + while (tmp$0.hasNext()) { + var a = tmp$0.next(); + { + builder.append(' ' + a + '=' + '"' + this.get_attributes().get(a) + '"'); + } + } + } + return builder.toString(); + } + } + }); + var tmp$2 = Kotlin.Class.create(tmp$1, {initialize:function(name_0){ + this.super_init(name_0); + } + , plus:function(receiver){ + { + this.get_children().add(new Anonymous.TextElement(receiver)); + } + } + }); + var tmp$3 = Kotlin.Class.create(tmp$2, {initialize:function(name_0){ + this.super_init(name_0); + } + , b:function(init){ + { + return this.initTag(new Anonymous.B, init); + } + } + , p:function(init){ + { + return this.initTag(new Anonymous.P, init); + } + } + , h1:function(init){ + { + return this.initTag(new Anonymous.H1, init); + } + } + , ul:function(init){ + { + return this.initTag(new Anonymous.UL, init); + } + } + , a_0:function(href, init){ + { + var a = this.initTag(new Anonymous.A, init); + a.set_href(href); + } + } + }); + var tmp$4 = Kotlin.Class.create(tmp$3, {initialize:function(){ + this.super_init('a'); + } + , get_href:function(){ + { + return this.get_attributes().get('href'); + } + } + , set_href:function(value){ + { + Anonymous.set(this.get_attributes(), 'href', value); + } + } + }); + var tmp$5 = Kotlin.Class.create(tmp$3, {initialize:function(){ + this.super_init('h1'); + } + }); + var tmp$6 = Kotlin.Class.create(tmp$3, {initialize:function(){ + this.super_init('p'); + } + }); + var tmp$7 = Kotlin.Class.create(tmp$3, {initialize:function(){ + this.super_init('li'); + } + }); + var tmp$8 = Kotlin.Class.create(tmp$3, {initialize:function(){ + this.super_init('b'); + } + }); + var tmp$9 = Kotlin.Class.create(tmp$3, {initialize:function(){ + this.super_init('ul'); + } + , li:function(init){ + { + return this.initTag(new Anonymous.LI, init); + } + } + }); + var tmp$10 = Kotlin.Class.create(tmp$3, {initialize:function(){ + this.super_init('body'); + } + }); + var tmp$11 = Kotlin.Class.create(tmp$2, {initialize:function(){ + this.super_init('title'); + } + }); + var tmp$12 = Kotlin.Class.create(tmp$2, {initialize:function(){ + this.super_init('head'); + } + , title:function(init){ + { + return this.initTag(new Anonymous.Title, init); + } + } + }); + var tmp$13 = Kotlin.Class.create(tmp$2, {initialize:function(){ + this.super_init('html'); + } + , head:function(init){ + { + return this.initTag(new Anonymous.Head, init); + } + } + , body:function(init){ + { + return this.initTag(new Anonymous.Body, init); + } + } + }); + var tmp$14 = Kotlin.Class.create(tmp$0, {initialize:function(text){ + this.$text = text; + } + , get_text:function(){ + return this.$text; + } + , render:function(builder, indent){ + { + builder.append(indent + this.get_text() + '\n'); + } + } + }); + return {Title:tmp$11, Body:tmp$10, HTML:tmp$13, Head:tmp$12, TextElement:tmp$14, UL:tmp$9, H1:tmp$5, P:tmp$6, LI:tmp$7, B:tmp$8, Tag:tmp$1, TagWithText:tmp$2, BodyTag:tmp$3, A:tmp$4, Element_0:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, main:function(args){ + { + var result = Anonymous.html_0(function(){ + { + this.head(function(){ + { + this.title(function(){ + { + this.plus('XML encoding with Kotlin'); + } + } + ); + } + } + ); + this.body(function(){ + { + this.h1(function(){ + { + this.plus('XML encoding with Kotlin'); + } + } + ); + this.p(function(){ + { + this.plus('this format can be used as an alternative markup to XML'); + } + } + ); + this.a_0('http://jetbrains.com/kotlin', function(){ + { + this.plus('Kotlin'); + } + } + ); + this.p(function(){ + { + this.plus('This is some'); + this.b(function(){ + { + this.plus('mixed'); + } + } + ); + this.plus('text. For more see the'); + this.a_0('http://jetbrains.com/kotlin', function(){ + { + this.plus('Kotlin'); + } + } + ); + this.plus('project'); + } + } + ); + this.p(function(){ + { + this.plus('some text'); + } + } + ); + this.p(function(){ + { + this.plus('Command line arguments were:'); + this.ul(function(){ + { + var tmp$0; + { + tmp$0 = Kotlin.arrayIterator(args); + while (tmp$0.hasNext()) { + var arg = tmp$0.next(); + { + this.li(function(){ + { + this.plus(arg); + } + } + ); + } + } + } + } + } + ); + } + } + ); + } + } + ); + } + } + ); + Kotlin.println(result); + } +} +, html_0:function(init){ + { + var html = new Anonymous.HTML; + init.call(html); + return html; + } +} +, set:function(receiver, key, value){ + { + return receiver.put(key, value); + } +} +}, {Element_0:classes.Element_0, TextElement:classes.TextElement, Tag:classes.Tag, TagWithText:classes.TagWithText, HTML:classes.HTML, Head:classes.Head, Title:classes.Title, BodyTag:classes.BodyTag, Body:classes.Body, UL:classes.UL, B:classes.B, LI:classes.LI, P:classes.P, H1:classes.H1, A:classes.A}); +Anonymous.initialize(); diff --git a/k2js/translator/testFiles/webDemoExamples2/out/life.js b/k2js/translator/testFiles/webDemoExamples2/out/life.js new file mode 100644 index 00000000000..15bb23c3152 --- /dev/null +++ b/k2js/translator/testFiles/webDemoExamples2/out/life.js @@ -0,0 +1,239 @@ +var classes = function(){ + var tmp$0 = Kotlin.Class.create({initialize:function(width, height, init){ + this.$width = width; + this.$height = height; + this.$live = Kotlin.arrayFromFun(this.get_height(), (tmp$0_0 = this , function(i){ + { + var tmp$0; + return Kotlin.arrayFromFun(tmp$0_0.get_width(), (tmp$0 = tmp$0_0 , function(j){ + { + return init(i, j); + } + } + )); + } + } + )); + } + , get_width:function(){ + return this.$width; + } + , get_height:function(){ + return this.$height; + } + , get_live:function(){ + return this.$live; + } + , liveCount:function(i, j){ + var tmp$0; + if ((new Kotlin.NumberRange(0, this.get_height() - 1 - 0 + 1, false)).contains(i) && (new Kotlin.NumberRange(0, this.get_width() - 1 - 0 + 1, false)).contains(j) && this.get_live()[i][j]) + tmp$0 = 1; + else + tmp$0 = 0; + { + return tmp$0; + } + } + , liveNeighbors:function(i, j){ + { + return this.liveCount(i - 1, j - 1) + this.liveCount(i - 1, j) + this.liveCount(i - 1, j + 1) + this.liveCount(i, j - 1) + this.liveCount(i, j + 1) + this.liveCount(i + 1, j - 1) + this.liveCount(i + 1, j) + this.liveCount(i + 1, j + 1); + } + } + , get:function(i, j){ + { + return this.get_live()[i][j]; + } + } + }); + return {Field:tmp$0}; +} +(); +var Anonymous = Kotlin.Namespace.create({initialize:function(){ +} +, next:function(field){ + { + return new Anonymous.Field(field.get_width(), field.get_height(), function(i, j){ + { + var n = field.liveNeighbors(i, j); + if (field.get(i, j)) + return (new Kotlin.NumberRange(2, 3 - 2 + 1, false)).contains(n); + else + return n == 3; + } + } + ); + } +} +, main:function(args){ + { + Anonymous.printField('***', 3); + Anonymous.printField('\n __*__\n _***_\n __*__\n ', 10); + Anonymous.printField('\n __*__\n _*_*_\n __*__\n ', 3); + Anonymous.printField('\n __**__\n __**__\n __**__\n ', 3); + Anonymous.printField('\n __**__\n __**__\n __**__\n __**__\n ', 6); + Anonymous.printField('\n ---------------\n ---***---***---\n ---------------\n -*----*-*----*-\n -*----*-*----*-\n -*----*-*----*-\n ---***---***---\n ---------------\n ---***---***---\n -*----*-*----*-\n -*----*-*----*-\n -*----*-*----*-\n ---------------\n ---***---***---\n ---------------\n ', 10); + } +} +, printField:function(s, steps){ + { + var tmp$0; + var field = Anonymous.makeField(s); + { + tmp$0 = (new Kotlin.NumberRange(1, steps - 1 + 1, false)).iterator(); + while (tmp$0.hasNext()) { + var step = tmp$0.next(); + { + var tmp$1; + Kotlin.println('Step: ' + step); + { + tmp$1 = (new Kotlin.NumberRange(0, field.get_height() - 1 - 0 + 1, false)).iterator(); + while (tmp$1.hasNext()) { + var i = tmp$1.next(); + { + var tmp$2; + { + tmp$2 = (new Kotlin.NumberRange(0, field.get_width() - 1 - 0 + 1, false)).iterator(); + while (tmp$2.hasNext()) { + var j = tmp$2.next(); + { + var tmp$3; + if (field.get(i, j)) + tmp$3 = '*'; + else + tmp$3 = ' '; + Kotlin.print(tmp$3); + } + } + } + Kotlin.println(''); + } + } + } + field = Anonymous.next(field); + } + } + } + } +} +, toList:function(receiver){ + { + return Anonymous.to(receiver, new Kotlin.ArrayList); + } +} +, get_size:function(receiver){ + var tmp$0; + if (receiver != null) + tmp$0 = receiver.length; + else + tmp$0 = 0; + { + return tmp$0; + } +} +, to:function(receiver, result){ + { + var tmp$0; + { + tmp$0 = Kotlin.arrayIterator(receiver); + while (tmp$0.hasNext()) { + var elem = tmp$0.next(); + { + result.add(elem); + } + } + } + return result; + } +} +, makeField:function(s){ + { + var tmp$2; + var tmp$0; + var lines = Kotlin.splitString(s, '\n'); + var w = Kotlin.sure(Kotlin.collectionsMax(Anonymous.toList(lines), Kotlin.comparator(function(o1, o2){ + { + var l1 = Anonymous.get_size(o1); + var l2 = Anonymous.get_size(o2); + return l1 - l2; + } + } + ))); + var data = Kotlin.arrayFromFun(lines.length, function(it_0){ + { + return Kotlin.arrayFromFun(Anonymous.get_size(w), function(it){ + { + return false; + } + } + ); + } + } + ); + { + tmp$0 = Kotlin.arrayIndices(data).iterator(); + while (tmp$0.hasNext()) { + var i_0 = tmp$0.next(); + { + var tmp$1; + data[i_0] = Kotlin.arrayFromFun(Anonymous.get_size(w), function(it){ + { + return false; + } + } + ); + { + tmp$1 = Kotlin.arrayIndices(data[i_0]).iterator(); + while (tmp$1.hasNext()) { + var j_0 = tmp$1.next(); + { + data[i_0][j_0] = false; + } + } + } + } + } + } + { + tmp$2 = Kotlin.arrayIndices(lines).iterator(); + while (tmp$2.hasNext()) { + var line = tmp$2.next(); + { + var tmp$3; + { + tmp$3 = Anonymous.get_indices(lines[line]).iterator(); + while (tmp$3.hasNext()) { + var x = tmp$3.next(); + { + var c = lines[line].charAt(x); + data[line][x] = c == '*'; + } + } + } + } + } + } + return new Anonymous.Field(Anonymous.get_size(w), lines.length, function(i, j){ + { + return data[i][j]; + } + } + ); + } +} +, get_indices:function(receiver){ + { + return new Kotlin.NumberRange(0, Anonymous.get_size(Kotlin.sure(receiver))); + } +} +, set:function(receiver, k, v){ + { + receiver.put(k, v); + } +} +, get_isEmpty:function(receiver){ + { + return receiver.length == 0; + } +} +}, {Field:classes.Field}); +Anonymous.initialize(); diff --git a/kotlin2js/k2js.iml b/kotlin2js/k2js.iml new file mode 100644 index 00000000000..af012ea065d --- /dev/null +++ b/kotlin2js/k2js.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/translator/lib/asm-util-3.3.1.jar b/translator/lib/asm-util-3.3.1.jar new file mode 100644 index 00000000000..0230bbcfb71 Binary files /dev/null and b/translator/lib/asm-util-3.3.1.jar differ diff --git a/translator/lib/guava-10.0.1.jar b/translator/lib/guava-10.0.1.jar new file mode 100644 index 00000000000..d107c0f3b0c Binary files /dev/null and b/translator/lib/guava-10.0.1.jar differ diff --git a/translator/lib/js.jar b/translator/lib/js.jar new file mode 100644 index 00000000000..878b0d9422b Binary files /dev/null and b/translator/lib/js.jar differ diff --git a/translator/src/org/jetbrains/k2js/analyze/Analyzer.java b/translator/src/org/jetbrains/k2js/analyze/Analyzer.java new file mode 100644 index 00000000000..d0aba16b5a6 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/analyze/Analyzer.java @@ -0,0 +1,117 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.analyze; + +import com.google.common.base.Predicate; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.Configuration; +import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.jet.lang.psi.JetPsiFactory; +import org.jetbrains.jet.lang.resolve.*; +import org.jetbrains.jet.lang.resolve.scopes.WritableScope; +import org.jetbrains.k2js.config.Config; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Pavel Talanov + */ +public final class Analyzer { + + private Analyzer() { + } + + @NotNull + public static BindingContext analyzeFilesAndCheckErrors(@NotNull List files, + @NotNull Config config) { + BindingContext bindingContext = analyzeFiles(files, config); + checkForErrors(withJsLibAdded(files, config), bindingContext); + return bindingContext; + } + + @NotNull + public static BindingContext analyzeFiles(@NotNull List files, + @NotNull Config config) { + Project project = config.getProject(); + return AnalyzingUtils.analyzeFiles(project, + JsConfiguration.jsLibConfiguration(project), + withJsLibAdded(files, config), + notLibFiles(config.getLibFiles()), + JetControlFlowDataTraceFactory.EMPTY); + } + + private static void checkForErrors(@NotNull List allFiles, @NotNull BindingContext bindingContext) { + AnalyzingUtils.throwExceptionOnErrors(bindingContext); + for (JetFile file : allFiles) { + AnalyzingUtils.checkForSyntacticErrors(file); + } + } + + //TODO: use some mechanism to avoid this + //TODO: move method somewhere + @NotNull + public static List withJsLibAdded(@NotNull List files, @NotNull Config config) { + List allFiles = new ArrayList(); + allFiles.addAll(files); + allFiles.addAll(config.getLibFiles()); + return allFiles; + } + + @NotNull + private static Predicate notLibFiles(@NotNull final List jsLibFiles) { + return new Predicate() { + @Override + public boolean apply(@Nullable PsiFile file) { + assert file instanceof JetFile; + @SuppressWarnings("UnnecessaryLocalVariable") boolean notLibFile = !jsLibFiles.contains(file); + return notLibFile; + } + }; + } + + private static final class JsConfiguration implements Configuration { + + @NotNull + private Project project; + + public static JsConfiguration jsLibConfiguration(@NotNull Project project) { + return new JsConfiguration(project); + } + + private JsConfiguration(@NotNull Project project) { + this.project = project; + } + + @Override + public void addDefaultImports(@NotNull BindingTrace trace, @NotNull WritableScope rootScope, + @NotNull Importer importer) { + ImportsResolver.ImportResolver importResolver = new ImportsResolver.ImportResolver(trace, true); + importResolver.processImportReference(JetPsiFactory.createImportDirective(project, "js.*"), rootScope, importer); + } + + @Override + public void extendNamespaceScope(@NotNull BindingTrace trace, @NotNull NamespaceDescriptor namespaceDescriptor, + @NotNull WritableScope namespaceMemberScope) { + } + } +} diff --git a/translator/src/org/jetbrains/k2js/config/Config.java b/translator/src/org/jetbrains/k2js/config/Config.java new file mode 100644 index 00000000000..0dc6d6b3cf9 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/config/Config.java @@ -0,0 +1,110 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.config; + +import com.intellij.openapi.project.Project; +import core.Dummy; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.k2js.utils.JetFileUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author Pavel Talanov + *

+ * Base class reprenting a configuration of translator. + */ +public abstract class Config { + + + //TODO: provide some generic way to get the files of the project + @NotNull + private static final List LIB_FILE_NAMES = Arrays.asList( + "/core/annotations.kt", + "/jquery/common.kt", + "/jquery/ui.kt", + "/core/javautil.kt", + "/core/javalang.kt", + "/core/core.kt", + "/core/math.kt", + "/core/json.kt", + "/raphael/raphael.kt", + "/html5/canvas.kt", + "/html5/files.kt", + "/html5/image.kt", + "/helper/ip.kt", + "/pixastic/pixastic.kt" + ); + + + @NotNull + private static List initLibFiles(@NotNull Project project) { + List libFiles = new ArrayList(); + for (String libFileName : LIB_FILE_NAMES) { + InputStream stream = Dummy.class.getResourceAsStream(libFileName); + //noinspection IOResourceOpenedButNotSafelyClosed + JetFile file = null; + try { + String text = readString(stream); + file = JetFileUtils.createPsiFile(libFileName, text, project); + } catch (IOException e) { + e.printStackTrace(); + } + libFiles.add(file); + } + return libFiles; + } + + + @Nullable + private /*var*/ List jsLibFiles = null; + + @NotNull + public abstract Project getProject(); + + @NotNull + public List getLibFiles() { + if (jsLibFiles == null) { + jsLibFiles = initLibFiles(getProject()); + } + + return jsLibFiles; + } + + static String readString(InputStream is) throws IOException { + char[] buf = new char[2048]; + Reader r = new InputStreamReader(is, "UTF-8"); + StringBuilder s = new StringBuilder(); + while (true) { + int n = r.read(buf); + if (n < 0) + break; + s.append(buf, 0, n); + } + return s.toString(); + } + + +} diff --git a/translator/src/org/jetbrains/k2js/config/IDEAConfig.java b/translator/src/org/jetbrains/k2js/config/IDEAConfig.java new file mode 100644 index 00000000000..f72d8668acd --- /dev/null +++ b/translator/src/org/jetbrains/k2js/config/IDEAConfig.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.config; + +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; + +/** + * @author Pavel Talanov + */ +public final class IDEAConfig extends Config { + + @NotNull + private final Project project; + + public IDEAConfig(@NotNull Project project) { + this.project = project; + } + + @NotNull + @Override + public Project getProject() { + return project; + } +} diff --git a/translator/src/org/jetbrains/k2js/config/TestConfig.java b/translator/src/org/jetbrains/k2js/config/TestConfig.java new file mode 100644 index 00000000000..22d57e9931a --- /dev/null +++ b/translator/src/org/jetbrains/k2js/config/TestConfig.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.config; + +import com.intellij.openapi.Disposable; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.compiler.JetCoreEnvironment; + +/** + * @author Pavel Talanov + */ +public final class TestConfig extends Config { + + @NotNull + private static JetCoreEnvironment getTestEnvironment() { + if (testOnlyEnvironment == null) { + testOnlyEnvironment = new JetCoreEnvironment(new Disposable() { + @Override + public void dispose() { + } + }); + } + return testOnlyEnvironment; + } + + @Nullable + private static /*var*/ JetCoreEnvironment testOnlyEnvironment = null; + + public TestConfig() { + } + + @NotNull + @Override + public Project getProject() { + return getTestEnvironment().getProject(); + } +} diff --git a/translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java b/translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java new file mode 100644 index 00000000000..ec186cc9e7f --- /dev/null +++ b/translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java @@ -0,0 +1,146 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.facade; + +import com.google.dart.compiler.backend.js.ast.JsProgram; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.k2js.analyze.Analyzer; +import org.jetbrains.k2js.config.Config; +import org.jetbrains.k2js.config.IDEAConfig; +import org.jetbrains.k2js.config.TestConfig; +import org.jetbrains.k2js.generate.CodeGenerator; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.utils.BindingUtils; +import org.jetbrains.k2js.utils.GenerationUtils; +import org.jetbrains.k2js.utils.JetFileUtils; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.*; + +import static org.jetbrains.k2js.translate.utils.PsiUtils.getNamespaceName; +import static org.jetbrains.k2js.utils.JetFileUtils.createPsiFileList; + +//TODO: clean up the code + +/** + * @author Pavel Talanov + *

+ * An entry point of translator. + */ +public final class K2JSTranslator { + + public static void translateWithCallToMainAndSaveToFile(@NotNull JetFile file, + @NotNull String outputPath, + @NotNull Project project) throws Exception { + K2JSTranslator translator = new K2JSTranslator(new IDEAConfig(project)); + String programCode = translator.generateProgramCode(file) + "\n"; + String callToMain = translator.generateCallToMain(file, ""); + FileWriter writer = new FileWriter(new File(outputPath)); + writer.write(programCode + callToMain); + writer.close(); + } + + public static void testTranslateFile(@NotNull String inputFile, + @NotNull String outputFile) throws Exception { + testTranslateFiles(Collections.singletonList(inputFile), outputFile); + } + + public static void testTranslateFiles(@NotNull List inputFiles, + @NotNull String outputFile) throws Exception { + K2JSTranslator translator = new K2JSTranslator(new TestConfig()); + List psiFiles = createPsiFileList(inputFiles, translator.getProject()); + JsProgram program = translator.generateProgram(psiFiles); + saveProgramToFile(outputFile, program); + } + + private static void saveProgramToFile(@NotNull String outputFile, @NotNull JsProgram program) throws IOException { + CodeGenerator generator = new CodeGenerator(); + generator.generateToFile(program, new File(outputFile)); + } + + @NotNull + private Config config; + + + public K2JSTranslator(@NotNull Config config) { + this.config = config; + } + + @NotNull + public String translateStringWithCallToMain(@NotNull String programText, @NotNull String argumentsString) { + JetFile file = JetFileUtils.createPsiFile("test", programText, getProject()); + String programCode = generateProgramCode(file) + "\n"; + String flushOutput = "Kotlin.System.flush();\n"; + String callToMain = generateCallToMain(file, argumentsString); + String programOutput = "Kotlin.System.output();\n"; + return programCode + flushOutput + callToMain + programOutput; + } + + @NotNull + private String generateProgramCode(@NotNull JetFile psiFile) { + JsProgram program = generateProgram(Arrays.asList(psiFile)); + CodeGenerator generator = new CodeGenerator(); + return generator.generateToString(program); + } + + @NotNull + public BindingContext analyzeProgramCode(@NotNull String programText) { + JetFile file = JetFileUtils.createPsiFile("test", programText, getProject()); + return Analyzer.analyzeFiles(Arrays.asList(file), config); + } + + + @NotNull + private JsProgram generateProgram(@NotNull List filesToTranslate) { + BindingContext bindingContext = Analyzer.analyzeFilesAndCheckErrors(filesToTranslate, config); + JetFile file = filesToTranslate.iterator().next(); + NamespaceDescriptor namespaceDescriptor = BindingUtils.getNamespaceDescriptor(bindingContext, file); + return Translation.generateAst(bindingContext, namespaceDescriptor, + Analyzer.withJsLibAdded(filesToTranslate, config), getProject()); + } + + + @NotNull + public String generateCallToMain(@NotNull JetFile file, @NotNull String argumentString) { + String namespaceName = getNamespaceName(file); + List arguments = parseString(argumentString); + return GenerationUtils.generateCallToMain(namespaceName, arguments); + } + + @NotNull + private List parseString(@NotNull String argumentString) { + List result = new ArrayList(); + StringTokenizer stringTokenizer = new StringTokenizer(argumentString); + while (stringTokenizer.hasMoreTokens()) { + result.add(stringTokenizer.nextToken()); + } + return result; + } + + + @NotNull + private Project getProject() { + return config.getProject(); + } + +} diff --git a/translator/src/org/jetbrains/k2js/facade/K2JSTranslatorUtils.java b/translator/src/org/jetbrains/k2js/facade/K2JSTranslatorUtils.java new file mode 100644 index 00000000000..8fafffc52ff --- /dev/null +++ b/translator/src/org/jetbrains/k2js/facade/K2JSTranslatorUtils.java @@ -0,0 +1,73 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.facade; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.k2js.config.TestConfig; + +/** + * Created by IntelliJ IDEA. + * User: Natalia.Ukhorskaya + * Date: 2/9/12 + * Time: 7:49 PM + */ + +public class K2JSTranslatorUtils { + @SuppressWarnings("FieldCanBeLocal") + private static String EXCEPTION = "exception="; + + @Nullable + public String translateToJS(@NotNull String code, @NotNull String arguments) { + try { + return generateJSCode(code, arguments); + } catch (AssertionError e) { + reportException(e); + return EXCEPTION + "Translation error."; + } catch (UnsupportedOperationException e) { + reportException(e); + return EXCEPTION + "Unsupported feature."; + } catch (Throwable e) { + reportException(e); + return EXCEPTION + "Unexpected exception."; + } + } + + @Nullable + public BindingContext getBindingContext(@NotNull String programText) { + try { + K2JSTranslator k2JSTranslator = new K2JSTranslator(new TestConfig()); + return k2JSTranslator.analyzeProgramCode(programText); + } catch (Throwable e) { + e.printStackTrace(); + reportException(e); + return null; + } + } + + @NotNull + private String generateJSCode(@NotNull String code, @NotNull String arguments) { + String generatedCode = (new K2JSTranslator(new TestConfig())).translateStringWithCallToMain(code, arguments); + return generatedCode; + } + + private void reportException(@NotNull Throwable e) { + System.out.println("Exception in translateToJS!!!"); + e.printStackTrace(); + } +} diff --git a/translator/src/org/jetbrains/k2js/generate/CodeGenerator.java b/translator/src/org/jetbrains/k2js/generate/CodeGenerator.java new file mode 100644 index 00000000000..ecb5d30b2c0 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/generate/CodeGenerator.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.generate; + +import com.google.dart.compiler.backend.js.JsSourceGenerationVisitor; +import com.google.dart.compiler.backend.js.ast.JsProgram; +import com.google.dart.compiler.util.DefaultTextOutput; +import com.google.dart.compiler.util.TextOutput; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * @author Pavel.Talanov + */ +public final class CodeGenerator { + + @NotNull + private final TextOutput output = new DefaultTextOutput(false); + + public CodeGenerator() { + } + + public void generateToFile(@NotNull JsProgram program, @NotNull File file) throws IOException { + generateCode(program); + FileWriter writer = new FileWriter(file); + writer.write(output.toString()); + writer.close(); + } + + @NotNull + public String generateToString(@NotNull JsProgram program) { + generateCode(program); + return output.toString(); + } + + private void generateCode(@NotNull JsProgram program) { + JsSourceGenerationVisitor sourceGenerator = + new JsSourceGenerationVisitor(output); + program.traverse(sourceGenerator, null); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/context/Aliaser.java b/translator/src/org/jetbrains/k2js/translate/context/Aliaser.java new file mode 100644 index 00000000000..f77a65a7e0d --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/context/Aliaser.java @@ -0,0 +1,100 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.context; + +import com.google.dart.compiler.backend.js.ast.JsName; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; + +import java.util.HashMap; +import java.util.Map; +import java.util.Stack; + +public class Aliaser { + + public static Aliaser newInstance() { + return new Aliaser(); + } + + @NotNull + private final Map aliasesForDescriptors = new HashMap(); + @NotNull + private final Map> aliasesForThis + = new HashMap>(); + + private Aliaser() { + } + + @NotNull + public JsNameRef getAliasForThis(@NotNull DeclarationDescriptor descriptor) { + Stack aliasStack = aliasesForThis.get(descriptor.getOriginal()); + assert !aliasStack.empty(); + JsName aliasName = aliasStack.peek(); + assert aliasName != null : "This " + descriptor.getOriginal() + " doesn't have an alias."; + return aliasName.makeRef(); + } + + public void setAliasForThis(@NotNull DeclarationDescriptor descriptor, @NotNull JsName alias) { + Stack aliasStack = aliasesForThis.get(descriptor.getOriginal()); + if (aliasStack == null) { + aliasStack = new Stack(); + aliasesForThis.put(descriptor, aliasStack); + } + aliasStack.push(alias); + } + + public void removeAliasForThis(@NotNull DeclarationDescriptor descriptor) { + Stack aliasStack = aliasesForThis.get(descriptor.getOriginal()); + assert !aliasStack.empty(); + aliasStack.pop(); + if (aliasStack.empty()) { + aliasesForThis.put(descriptor, null); + } + } + + public boolean hasAliasForThis(@NotNull DeclarationDescriptor descriptor) { + Stack aliasStack = aliasesForThis.get(descriptor.getOriginal()); + if (aliasStack == null) { + return false; + } + return (!aliasStack.empty()); + } + + @NotNull + public JsName getAliasForDeclaration(@NotNull DeclarationDescriptor declaration) { + JsName alias = aliasesForDescriptors.get(declaration.getOriginal()); + assert alias != null : "Use has alias for declaration to check."; + return alias; + } + + public void setAliasForDescriptor(@NotNull DeclarationDescriptor declaration, @NotNull JsName alias) { + assert (!hasAliasForDeclaration(declaration.getOriginal())) : "This declaration already has an alias!"; + aliasesForDescriptors.put(declaration.getOriginal(), alias); + } + + public void removeAliasForDescriptor(@NotNull DeclarationDescriptor declaration) { + assert (hasAliasForDeclaration(declaration.getOriginal())) : "This declaration does not has an alias!"; + aliasesForDescriptors.remove(declaration.getOriginal()); + } + + public boolean hasAliasForDeclaration(@NotNull DeclarationDescriptor declaration) { + return aliasesForDescriptors.containsKey(declaration.getOriginal()); + } + + +} \ No newline at end of file diff --git a/translator/src/org/jetbrains/k2js/translate/context/DynamicContext.java b/translator/src/org/jetbrains/k2js/translate/context/DynamicContext.java new file mode 100644 index 00000000000..7e09549fdb9 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/context/DynamicContext.java @@ -0,0 +1,84 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.context; + +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; + +public class DynamicContext { + + @NotNull + public static DynamicContext rootContext(@NotNull NamingScope rootScope, @NotNull JsBlock globalBlock) { + return new DynamicContext(rootScope, rootScope, globalBlock); + } + + @NotNull + public static DynamicContext contextWithScope(@NotNull NamingScope scope) { + return new DynamicContext(scope, scope, new JsBlock()); + } + + //TODO: current/block scope logic unclear. is it necessary? + @NotNull + private NamingScope currentScope; + + @NotNull + private NamingScope blockScope; + + @NotNull + private JsBlock currentBlock; + + private DynamicContext(@NotNull NamingScope scope, @NotNull NamingScope blockScope, @NotNull JsBlock block) { + this.currentScope = scope; + this.currentBlock = block; + this.blockScope = blockScope; + } + + @NotNull + public DynamicContext innerScope(@NotNull JsScope scope) { + return new DynamicContext(currentScope.innerScope(scope), blockScope, currentBlock); + } + + @NotNull + public NamingScope getScope() { + return blockScope; + } + + @NotNull + public DynamicContext innerBlock(@NotNull JsBlock block) { + return new DynamicContext(currentScope, currentScope, block); + } + + @NotNull + public TemporaryVariable declareTemporary(@NotNull JsExpression initExpression) { + JsName temporaryName = blockScope.declareTemporary(); + JsVars temporaryDeclaration = AstUtil.newVar(temporaryName, null); + jsBlock().addVarDeclaration(temporaryDeclaration); + return new TemporaryVariable(temporaryName, initExpression); + } + + + @NotNull + public JsScope jsScope() { + return currentScope.jsScope(); + } + + @NotNull + public JsBlock jsBlock() { + return currentBlock; + } +} \ No newline at end of file diff --git a/translator/src/org/jetbrains/k2js/translate/context/Namer.java b/translator/src/org/jetbrains/k2js/translate/context/Namer.java new file mode 100644 index 00000000000..c92af4d1bac --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/context/Namer.java @@ -0,0 +1,170 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.context; + +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.JsScope; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; + +/** + * @author Pavel Talanov + *

+ * Encapuslates different types of constants and naming conventions. + */ +public final class Namer { + + private static final String INITIALIZE_METHOD_NAME = "initialize"; + private static final String CLASS_OBJECT_NAME = "Class"; + private static final String TRAIT_OBJECT_NAME = "Trait"; + private static final String NAMESPACE_OBJECT_NAME = "Namespace"; + private static final String OBJECT_OBJECT_NAME = "object"; + private static final String SETTER_PREFIX = "set_"; + private static final String GETTER_PREFIX = "get_"; + private static final String BACKING_FIELD_PREFIX = "$"; + private static final String SUPER_METHOD_NAME = "super_init"; + private static final String KOTLIN_OBJECT_NAME = "Kotlin"; + private static final String ANONYMOUS_NAMESPACE = "Anonymous"; + private static final String RECEIVER_PARAMETER_NAME = "receiver"; + + @NotNull + public static String getReceiverParameterName() { + return RECEIVER_PARAMETER_NAME; + } + + @NotNull + public static String getAnonymousNamespaceName() { + return ANONYMOUS_NAMESPACE; + } + + @NotNull + public static JsNameRef initializeMethodReference() { + return AstUtil.newQualifiedNameRef(INITIALIZE_METHOD_NAME); + } + + @NotNull + public static String superMethodName() { + return SUPER_METHOD_NAME; + } + + @NotNull + public static String nameForClassesVariable() { + return "classes"; + } + + @NotNull + public static String getNameForAccessor(@NotNull String propertyName, boolean isGetter) { + if (isGetter) { + return getNameForGetter(propertyName); + } else { + return getNameForSetter(propertyName); + } + } + + public static String getKotlinBackingFieldName(String propertyName) { + return getNameWithPrefix(propertyName, BACKING_FIELD_PREFIX); + } + + public static String getNameForGetter(String propertyName) { + return getNameWithPrefix(propertyName, GETTER_PREFIX); + } + + public static String getNameForSetter(String propertyName) { + return getNameWithPrefix(propertyName, SETTER_PREFIX); + } + + private static String getNameWithPrefix(String name, String prefix) { + return prefix + name; + } + + public static Namer newInstance(@NotNull JsScope rootScope) { + return new Namer(rootScope); + } + + @NotNull + private final JsName kotlinName; + @NotNull + private final JsScope kotlinScope; + @NotNull + private final JsName className; + @NotNull + private final JsName traitName; + @NotNull + private final JsName namespaceName; + @NotNull + private final JsName objectName; + + private Namer(@NotNull JsScope rootScope) { + kotlinName = rootScope.declareName(KOTLIN_OBJECT_NAME); + kotlinScope = new JsScope(rootScope, "Kotlin standard object"); + traitName = kotlinScope.declareName(TRAIT_OBJECT_NAME); + namespaceName = kotlinScope.declareName(NAMESPACE_OBJECT_NAME); + className = kotlinScope.declareName(CLASS_OBJECT_NAME); + objectName = kotlinScope.declareName(OBJECT_OBJECT_NAME); + } + + @NotNull + public JsNameRef classCreationMethodReference() { + return kotlin(createMethodReference(className)); + } + + @NotNull + public JsNameRef traitCreationMethodReference() { + return kotlin(createMethodReference(traitName)); + } + + @NotNull + public JsNameRef namespaceCreationMethodReference() { + return kotlin(createMethodReference(namespaceName)); + } + + @NotNull + public JsNameRef objectCreationMethodReference() { + return kotlin(createMethodReference(objectName)); + } + + @NotNull + private JsNameRef createMethodReference(@NotNull JsName name) { + JsNameRef qualifier = name.makeRef(); + JsNameRef reference = AstUtil.newQualifiedNameRef("create"); + AstUtil.setQualifier(reference, qualifier); + return reference; + } + + @NotNull + private JsNameRef kotlin(@NotNull JsNameRef reference) { + JsNameRef kotlinReference = kotlinName.makeRef(); + AstUtil.setQualifier(reference, kotlinReference); + return reference; + } + + @NotNull + public JsNameRef kotlinObject() { + return kotlinName.makeRef(); + } + + @NotNull + public JsNameRef isOperationReference() { + return kotlin(AstUtil.newQualifiedNameRef("isType")); + } + + @NotNull + /*package*/ JsScope getKotlinScope() { + return kotlinScope; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/context/NamingScope.java b/translator/src/org/jetbrains/k2js/translate/context/NamingScope.java new file mode 100644 index 00000000000..650f0ffb5b1 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/context/NamingScope.java @@ -0,0 +1,98 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.context; + +import com.google.dart.compiler.backend.js.ast.JsName; +import com.google.dart.compiler.backend.js.ast.JsScope; +import org.jetbrains.annotations.NotNull; + +/** + * @author Pavel Talanov + *

+ * Basically a wrapper around JsScope. + */ +public final class NamingScope { + + @NotNull + public static NamingScope rootScope(@NotNull JsScope rootScope) { + return new NamingScope(rootScope); + } + + @NotNull + private final JsScope scope; + + private NamingScope(@NotNull JsScope correspondingScope) { + this.scope = correspondingScope; + } + + @NotNull + public NamingScope innerScope(@NotNull String scopeName) { + JsScope innerJsScope = new JsScope(jsScope(), scopeName); + return new NamingScope(innerJsScope); + } + + @NotNull + public NamingScope innerScope(@NotNull JsScope correspondingScope) { + return new NamingScope(correspondingScope); + } + + @NotNull + /*package*/ JsName declareUnobfuscatableName(@NotNull String name) { + JsName declaredName = scope.declareName(name); + declaredName.setObfuscatable(false); + return declaredName; + } + + @NotNull + /*package*/ JsName declareObfuscatableName(@NotNull String name) { + return scope.declareName(mayBeObfuscateName(name, true)); + } + + //TODO: temporary solution + @NotNull + private String mayBeObfuscateName(@NotNull String name, boolean shouldObfuscate) { + if (!shouldObfuscate) { + return name; + } + return doObfuscate(name); + } + + @NotNull + private String doObfuscate(@NotNull String name) { + int obfuscate = 0; + String result = name; + while (true) { + JsName existingNameWithSameIdent = scope.findExistingName(result); + boolean isDuplicate = (existingNameWithSameIdent != null) && (scope.ownsName(existingNameWithSameIdent)); + + if (!isDuplicate) break; + + result = name + "$" + obfuscate; + obfuscate++; + } + return result; + } + + public JsName declareTemporary() { + return scope.declareTemporary(); + } + + @NotNull + public JsScope jsScope() { + return scope; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java b/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java new file mode 100644 index 00000000000..b1d0e5e8fef --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java @@ -0,0 +1,180 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.context; + +import com.google.dart.compiler.backend.js.ast.JsName; +import com.google.dart.compiler.backend.js.ast.JsScope; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; + +import java.util.HashMap; +import java.util.Map; + +import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getFQName; + +/** + * @author Pavel Talanov + *

+ * Provides a mechanism to bind some of the kotlin/java declations with library implementations. + * Makes sense only for those declaration that cannot be annotated. (Use library annotation in this case) + */ +public final class StandardClasses { + + private final class Builder { + + @Nullable + private /*var*/ String currentFQName = null; + @Nullable + private /*var*/ String currentObjectName = null; + + @NotNull + public Builder forFQ(@NotNull String classFQName) { + currentFQName = classFQName; + return this; + } + + @NotNull + public Builder kotlinClass(@NotNull String kotlinName) { + kotlinTopLevelObject(kotlinName); + constructor(); + return this; + } + + private void kotlinTopLevelObject(@NotNull String kotlinName) { + assert currentFQName != null; + currentObjectName = kotlinName; + declareKotlinObject(currentFQName, kotlinName); + } + + @NotNull + public Builder kotlinFunction(@NotNull String kotlinName) { + kotlinTopLevelObject(kotlinName); + return this; + } + + @NotNull + private Builder constructor() { + assert currentFQName != null; + assert currentObjectName != null; + declareInner(currentFQName, "", currentObjectName); + return this; + } + + @NotNull + public Builder methods(@NotNull String... methodNames) { + assert currentFQName != null; + declareMethods(currentFQName, methodNames); + return this; + } + + @NotNull + public Builder properties(@NotNull String... propertyNames) { + assert currentFQName != null; + declareReadonlyProperties(currentFQName, propertyNames); + return this; + } + } + + @NotNull + public static StandardClasses bindImplementations(@NotNull JsScope kotlinObjectScope) { + StandardClasses standardClasses = new StandardClasses(kotlinObjectScope); + declareJetObjects(standardClasses); + return standardClasses; + } + + private static void declareJetObjects(@NotNull StandardClasses standardClasses) { + + standardClasses.declare().forFQ("jet.Iterator").kotlinClass("ArrayIteratorIntrinsic") + .methods("next").properties("hasNext"); + + standardClasses.declare().forFQ("jet.IntRange").kotlinClass("NumberRange") + .methods("iterator", "contains").properties("start", "size", "end", "reversed"); + + standardClasses.declare().forFQ("jet.sure").kotlinFunction("sure"); + + standardClasses.declare().forFQ("jet.Any.toString").kotlinFunction("toString"); + + standardClasses.declare().forFQ("java.util.Collections..max").kotlinFunction("collectionsMax"); + } + + + @NotNull + private final JsScope kotlinScope; + + + @NotNull + private final Map standardObjects = new HashMap(); + + @NotNull + private final Map scopeMap = new HashMap(); + + private StandardClasses(@NotNull JsScope kotlinScope) { + this.kotlinScope = kotlinScope; + } + + private void declareTopLevelObjectInScope(@NotNull JsScope scope, @NotNull Map map, + @NotNull String fullQualifiedName, @NotNull String name) { + JsName declaredName = scope.declareName(name); + declaredName.setObfuscatable(false); + map.put(fullQualifiedName, declaredName); + scopeMap.put(fullQualifiedName, new JsScope(scope, "scope for " + name)); + } + + private void declareKotlinObject(@NotNull String fullQualifiedName, @NotNull String kotlinLibName) { + declareTopLevelObjectInScope(kotlinScope, standardObjects, fullQualifiedName, kotlinLibName); + } + + private void declareInner(@NotNull String fullQualifiedClassName, + @NotNull String shortMethodName, + @NotNull String javascriptName) { + JsScope classScope = scopeMap.get(fullQualifiedClassName); + assert classScope != null; + String fullQualifiedMethodName = fullQualifiedClassName + "." + shortMethodName; + JsName declaredName = classScope.declareName(javascriptName); + declaredName.setObfuscatable(false); + standardObjects.put(fullQualifiedMethodName, declaredName); + } + + private void declareMethods(@NotNull String classFQName, + @NotNull String... methodNames) { + for (String methodName : methodNames) { + declareInner(classFQName, methodName, methodName); + } + } + + private void declareReadonlyProperties(@NotNull String classFQName, + @NotNull String... propertyNames) { + for (String propertyName : propertyNames) { + declareInner(classFQName, propertyName, propertyName); + } + } + + public boolean isStandardObject(@NotNull DeclarationDescriptor descriptor) { + return standardObjects.containsKey(getFQName(descriptor)); + } + + @NotNull + public JsName getStandardObjectName(@NotNull DeclarationDescriptor descriptor) { + return standardObjects.get(getFQName(descriptor)); + } + + @NotNull + private Builder declare() { + return new Builder(); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/context/StaticContext.java b/translator/src/org/jetbrains/k2js/translate/context/StaticContext.java new file mode 100644 index 00000000000..32a0065efb2 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/context/StaticContext.java @@ -0,0 +1,478 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.context; + +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.JsProgram; +import com.google.dart.compiler.backend.js.ast.JsRootScope; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.types.JetStandardLibrary; +import org.jetbrains.k2js.translate.context.generator.Generator; +import org.jetbrains.k2js.translate.context.generator.Rule; +import org.jetbrains.k2js.translate.intrinsic.Intrinsics; +import org.jetbrains.k2js.translate.utils.AnnotationsUtils; + +import java.util.Set; + +import static org.jetbrains.k2js.translate.utils.AnnotationsUtils.*; +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.*; + +/** + * @author Pavel Talanov + *

+ * Aggregates all the static parts of the context. + */ +public final class StaticContext { + + public static StaticContext generateStaticContext(@NotNull JetStandardLibrary library, + @NotNull BindingContext bindingContext) { + JsProgram program = new JsProgram("main"); + JsRootScope jsRootScope = program.getRootScope(); + Namer namer = Namer.newInstance(jsRootScope); + Aliaser aliaser = Aliaser.newInstance(); + NamingScope scope = NamingScope.rootScope(jsRootScope); + Intrinsics intrinsics = Intrinsics.standardLibraryIntrinsics(library); + StandardClasses standardClasses = + StandardClasses.bindImplementations(namer.getKotlinScope()); + return new StaticContext(program, bindingContext, aliaser, + namer, intrinsics, standardClasses, scope); + } + + @NotNull + private final JsProgram program; + + @NotNull + private final BindingContext bindingContext; + + @NotNull + private final Aliaser aliaser; + + @NotNull + private final Namer namer; + + @NotNull + private final Intrinsics intrinsics; + + @NotNull + private final StandardClasses standardClasses; + + @NotNull + private final NamingScope rootScope; + + @NotNull + private final Generator names = new NameGenerator(); + @NotNull + private final Generator scopes = new ScopeGenerator(); + @NotNull + private final Generator qualifiers = new QualifierGenerator(); + @NotNull + private final Generator qualifierIsNull = new QualifierIsNullGenerator(); + + + //TODO: too many parameters in constructor + private StaticContext(@NotNull JsProgram program, @NotNull BindingContext bindingContext, + @NotNull Aliaser aliaser, + @NotNull Namer namer, @NotNull Intrinsics intrinsics, + @NotNull StandardClasses standardClasses, @NotNull NamingScope rootScope) { + this.program = program; + this.bindingContext = bindingContext; + this.aliaser = aliaser; + this.namer = namer; + this.intrinsics = intrinsics; + this.rootScope = rootScope; + this.standardClasses = standardClasses; + } + + @NotNull + public JsProgram getProgram() { + return program; + } + + @NotNull + public BindingContext getBindingContext() { + return bindingContext; + } + + @NotNull + public Aliaser getAliaser() { + return aliaser; + } + + @NotNull + public Intrinsics getIntrinsics() { + return intrinsics; + } + + @NotNull + public Namer getNamer() { + return namer; + } + + @NotNull + public NamingScope getRootScope() { + return rootScope; + } + + @NotNull + public StandardClasses getStandardClasses() { + return standardClasses; + } + + @NotNull + public NamingScope getScopeForDescriptor(@NotNull DeclarationDescriptor descriptor) { + NamingScope namingScope = scopes.get(descriptor); + assert namingScope != null : "Must have a scope for descriptor"; + return namingScope; + } + + @NotNull + public JsName getNameForDescriptor(@NotNull DeclarationDescriptor descriptor) { + JsName name = names.get(descriptor.getOriginal()); + assert name != null : "Must have name for descriptor"; + return name; + } + + private final class NameGenerator extends Generator { + public NameGenerator() { + Rule namesForStandardClasses = new Rule() { + @Override + @Nullable + public JsName apply(@NotNull DeclarationDescriptor data) { + if (!standardClasses.isStandardObject(data)) { + return null; + } + return standardClasses.getStandardObjectName(data); + } + }; + Rule namespacesShouldBeDefinedInRootScope = new Rule() { + @Override + @Nullable + public JsName apply(@NotNull DeclarationDescriptor descriptor) { + if (!(descriptor instanceof NamespaceDescriptor)) { + return null; + } + String nameForNamespace = getNameForNamespace((NamespaceDescriptor) descriptor); + return getRootScope().declareUnobfuscatableName(nameForNamespace); + } + }; + Rule memberDeclarationsInsideParentsScope = new Rule() { + @Override + @Nullable + public JsName apply(@NotNull DeclarationDescriptor descriptor) { + NamingScope namingScope = getEnclosingScope(descriptor); + return namingScope.declareObfuscatableName(descriptor.getName()); + } + }; + Rule constructorHasTheSameNameAsTheClass = new Rule() { + @Override + public JsName apply(@NotNull DeclarationDescriptor descriptor) { + if (!(descriptor instanceof ConstructorDescriptor)) { + return null; + } + ClassDescriptor containingClass = getContainingClass(descriptor); + assert containingClass != null : "Can't have constructor without a class"; + return getNameForDescriptor(containingClass); + } + }; + Rule accessorsHasNamesWithSpecialPrefixes = new Rule() { + @Override + public JsName apply(@NotNull DeclarationDescriptor descriptor) { + if (!(descriptor instanceof PropertyAccessorDescriptor)) { + return null; + } + boolean isGetter = descriptor instanceof PropertyGetterDescriptor; + String propertyName = ((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty().getName(); + String accessorName = Namer.getNameForAccessor(propertyName, isGetter); + NamingScope enclosingScope = getEnclosingScope(descriptor); + return enclosingScope.declareObfuscatableName(accessorName); + } + }; + + Rule namesAnnotatedAsLibraryHasUnobfuscatableNames = new Rule() { + @Override + public JsName apply(@NotNull DeclarationDescriptor descriptor) { + //TODO: refactor + String name = null; + AnnotationDescriptor annotation = getAnnotationByName(descriptor, LIBRARY_ANNOTATION_FQNAME); + if (annotation != null) { + name = AnnotationsUtils.getAnnotationStringParameter(descriptor, LIBRARY_ANNOTATION_FQNAME); + name = (!name.isEmpty()) ? name : descriptor.getName(); + } else { + ClassDescriptor containingClass = getContainingClass(descriptor); + if (containingClass == null) return null; + if (getAnnotationByName(containingClass, LIBRARY_ANNOTATION_FQNAME) != null) { + name = descriptor.getName(); + } + } + if (name != null) { + return getEnclosingScope(descriptor).declareUnobfuscatableName(name); + } + return null; + } + }; + Rule propertiesCorrespondToSpeciallyTreatedBackingFieldNames = new Rule() { + @Override + public JsName apply(@NotNull DeclarationDescriptor descriptor) { + if (!(descriptor instanceof PropertyDescriptor)) { + return null; + } + NamingScope enclosingScope = getEnclosingScope(descriptor); + return enclosingScope.declareObfuscatableName(Namer.getKotlinBackingFieldName(descriptor.getName())); + } + }; + //TODO: hack! + Rule toStringHack = new Rule() { + @Override + public JsName apply(@NotNull DeclarationDescriptor descriptor) { + if (!(descriptor instanceof FunctionDescriptor)) { + return null; + } + if (!descriptor.getName().equals("toString")) { + return null; + } + if (((FunctionDescriptor) descriptor).getValueParameters().isEmpty()) { + return getEnclosingScope(descriptor).declareUnobfuscatableName("toString"); + } + return null; + } + + }; + Rule namesForNativeObjectsAreUnobfuscatable = new Rule() { + @Override + public JsName apply(@NotNull DeclarationDescriptor descriptor) { + String name = null; + AnnotationDescriptor annotation = getAnnotationByName(descriptor, NATIVE_ANNOTATION_FQNAME); + if (annotation != null) { + name = AnnotationsUtils.getAnnotationStringParameter(descriptor, NATIVE_ANNOTATION_FQNAME); + name = (!name.isEmpty()) ? name : descriptor.getName(); + } else { + ClassDescriptor containingClass = getContainingClass(descriptor); + if (containingClass == null) return null; + if (getAnnotationByName(containingClass, NATIVE_ANNOTATION_FQNAME) != null) { + name = descriptor.getName(); + } + } + if (name != null) { + return getEnclosingScope(descriptor).declareUnobfuscatableName(name); + } + return null; + + } + }; + Rule overridingDescriptorsReferToOriginalName = new Rule() { + @Override + public JsName apply(@NotNull DeclarationDescriptor descriptor) { + //TODO: refactor + if (descriptor instanceof FunctionDescriptor) { + Set overriddenDescriptors = ((FunctionDescriptor) descriptor).getOverriddenDescriptors(); + if (overriddenDescriptors.isEmpty()) { + return null; + } else { + //assert overriddenDescriptors.size() == 1; + //TODO: for now translator can't deal with multiple inheritance good enough + for (FunctionDescriptor overriddenDescriptor : overriddenDescriptors) { + return getNameForDescriptor(overriddenDescriptor); + } + } + } + return null; + } + }; + addRule(namesForStandardClasses); + addRule(constructorHasTheSameNameAsTheClass); + addRule(namesAnnotatedAsLibraryHasUnobfuscatableNames); + addRule(namesForNativeObjectsAreUnobfuscatable); + addRule(toStringHack); + addRule(propertiesCorrespondToSpeciallyTreatedBackingFieldNames); + addRule(namespacesShouldBeDefinedInRootScope); + addRule(accessorsHasNamesWithSpecialPrefixes); + addRule(overridingDescriptorsReferToOriginalName); + addRule(memberDeclarationsInsideParentsScope); + } + } + + private NamingScope getEnclosingScope(@NotNull DeclarationDescriptor descriptor) { + DeclarationDescriptor containingDeclaration = getContainingDeclaration(descriptor); + return getScopeForDescriptor(containingDeclaration.getOriginal()); + } + + + private final class ScopeGenerator extends Generator { + + public ScopeGenerator() { + Rule generateNewScopesForClassesWithNoAncestors = new Rule() { + @Override + public NamingScope apply(@NotNull DeclarationDescriptor descriptor) { + if (!(descriptor instanceof ClassDescriptor)) { + return null; + } + if (getSuperclass((ClassDescriptor) descriptor) == null) { + return getRootScope().innerScope("Scope for class " + descriptor.getName()); + } + return null; + } + }; + Rule generateInnerScopesForDerivedClasses = new Rule() { + @Override + public NamingScope apply(@NotNull DeclarationDescriptor descriptor) { + if (!(descriptor instanceof ClassDescriptor)) { + return null; + } + ClassDescriptor superclass = getSuperclass((ClassDescriptor) descriptor); + if (superclass == null) { + return null; + } + return getScopeForDescriptor(superclass).innerScope("Scope for class " + descriptor.getName()); + } + }; + Rule generateNewScopesForNamespaceDescriptors = new Rule() { + @Override + public NamingScope apply(@NotNull DeclarationDescriptor descriptor) { + if (!(descriptor instanceof NamespaceDescriptor)) { + return null; + } + return getRootScope().innerScope("Namespace " + descriptor.getName()); + } + }; + Rule generateInnerScopesForMembers = new Rule() { + @Override + public NamingScope apply(@NotNull DeclarationDescriptor descriptor) { + NamingScope enclosingScope = getEnclosingScope(descriptor); + return enclosingScope.innerScope("Scope for member " + descriptor.getName()); + } + }; + addRule(generateNewScopesForClassesWithNoAncestors); + addRule(generateInnerScopesForDerivedClasses); + addRule(generateNewScopesForNamespaceDescriptors); + addRule(generateInnerScopesForMembers); + } + } + + @Nullable + public JsNameRef getQualifierForDescriptor(@NotNull DeclarationDescriptor descriptor) { + if (qualifierIsNull.get(descriptor) != null) { + return null; + } + return qualifiers.get(descriptor.getOriginal()); + } + + private final class QualifierGenerator extends Generator { + public QualifierGenerator() { + Rule namespacesHaveNoQualifiers = new Rule() { + @Override + public JsNameRef apply(@NotNull DeclarationDescriptor descriptor) { + if (!standardClasses.isStandardObject(descriptor)) { + return null; + } + return namer.kotlinObject(); + } + }; + Rule namespaceLevelDeclarationsHaveEnclosingNamespacesNamesAsQualifier = new Rule() { + @Override + public JsNameRef apply(@NotNull DeclarationDescriptor descriptor) { + DeclarationDescriptor containingDeclaration = getContainingDeclaration(descriptor); + if (!(containingDeclaration instanceof NamespaceDescriptor)) { + return null; + } + JsName containingDeclarationName = getNameForDescriptor(containingDeclaration); + return containingDeclarationName.makeRef(); + } + }; + Rule constructorHaveTheSameQualifierAsTheClass = new Rule() { + @Override + public JsNameRef apply(@NotNull DeclarationDescriptor descriptor) { + if (!(descriptor instanceof ConstructorDescriptor)) { + return null; + } + ClassDescriptor containingClass = getContainingClass(descriptor); + assert containingClass != null : "Can't have constructor without a class"; + return getQualifierForDescriptor(containingClass); + } + }; + Rule libraryObjectsHaveKotlinQualifier = new Rule() { + + @Override + public JsNameRef apply(@NotNull DeclarationDescriptor descriptor) { + if (getAnnotationByName(descriptor, AnnotationsUtils.LIBRARY_ANNOTATION_FQNAME) != null) { + return namer.kotlinObject(); + } + return null; + } + }; + Rule membersOfAnnotatedClassesHaveKotlinQualifier = new Rule() { + @Override + public JsNameRef apply(@NotNull DeclarationDescriptor descriptor) { + ClassDescriptor containingClass = getContainingClass(descriptor); + if (containingClass == null) { + return null; + } + if (getAnnotationByName(descriptor, LIBRARY_ANNOTATION_FQNAME) != null) { + return namer.kotlinObject(); + } + return null; + } + }; + addRule(libraryObjectsHaveKotlinQualifier); + addRule(membersOfAnnotatedClassesHaveKotlinQualifier); + addRule(constructorHaveTheSameQualifierAsTheClass); + addRule(namespacesHaveNoQualifiers); + addRule(namespaceLevelDeclarationsHaveEnclosingNamespacesNamesAsQualifier); + } + } + + private class QualifierIsNullGenerator extends Generator { + + private QualifierIsNullGenerator() { + Rule propertiesHaveNoQualifiers = new Rule() { + @Override + public Boolean apply(@NotNull DeclarationDescriptor descriptor) { + if (!(descriptor instanceof PropertyDescriptor)) { + return null; + } + return true; + } + }; + Rule variableAsFunctionsHaveNoQualifiers = new Rule() { + @Override + public Boolean apply(@NotNull DeclarationDescriptor descriptor) { + if (!isVariableAsFunction(descriptor)) { + return null; + } + return true; + } + }; + //TODO: hack! + Rule nativeObjectsHaveNoQualifiers = new Rule() { + @Override + public Boolean apply(@NotNull DeclarationDescriptor descriptor) { + if (!AnnotationsUtils.isNativeObject(descriptor)) { + return null; + } + return true; + } + }; + addRule(propertiesHaveNoQualifiers); + addRule(variableAsFunctionsHaveNoQualifiers); + addRule(nativeObjectsHaveNoQualifiers); + } + } +} \ No newline at end of file diff --git a/translator/src/org/jetbrains/k2js/translate/context/TemporaryVariable.java b/translator/src/org/jetbrains/k2js/translate/context/TemporaryVariable.java new file mode 100644 index 00000000000..09c6929cf9d --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/context/TemporaryVariable.java @@ -0,0 +1,54 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.context; + +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.util.AstUtil; +import org.jetbrains.annotations.NotNull; + +/** + * @author Pavel Talanov + */ +public final class TemporaryVariable { + + @NotNull + private final JsExpression assignmentExpression; + @NotNull + private final JsName variableName; + + /*package*/ TemporaryVariable(@NotNull JsName temporaryName, @NotNull JsExpression initExpression) { + this.variableName = temporaryName; + this.assignmentExpression = AstUtil.newAssignment(variableName.makeRef(), initExpression); + } + + @NotNull + public JsNameRef nameReference() { + return variableName.makeRef(); + } + + @NotNull + public JsName name() { + return variableName; + } + + @NotNull + public JsExpression assignmentExpression() { + return assignmentExpression; + } +} \ No newline at end of file diff --git a/translator/src/org/jetbrains/k2js/translate/context/TranslationContext.java b/translator/src/org/jetbrains/k2js/translate/context/TranslationContext.java new file mode 100644 index 00000000000..e28a0332e0b --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/context/TranslationContext.java @@ -0,0 +1,155 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.context; + +import com.google.dart.compiler.backend.js.ast.*; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.k2js.translate.intrinsic.Intrinsics; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.getDescriptorForElement; + +/** + * @author Pavel Talanov + *

+ * All the info about the state of the translation process. + */ +public final class TranslationContext { + + @NotNull + private final DynamicContext dynamicContext; + @NotNull + private final StaticContext staticContext; + + @NotNull + public static TranslationContext rootContext(@NotNull StaticContext staticContext) { + JsProgram program = staticContext.getProgram(); + JsBlock globalBlock = program.getGlobalBlock(); + return new TranslationContext(staticContext, + DynamicContext.rootContext(staticContext.getRootScope(), globalBlock)); + } + + private TranslationContext(@NotNull StaticContext staticContext, @NotNull DynamicContext dynamicContext) { + this.dynamicContext = dynamicContext; + this.staticContext = staticContext; + } + + @NotNull + public TranslationContext contextWithScope(@NotNull NamingScope newScope) { + return new TranslationContext(staticContext, DynamicContext.contextWithScope(newScope)); + } + + // Note: Should be used ONLY if scope has no corresponding descriptor + @NotNull + public TranslationContext innerJsScope(@NotNull JsScope enclosingScope) { + return new TranslationContext(staticContext, dynamicContext.innerScope(enclosingScope)); + } + + @NotNull + public TranslationContext innerBlock(@NotNull JsBlock block) { + return new TranslationContext(staticContext, dynamicContext.innerBlock(block)); + } + + @NotNull + public TranslationContext newDeclaration(@NotNull DeclarationDescriptor descriptor) { + return contextWithScope(getScopeForDescriptor(descriptor)); + } + + @NotNull + public TranslationContext newDeclaration(@NotNull PsiElement element) { + return newDeclaration(getDescriptorForElement(bindingContext(), element)); + } + + @NotNull + public BindingContext bindingContext() { + return staticContext.getBindingContext(); + } + + @NotNull + public NamingScope getScopeForDescriptor(@NotNull DeclarationDescriptor descriptor) { + return staticContext.getScopeForDescriptor(descriptor); + } + + @NotNull + public NamingScope getScopeForElement(@NotNull PsiElement element) { + DeclarationDescriptor descriptorForElement = getDescriptorForElement(bindingContext(), element); + return getScopeForDescriptor(descriptorForElement); + } + + @NotNull + public JsName getNameForElement(@NotNull PsiElement element) { + DeclarationDescriptor descriptor = getDescriptorForElement(bindingContext(), element); + return getNameForDescriptor(descriptor); + } + + @NotNull + public JsName getNameForDescriptor(@NotNull DeclarationDescriptor descriptor) { + return staticContext.getNameForDescriptor(descriptor); + } + + @Nullable + public JsNameRef getQualifierForDescriptor(@NotNull DeclarationDescriptor descriptor) { + return staticContext.getQualifierForDescriptor(descriptor.getOriginal()); + } + + @NotNull + public TemporaryVariable declareTemporary(@NotNull JsExpression initExpression) { + return dynamicContext.declareTemporary(initExpression); + } + + @NotNull + public Aliaser aliaser() { + return staticContext.getAliaser(); + } + + @NotNull + public Namer namer() { + return staticContext.getNamer(); + } + + @NotNull + public Intrinsics intrinsics() { + return staticContext.getIntrinsics(); + } + + @NotNull + public JsProgram program() { + return staticContext.getProgram(); + } + + @NotNull + private StandardClasses standardClasses() { + return staticContext.getStandardClasses(); + } + + @NotNull + public NamingScope getScope() { + return dynamicContext.getScope(); + } + + @NotNull + public JsScope jsScope() { + return dynamicContext.jsScope(); + } + + public void addStatementToCurrentBlock(@NotNull JsStatement statement) { + dynamicContext.jsBlock().addStatement(statement); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/context/generator/Generator.java b/translator/src/org/jetbrains/k2js/translate/context/generator/Generator.java new file mode 100644 index 00000000000..720e3a8d7e1 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/context/generator/Generator.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.context.generator; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; + +import java.util.List; +import java.util.Map; + +/** + * @author Pavel Talanov + */ +public class Generator { + + + @NotNull + private final Map values = Maps.newHashMap(); + @NotNull + private final List> rules = Lists.newArrayList(); + + public void addRule(@NotNull Rule rule) { + rules.add(rule); + } + + @Nullable + public V get(@NotNull DeclarationDescriptor descriptor) { + V result = values.get(descriptor); + if (result != null) { + return result; + } + result = generate(descriptor); + values.put(descriptor, result); + return result; + } + + @Nullable + private V generate(@NotNull DeclarationDescriptor descriptor) { + V result = null; + for (Rule rule : rules) { + result = rule.apply(descriptor); + if (result != null) { + return result; + } + } + return result; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/context/generator/Rule.java b/translator/src/org/jetbrains/k2js/translate/context/generator/Rule.java new file mode 100644 index 00000000000..e3550578ef5 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/context/generator/Rule.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.context.generator; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; + +/** + * @author Pavel Talanov + */ +public interface Rule { + + @Nullable + V apply(@NotNull DeclarationDescriptor descriptor); +} diff --git a/translator/src/org/jetbrains/k2js/translate/declaration/ClassDeclarationTranslator.java b/translator/src/org/jetbrains/k2js/translate/declaration/ClassDeclarationTranslator.java new file mode 100644 index 00000000000..fd110f10e7a --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/declaration/ClassDeclarationTranslator.java @@ -0,0 +1,167 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.declaration; + +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.ClassDescriptor; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.psi.JetClass; +import org.jetbrains.k2js.translate.context.Namer; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.utils.BindingUtils; +import org.jetbrains.k2js.translate.utils.ClassSorter; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getAllClassesDefinedInNamespace; + +/** + * @author Pavel Talanov + *

+ * Generates a big block where are all the classes(objects representing them) are created. + */ +public final class ClassDeclarationTranslator extends AbstractTranslator { + + @NotNull + private final List descriptors; + @NotNull + private final Map localToGlobalClassName; + @NotNull + private final JsScope dummyFunctionScope; + @Nullable + private JsName declarationsObject = null; + @Nullable + private JsStatement declarationsStatement = null; + + public ClassDeclarationTranslator(@NotNull List descriptors, + @NotNull TranslationContext context) { + super(context); + this.descriptors = descriptors; + this.localToGlobalClassName = new HashMap(); + this.dummyFunctionScope = new JsScope(context().jsScope(), "class declaration function"); + } + + public void generateDeclarations() { + declarationsObject = context().jsScope().declareName(Namer.nameForClassesVariable()); + assert declarationsObject != null; + declarationsStatement = + AstUtil.newVar(declarationsObject, generateDummyFunctionInvocation()); + } + + @NotNull + public JsName getDeclarationsObjectName() { + assert declarationsObject != null : "Should run generateDeclarations first"; + return declarationsObject; + } + + @NotNull + public JsStatement getDeclarationsStatement() { + assert declarationsStatement != null : "Should run generateDeclarations first"; + return declarationsStatement; + } + + @NotNull + private JsInvocation generateDummyFunctionInvocation() { + JsFunction dummyFunction = JsFunction.getAnonymousFunctionWithScope(dummyFunctionScope); + List classDeclarations = generateClassDeclarationStatements(); + classDeclarations.add(new JsReturn(generateReturnedObjectLiteral())); + dummyFunction.setBody(AstUtil.newBlock(classDeclarations)); + return AstUtil.newInvocation(dummyFunction); + } + + @NotNull + private JsObjectLiteral generateReturnedObjectLiteral() { + JsObjectLiteral returnedValueLiteral = new JsObjectLiteral(); + for (JsName localName : localToGlobalClassName.keySet()) { + returnedValueLiteral.getPropertyInitializers().add(classEntry(localName)); + } + return returnedValueLiteral; + } + + @NotNull + private JsPropertyInitializer classEntry(@NotNull JsName localName) { + return new JsPropertyInitializer(localToGlobalClassName.get(localName).makeRef(), localName.makeRef()); + } + + @NotNull + private List generateClassDeclarationStatements() { + List classDeclarations = new ArrayList(); + for (JetClass jetClass : getClassDeclarations()) { + classDeclarations.add(generateDeclaration(jetClass)); + } + removeAliases(); + return classDeclarations; + } + + private void removeAliases() { + for (JetClass jetClass : getClassDeclarations()) { + ClassDescriptor descriptor = BindingUtils.getClassDescriptor(context().bindingContext(), jetClass); + context().aliaser().removeAliasForDescriptor(descriptor); + } + } + + @NotNull + private List getClassDeclarations() { + List classes = new ArrayList(); + for (ClassDescriptor classDescriptor : descriptors) { + classes.add(BindingUtils.getClassForDescriptor(context().bindingContext(), classDescriptor)); + } + return ClassSorter.sortUsingInheritanceOrder(classes, context().bindingContext()); + } + + @NotNull + private JsStatement generateDeclaration(@NotNull JetClass declaration) { + JsName localClassName = generateLocalAlias(declaration); + JsInvocation classDeclarationExpression = + Translation.translateClassDeclaration(declaration, context()); + return AstUtil.newVar(localClassName, classDeclarationExpression); + } + + @NotNull + private JsName generateLocalAlias(@NotNull JetClass declaration) { + JsName globalClassName = context().getNameForElement(declaration); + JsName localAlias = dummyFunctionScope.declareTemporary(); + localToGlobalClassName.put(localAlias, globalClassName); + ClassDescriptor descriptor = BindingUtils.getClassDescriptor(context().bindingContext(), declaration); + context().aliaser().setAliasForDescriptor(descriptor, localAlias); + return localAlias; + } + + @NotNull + public JsObjectLiteral classDeclarationsForNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) { + JsObjectLiteral result = new JsObjectLiteral(); + for (ClassDescriptor classDescriptor : getAllClassesDefinedInNamespace(namespaceDescriptor)) { + result.getPropertyInitializers().add(getClassNameToClassObject(classDescriptor)); + } + return result; + } + + @NotNull + private JsPropertyInitializer getClassNameToClassObject(@NotNull ClassDescriptor classDescriptor) { + JsName className = context().getNameForDescriptor(classDescriptor); + JsNameRef alreadyDefinedClassReferernce = AstUtil.qualified(className, getDeclarationsObjectName().makeRef()); + return new JsPropertyInitializer(className.makeRef(), alreadyDefinedClassReferernce); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/declaration/ClassTranslator.java b/translator/src/org/jetbrains/k2js/translate/declaration/ClassTranslator.java new file mode 100644 index 00000000000..7469159224a --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/declaration/ClassTranslator.java @@ -0,0 +1,181 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.declaration; + +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.ClassDescriptor; +import org.jetbrains.jet.lang.descriptors.ClassKind; +import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; +import org.jetbrains.jet.lang.psi.JetClassOrObject; +import org.jetbrains.jet.lang.psi.JetParameter; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; + +import java.util.ArrayList; +import java.util.List; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.getClassDescriptor; +import static org.jetbrains.k2js.translate.utils.BindingUtils.getPropertyDescriptorForConstructorParameter; +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.findAncestorClass; +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getSuperclassDescriptors; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getPrimaryConstructorParameters; + +/** + * @author Pavel Talanov + *

+ * Generates a definition of a single class. + */ +public final class ClassTranslator extends AbstractTranslator { + + @NotNull + public static JsPropertyInitializer translateAsProperty(@NotNull JetClassOrObject classDeclaration, + @NotNull TranslationContext context) { + JsInvocation classCreationExpression = generateClassCreationExpression(classDeclaration, context); + JsName className = context.getNameForElement(classDeclaration); + return new JsPropertyInitializer(className.makeRef(), classCreationExpression); + } + + @NotNull + public static JsInvocation generateClassCreationExpression(@NotNull JetClassOrObject classDeclaration, + @NotNull TranslationContext context) { + return (new ClassTranslator(classDeclaration, context)).translateClass(); + } + + @NotNull + private final DeclarationBodyVisitor declarationBodyVisitor = new DeclarationBodyVisitor(); + + @NotNull + private final JetClassOrObject classDeclaration; + + @NotNull + private final ClassDescriptor descriptor; + + private ClassTranslator(@NotNull JetClassOrObject classDeclaration, @NotNull TranslationContext context) { + super(context.newDeclaration(classDeclaration)); + this.descriptor = getClassDescriptor(context.bindingContext(), classDeclaration); + this.classDeclaration = classDeclaration; + } + + @NotNull + private JsInvocation translateClass() { + JsInvocation jsClassDeclaration = classCreateMethodInvocation(); + addSuperclassReferences(jsClassDeclaration); + addClassOwnDeclarations(jsClassDeclaration); + return jsClassDeclaration; + } + + @NotNull + private JsInvocation classCreateMethodInvocation() { + if (isObject()) { + return AstUtil.newInvocation(context().namer().objectCreationMethodReference()); + } else if (isTrait()) { + return AstUtil.newInvocation(context().namer().traitCreationMethodReference()); + } else { + return AstUtil.newInvocation(context().namer().classCreationMethodReference()); + } + } + + private boolean isObject() { + return descriptor.getKind().equals(ClassKind.OBJECT); + } + + private boolean isTrait() { + return descriptor.getKind().equals(ClassKind.TRAIT); + } + + private void addClassOwnDeclarations(@NotNull JsInvocation jsClassDeclaration) { + JsObjectLiteral jsClassDescription = translateClassDeclarations(); + jsClassDeclaration.getArguments().add(jsClassDescription); + } + + private void addSuperclassReferences(@NotNull JsInvocation jsClassDeclaration) { + for (JsExpression superClassReference : getSuperclassNameReferences()) { + jsClassDeclaration.getArguments().add(superClassReference); + } + } + + @NotNull + private List getSuperclassNameReferences() { + List superclassReferences = new ArrayList(); + List superclassDescriptors = getSuperclassDescriptors(descriptor); + addAncestorClass(superclassReferences, superclassDescriptors); + addTraits(superclassReferences, superclassDescriptors); + return superclassReferences; + } + + private void addTraits(@NotNull List superclassReferences, + @NotNull List superclassDescriptors) { + for (ClassDescriptor superClassDescriptor : + superclassDescriptors) { + assert (superClassDescriptor.getKind() == ClassKind.TRAIT) : "Only traits are expected here"; + superclassReferences.add(getClassReference(superClassDescriptor)); + } + } + + private void addAncestorClass(@NotNull List superclassReferences, + @NotNull List superclassDescriptors) { + //here we remove ancestor class from the list + ClassDescriptor ancestorClass = findAndRemoveAncestorClass(superclassDescriptors); + if (ancestorClass != null) { + superclassReferences.add(getClassReference(ancestorClass)); + } + } + + @NotNull + private JsExpression getClassReference(@NotNull ClassDescriptor superClassDescriptor) { + //NOTE: aliasing here is needed for the declaration generation step + if (context().aliaser().hasAliasForDeclaration(superClassDescriptor)) { + return context().aliaser().getAliasForDeclaration(superClassDescriptor).makeRef(); + } + return context().getNameForDescriptor(superClassDescriptor).makeRef(); + } + + @Nullable + private ClassDescriptor findAndRemoveAncestorClass(@NotNull List superclassDescriptors) { + ClassDescriptor ancestorClass = findAncestorClass(superclassDescriptors); + superclassDescriptors.remove(ancestorClass); + return ancestorClass; + } + + @NotNull + private JsObjectLiteral translateClassDeclarations() { + List propertyList = new ArrayList(); + if (!isTrait()) { + propertyList.add(Translation.generateClassInitializerMethod(classDeclaration, context())); + } + propertyList.addAll(translatePropertiesAsConstructorParameters()); + propertyList.addAll(declarationBodyVisitor.traverseClass(classDeclaration, context())); + return new JsObjectLiteral(propertyList); + } + + @NotNull + private List translatePropertiesAsConstructorParameters() { + List result = new ArrayList(); + for (JetParameter parameter : getPrimaryConstructorParameters(classDeclaration)) { + PropertyDescriptor descriptor = + getPropertyDescriptorForConstructorParameter(context().bindingContext(), parameter); + if (descriptor != null) { + result.addAll(PropertyTranslator.translateAccessors(descriptor, context())); + } + } + return result; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/declaration/DeclarationBodyVisitor.java b/translator/src/org/jetbrains/k2js/translate/declaration/DeclarationBodyVisitor.java new file mode 100644 index 00000000000..2cdb5629247 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/declaration/DeclarationBodyVisitor.java @@ -0,0 +1,107 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.declaration; + +import com.google.dart.compiler.backend.js.ast.JsPropertyInitializer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.general.TranslatorVisitor; +import org.jetbrains.k2js.translate.utils.BindingUtils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.getDeclarationsForNamespace; +import static org.jetbrains.k2js.translate.utils.BindingUtils.getPropertyDescriptorForObjectDeclaration; + +/** + * @author Pavel Talanov + */ +public final class DeclarationBodyVisitor extends TranslatorVisitor> { + + + @NotNull + public List traverseClass(@NotNull JetClassOrObject jetClass, + @NotNull TranslationContext context) { + List properties = new ArrayList(); + for (JetDeclaration declaration : jetClass.getDeclarations()) { + properties.addAll(declaration.accept(this, context)); + } + return properties; + } + + @NotNull + public List traverseNamespace(@NotNull NamespaceDescriptor namespace, + @NotNull TranslationContext context) { + List properties = new ArrayList(); + for (JetDeclaration declaration : getDeclarationsForNamespace(context.bindingContext(), namespace)) { + properties.addAll(declaration.accept(this, context)); + } + return properties; + } + + @Override + @NotNull + public List visitClass(@NotNull JetClass expression, @NotNull TranslationContext context) { + return Collections.emptyList(); + } + + @Override + @NotNull + public List visitNamedFunction(@NotNull JetNamedFunction expression, + @NotNull TranslationContext context) { + return Collections.singletonList(Translation.functionTranslator(expression, context).translateAsMethod()); + } + + @Override + @NotNull + public List visitProperty(@NotNull JetProperty expression, + @NotNull TranslationContext context) { + PropertyDescriptor propertyDescriptor = + BindingUtils.getPropertyDescriptor(context.bindingContext(), expression); + return PropertyTranslator.translateAccessors(propertyDescriptor, context); + } + + @Override + @NotNull + public List visitObjectDeclaration(@NotNull JetObjectDeclaration expression, + @NotNull TranslationContext context) { + return Collections.singletonList(ClassTranslator.translateAsProperty(expression, context)); + } + + @Override + @NotNull + public List visitObjectDeclarationName(@NotNull JetObjectDeclarationName expression, + @NotNull TranslationContext context) { + PropertyDescriptor propertyDescriptor = + getPropertyDescriptorForObjectDeclaration(context.bindingContext(), expression); + return PropertyTranslator.translateAccessors(propertyDescriptor, context); + } + + @Override + @NotNull + public List visitAnonymousInitializer(@NotNull JetClassInitializer expression, + @NotNull TranslationContext context) { + // parsed it in initializer visitor => no additional actions are needed + return Collections.emptyList(); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/declaration/NamespaceDeclarationTranslator.java b/translator/src/org/jetbrains/k2js/translate/declaration/NamespaceDeclarationTranslator.java new file mode 100644 index 00000000000..9b748e511f2 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/declaration/NamespaceDeclarationTranslator.java @@ -0,0 +1,112 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.declaration; + +import com.google.common.collect.Lists; +import com.google.dart.compiler.backend.js.ast.JsStatement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.ClassDescriptor; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; + +import java.util.List; +import java.util.Set; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.getAllNonNativeNamespaceDescriptors; +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getAllClassesDefinedInNamespace; + +/** + * @author Pavel Talanov + */ +public final class NamespaceDeclarationTranslator extends AbstractTranslator { + + public static List translateFiles(@NotNull List files, @NotNull TranslationContext context) { + Set namespaceDescriptorSet = getAllNonNativeNamespaceDescriptors(context.bindingContext(), files); + return (new NamespaceDeclarationTranslator(Lists.newArrayList(namespaceDescriptorSet), context)).translate(); + } + + @NotNull + private final ClassDeclarationTranslator classDeclarationTranslator; + @NotNull + private final List namespaceDescriptors; + + private NamespaceDeclarationTranslator(@NotNull List namespaceDescriptors, + @NotNull TranslationContext context) { + super(context); + this.namespaceDescriptors = namespaceDescriptors; + this.classDeclarationTranslator = new ClassDeclarationTranslator(getAllClasses(), context); + } + + @NotNull + private List getAllClasses() { + List result = Lists.newArrayList(); + for (NamespaceDescriptor namespaceDescriptor : namespaceDescriptors) { + result.addAll(getAllClassesDefinedInNamespace(namespaceDescriptor)); + } + return result; + } + + //TODO: logic seems not so clear, may be a couple of extract method should help + @NotNull + private List translate() { + classDeclarationTranslator.generateDeclarations(); + List result = Lists.newArrayList(); + result.add(classDeclarationsStatement()); + List namespaceTranslators = getTranslatorsForNonEmptyNamespaces(); + result.addAll(declarationStatements(namespaceTranslators)); + result.addAll(initializeStatements(namespaceTranslators)); + return result; + } + + @NotNull + private JsStatement classDeclarationsStatement() { + return classDeclarationTranslator.getDeclarationsStatement(); + } + + @NotNull + private List getTranslatorsForNonEmptyNamespaces() { + List namespaceTranslators = Lists.newArrayList(); + for (NamespaceDescriptor descriptor : namespaceDescriptors) { + NamespaceTranslator namespaceTranslator = + new NamespaceTranslator(descriptor, classDeclarationTranslator, context()); + if (!namespaceTranslator.isNamespaceEmpty()) { + namespaceTranslators.add(namespaceTranslator); + } + } + return namespaceTranslators; + } + + @NotNull + private List declarationStatements(@NotNull List namespaceTranslators) { + List result = Lists.newArrayList(); + for (NamespaceTranslator translator : namespaceTranslators) { + result.add(translator.getDeclarationStatement()); + } + return result; + } + + @NotNull + private List initializeStatements(@NotNull List namespaceTranslators) { + List result = Lists.newArrayList(); + for (NamespaceTranslator translator : namespaceTranslators) { + result.add(translator.getInitializeStatement()); + } + return result; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/declaration/NamespaceTranslator.java b/translator/src/org/jetbrains/k2js/translate/declaration/NamespaceTranslator.java new file mode 100644 index 00000000000..3f82a727606 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/declaration/NamespaceTranslator.java @@ -0,0 +1,98 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.declaration; + +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.descriptors.NamespaceDescriptor; +import org.jetbrains.k2js.translate.context.Namer; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.utils.BindingUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Pavel.Talanov + *

+ * Genereate code for a single descriptor. + */ +public final class NamespaceTranslator extends AbstractTranslator { + + @NotNull + private final NamespaceDescriptor descriptor; + @NotNull + private final JsName namespaceName; + @NotNull + private final ClassDeclarationTranslator classDeclarationTranslator; + + /*package*/ NamespaceTranslator(@NotNull NamespaceDescriptor descriptor, + @NotNull ClassDeclarationTranslator classDeclarationTranslator, + @NotNull TranslationContext context) { + super(context.newDeclaration(descriptor)); + this.descriptor = descriptor; + this.namespaceName = context.getNameForDescriptor(descriptor); + this.classDeclarationTranslator = classDeclarationTranslator; + } + + //TODO: at the moment this check is very ineffective, possible solution is to cash the result of getDFN + // other solution is to determine it's not affecting performance :D + public boolean isNamespaceEmpty() { + return BindingUtils.getDeclarationsForNamespace(context().bindingContext(), descriptor).isEmpty(); + } + + + @NotNull + public JsStatement getInitializeStatement() { + JsNameRef initializeMethodReference = Namer.initializeMethodReference(); + AstUtil.setQualifier(initializeMethodReference, namespaceName.makeRef()); + return AstUtil.newInvocation(initializeMethodReference).makeStmt(); + } + + @NotNull + private JsInvocation namespaceCreateMethodInvocation() { + return AstUtil.newInvocation(context().namer().namespaceCreationMethodReference()); + } + + @NotNull + public JsStatement getDeclarationStatement() { + JsInvocation namespaceDeclaration = namespaceCreateMethodInvocation(); + addMemberDeclarations(namespaceDeclaration); + addClassesDeclarations(namespaceDeclaration); + return AstUtil.newVar(namespaceName, namespaceDeclaration); + } + + private void addClassesDeclarations(@NotNull JsInvocation namespaceDeclaration) { + namespaceDeclaration.getArguments().add(classDeclarationTranslator.classDeclarationsForNamespace(descriptor)); + } + + private void addMemberDeclarations(@NotNull JsInvocation jsNamespace) { + JsObjectLiteral jsClassDescription = translateNamespaceMemberDeclarations(); + jsNamespace.getArguments().add(jsClassDescription); + } + + @NotNull + private JsObjectLiteral translateNamespaceMemberDeclarations() { + List propertyList = new ArrayList(); + propertyList.add(Translation.generateNamespaceInitializerMethod(descriptor, context())); + propertyList.addAll(new DeclarationBodyVisitor().traverseNamespace(descriptor, context())); + return new JsObjectLiteral(propertyList); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/declaration/PropertyTranslator.java b/translator/src/org/jetbrains/k2js/translate/declaration/PropertyTranslator.java new file mode 100644 index 00000000000..610d6396b24 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/declaration/PropertyTranslator.java @@ -0,0 +1,158 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.declaration; + +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; +import org.jetbrains.jet.lang.descriptors.PropertyGetterDescriptor; +import org.jetbrains.jet.lang.descriptors.PropertySetterDescriptor; +import org.jetbrains.jet.lang.psi.JetProperty; +import org.jetbrains.jet.lang.psi.JetPropertyAccessor; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.utils.BindingUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.jetbrains.k2js.translate.utils.TranslationUtils.*; + +/** + * @author Pavel Talanov + *

+ * Translates single property /w accessors. + */ +public final class PropertyTranslator extends AbstractTranslator { + + @NotNull + private final PropertyDescriptor property; + @NotNull + private final List accessors = new ArrayList(); + @Nullable + private final JetProperty declaration; + + static public List translateAccessors(@NotNull PropertyDescriptor descriptor, + @NotNull TranslationContext context) { + PropertyTranslator propertyTranslator = new PropertyTranslator(descriptor, context); + return propertyTranslator.translate(); + } + + private PropertyTranslator(@NotNull PropertyDescriptor property, @NotNull TranslationContext context) { + super(context); + this.property = property; + this.declaration = BindingUtils.getPropertyForDescriptor(context().bindingContext(), property); + } + + @NotNull + private List translate() { + addGetter(); + if (property.isVar()) { + addSetter(); + } + return accessors; + } + + private void addGetter() { + if (hasCustomGetter()) { + accessors.add(translateCustomAccessor(getCustomGetterDeclaration())); + } else { + accessors.add(generateDefaultGetter()); + } + } + + private void addSetter() { + if (hasCustomSetter()) { + accessors.add(translateCustomAccessor(getCustomSetterDeclaration())); + } else { + accessors.add(generateDefaultSetter()); + } + } + + private boolean hasCustomGetter() { + return ((declaration != null) && (declaration.getGetter() != null)); + } + + private boolean hasCustomSetter() { + return ((declaration != null) && (declaration.getSetter() != null)); + } + + @NotNull + private JetPropertyAccessor getCustomGetterDeclaration() { + assert declaration != null; + JetPropertyAccessor getterDeclaration = declaration.getGetter(); + assert getterDeclaration != null; + return getterDeclaration; + } + + @NotNull + private JetPropertyAccessor getCustomSetterDeclaration() { + assert declaration != null; + JetPropertyAccessor setter = declaration.getSetter(); + assert setter != null; + return setter; + } + + @NotNull + private JsPropertyInitializer generateDefaultGetter() { + PropertyGetterDescriptor getterDescriptor = property.getGetter(); + assert getterDescriptor != null : "Getter descriptor should not be null"; + return AstUtil.newNamedMethod(context().getNameForDescriptor(getterDescriptor), + generateDefaultGetterFunction(getterDescriptor)); + } + + @NotNull + private JsFunction generateDefaultGetterFunction(@NotNull PropertyGetterDescriptor descriptor) { + JsReturn returnExpression = new JsReturn(backingFieldReference(context(), property)); + JsFunction getterFunction = functionWithScope(context().getScopeForDescriptor(descriptor)); + getterFunction.setBody(AstUtil.convertToBlock(returnExpression)); + return getterFunction; + } + + @NotNull + private JsPropertyInitializer generateDefaultSetter() { + PropertySetterDescriptor setterDescriptor = property.getSetter(); + assert setterDescriptor != null : "Setter descriptor should not be null"; + return AstUtil.newNamedMethod(context().getNameForDescriptor(setterDescriptor), + generateDefaultSetterFunction(setterDescriptor)); + } + + @NotNull + private JsFunction generateDefaultSetterFunction(@NotNull PropertySetterDescriptor propertySetterDescriptor) { + JsFunction result = functionWithScope(context().getScopeForDescriptor(propertySetterDescriptor)); + JsParameter defaultParameter = + new JsParameter(propertyAccessContext(propertySetterDescriptor).jsScope().declareTemporary()); + JsStatement assignment = assignmentToBackingField(context(), property, defaultParameter.getName().makeRef()); + result.setParameters(Arrays.asList(defaultParameter)); + result.setBody(AstUtil.convertToBlock(assignment)); + return result; + } + + @NotNull + private TranslationContext propertyAccessContext(@NotNull PropertySetterDescriptor propertySetterDescriptor) { + return context().newDeclaration(propertySetterDescriptor); + } + + @NotNull + private JsPropertyInitializer translateCustomAccessor(@NotNull JetPropertyAccessor expression) { + return Translation.functionTranslator(expression, context()).translateAsMethod(); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/expression/ExpressionVisitor.java b/translator/src/org/jetbrains/k2js/translate/expression/ExpressionVisitor.java new file mode 100644 index 00000000000..f1b74b5b9d1 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/expression/ExpressionVisitor.java @@ -0,0 +1,419 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.expression; + +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +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.lang.resolve.constants.NullValue; +import org.jetbrains.k2js.translate.context.TemporaryVariable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.declaration.ClassTranslator; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.general.TranslatorVisitor; +import org.jetbrains.k2js.translate.operation.BinaryOperationTranslator; +import org.jetbrains.k2js.translate.operation.IncrementTranslator; +import org.jetbrains.k2js.translate.operation.UnaryOperationTranslator; +import org.jetbrains.k2js.translate.reference.*; +import org.jetbrains.k2js.translate.utils.BindingUtils; +import org.jetbrains.k2js.translate.utils.TranslationUtils; + +import java.util.List; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.*; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getObjectDeclarationName; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.translateInitializerForProperty; + +/** + * @author Pavel Talanov + */ +public final class ExpressionVisitor extends TranslatorVisitor { + + @NotNull + private JsExpression translateAsExpression(@NotNull JetExpression expression, + @NotNull TranslationContext context) { + return AstUtil.convertToExpression(expression.accept(this, context)); + } + + @Override + @NotNull + public JsNode visitConstantExpression(@NotNull JetConstantExpression expression, + @NotNull TranslationContext context) { + CompileTimeConstant compileTimeValue = + context.bindingContext().get(BindingContext.COMPILE_TIME_VALUE, expression); + assert compileTimeValue != null; + if (compileTimeValue instanceof NullValue) { + return context.program().getNullLiteral(); + } + Object value = compileTimeValue.getValue(); + if (value instanceof Integer) { + return context.program().getNumberLiteral((Integer) value); + } + if (value instanceof Boolean) { + return context.program().getBooleanLiteral((Boolean) value); + } + + //TODO: test + if (value instanceof Float) { + return context.program().getNumberLiteral((Float) value); + } + if (value instanceof Double) { + return context.program().getNumberLiteral((Double) value); + } + if (value instanceof String) { + return context.program().getStringLiteral((String) value); + } + if (value instanceof Character) { + return context.program().getStringLiteral(value.toString()); + } + //TODO: all values + throw new AssertionError("Unsupported constant expression" + expression.toString()); + } + + @Override + @NotNull + public JsNode visitBlockExpression(@NotNull JetBlockExpression jetBlock, @NotNull TranslationContext context) { + List statements = jetBlock.getStatements(); + JsBlock jsBlock = new JsBlock(); + TranslationContext blockContext = context.innerBlock(jsBlock); + for (JetElement statement : statements) { + assert statement instanceof JetExpression : "Elements in JetBlockExpression " + + "should be of type JetExpression"; + JsNode jsNode = statement.accept(this, blockContext); + jsBlock.addStatement(AstUtil.convertToStatement(jsNode)); + } + return jsBlock; + } + + @Override + @NotNull + public JsNode visitReturnExpression(@NotNull JetReturnExpression jetReturnExpression, + @NotNull TranslationContext context) { + JetExpression returnedExpression = jetReturnExpression.getReturnedExpression(); + if (returnedExpression != null) { + JsExpression jsExpression = translateAsExpression(returnedExpression, context); + return new JsReturn(jsExpression); + } + return new JsReturn(); + } + + @Override + @NotNull + public JsNode visitParenthesizedExpression(@NotNull JetParenthesizedExpression expression, + @NotNull TranslationContext context) { + JetExpression expressionInside = expression.getExpression(); + if (expressionInside != null) { + return expressionInside.accept(this, context); + } + return context.program().getEmptyStmt(); + } + + @Override + @NotNull + public JsNode visitBinaryExpression(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + return BinaryOperationTranslator.translate(expression, context); + } + + @Override + @NotNull + // assume it is a local variable declaration + public JsNode visitProperty(@NotNull JetProperty expression, @NotNull TranslationContext context) { + DeclarationDescriptor descriptor = getDescriptorForElement(context.bindingContext(), expression); + JsName jsPropertyName = context.getNameForDescriptor(descriptor); + JsExpression jsInitExpression = translateInitializerForProperty(expression, context); + return AstUtil.newVar(jsPropertyName, jsInitExpression); + } + + @Override + @NotNull + public JsNode visitCallExpression(@NotNull JetCallExpression expression, + @NotNull TranslationContext context) { + return CallExpressionTranslator.translate(expression, null, CallType.NORMAL, context); + } + + @Override + @NotNull + public JsNode visitIfExpression(@NotNull JetIfExpression expression, @NotNull TranslationContext context) { + JsIf ifStatement = translateAsIfStatement(expression, context); + if (BindingUtils.isStatement(context.bindingContext(), expression)) { + return ifStatement; + } + TemporaryVariable result = context.declareTemporary(context.program().getNullLiteral()); + AstUtil.SaveLastExpressionMutator saveResultToTemporaryMutator = + new AstUtil.SaveLastExpressionMutator(result.nameReference()); + JsNode mutatedIfStatement = AstUtil.mutateLastExpression(ifStatement, + saveResultToTemporaryMutator); + JsStatement resultingStatement = AstUtil.convertToStatement(mutatedIfStatement); + context.addStatementToCurrentBlock(resultingStatement); + return result.nameReference(); + } + + @Override + @NotNull + public JsNode visitSimpleNameExpression(@NotNull JetSimpleNameExpression expression, + @NotNull TranslationContext context) { + return ReferenceTranslator.translateSimpleName(expression, context); + } + + + @NotNull + private JsIf translateAsIfStatement(@NotNull JetIfExpression expression, + @NotNull TranslationContext context) { + JsIf result = new JsIf(); + result.setIfExpr(translateConditionExpression(expression.getCondition(), context)); + result.setThenStmt(translateNullableExpressionAsNotNullStatement(expression.getThen(), context)); + result.setElseStmt(translateElseAsStatement(expression, context)); + return result; + } + + @Nullable + private JsStatement translateElseAsStatement(@NotNull JetIfExpression expression, + @NotNull TranslationContext context) { + JetExpression jetElse = expression.getElse(); + if (jetElse == null) { + return null; + } + return AstUtil.convertToStatement(jetElse.accept(this, context)); + } + + @NotNull + private JsStatement translateNullableExpressionAsNotNullStatement(@Nullable JetExpression nullableExpression, + @NotNull TranslationContext context) { + if (nullableExpression == null) { + return context.program().getEmptyStmt(); + } + return AstUtil.convertToStatement(nullableExpression.accept(this, context)); + } + + @NotNull + private JsExpression translateConditionExpression(@Nullable JetExpression expression, + @NotNull TranslationContext context) { + JsExpression jsCondition = translateNullableExpression(expression, context); + assert (jsCondition != null) : "Condition should not be empty"; + return AstUtil.convertToExpression(jsCondition); + } + + @Nullable + private JsExpression translateNullableExpression(@Nullable JetExpression expression, + @NotNull TranslationContext context) { + if (expression == null) { + return null; + } + return translateAsExpression(expression, context); + } + + @Override + @NotNull + public JsNode visitWhileExpression(@NotNull JetWhileExpression expression, @NotNull TranslationContext context) { + JsWhile result = new JsWhile(); + result.setCondition(translateConditionExpression(expression.getCondition(), context)); + result.setBody(translateNullableExpressionAsNotNullStatement(expression.getBody(), context)); + return result; + } + + @Override + @NotNull + public JsNode visitDoWhileExpression(@NotNull JetDoWhileExpression expression, @NotNull TranslationContext context) { + JsDoWhile result = new JsDoWhile(); + result.setCondition(translateConditionExpression(expression.getCondition(), context)); + result.setBody(translateNullableExpressionAsNotNullStatement(expression.getBody(), context)); + return result; + } + + @Override + @NotNull + public JsNode visitStringTemplateExpression(@NotNull JetStringTemplateExpression expression, + @NotNull TranslationContext context) { + JsStringLiteral stringLiteral = resolveAsStringConstant(expression, context); + if (stringLiteral != null) { + return stringLiteral; + } + return resolveAsTemplate(expression, context); + } + + @NotNull + private JsNode resolveAsTemplate(@NotNull JetStringTemplateExpression expression, + @NotNull TranslationContext context) { + return StringTemplateTranslator.translate(expression, context); + } + + @Nullable + private JsStringLiteral resolveAsStringConstant(@NotNull JetExpression expression, + @NotNull TranslationContext context) { + Object value = getCompileTimeValue(context.bindingContext(), expression); + if (value == null) { + return null; + } + assert value instanceof String : "Compile time constant template should be a String constant."; + String constantString = (String) value; + return context.program().getStringLiteral(constantString); + } + + @Override + @NotNull + public JsNode visitDotQualifiedExpression(@NotNull JetDotQualifiedExpression expression, + @NotNull TranslationContext context) { + return QualifiedExpressionTranslator.translateQualifiedExpression(expression, context); + } + + @Override + @NotNull + public JsNode visitPrefixExpression(@NotNull JetPrefixExpression expression, + @NotNull TranslationContext context) { + return UnaryOperationTranslator.translate(expression, context); + + } + + @Override + @NotNull + public JsNode visitPostfixExpression(@NotNull JetPostfixExpression expression, + @NotNull TranslationContext context) { + return IncrementTranslator.translate(expression, context); + } + + @Override + @NotNull + public JsNode visitIsExpression(@NotNull JetIsExpression expression, + @NotNull TranslationContext context) { + return Translation.patternTranslator(context).translateIsExpression(expression); + } + + @Override + @NotNull + public JsNode visitSafeQualifiedExpression(@NotNull JetSafeQualifiedExpression expression, + @NotNull TranslationContext context) { + return QualifiedExpressionTranslator.translateQualifiedExpression(expression, context); + } + + @Override + @NotNull + public JsNode visitWhenExpression(@NotNull JetWhenExpression expression, + @NotNull TranslationContext context) { + return Translation.translateWhenExpression(expression, context); + } + + + @Override + @NotNull + public JsNode visitBinaryWithTypeRHSExpression(@NotNull JetBinaryExpressionWithTypeRHS expression, + @NotNull TranslationContext context) { + // we actually do not care for types in js + return Translation.translateExpression(expression.getLeft(), context); + } + + @Override + @NotNull + public JsNode visitBreakExpression(@NotNull JetBreakExpression expression, + @NotNull TranslationContext context) { + return new JsBreak(); + } + + @Override + @NotNull + public JsNode visitContinueExpression(@NotNull JetContinueExpression expression, + @NotNull TranslationContext context) { + return new JsContinue(); + } + + @Override + @NotNull + public JsNode visitFunctionLiteralExpression(@NotNull JetFunctionLiteralExpression expression, + @NotNull TranslationContext context) { + return Translation.functionTranslator(expression, context).translateAsLiteral(); + } + + @Override + @NotNull + public JsNode visitThisExpression(@NotNull JetThisExpression expression, + @NotNull TranslationContext context) { + DeclarationDescriptor descriptor = + getDescriptorForReferenceExpression(context.bindingContext(), expression.getInstanceReference()); + return TranslationUtils.getThisObject(context, descriptor); + } + + @Override + @NotNull + public JsNode visitArrayAccessExpression(@NotNull JetArrayAccessExpression expression, + @NotNull TranslationContext context) { + return AccessTranslator.translateAsGet(expression, context); + } + + @Override + @NotNull + public JsNode visitForExpression(@NotNull JetForExpression expression, + @NotNull TranslationContext context) { + return ForTranslator.translate(expression, context); + } + + @Override + @NotNull + public JsNode visitTryExpression(@NotNull JetTryExpression expression, + @NotNull TranslationContext context) { + return TryTranslator.translate(expression, context); + } + + @Override + @NotNull + public JsNode visitTupleExpression(@NotNull JetTupleExpression expression, + @NotNull TranslationContext context) { + JsArrayLiteral result = new JsArrayLiteral(); + for (JetExpression entry : expression.getEntries()) { + result.getExpressions().add(Translation.translateAsExpression(entry, context)); + } + return result; + } + + @Override + @NotNull + public JsNode visitThrowExpression(@NotNull JetThrowExpression expression, + @NotNull TranslationContext context) { + JetExpression thrownExpression = expression.getThrownExpression(); + assert thrownExpression != null : "Thrown expression must not be null"; + return new JsThrow(translateAsExpression(thrownExpression, context)); + } + + @Override + @NotNull + public JsNode visitObjectLiteralExpression(@NotNull JetObjectLiteralExpression expression, + @NotNull TranslationContext context) { + return ClassTranslator.generateClassCreationExpression(expression.getObjectDeclaration(), context); + } + + @Override + @NotNull + public JsNode visitObjectDeclaration(@NotNull JetObjectDeclaration expression, + @NotNull TranslationContext context) { + JetObjectDeclarationName objectDeclarationName = getObjectDeclarationName(expression); + DeclarationDescriptor descriptor = getDescriptorForElement(context.bindingContext(), objectDeclarationName); + JsName propertyName = context.getNameForDescriptor(descriptor); + JsExpression value = ClassTranslator.generateClassCreationExpression(expression, context); + return AstUtil.newVar(propertyName, value); + } + + @Override + @NotNull + public JsNode visitNamedFunction(@NotNull JetNamedFunction function, + @NotNull TranslationContext context) { + return FunctionTranslator.newInstance(function, context).translateAsLocalFunction(); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/expression/ForTranslator.java b/translator/src/org/jetbrains/k2js/translate/expression/ForTranslator.java new file mode 100644 index 00000000000..c0eb4e6c17e --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/expression/ForTranslator.java @@ -0,0 +1,118 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.expression; + +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.CallableDescriptor; +import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; +import org.jetbrains.jet.lang.psi.JetExpression; +import org.jetbrains.jet.lang.psi.JetForExpression; +import org.jetbrains.jet.lang.psi.JetParameter; +import org.jetbrains.k2js.translate.context.TemporaryVariable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.reference.CallBuilder; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.*; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getLoopBody; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getLoopParameter; + +/** + * @author Pavel Talanov + */ +public final class ForTranslator extends AbstractTranslator { + + @NotNull + public static JsStatement translate(@NotNull JetForExpression expression, + @NotNull TranslationContext context) { + return (new ForTranslator(expression, context).translate()); + } + + @NotNull + private final JetForExpression expression; + + private ForTranslator(@NotNull JetForExpression forExpression, @NotNull TranslationContext context) { + super(context); + this.expression = forExpression; + } + + @NotNull + private JsBlock translate() { + JsName parameterName = declareParameter(); + TemporaryVariable iterator = context().declareTemporary(iteratorMethodInvocation()); + JsBlock bodyBlock = generateCycleBody(parameterName, iterator); + JsWhile cycle = new JsWhile(hasNextMethodInvocation(iterator), bodyBlock); + return AstUtil.newBlock(iterator.assignmentExpression().makeStmt(), cycle); + } + + @NotNull + private JsName declareParameter() { + JetParameter loopParameter = getLoopParameter(expression); + return context().getNameForElement(loopParameter); + } + + @NotNull + private JsBlock generateCycleBody(@NotNull JsName parameterName, @NotNull TemporaryVariable iterator) { + JsBlock cycleBody = new JsBlock(); + JsStatement parameterAssignment = + AstUtil.newVar(parameterName, nextMethodInvocation(iterator)); + JsNode originalBody = Translation.translateExpression(getLoopBody(expression), context().innerBlock(cycleBody)); + cycleBody.addStatement(parameterAssignment); + cycleBody.addStatement(AstUtil.convertToBlock(originalBody)); + return cycleBody; + } + + @NotNull + private JsExpression nextMethodInvocation(@NotNull TemporaryVariable iterator) { + FunctionDescriptor nextFunction = getNextFunction(context().bindingContext(), getLoopRange()); + return translateMethodInvocation(iterator.nameReference(), nextFunction); + } + + @NotNull + private JsExpression hasNextMethodInvocation(@NotNull TemporaryVariable iterator) { + CallableDescriptor hasNextFunction = getHasNextCallable(context().bindingContext(), getLoopRange()); + return translateMethodInvocation(iterator.nameReference(), hasNextFunction); + } + + @NotNull + private JsExpression iteratorMethodInvocation() { + JetExpression rangeExpression = getLoopRange(); + JsExpression range = Translation.translateAsExpression(rangeExpression, context()); + FunctionDescriptor iteratorFunction = getIteratorFunction(context().bindingContext(), rangeExpression); + return translateMethodInvocation(range, iteratorFunction); + } + + @NotNull + private JetExpression getLoopRange() { + JetExpression rangeExpression = expression.getLoopRange(); + assert rangeExpression != null; + return rangeExpression; + } + + @NotNull + private JsExpression translateMethodInvocation(@Nullable JsExpression receiver, + @NotNull CallableDescriptor descriptor) { + return CallBuilder.build(context()) + .receiver(receiver) + .descriptor(descriptor) + .translate(); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/expression/FunctionTranslator.java b/translator/src/org/jetbrains/k2js/translate/expression/FunctionTranslator.java new file mode 100644 index 00000000000..0d16bf5ea3c --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/expression/FunctionTranslator.java @@ -0,0 +1,223 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.expression; + + +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.descriptors.*; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.types.JetStandardClasses; +import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.k2js.translate.context.Namer; +import org.jetbrains.k2js.translate.context.TemporaryVariable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.utils.DescriptorUtils; + +import java.util.ArrayList; +import java.util.List; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.getFunctionDescriptor; +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.*; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.*; + + +/** + * @author Pavel Talanov + */ +public final class FunctionTranslator extends AbstractTranslator { + + @NotNull + public static FunctionTranslator newInstance(@NotNull JetDeclarationWithBody function, + @NotNull TranslationContext context) { + return new FunctionTranslator(function, context); + } + + @NotNull + private final JetDeclarationWithBody functionDeclaration; + @NotNull + private final JsFunction functionObject; + @NotNull + private final TranslationContext functionBodyContext; + @NotNull + private final FunctionDescriptor descriptor; + // function body needs to be explicitly created here to include it in the context + @NotNull + private final JsBlock functionBody; + + private FunctionTranslator(@NotNull JetDeclarationWithBody functionDeclaration, + @NotNull TranslationContext context) { + super(context); + this.functionBody = new JsBlock(); + this.descriptor = getFunctionDescriptor(context.bindingContext(), functionDeclaration); + this.functionDeclaration = functionDeclaration; + this.functionObject = createFunctionObject(); + this.functionBodyContext = functionBodyContext().innerBlock(functionBody); + } + + + @NotNull + public JsFunction translateAsLocalFunction() { + JsName functionName = context().getNameForElement(functionDeclaration); + JsFunction function = generateFunctionObject(); + function.setName(functionName); + return function; + } + + @NotNull + public JsPropertyInitializer translateAsMethod() { + JsName functionName = context().getNameForElement(functionDeclaration); + JsFunction function = generateFunctionObject(); + return new JsPropertyInitializer(functionName.makeRef(), function); + } + + @NotNull + public JsExpression translateAsLiteral() { + assert getExpectedThisDescriptor(descriptor) == null; + ClassDescriptor containingClass = getContainingClass(descriptor); + if (containingClass == null) { + return generateFunctionObject(); + } + return generateFunctionObjectWithAliasedThisReference(containingClass); + } + + @NotNull + private JsExpression generateFunctionObjectWithAliasedThisReference(@NotNull ClassDescriptor containingClass) { + TemporaryVariable aliasForThis = newAliasForThis(context(), containingClass); + JsFunction function = generateFunctionObject(); + removeAliasForThis(context(), containingClass); + return AstUtil.newSequence(aliasForThis.assignmentExpression(), function); + } + + @NotNull + private JsFunction generateFunctionObject() { + functionObject.setParameters(translateParameters()); + translateBody(); + functionObject.setBody(functionBody); + restoreContext(); + return functionObject; + } + + private void restoreContext() { + if (isExtensionFunction()) { + DeclarationDescriptor expectedReceiverDescriptor = getExpectedReceiverDescriptor(descriptor); + assert expectedReceiverDescriptor != null : "Extension functions should always have receiver descriptors."; + functionBodyContext.aliaser().removeAliasForThis(expectedReceiverDescriptor); + } + } + + @NotNull + private JsFunction createFunctionObject() { + if (isDeclaration()) { + return functionWithScope(context().getScopeForDescriptor(descriptor)); + } + if (isLiteral()) { + //TODO: changing this piece of code to more natural "same as for declaration" results in life test failing + //TODO: must investigate + return new JsFunction(context().jsScope()); + } + throw new AssertionError("Unsupported type of functionDeclaration."); + } + + private void translateBody() { + JetExpression jetBodyExpression = functionDeclaration.getBodyExpression(); + if (jetBodyExpression == null) { + assert descriptor.getModality().equals(Modality.ABSTRACT); + return; + } + JsNode realBody = Translation.translateExpression(jetBodyExpression, functionBodyContext); + functionBody.addStatement(wrapWithReturnIfNeeded(realBody, mustAddReturnToGeneratedFunctionBody())); + } + + private boolean mustAddReturnToGeneratedFunctionBody() { + JetType functionReturnType = descriptor.getReturnType(); + assert functionReturnType != null : "Function return typed type must be resolved."; + return (!functionDeclaration.hasBlockBody()) && (!JetStandardClasses.isUnit(functionReturnType)); + } + + @NotNull + private JsBlock wrapWithReturnIfNeeded(@NotNull JsNode body, boolean needsReturn) { + if (!needsReturn) { + return AstUtil.convertToBlock(body); + } + return AstUtil.convertToBlock(lastExpressionReturned(body)); + } + + private JsNode lastExpressionReturned(@NotNull JsNode body) { + return AstUtil.mutateLastExpression(body, new AstUtil.Mutator() { + @Override + @NotNull + public JsNode mutate(@NotNull JsNode node) { + if (!(node instanceof JsExpression)) { + return node; + } + return new JsReturn((JsExpression) node); + } + }); + } + + @NotNull + private TranslationContext functionBodyContext() { + if (isLiteral()) { + return context().innerJsScope(functionObject.getScope()); + } else { + return context().newDeclaration(functionDeclaration); + } + } + + @NotNull + private List translateParameters() { + List jsParameters = new ArrayList(); + mayBeAddThisParameterForExtensionFunction(jsParameters); + for (ValueParameterDescriptor valueParameter : descriptor.getValueParameters()) { + JsName parameterName = declareParameter(valueParameter); + jsParameters.add(new JsParameter(parameterName)); + } + return jsParameters; + } + + @NotNull + private JsName declareParameter(@NotNull ValueParameterDescriptor valueParameter) { + return context().getNameForDescriptor(valueParameter); + } + + private void mayBeAddThisParameterForExtensionFunction(@NotNull List jsParameters) { + if (isExtensionFunction()) { + JsName receiver = functionBodyContext.jsScope().declareName(Namer.getReceiverParameterName()); + DeclarationDescriptor expectedReceiverDescriptor = getExpectedReceiverDescriptor(descriptor); + assert expectedReceiverDescriptor != null; + context().aliaser().setAliasForThis(expectedReceiverDescriptor, receiver); + jsParameters.add(new JsParameter(receiver)); + } + } + + private boolean isExtensionFunction() { + return DescriptorUtils.isExtensionFunction(descriptor) && !isLiteral(); + } + + private boolean isLiteral() { + return functionDeclaration instanceof JetFunctionLiteralExpression; + } + + private boolean isDeclaration() { + return (functionDeclaration instanceof JetNamedFunction) || + (functionDeclaration instanceof JetPropertyAccessor); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/expression/PatternTranslator.java b/translator/src/org/jetbrains/k2js/translate/expression/PatternTranslator.java new file mode 100644 index 00000000000..26810dab5c2 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/expression/PatternTranslator.java @@ -0,0 +1,134 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.expression; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsInvocation; +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.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.ClassDescriptor; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.utils.BindingUtils; +import org.jetbrains.k2js.translate.utils.TranslationUtils; + +/** + * @author Pavel Talanov + */ +public final class PatternTranslator extends AbstractTranslator { + + @NotNull + public static PatternTranslator newInstance(@NotNull TranslationContext context) { + return new PatternTranslator(context); + } + + private PatternTranslator(@NotNull TranslationContext context) { + super(context); + } + + @NotNull + public JsExpression translateIsExpression(@NotNull JetIsExpression expression) { + JsExpression left = Translation.translateAsExpression(expression.getLeftHandSide(), context()); + JetPattern pattern = getPattern(expression); + JsExpression resultingExpression = translatePattern(pattern, left); + if (expression.isNegated()) { + return AstUtil.negated(resultingExpression); + } + return resultingExpression; + } + + @NotNull + private JetPattern getPattern(@NotNull JetIsExpression expression) { + JetPattern pattern = expression.getPattern(); + assert pattern != null : "Pattern should not be null"; + return pattern; + } + + @NotNull + public JsExpression translatePattern(@NotNull JetPattern pattern, @NotNull JsExpression expressionToMatch) { + if (pattern instanceof JetTypePattern) { + return translateTypePattern(expressionToMatch, (JetTypePattern) pattern); + } + if (pattern instanceof JetExpressionPattern) { + return translateExpressionPattern(expressionToMatch, (JetExpressionPattern) pattern); + } + throw new AssertionError("Unsupported pattern type " + pattern.getClass()); + } + + @NotNull + private JsExpression translateTypePattern(@NotNull JsExpression expressionToMatch, + @NotNull JetTypePattern pattern) { + //TODO: look into using intrinsics or other mechanisms to implement this logic + JsName className = getClassReference(pattern).getName(); + if (className.getIdent().equals("String")) { + return AstUtil.typeof(expressionToMatch, program().getStringLiteral("string")); + } + if (className.getIdent().equals("Int")) { + return AstUtil.typeof(expressionToMatch, program().getStringLiteral("number")); + } + + JsInvocation isCheck = AstUtil.newInvocation(context().namer().isOperationReference(), + expressionToMatch, getClassReference(pattern)); + if (isNullable(pattern)) { + return addNullCheck(expressionToMatch, isCheck); + } + return isCheck; + } + + @NotNull + private JsExpression addNullCheck(@NotNull JsExpression expressionToMatch, @NotNull JsInvocation isCheck) { + return AstUtil.or(TranslationUtils.isNullCheck(context(), expressionToMatch), isCheck); + } + + private boolean isNullable(JetTypePattern pattern) { + return BindingUtils.getTypeByReference(context().bindingContext(), + getTypeReference(pattern)).isNullable(); + } + + @NotNull + private JsNameRef getClassReference(@NotNull JetTypePattern pattern) { + JetTypeReference typeReference = getTypeReference(pattern); + return getClassNameReferenceForTypeReference(typeReference); + } + + @NotNull + private JetTypeReference getTypeReference(@NotNull JetTypePattern pattern) { + JetTypeReference typeReference = pattern.getTypeReference(); + assert typeReference != null : "Type pattern should contain a type reference"; + return typeReference; + } + + @NotNull + private JsNameRef getClassNameReferenceForTypeReference(@NotNull JetTypeReference typeReference) { + ClassDescriptor referencedClass = BindingUtils.getClassDescriptorForTypeReference + (context().bindingContext(), typeReference); + return TranslationUtils.getQualifiedReference(context(), referencedClass); + } + + @NotNull + private JsExpression translateExpressionPattern(JsExpression expressionToMatch, JetExpressionPattern pattern) { + JetExpression patternExpression = pattern.getExpression(); + assert patternExpression != null : "Expression patter should have an expression."; + JsExpression expressionToMatchAgainst = + Translation.translateAsExpression(patternExpression, context()); + return AstUtil.equals(expressionToMatch, expressionToMatchAgainst); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/expression/StringTemplateTranslator.java b/translator/src/org/jetbrains/k2js/translate/expression/StringTemplateTranslator.java new file mode 100644 index 00000000000..a5f14bd8878 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/expression/StringTemplateTranslator.java @@ -0,0 +1,101 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.expression; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsStringLiteral; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; + +import static com.google.dart.compiler.util.AstUtil.sum; + +/** + * @author Pavel Talanov + */ +//TODO: add toString call for non-primitive object +public final class StringTemplateTranslator extends AbstractTranslator { + + @NotNull + public static JsExpression translate(@NotNull JetStringTemplateExpression expression, + @NotNull TranslationContext context) { + return (new StringTemplateTranslator(expression, context).translate()); + } + + @NotNull + private final JetStringTemplateExpression expression; + + private StringTemplateTranslator(@NotNull JetStringTemplateExpression expression, + @NotNull TranslationContext context) { + super(context); + this.expression = expression; + } + + @NotNull + private JsExpression translate() { + assert expression.getEntries().length != 0 : "String template must have one or more entries."; + EntryVisitor entryVisitor = new EntryVisitor(); + for (JetStringTemplateEntry entry : expression.getEntries()) { + entry.accept(entryVisitor); + } + return entryVisitor.getResultingExpression(); + } + + private final class EntryVisitor extends JetVisitorVoid { + + @Nullable + private JsExpression resultingExpression = null; + + void append(@NotNull JsExpression expression) { + if (resultingExpression == null) { + resultingExpression = expression; + } else { + resultingExpression = sum(resultingExpression, expression); + } + } + + @Override + public void visitStringTemplateEntryWithExpression(@NotNull JetStringTemplateEntryWithExpression entry) { + JetExpression entryExpression = entry.getExpression(); + assert entryExpression != null : + "JetStringTemplateEntryWithExpression must have not null entry expression."; + append(Translation.translateAsExpression(entryExpression, context())); + } + + //TODO: duplication + @Override + public void visitLiteralStringTemplateEntry(@NotNull JetLiteralStringTemplateEntry entry) { + JsStringLiteral stringConstant = context().program().getStringLiteral(entry.getText()); + append(stringConstant); + } + + @Override + public void visitEscapeStringTemplateEntry(@NotNull JetEscapeStringTemplateEntry entry) { + JsStringLiteral escapedValue = context().program().getStringLiteral(entry.getUnescapedValue()); + append(escapedValue); + } + + @NotNull + public JsExpression getResultingExpression() { + assert resultingExpression != null; + return resultingExpression; + } + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/expression/TryTranslator.java b/translator/src/org/jetbrains/k2js/translate/expression/TryTranslator.java new file mode 100644 index 00000000000..a163939a748 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/expression/TryTranslator.java @@ -0,0 +1,108 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.expression; + +import com.google.dart.compiler.backend.js.ast.JsBlock; +import com.google.dart.compiler.backend.js.ast.JsCatch; +import com.google.dart.compiler.backend.js.ast.JsName; +import com.google.dart.compiler.backend.js.ast.JsTry; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; + +import java.util.ArrayList; +import java.util.List; + +import static com.google.dart.compiler.util.AstUtil.convertToBlock; + +/** + * @author Pavel Talanov + */ +//TODO: not tested at all +//TODO: not implemented catch logic +public final class TryTranslator extends AbstractTranslator { + + @NotNull + public static JsTry translate(@NotNull JetTryExpression expression, + @NotNull TranslationContext context) { + return (new TryTranslator(expression, context)).translate(); + } + + @NotNull + private final JetTryExpression expression; + + private TryTranslator(@NotNull JetTryExpression expression, + @NotNull TranslationContext context) { + super(context); + this.expression = expression; + } + + private JsTry translate() { + JsTry result = new JsTry(); + result.setTryBlock(translateTryBlock()); + result.setFinallyBlock(translateFinallyBlock()); + result.getCatches().addAll(translateCatches()); + return result; + } + + @Nullable + private JsBlock translateFinallyBlock() { + JetFinallySection finallyBlock = expression.getFinallyBlock(); + if (finallyBlock == null) return null; + + return convertToBlock(Translation.translateAsStatement(finallyBlock.getFinalExpression(), context())); + } + + @NotNull + private JsBlock translateTryBlock() { + return convertToBlock(Translation.translateAsStatement(expression.getTryBlock(), context())); + } + + + @NotNull + private List translateCatches() { + List result = new ArrayList(); + for (JetCatchClause catchClause : expression.getCatchClauses()) { + result.add(translateCatchClause(catchClause)); + } + return result; + } + + @NotNull + private JsCatch translateCatchClause(@NotNull JetCatchClause catchClause) { + JetParameter catchParameter = catchClause.getCatchParameter(); + assert catchParameter != null : "Valid catch must have a parameter."; + + JsName parameterName = context().getNameForElement(catchParameter); + JsCatch result = new JsCatch(context().jsScope(), parameterName.getIdent()); + result.setBody(translateCatchBody(catchClause)); + return result; + } + + @NotNull + private JsBlock translateCatchBody(@NotNull JetCatchClause catchClause) { + JetExpression catchBody = catchClause.getCatchBody(); + if (catchBody == null) { + return convertToBlock(program().getEmptyStmt()); + } + return convertToBlock(Translation.translateAsStatement(catchBody, context())); + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/expression/WhenTranslator.java b/translator/src/org/jetbrains/k2js/translate/expression/WhenTranslator.java new file mode 100644 index 00000000000..0010081b70f --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/expression/WhenTranslator.java @@ -0,0 +1,211 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.expression; + +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.k2js.translate.context.TemporaryVariable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Pavel Talanov + */ +public class WhenTranslator extends AbstractTranslator { + + @NotNull + static public JsNode translateWhenExpression(@NotNull JetWhenExpression expression, @NotNull TranslationContext context) { + WhenTranslator translator = new WhenTranslator(expression, context); + return translator.translate(); + } + + @NotNull + private final JetWhenExpression whenExpression; + @NotNull + private final JsExpression expressionToMatch; + @NotNull + private final TemporaryVariable dummyCounter; + @NotNull + private final TemporaryVariable result; + + private int currentEntryNumber = 0; + + private WhenTranslator(@NotNull JetWhenExpression expression, @NotNull TranslationContext context) { + super(context); + this.whenExpression = expression; + this.expressionToMatch = translateExpressionToMatch(whenExpression); + this.dummyCounter = context.declareTemporary(context().program().getNumberLiteral(0)); + this.result = context.declareTemporary(program().getNullLiteral()); + } + + @NotNull + JsNode translate() { + JsFor resultingFor = generateDummyFor(); + List entries = translateEntries(); + resultingFor.setBody(AstUtil.newBlock(entries)); + context().addStatementToCurrentBlock(resultingFor); + return result.nameReference(); + } + + @NotNull + private List translateEntries() { + List entries = new ArrayList(); + for (JetWhenEntry entry : whenExpression.getEntries()) { + entries.add(surroundWithDummyIf(translateEntry(entry))); + } + return entries; + } + + @NotNull + private JsStatement surroundWithDummyIf(@NotNull JsStatement entryStatement) { + JsExpression stepNumberEqualsCurrentEntryNumber = new JsBinaryOperation(JsBinaryOperator.EQ, + dummyCounter.nameReference(), context().program().getNumberLiteral(currentEntryNumber)); + currentEntryNumber++; + return new JsIf(stepNumberEqualsCurrentEntryNumber, entryStatement, null); + } + + @NotNull + private JsFor generateDummyFor() { + JsFor result = new JsFor(); + result.setInitExpr(dummyCounter.assignmentExpression()); + result.setIncrExpr(generateIncrementStatement()); + result.setCondition(generateConditionStatement()); + return result; + } + + @NotNull + private JsBinaryOperation generateConditionStatement() { + JsNumberLiteral entriesNumber = program().getNumberLiteral(whenExpression.getEntries().size()); + return new JsBinaryOperation(JsBinaryOperator.LT, dummyCounter.nameReference(), entriesNumber); + } + + @NotNull + private JsPrefixOperation generateIncrementStatement() { + return new JsPrefixOperation(JsUnaryOperator.INC, dummyCounter.nameReference()); + } + + @NotNull + private JsStatement translateEntry(@NotNull JetWhenEntry entry) { + JsStatement statementToExecute = withReturnValueCaptured(translateEntryExpression(entry)); + if (entry.isElse()) { + return statementToExecute; + } + JsExpression condition = translateConditions(entry); + return new JsIf(condition, addDummyBreak(statementToExecute), null); + } + + @NotNull + JsStatement withReturnValueCaptured(@NotNull JsNode node) { + + return AstUtil.convertToStatement(AstUtil.mutateLastExpression(node, + new AstUtil.SaveLastExpressionMutator(result.nameReference()))); + } + + @NotNull + private JsNode translateEntryExpression(@NotNull JetWhenEntry entry) { + JetExpression expressionToExecute = entry.getExpression(); + assert expressionToExecute != null : "WhenEntry should have whenExpression to execute."; + return Translation.translateExpression(expressionToExecute, context()); + } + + @NotNull + private JsExpression translateConditions(@NotNull JetWhenEntry entry) { + List conditions = new ArrayList(); + for (JetWhenCondition condition : entry.getConditions()) { + conditions.add(translateCondition(condition)); + } + return anyOfThemIsTrue(conditions); + } + + @NotNull + private JsExpression anyOfThemIsTrue(List conditions) { + assert !conditions.isEmpty() : "When entry (not else) should have at least one condition"; + JsExpression current = null; + for (JsExpression condition : conditions) { + current = addCaseCondition(current, condition); + } + assert current != null; + return current; + } + + @NotNull + private JsExpression addCaseCondition(@Nullable JsExpression current, @NotNull JsExpression condition) { + if (current == null) { + return condition; + } else { + return AstUtil.or(current, condition); + } + } + + @NotNull + private JsExpression translateCondition(@NotNull JetWhenCondition condition) { + if ((condition instanceof JetWhenConditionIsPattern) || (condition instanceof JetWhenConditionWithExpression)) { + return translatePatternCondition(condition); + } + throw new AssertionError("Unsupported when condition " + condition.getClass()); + } + + @NotNull + private JsBlock addDummyBreak(@NotNull JsStatement statement) { + return AstUtil.newBlock(statement, new JsBreak()); + } + + @NotNull + private JsExpression translatePatternCondition(@NotNull JetWhenCondition condition) { + JsExpression patternMatchExpression = Translation.patternTranslator(context()). + translatePattern(getPattern(condition), expressionToMatch); + if (isNegated(condition)) { + return AstUtil.negated(patternMatchExpression); + } + return patternMatchExpression; + } + + private boolean isNegated(@NotNull JetWhenCondition condition) { + if (condition instanceof JetWhenConditionIsPattern) { + return ((JetWhenConditionIsPattern) condition).isNegated(); + } + return false; + } + + @NotNull + private JetPattern getPattern(@NotNull JetWhenCondition condition) { + JetPattern pattern; + if (condition instanceof JetWhenConditionIsPattern) { + pattern = ((JetWhenConditionIsPattern) condition).getPattern(); + } else if (condition instanceof JetWhenConditionWithExpression) { + pattern = ((JetWhenConditionWithExpression) condition).getPattern(); + } else { + throw new AssertionError("Wrong type of JetWhenCondition"); + } + assert pattern != null : "Condition should have a non null pattern."; + return pattern; + } + + @NotNull + private JsExpression translateExpressionToMatch(@NotNull JetWhenExpression expression) { + JetExpression subject = expression.getSubjectExpression(); + assert subject != null : "Subject should not be null."; + return Translation.translateAsExpression(subject, context()); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/general/AbstractTranslator.java b/translator/src/org/jetbrains/k2js/translate/general/AbstractTranslator.java new file mode 100644 index 00000000000..0aeb385e7fe --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/general/AbstractTranslator.java @@ -0,0 +1,51 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.general; + +import com.google.dart.compiler.backend.js.ast.JsProgram; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.k2js.translate.context.Aliaser; +import org.jetbrains.k2js.translate.context.TranslationContext; + +/** + * @author Pavel Talanov + */ +//TODO: provide helper methods for different parts of context +public abstract class AbstractTranslator { + + @NotNull + private final TranslationContext context; + + protected AbstractTranslator(@NotNull TranslationContext context) { + this.context = context; + } + + @NotNull + protected JsProgram program() { + return context.program(); + } + + @NotNull + protected TranslationContext context() { + return context; + } + + @NotNull + protected Aliaser aliaser() { + return context.aliaser(); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/general/Translation.java b/translator/src/org/jetbrains/k2js/translate/general/Translation.java new file mode 100644 index 00000000000..c80c7772be0 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/general/Translation.java @@ -0,0 +1,124 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.general; + +import com.google.dart.compiler.backend.js.JsNamer; +import com.google.dart.compiler.backend.js.JsPrettyNamer; +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.AstUtil; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.types.JetStandardLibrary; +import org.jetbrains.k2js.translate.context.StaticContext; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.declaration.ClassTranslator; +import org.jetbrains.k2js.translate.declaration.NamespaceDeclarationTranslator; +import org.jetbrains.k2js.translate.expression.ExpressionVisitor; +import org.jetbrains.k2js.translate.expression.FunctionTranslator; +import org.jetbrains.k2js.translate.expression.PatternTranslator; +import org.jetbrains.k2js.translate.expression.WhenTranslator; +import org.jetbrains.k2js.translate.initializer.ClassInitializerTranslator; +import org.jetbrains.k2js.translate.initializer.NamespaceInitializerTranslator; + +import java.util.List; + +/** + * @author Pavel Talanov + *

+ * This class provides a interface which all translators use to interact with each other. + * Goal is to simlify interaction between translators. + */ +public final class Translation { + + @NotNull + public static FunctionTranslator functionTranslator(@NotNull JetDeclarationWithBody function, + @NotNull TranslationContext context) { + return FunctionTranslator.newInstance(function, context); + } + + @NotNull + public static List translateFiles(@NotNull List files, @NotNull TranslationContext context) { + return NamespaceDeclarationTranslator.translateFiles(files, context); + } + + @NotNull + public static JsInvocation translateClassDeclaration(@NotNull JetClass classDeclaration, + @NotNull TranslationContext context) { + return ClassTranslator.generateClassCreationExpression(classDeclaration, context); + } + + @NotNull + public static PatternTranslator patternTranslator(@NotNull TranslationContext context) { + return PatternTranslator.newInstance(context); + } + + @NotNull + public static JsNode translateExpression(@NotNull JetExpression expression, @NotNull TranslationContext context) { + return expression.accept(new ExpressionVisitor(), context); + } + + @NotNull + public static JsExpression translateAsExpression(@NotNull JetExpression expression, + @NotNull TranslationContext context) { + return AstUtil.convertToExpression(translateExpression(expression, context)); + } + + @NotNull + public static JsStatement translateAsStatement(@NotNull JetExpression expression, + @NotNull TranslationContext context) { + return AstUtil.convertToStatement(translateExpression(expression, context)); + } + + @NotNull + public static JsNode translateWhenExpression(@NotNull JetWhenExpression expression, + @NotNull TranslationContext context) { + return WhenTranslator.translateWhenExpression(expression, context); + } + + //TODO: see if generate*Initializer methods fit somewhere else + @NotNull + public static JsPropertyInitializer generateClassInitializerMethod(@NotNull JetClassOrObject classDeclaration, + @NotNull TranslationContext context) { + return (new ClassInitializerTranslator(classDeclaration, context)).generateInitializeMethod(); + } + + @NotNull + public static JsPropertyInitializer generateNamespaceInitializerMethod(@NotNull NamespaceDescriptor namespace, + @NotNull TranslationContext context) { + return (new NamespaceInitializerTranslator(namespace, context)).generateInitializeMethod(); + } + + public static JsProgram generateAst(@NotNull BindingContext bindingContext, + @NotNull NamespaceDescriptor namespaceToTranslate, + @NotNull List files, + @NotNull Project project) { + //TODO: move some of the code somewhere + JetStandardLibrary standardLibrary = JetStandardLibrary.getJetStandardLibrary(project); + StaticContext staticContext = StaticContext.generateStaticContext(standardLibrary, bindingContext); + JsBlock block = staticContext.getProgram().getFragmentBlock(0); + TranslationContext context = TranslationContext.rootContext(staticContext); + block.getStatements().addAll(Translation.translateFiles(files, context)); + JsNamer namer = new JsPrettyNamer(); + namer.exec(context.program()); + return context.program(); + } + + +} diff --git a/translator/src/org/jetbrains/k2js/translate/general/TranslatorVisitor.java b/translator/src/org/jetbrains/k2js/translate/general/TranslatorVisitor.java new file mode 100644 index 00000000000..c42299032f2 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/general/TranslatorVisitor.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.general; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetElement; +import org.jetbrains.jet.lang.psi.JetVisitor; +import org.jetbrains.k2js.translate.context.TranslationContext; + +/** + * @author Pavel Talanov + *

+ * This class is a base class for all visitors. + */ +public class TranslatorVisitor extends JetVisitor { + + @Override + @NotNull + public T visitJetElement(JetElement expression, TranslationContext context) { + throw new UnsupportedOperationException("Unsupported expression encountered:" + expression.toString()); + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/initializer/AbstractInitializerTranslator.java b/translator/src/org/jetbrains/k2js/translate/initializer/AbstractInitializerTranslator.java new file mode 100644 index 00000000000..6c53ec13495 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/initializer/AbstractInitializerTranslator.java @@ -0,0 +1,68 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.initializer; + +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.JsStatement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.psi.JetClassOrObject; +import org.jetbrains.k2js.translate.context.Namer; +import org.jetbrains.k2js.translate.context.NamingScope; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public abstract class AbstractInitializerTranslator extends AbstractTranslator { + + @NotNull + private final InitializerVisitor visitor; + @NotNull + protected final NamingScope initializerMethodScope; + + protected AbstractInitializerTranslator(@NotNull NamingScope scope, @NotNull TranslationContext context) { + super(context.contextWithScope(scope)); + this.visitor = new InitializerVisitor(); + this.initializerMethodScope = scope; + } + + abstract protected JsFunction generateInitializerFunction(); + + @NotNull + public JsPropertyInitializer generateInitializeMethod() { + JsPropertyInitializer initializer = new JsPropertyInitializer(); + initializer.setLabelExpr(Namer.initializeMethodReference()); + initializer.setValueExpr(generateInitializerFunction()); + return initializer; + } + + @NotNull + protected List translateClassInitializers(@NotNull JetClassOrObject declaration) { + return visitor.traverseClass(declaration, context()); + } + + @NotNull + protected List translateNamespaceInitializers(@NotNull NamespaceDescriptor namespace) { + return visitor.traverseNamespace(namespace, context()); + + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/initializer/ClassInitializerTranslator.java b/translator/src/org/jetbrains/k2js/translate/initializer/ClassInitializerTranslator.java new file mode 100644 index 00000000000..154858888bd --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/initializer/ClassInitializerTranslator.java @@ -0,0 +1,141 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.initializer; + +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; +import org.jetbrains.jet.lang.psi.JetClassOrObject; +import org.jetbrains.jet.lang.psi.JetDelegationSpecifier; +import org.jetbrains.jet.lang.psi.JetDelegatorToSuperCall; +import org.jetbrains.jet.lang.psi.JetParameter; +import org.jetbrains.k2js.translate.context.Namer; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.utils.PsiUtils; +import org.jetbrains.k2js.translate.utils.TranslationUtils; + +import java.util.ArrayList; +import java.util.List; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.*; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.assignmentToBackingField; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.functionWithScope; + +/** + * @author Pavel Talanov + */ +public final class ClassInitializerTranslator extends AbstractInitializerTranslator { + + @NotNull + private final JetClassOrObject classDeclaration; + @NotNull + private final List initializerStatements = new ArrayList(); + + public ClassInitializerTranslator(@NotNull JetClassOrObject classDeclaration, @NotNull TranslationContext context) { + super(context.getScopeForElement(classDeclaration).innerScope + ("initializer " + classDeclaration.getName()), context); + this.classDeclaration = classDeclaration; + } + + @Override + @NotNull + protected JsFunction generateInitializerFunction() { + JsFunction result = functionWithScope(initializerMethodScope); + //NOTE: that while we translateAsLocalNameReference constructor parameters we also add property initializer statements + // for properties declared as constructor parameters + result.setParameters(translatePrimaryConstructorParameters()); + mayBeAddCallToSuperMethod(); + result.setBody(generateInitializerMethodBody()); + return result; + } + + @NotNull + private JsBlock generateInitializerMethodBody() { + initializerStatements.addAll(translateClassInitializers(classDeclaration)); + return AstUtil.newBlock(initializerStatements); + } + + private void mayBeAddCallToSuperMethod() { + if (hasAncestorClass(context().bindingContext(), classDeclaration)) { + JetDelegatorToSuperCall superCall = getSuperCall(); + if (superCall == null) return; + addCallToSuperMethod(superCall); + } + } + + private void addCallToSuperMethod(@NotNull JetDelegatorToSuperCall superCall) { + //TODO: look into + JsName superMethodName = initializerMethodScope.jsScope().declareName(Namer.superMethodName()); + List arguments = translateArguments(superCall); + initializerStatements.add(AstUtil.convertToStatement + (AstUtil.newInvocation(AstUtil.thisQualifiedReference(superMethodName), arguments))); + } + + @NotNull + private List translateArguments(@NotNull JetDelegatorToSuperCall superCall) { + //TODO: use the same mechanism as in call translator + return TranslationUtils.translateArgumentList(context(), superCall.getValueArguments()); + } + + @Nullable + private JetDelegatorToSuperCall getSuperCall() { + JetDelegatorToSuperCall result = null; + for (JetDelegationSpecifier specifier : classDeclaration.getDelegationSpecifiers()) { + if (specifier instanceof JetDelegatorToSuperCall) { + result = (JetDelegatorToSuperCall) specifier; + } + } + //assert result != null : "Class must call ancestor's constructor."; + return result; + } + + @NotNull + List translatePrimaryConstructorParameters() { + List parameterList = PsiUtils.getPrimaryConstructorParameters(classDeclaration); + List result = new ArrayList(); + for (JetParameter jetParameter : parameterList) { + result.add(translateParameter(jetParameter)); + } + return result; + } + + @NotNull + private JsParameter translateParameter(@NotNull JetParameter jetParameter) { + DeclarationDescriptor parameterDescriptor = + getDescriptorForElement(context().bindingContext(), jetParameter); + JsName parameterName = context().getNameForDescriptor(parameterDescriptor); + JsParameter jsParameter = new JsParameter(parameterName); + mayBeAddInitializerStatementForProperty(jsParameter, jetParameter); + return jsParameter; + } + + private void mayBeAddInitializerStatementForProperty(@NotNull JsParameter jsParameter, + @NotNull JetParameter jetParameter) { + PropertyDescriptor propertyDescriptor = + getPropertyDescriptorForConstructorParameter(context().bindingContext(), jetParameter); + if (propertyDescriptor != null) { + JsStatement assignmentToBackingFieldExpression = assignmentToBackingField + (context(), propertyDescriptor, jsParameter.getName().makeRef()); + initializerStatements.add(assignmentToBackingFieldExpression); + } + } + + +} diff --git a/translator/src/org/jetbrains/k2js/translate/initializer/InitializerVisitor.java b/translator/src/org/jetbrains/k2js/translate/initializer/InitializerVisitor.java new file mode 100644 index 00000000000..20b5cc5f835 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/initializer/InitializerVisitor.java @@ -0,0 +1,122 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.initializer; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsInvocation; +import com.google.dart.compiler.backend.js.ast.JsName; +import com.google.dart.compiler.backend.js.ast.JsStatement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.declaration.ClassTranslator; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.general.TranslatorVisitor; +import org.jetbrains.k2js.translate.utils.BindingUtils; +import org.jetbrains.k2js.translate.utils.TranslationUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static java.util.Collections.singletonList; +import static org.jetbrains.k2js.translate.utils.BindingUtils.getDeclarationsForNamespace; +import static org.jetbrains.k2js.translate.utils.BindingUtils.getPropertyDescriptorForObjectDeclaration; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getObjectDeclarationForName; + +/** + * @author Pavel Talanov + */ +public final class InitializerVisitor extends TranslatorVisitor> { + + /*package*/ InitializerVisitor() { + } + + @Override + @NotNull + public List visitProperty(@NotNull JetProperty expression, @NotNull TranslationContext context) { + JetExpression initializer = expression.getInitializer(); + if (initializer == null) { + return new ArrayList(); + } + return Arrays.asList(translateInitializer(expression, context, initializer)); + } + + @NotNull + private JsStatement translateInitializer(@NotNull JetProperty property, @NotNull TranslationContext context, + @NotNull JetExpression initializer) { + JsExpression initExpression = Translation.translateAsExpression(initializer, context); + return assignmentToBackingField(property, initExpression, context); + } + + //TODO: + @NotNull + JsStatement assignmentToBackingField(@NotNull JetProperty property, @NotNull JsExpression initExpression, + @NotNull TranslationContext context) { + + PropertyDescriptor propertyDescriptor = BindingUtils.getPropertyDescriptor(context.bindingContext(), property); + return TranslationUtils.assignmentToBackingField(context, propertyDescriptor, initExpression); + } + + @Override + @NotNull + public List visitAnonymousInitializer(@NotNull JetClassInitializer initializer, + @NotNull TranslationContext context) { + return Arrays.asList(Translation.translateAsStatement(initializer.getBody(), context)); + } + + @Override + @NotNull + // Not interested in other types of declarations, they do not contain initializers. + public List visitDeclaration(@NotNull JetDeclaration expression, @NotNull TranslationContext context) { + return Collections.emptyList(); + } + + @Override + @NotNull + public List visitObjectDeclarationName(@NotNull JetObjectDeclarationName objectName, + @NotNull TranslationContext context) { + PropertyDescriptor propertyDescriptorForObjectDeclaration + = getPropertyDescriptorForObjectDeclaration(context.bindingContext(), objectName); + JsName objectPropertyName = context.getNameForDescriptor(propertyDescriptorForObjectDeclaration); + JetObjectDeclaration objectDeclaration = getObjectDeclarationForName(objectName); + JsInvocation objectValue = ClassTranslator.generateClassCreationExpression(objectDeclaration, context); + return singletonList(TranslationUtils.assignmentToBackingField(context, + propertyDescriptorForObjectDeclaration, objectValue)); + } + + @NotNull + public List traverseClass(@NotNull JetClassOrObject expression, @NotNull TranslationContext context) { + List initializerStatements = new ArrayList(); + for (JetDeclaration declaration : expression.getDeclarations()) { + initializerStatements.addAll(declaration.accept(this, context)); + } + return initializerStatements; + } + + @NotNull + public List traverseNamespace(@NotNull NamespaceDescriptor namespace, @NotNull TranslationContext context) { + List initializerStatements = new ArrayList(); + for (JetDeclaration declaration : getDeclarationsForNamespace(context.bindingContext(), namespace)) { + initializerStatements.addAll(declaration.accept(this, context)); + } + return initializerStatements; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/initializer/NamespaceInitializerTranslator.java b/translator/src/org/jetbrains/k2js/translate/initializer/NamespaceInitializerTranslator.java new file mode 100644 index 00000000000..4132315e645 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/initializer/NamespaceInitializerTranslator.java @@ -0,0 +1,50 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.initializer; + +import com.google.dart.compiler.backend.js.ast.JsFunction; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.k2js.translate.context.TranslationContext; + +import static org.jetbrains.k2js.translate.utils.TranslationUtils.functionWithScope; + +/** + * @author Pavel Talanov + */ +public final class NamespaceInitializerTranslator extends AbstractInitializerTranslator { + + @NotNull + private final NamespaceDescriptor namespace; + + public NamespaceInitializerTranslator(@NotNull NamespaceDescriptor namespace, @NotNull TranslationContext context) { + super(context.getScopeForDescriptor(namespace).innerScope + ("initializer " + namespace.getName()), context); + this.namespace = namespace; + } + + @Override + @NotNull + protected JsFunction generateInitializerFunction() { + JsFunction result = functionWithScope(initializerMethodScope); + result.setBody(AstUtil.newBlock(translateNamespaceInitializers(namespace))); + return result; + } + + +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/CompareToIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/CompareToIntrinsic.java new file mode 100644 index 00000000000..0dbeeb4fca4 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/CompareToIntrinsic.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.types.expressions.OperatorConventions; +import org.jetbrains.jet.lexer.JetToken; + +/** + * @author Pavel Talanov + */ +public abstract class CompareToIntrinsic implements Intrinsic { + + private JetToken comparisonToken = null; + + @NotNull + protected JetToken getComparisonToken() { + assert comparisonToken != null : "Should use set token first"; + return comparisonToken; + } + + public void setComparisonToken(@NotNull JetToken comparisonToken) { + assert OperatorConventions.COMPARISON_OPERATIONS.contains(comparisonToken) + : "Should be a comparison operation"; + this.comparisonToken = comparisonToken; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/EqualsIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/EqualsIntrinsic.java new file mode 100644 index 00000000000..3cd074970eb --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/EqualsIntrinsic.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic; + +import org.jetbrains.annotations.NotNull; + +/** + * @author Pavel Talanov + */ +public abstract class EqualsIntrinsic implements Intrinsic { + + @NotNull + private Boolean isNegated = false; + + public void setNegated(boolean isNegated) { + this.isNegated = isNegated; + } + + protected boolean isNegated() { + return isNegated; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/FunctionIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/FunctionIntrinsic.java new file mode 100644 index 00000000000..9a5e0eab723 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/FunctionIntrinsic.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic; + +/** + * @author Pavel Talanov + */ +public interface FunctionIntrinsic extends Intrinsic { + +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/Intrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/Intrinsic.java new file mode 100644 index 00000000000..425e5f04b68 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/Intrinsic.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; + +import java.util.List; + +/** + * @author Pavel Talanov + *

+ * Base class for all intrinsics. + */ +public interface Intrinsic { + + @NotNull + JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context); +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/Intrinsics.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/Intrinsics.java new file mode 100644 index 00000000000..9893e8f489d --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/Intrinsics.java @@ -0,0 +1,257 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic; + +import com.google.common.collect.Lists; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.resolve.scopes.JetScope; +import org.jetbrains.jet.lang.types.JetStandardClasses; +import org.jetbrains.jet.lang.types.JetStandardLibrary; +import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.PrimitiveType; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.k2js.translate.intrinsic.array.*; +import org.jetbrains.k2js.translate.intrinsic.primitive.*; +import org.jetbrains.k2js.translate.intrinsic.string.CharAtIntrinsic; +import org.jetbrains.k2js.translate.intrinsic.string.LengthIntrinsic; +import org.jetbrains.k2js.translate.intrinsic.tuple.TupleAccessIntrinsic; +import org.jetbrains.k2js.translate.operation.OperatorTable; +import org.jetbrains.k2js.translate.utils.DescriptorUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.jetbrains.jet.lang.types.expressions.OperatorConventions.*; +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getFunctionByName; +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getPropertyByName; + +/** + * @author Pavel Talanov + *

+ * Provides mechanism to substitute method calls /w native constucts directly. + */ +public final class Intrinsics { + + @NotNull + private final Map functionIntrinsics = + new HashMap(); + + @NotNull + private final Map equalsIntrinsics = + new HashMap(); + + @NotNull + private final Map compareToIntrinsics = + new HashMap(); + + public static Intrinsics standardLibraryIntrinsics(@NotNull JetStandardLibrary library) { + return new Intrinsics(library); + } + + @NotNull + private final JetStandardLibrary library; + + private Intrinsics(@NotNull JetStandardLibrary library) { + this.library = library; + declareOperatorIntrinsics(); + declareStringIntrinsics(); + declareTuplesIntrinsics(); + declareArrayIntrinsics(); + } + + private void declareTuplesIntrinsics() { + for (int tupleSize = 0; tupleSize < JetStandardClasses.TUPLE_COUNT; ++tupleSize) { + declareTupleIntrinsics(tupleSize); + } + } + + //TODO: provide generic mechanism or refactor + private void declareArrayIntrinsics() { + + List arrayTypes = getLibraryArrayTypes(); + + for (JetType arrayType : arrayTypes) { + declareIntrinsicsForArrayType(arrayType); + } + declareNullConstructorIntrinsic(); + } + + private void declareNullConstructorIntrinsic() { + //TODO: + FunctionDescriptor nullArrayConstructor = library.getLibraryScope().getFunctions("Array").iterator().next(); + functionIntrinsics.put(nullArrayConstructor, ArrayNullConstructorIntrinsic.INSTANCE); + } + + //TODO: some dangerous operation unchecked here + private void declareIntrinsicsForArrayType(@NotNull JetType arrayType) { + JetScope arrayMemberScope = arrayType.getMemberScope(); + FunctionDescriptor setFunction = getFunctionByName(arrayMemberScope, "set"); + functionIntrinsics.put(setFunction, ArraySetIntrinsic.INSTANCE); + FunctionDescriptor getFunction = getFunctionByName(arrayMemberScope, "get"); + functionIntrinsics.put(getFunction, ArrayGetIntrinsic.INSTANCE); + PropertyDescriptor sizeProperty = getPropertyByName(arrayMemberScope, "size"); + functionIntrinsics.put(sizeProperty.getGetter(), ArraySizeIntrinsic.INSTANCE); + PropertyDescriptor indicesProperty = getPropertyByName(arrayMemberScope, "indices"); + functionIntrinsics.put(indicesProperty.getGetter(), ArrayIndicesIntrinsic.INSTANCE); + FunctionDescriptor iteratorFunction = getFunctionByName(arrayMemberScope, "iterator"); + functionIntrinsics.put(iteratorFunction, ArrayIteratorIntrinsic.INSTANCE); + ConstructorDescriptor arrayConstructor = + ((ClassDescriptor) arrayMemberScope.getContainingDeclaration()).getConstructors().iterator().next(); + functionIntrinsics.put(arrayConstructor, ArrayFunctionConstructorIntrinsic.INSTANCE); + } + + private List getLibraryArrayTypes() { + List arrayTypes = Lists.newArrayList(); + for (PrimitiveType type : PrimitiveType.values()) { + arrayTypes.add(library.getPrimitiveArrayJetType(type)); + } + arrayTypes.add(library.getArray().getDefaultType()); + return arrayTypes; + } + + private void declareTupleIntrinsics(int tupleSize) { + JetScope libraryScope = library.getLibraryScope(); + assert libraryScope != null; + ClassifierDescriptor tupleDescriptor = libraryScope.getClassifier("Tuple" + tupleSize); + assert tupleDescriptor != null; + declareTupleIntrinsicAccessors(tupleDescriptor, tupleSize); + } + + private void declareStringIntrinsics() { + PropertyDescriptor lengthProperty = + getPropertyByName(library.getCharSequence().getDefaultType().getMemberScope(), "length"); + functionIntrinsics.put(lengthProperty.getGetter(), LengthIntrinsic.INSTANCE); + FunctionDescriptor getFunction = + getFunctionByName(library.getString().getDefaultType().getMemberScope(), "get"); + functionIntrinsics.put(getFunction, CharAtIntrinsic.INSTANCE); + } + + private void declareTupleIntrinsicAccessors(@NotNull ClassifierDescriptor tupleDescriptor, + int tupleSize) { + for (int elementIndex = 0; elementIndex < tupleSize; ++elementIndex) { + String accessorName = "_" + (elementIndex + 1); + PropertyDescriptor propertyDescriptor = + getPropertyByName(tupleDescriptor.getDefaultType().getMemberScope(), accessorName); + functionIntrinsics.put(propertyDescriptor.getGetter(), new TupleAccessIntrinsic(elementIndex)); + } + } + + private void declareOperatorIntrinsics() { + IntrinsicDeclarationVisitor visitor = new IntrinsicDeclarationVisitor(); + for (DeclarationDescriptor descriptor : library.getLibraryScope().getAllDescriptors()) { + //noinspection NullableProblems + descriptor.accept(visitor, null); + } + } + + public boolean isIntrinsic(@NotNull DeclarationDescriptor descriptor) { + //NOTE: that if we want to add other intrinsics we have to modify this method + if (descriptor instanceof FunctionDescriptor) { + FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor.getOriginal(); + return (equalsIntrinsics.containsKey(functionDescriptor) || + compareToIntrinsics.containsKey(functionDescriptor) || + functionIntrinsics.containsKey(functionDescriptor)); + } + return false; + } + + @NotNull + public FunctionIntrinsic getFunctionIntrinsic(@NotNull FunctionDescriptor descriptor) { + return functionIntrinsics.get(descriptor.getOriginal()); + } + + @NotNull + public CompareToIntrinsic getCompareToIntrinsic(@NotNull FunctionDescriptor descriptor) { + return compareToIntrinsics.get(descriptor.getOriginal()); + } + + @NotNull + public EqualsIntrinsic getEqualsIntrinsic(@NotNull FunctionDescriptor descriptor) { + return equalsIntrinsics.get(descriptor.getOriginal()); + } + + private final class IntrinsicDeclarationVisitor extends DeclarationDescriptorVisitor { + + @Override + public Void visitClassDescriptor(@NotNull ClassDescriptor descriptor, @Nullable Void nothing) { + for (DeclarationDescriptor memberDescriptor : + descriptor.getDefaultType().getMemberScope().getAllDescriptors()) { + //noinspection NullableProblems + memberDescriptor.accept(this, null); + } + return null; + } + + @Override + public Void visitFunctionDescriptor(@NotNull FunctionDescriptor descriptor, @Nullable Void nothing) { + if (!isIntrinsic(descriptor)) { + declareOperatorIntrinsic(descriptor); + } + return null; + } + + + /*package*/ void declareOperatorIntrinsic(@NotNull FunctionDescriptor descriptor) { + tryResolveAsEqualsCompareToOrRangeToIntrinsic(descriptor); + tryResolveAsUnaryIntrinsics(descriptor); + tryResolveAsBinaryIntrinsics(descriptor); + } + + private void tryResolveAsEqualsCompareToOrRangeToIntrinsic(@NotNull FunctionDescriptor descriptor) { + String functionName = descriptor.getName(); + if (functionName.equals(COMPARE_TO)) { + compareToIntrinsics.put(descriptor, PrimitiveCompareToIntrinsic.newInstance()); + } + if (functionName.equals(EQUALS)) { + equalsIntrinsics.put(descriptor, PrimitiveEqualsIntrinsic.newInstance()); + } + if (functionName.equals("rangeTo")) { + functionIntrinsics.put(descriptor, PrimitiveRangeToIntrinsic.newInstance()); + } + } + + private void tryResolveAsUnaryIntrinsics(@NotNull FunctionDescriptor descriptor) { + String functionName = descriptor.getName(); + JetToken token = UNARY_OPERATION_NAMES.inverse().get(functionName); + + if (token == null) return; + if (!isUnaryOperation(descriptor)) return; + + functionIntrinsics.put(descriptor, PrimitiveUnaryOperationIntrinsic.newInstance(token)); + } + + private void tryResolveAsBinaryIntrinsics(@NotNull FunctionDescriptor descriptor) { + String functionName = descriptor.getName(); + + if (isUnaryOperation(descriptor)) return; + + JetToken token = BINARY_OPERATION_NAMES.inverse().get(functionName); + if (token == null) return; + + if (!OperatorTable.hasCorrespondingBinaryOperator(token)) return; + functionIntrinsics.put(descriptor, PrimitiveBinaryOperationIntrinsic.newInstance(token)); + } + + private boolean isUnaryOperation(@NotNull FunctionDescriptor descriptor) { + return !DescriptorUtils.hasParameters(descriptor); + } + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayFunctionConstructorIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayFunctionConstructorIntrinsic.java new file mode 100644 index 00000000000..6cd6f5cd2fd --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayFunctionConstructorIntrinsic.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.array; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public enum ArrayFunctionConstructorIntrinsic implements FunctionIntrinsic { + + INSTANCE; + + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, + @NotNull List arguments, + @NotNull TranslationContext context) { + assert receiver == null; + assert arguments.size() == 2; + //TODO: provide better mechanism + JsNameRef iteratorFunName = AstUtil.newQualifiedNameRef("Kotlin.arrayFromFun"); + return AstUtil.newInvocation(iteratorFunName, arguments); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayGetIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayGetIntrinsic.java new file mode 100644 index 00000000000..ea0d565247d --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayGetIntrinsic.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.array; + +import com.google.dart.compiler.backend.js.ast.JsArrayAccess; +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public enum ArrayGetIntrinsic implements FunctionIntrinsic { + + INSTANCE; + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert receiver != null; + assert arguments.size() == 1 : "Array get expression must have one argument."; + JsExpression indexExpression = arguments.get(0); + return new JsArrayAccess(receiver, indexExpression); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayIndicesIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayIndicesIntrinsic.java new file mode 100644 index 00000000000..c9e9f9d1005 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayIndicesIntrinsic.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.array; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public enum ArrayIndicesIntrinsic implements FunctionIntrinsic { + + INSTANCE; + + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert receiver != null; + assert arguments.size() == 0; + //TODO: provide better mechanism + JsNameRef iteratorFunName = AstUtil.newQualifiedNameRef("Kotlin.arrayIndices"); + return AstUtil.newInvocation(iteratorFunName, receiver); + } +} \ No newline at end of file diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayIteratorIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayIteratorIntrinsic.java new file mode 100644 index 00000000000..cc04aa26246 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayIteratorIntrinsic.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.array; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public enum ArrayIteratorIntrinsic implements FunctionIntrinsic { + + INSTANCE; + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert receiver != null; + assert arguments.size() == 0; + //TODO: provide better mechanism + JsNameRef iteratorFunName = AstUtil.newQualifiedNameRef("Kotlin.arrayIterator"); + return AstUtil.newInvocation(iteratorFunName, receiver); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayNullConstructorIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayNullConstructorIntrinsic.java new file mode 100644 index 00000000000..a9e0ee1cea3 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArrayNullConstructorIntrinsic.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.array; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public enum ArrayNullConstructorIntrinsic implements FunctionIntrinsic { + + INSTANCE; + + //TODO: implement function passing to array constructor + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert receiver == null; + assert arguments.size() == 1; + //TODO: provide better mechanism + JsNameRef nullArrayFunName = AstUtil.newQualifiedNameRef("Kotlin.nullArray"); + return AstUtil.newInvocation(nullArrayFunName, arguments); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArraySetIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArraySetIntrinsic.java new file mode 100644 index 00000000000..03f41d57c7c --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArraySetIntrinsic.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.array; + +import com.google.dart.compiler.backend.js.ast.JsArrayAccess; +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public enum ArraySetIntrinsic implements FunctionIntrinsic { + + INSTANCE; + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert receiver != null; + assert arguments.size() == 2 : "Array set expression must have two arguments."; + JsExpression indexExpression = arguments.get(0); + JsExpression value = arguments.get(1); + JsArrayAccess arrayAccess = AstUtil.newArrayAccess(receiver, indexExpression); + return AstUtil.newAssignment(arrayAccess, value); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArraySizeIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArraySizeIntrinsic.java new file mode 100644 index 00000000000..69a04d2231f --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/array/ArraySizeIntrinsic.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.array; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public enum ArraySizeIntrinsic implements FunctionIntrinsic { + + INSTANCE; + + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert receiver != null; + assert arguments.isEmpty() : "Length expression must have zero arguments."; + //TODO: provide better way + JsNameRef lengthProperty = AstUtil.newQualifiedNameRef("length"); + AstUtil.setQualifier(lengthProperty, receiver); + return lengthProperty; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveBinaryOperationIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveBinaryOperationIntrinsic.java new file mode 100644 index 00000000000..5d6039319e9 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveBinaryOperationIntrinsic.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.primitive; + +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.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; +import org.jetbrains.k2js.translate.operation.OperatorTable; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public final class PrimitiveBinaryOperationIntrinsic implements FunctionIntrinsic { + + @NotNull + public static PrimitiveBinaryOperationIntrinsic newInstance(@NotNull JetToken token) { + JsBinaryOperator operator = OperatorTable.getBinaryOperator(token); + return new PrimitiveBinaryOperationIntrinsic(operator); + } + + @NotNull + private final JsBinaryOperator operator; + + private PrimitiveBinaryOperationIntrinsic(@NotNull JsBinaryOperator operator) { + this.operator = operator; + } + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert arguments.size() == 1 : "Binary operator should have a receiver and one argument"; + return new JsBinaryOperation(operator, receiver, arguments.get(0)); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveCompareToIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveCompareToIntrinsic.java new file mode 100644 index 00000000000..c43708008e5 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveCompareToIntrinsic.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.primitive; + +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.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.CompareToIntrinsic; +import org.jetbrains.k2js.translate.operation.OperatorTable; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public final class PrimitiveCompareToIntrinsic extends CompareToIntrinsic { + + @NotNull + public static PrimitiveCompareToIntrinsic newInstance() { + return new PrimitiveCompareToIntrinsic(); + } + + private PrimitiveCompareToIntrinsic() { + } + + @NotNull + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert arguments.size() == 1 : "Equals operation should have one argument"; + JsBinaryOperator operator = OperatorTable.getBinaryOperator(getComparisonToken()); + JsExpression argument = arguments.get(0); + return new JsBinaryOperation(operator, receiver, argument); + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveEqualsIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveEqualsIntrinsic.java new file mode 100644 index 00000000000..05cd57be9cd --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveEqualsIntrinsic.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.primitive; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.EqualsIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public final class PrimitiveEqualsIntrinsic extends EqualsIntrinsic { + + @NotNull + public static PrimitiveEqualsIntrinsic newInstance() { + return new PrimitiveEqualsIntrinsic(); + } + + private PrimitiveEqualsIntrinsic() { + } + + @NotNull + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert arguments.size() == 1 : "Equals operation should have one argument"; + if (isNegated()) { + return AstUtil.notEqual(receiver, arguments.get(0)); + } else { + return AstUtil.equals(receiver, arguments.get(0)); + } + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveRangeToIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveRangeToIntrinsic.java new file mode 100644 index 00000000000..723beaf07dc --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveRangeToIntrinsic.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.primitive; + +import com.google.dart.compiler.backend.js.ast.JsBinaryOperation; +import com.google.dart.compiler.backend.js.ast.JsBooleanLiteral; +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNew; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.Arrays; +import java.util.List; + +/** + * @author Pavel Talanov + */ +public final class PrimitiveRangeToIntrinsic implements FunctionIntrinsic { + + @NotNull + public static PrimitiveRangeToIntrinsic newInstance() { + return new PrimitiveRangeToIntrinsic(); + } + + private PrimitiveRangeToIntrinsic() { + } + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression rangeStart, @NotNull List arguments, + @NotNull TranslationContext context) { + assert arguments.size() == 1 : "RangeTo must have one argument."; + JsExpression rangeEnd = arguments.get(0); + JsBinaryOperation rangeSize = AstUtil.sum(AstUtil.subtract(rangeEnd, rangeStart), + context.program().getNumberLiteral(1)); + //TODO: provide a way not to hard code this value + JsNew numberRangeConstructorInvocation + = new JsNew(AstUtil.newQualifiedNameRef("Kotlin.NumberRange")); + //TODO: add tests and correct expression for reversed ranges. + JsBooleanLiteral isRangeReversed = context.program().getFalseLiteral(); + numberRangeConstructorInvocation.setArguments(Arrays.asList(rangeStart, rangeSize, isRangeReversed)); + return numberRangeConstructorInvocation; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveUnaryOperationIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveUnaryOperationIntrinsic.java new file mode 100644 index 00000000000..817461472a3 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveUnaryOperationIntrinsic.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.primitive; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsPrefixOperation; +import com.google.dart.compiler.backend.js.ast.JsUnaryOperator; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; +import org.jetbrains.k2js.translate.operation.OperatorTable; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public final class PrimitiveUnaryOperationIntrinsic implements FunctionIntrinsic { + + @NotNull + public static PrimitiveUnaryOperationIntrinsic newInstance(@NotNull JetToken token) { + JsUnaryOperator operator = OperatorTable.getUnaryOperator(token); + return new PrimitiveUnaryOperationIntrinsic(operator); + } + + @NotNull + private final JsUnaryOperator operator; + + private PrimitiveUnaryOperationIntrinsic(@NotNull JsUnaryOperator operator) { + this.operator = operator; + } + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert receiver != null; + assert arguments.size() == 0 : "Unary operator should not have arguments."; + //NOTE: cannot use this for increment/decrement + return new JsPrefixOperation(operator, receiver); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/string/CharAtIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/string/CharAtIntrinsic.java new file mode 100644 index 00000000000..e2bcfb82eb3 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/string/CharAtIntrinsic.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.string; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public enum CharAtIntrinsic implements FunctionIntrinsic { + + INSTANCE; + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert receiver != null; + assert arguments.size() == 1 : "get Char expression must have 1 arguments."; + //TODO: provide better way + JsNameRef charAtReference = AstUtil.newQualifiedNameRef("charAt"); + AstUtil.setQualifier(charAtReference, receiver); + return AstUtil.newInvocation(charAtReference, arguments); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/string/LengthIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/string/LengthIntrinsic.java new file mode 100644 index 00000000000..3e66610f8e2 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/string/LengthIntrinsic.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.string; + + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public enum LengthIntrinsic implements FunctionIntrinsic { + + INSTANCE; + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert receiver != null; + assert arguments.isEmpty() : "Length expression must have zero arguments."; + //TODO: provide better way + JsNameRef lengthProperty = AstUtil.newQualifiedNameRef("length"); + AstUtil.setQualifier(lengthProperty, receiver); + return lengthProperty; + } +} \ No newline at end of file diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/tuple/TupleAccessIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/tuple/TupleAccessIntrinsic.java new file mode 100644 index 00000000000..0dd7aa92dcb --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/tuple/TupleAccessIntrinsic.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.intrinsic.tuple; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; + +import java.util.List; + +/** + * @author Pavel Talanov + */ +public final class TupleAccessIntrinsic implements FunctionIntrinsic { + + private final int elementIndex; + + public TupleAccessIntrinsic(int elementIndex) { + this.elementIndex = elementIndex; + } + + @NotNull + @Override + public JsExpression apply(@Nullable JsExpression receiver, @NotNull List arguments, + @NotNull TranslationContext context) { + assert arguments.isEmpty() : "Tuple access expression should not have any arguments."; + return AstUtil.newArrayAccess(receiver, context.program().getNumberLiteral(elementIndex)); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/operation/AssignmentTranslator.java b/translator/src/org/jetbrains/k2js/translate/operation/AssignmentTranslator.java new file mode 100644 index 00000000000..59a0b1fbe69 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/operation/AssignmentTranslator.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.operation; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetBinaryExpression; +import org.jetbrains.jet.lang.types.expressions.OperatorConventions; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.reference.AccessTranslator; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.isVariableReassignment; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getOperationToken; +import static org.jetbrains.k2js.translate.utils.PsiUtils.isAssignment; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.isIntrinsicOperation; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.translateRightExpression; + +/** + * @author Pavel Talanov + */ +public abstract class AssignmentTranslator extends AbstractTranslator { + + public static boolean isAssignmentOperator(JetBinaryExpression expression) { + JetToken operationToken = getOperationToken(expression); + return (OperatorConventions.ASSIGNMENT_OPERATIONS.keySet().contains(operationToken) + || isAssignment(operationToken)); + } + + @NotNull + public static JsExpression translate(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + if (isIntrinsicOperation(context, expression)) { + return IntrinsicAssignmentTranslator.translate(expression, context); + } + return OverloadedAssignmentTranslator.translate(expression, context); + } + + @NotNull + protected final JetBinaryExpression expression; + protected final AccessTranslator accessTranslator; + protected final boolean isVariableReassignment; + @NotNull + protected final JsExpression right; + + protected AssignmentTranslator(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + super(context); + this.expression = expression; + this.isVariableReassignment = isVariableReassignment(context.bindingContext(), expression); + this.accessTranslator = AccessTranslator.getAccessTranslator(expression.getLeft(), context()); + this.right = translateRightExpression(context(), expression); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/operation/BinaryOperationTranslator.java b/translator/src/org/jetbrains/k2js/translate/operation/BinaryOperationTranslator.java new file mode 100644 index 00000000000..fba92b190fb --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/operation/BinaryOperationTranslator.java @@ -0,0 +1,157 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.operation; + +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.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; +import org.jetbrains.jet.lang.psi.JetBinaryExpression; +import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; +import org.jetbrains.jet.lang.types.expressions.OperatorConventions; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.jet.lexer.JetTokens; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.intrinsic.EqualsIntrinsic; +import org.jetbrains.k2js.translate.reference.CallBuilder; +import org.jetbrains.k2js.translate.reference.CallType; + +import java.util.Arrays; + +import static com.google.dart.compiler.util.AstUtil.not; +import static org.jetbrains.k2js.translate.operation.AssignmentTranslator.isAssignmentOperator; +import static org.jetbrains.k2js.translate.operation.CompareToTranslator.isCompareToCall; +import static org.jetbrains.k2js.translate.utils.BindingUtils.getFunctionDescriptorForOperationExpression; +import static org.jetbrains.k2js.translate.utils.BindingUtils.getResolvedCall; +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.isEquals; +import static org.jetbrains.k2js.translate.utils.PsiUtils.*; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.translateLeftExpression; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.translateRightExpression; + + +/** + * @author Pavel Talanov + */ +public final class BinaryOperationTranslator extends AbstractTranslator { + + @NotNull + public static JsExpression translate(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + return (new BinaryOperationTranslator(expression, context).translate()); + } + + @NotNull + /*package*/ static JsExpression translateAsOverloadedCall(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + return (new BinaryOperationTranslator(expression, context)).translateAsOverloadedBinaryOperation(); + } + + @NotNull + private final JetBinaryExpression expression; + + @Nullable + private final FunctionDescriptor operationDescriptor; + + private BinaryOperationTranslator(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + super(context); + this.expression = expression; + this.operationDescriptor = + getFunctionDescriptorForOperationExpression(context().bindingContext(), expression); + } + + @NotNull + private JsExpression translate() { + if (isAssignmentOperator(expression)) { + return AssignmentTranslator.translate(expression, context()); + } + if (isNotOverloadable()) { + return translateAsUnOverloadableBinaryOperation(); + } + if (isCompareToCall(expression, context())) { + return CompareToTranslator.translate(expression, context()); + } + assert operationDescriptor != null : + "Overloadable operations must have not null descriptor"; + if (isEquals(operationDescriptor)) { + return translateAsEqualsCall(); + } + return translateAsOverloadedBinaryOperation(); + } + + private boolean isNotOverloadable() { + return operationDescriptor == null; + } + + @NotNull + private JsExpression translateAsEqualsCall() { + assert operationDescriptor != null : "Equals operation must resolve to descriptor."; + EqualsIntrinsic intrinsic = context().intrinsics().getEqualsIntrinsic(operationDescriptor); + intrinsic.setNegated(expression.getOperationToken().equals(JetTokens.EXCLEQ)); + JsExpression left = translateLeftExpression(context(), expression); + JsExpression right = translateRightExpression(context(), expression); + return intrinsic.apply(left, Arrays.asList(right), context()); + } + + @NotNull + private JsExpression translateAsUnOverloadableBinaryOperation() { + JetToken token = getOperationToken(expression); + JsBinaryOperator operator = OperatorTable.getBinaryOperator(token); + assert OperatorConventions.NOT_OVERLOADABLE.contains(token); + JsExpression left = translateLeftExpression(context(), expression); + JsExpression right = translateRightExpression(context(), expression); + return new JsBinaryOperation(operator, left, right); + } + + + @NotNull + private JsExpression translateAsOverloadedBinaryOperation() { + CallBuilder callBuilder = setReceiverAndArguments(); + ResolvedCall resolvedCall1 = + getResolvedCall(context().bindingContext(), expression.getOperationReference()); + JsExpression result = callBuilder.resolvedCall(resolvedCall1) + .type(CallType.NORMAL).translate(); + return mayBeWrapWithNegation(result); + } + + @NotNull + private CallBuilder setReceiverAndArguments() { + CallBuilder callBuilder = CallBuilder.build(context()); + + JsExpression leftExpression = translateLeftExpression(context(), expression); + JsExpression rightExpression = translateRightExpression(context(), expression); + + if (isInOrNotInOperation(expression)) { + return callBuilder.receiver(rightExpression).args(leftExpression); + } else { + return callBuilder.receiver(leftExpression).args(rightExpression); + } + } + + @NotNull + private JsExpression mayBeWrapWithNegation(@NotNull JsExpression result) { + if (isNotInOperation(expression)) { + return not(result); + } else { + return result; + } + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/operation/CompareToTranslator.java b/translator/src/org/jetbrains/k2js/translate/operation/CompareToTranslator.java new file mode 100644 index 00000000000..3ce5449c216 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/operation/CompareToTranslator.java @@ -0,0 +1,100 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.operation; + +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.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; +import org.jetbrains.jet.lang.psi.JetBinaryExpression; +import org.jetbrains.jet.lang.types.expressions.OperatorConventions; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.intrinsic.CompareToIntrinsic; +import org.jetbrains.k2js.translate.utils.TranslationUtils; + +import java.util.Arrays; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.getFunctionDescriptorForOperationExpression; +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.isCompareTo; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getOperationToken; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.*; + +/** + * @author Pavel Talanov + */ +public final class CompareToTranslator extends AbstractTranslator { + + public static boolean isCompareToCall(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + FunctionDescriptor operationDescriptor = + getFunctionDescriptorForOperationExpression(context.bindingContext(), expression); + + if (operationDescriptor == null) return false; + + return (isCompareTo(operationDescriptor)); + } + + @NotNull + public static JsExpression translate(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + return (new CompareToTranslator(expression, context)).translate(); + } + + @NotNull + private final JetBinaryExpression expression; + + @NotNull + private final FunctionDescriptor descriptor; + + private CompareToTranslator(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + super(context); + this.expression = expression; + FunctionDescriptor functionDescriptor = + getFunctionDescriptorForOperationExpression(context.bindingContext(), expression); + assert functionDescriptor != null : "CompareTo should always have a descriptor"; + this.descriptor = functionDescriptor; + assert (OperatorConventions.COMPARISON_OPERATIONS.contains(getOperationToken(expression))); + } + + @NotNull + private JsExpression translate() { + if (isIntrinsicOperation(context(), expression)) { + return intrinsicCompareTo(); + } + return overloadedCompareTo(); + } + + @NotNull + private JsExpression overloadedCompareTo() { + JsBinaryOperator correspondingOperator = OperatorTable.getBinaryOperator(getOperationToken(expression)); + JsExpression methodCall = BinaryOperationTranslator.translateAsOverloadedCall(expression, context()); + return new JsBinaryOperation(correspondingOperator, methodCall, TranslationUtils.zeroLiteral(context())); + } + + @NotNull + private JsExpression intrinsicCompareTo() { + CompareToIntrinsic intrinsic = context().intrinsics().getCompareToIntrinsic(descriptor); + intrinsic.setComparisonToken((JetToken) expression.getOperationToken()); + JsExpression left = translateLeftExpression(context(), expression); + JsExpression right = translateRightExpression(context(), expression); + return intrinsic.apply(left, Arrays.asList(right), context()); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/operation/IncrementTranslator.java b/translator/src/org/jetbrains/k2js/translate/operation/IncrementTranslator.java new file mode 100644 index 00000000000..1e81b5f78a8 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/operation/IncrementTranslator.java @@ -0,0 +1,126 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.operation; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetExpression; +import org.jetbrains.jet.lang.psi.JetUnaryExpression; +import org.jetbrains.jet.lang.types.expressions.OperatorConventions; +import org.jetbrains.k2js.translate.context.TemporaryVariable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.reference.AccessTranslator; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.isStatement; +import static org.jetbrains.k2js.translate.utils.BindingUtils.isVariableReassignment; +import static org.jetbrains.k2js.translate.utils.PsiUtils.*; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.isIntrinsicOperation; + +/** + * @author Pavel Talanov + */ +// TODO: provide better increment translator logic +public abstract class IncrementTranslator extends AbstractTranslator { + + public static boolean isIncrement(@NotNull JetUnaryExpression expression) { + return OperatorConventions.INCREMENT_OPERATIONS.contains(getOperationToken(expression)); + } + + @NotNull + public static JsExpression translate(@NotNull JetUnaryExpression expression, + @NotNull TranslationContext context) { + if (isIntrinsicOperation(context, expression)) { + return IntrinsicIncrementTranslator.translate(expression, context); + } + return OverloadedIncrementTranslator.translate(expression, context); + } + + @NotNull + protected final JetUnaryExpression expression; + @NotNull + protected final AccessTranslator accessTranslator; + private final boolean isVariableReassignment; + + protected IncrementTranslator(@NotNull JetUnaryExpression expression, + @NotNull TranslationContext context) { + super(context); + this.expression = expression; + this.isVariableReassignment = isVariableReassignment(context.bindingContext(), expression); + JetExpression baseExpression = getBaseExpression(expression); + this.accessTranslator = AccessTranslator.getAccessTranslator(baseExpression, context()); + } + + @NotNull + protected JsExpression translateAsMethodCall() { + if (returnValueIgnored() || isPrefix(expression)) { + return asPrefix(); + } + if (isVariableReassignment) { + return asPostfixWithReassignment(); + } else { + return asPostfixWithNoReassignment(); + } + } + + private boolean returnValueIgnored() { + return isStatement(context().bindingContext(), expression); + } + + @NotNull + private JsExpression asPrefix() { + JsExpression getExpression = accessTranslator.translateAsGet(); + if (isVariableReassignment) { + return variableReassignment(getExpression); + } + return operationExpression(getExpression); + } + + //TODO: decide if this expression can be optimised in case of direct access (not property) + @NotNull + private JsExpression asPostfixWithReassignment() { + // code fragment: expr(a++) + // generate: expr( (t1 = a, t2 = t1, a = t1.inc(), t2) ) + TemporaryVariable t1 = context().declareTemporary(accessTranslator.translateAsGet()); + TemporaryVariable t2 = context().declareTemporary(t1.nameReference()); + JsExpression variableReassignment = variableReassignment(t1.nameReference()); + return AstUtil.newSequence(t1.assignmentExpression(), t2.assignmentExpression(), + variableReassignment, t2.nameReference()); + } + + //TODO: TEST + @NotNull + private JsExpression asPostfixWithNoReassignment() { + // code fragment: expr(a++) + // generate: expr( (t1 = a, t2 = t1, t2.inc(), t1) ) + TemporaryVariable t1 = context().declareTemporary(accessTranslator.translateAsGet()); + TemporaryVariable t2 = context().declareTemporary(t1.nameReference()); + JsExpression methodCall = operationExpression(t2.nameReference()); + JsExpression returnedValue = t1.nameReference(); + return AstUtil.newSequence(t1.assignmentExpression(), t2.assignmentExpression(), methodCall, returnedValue); + } + + @NotNull + private JsExpression variableReassignment(@NotNull JsExpression toCallMethodUpon) { + JsExpression overloadedMethodCallOnPropertyGetter = operationExpression(toCallMethodUpon); + return accessTranslator.translateAsSet(overloadedMethodCallOnPropertyGetter); + } + + @NotNull + abstract JsExpression operationExpression(@NotNull JsExpression receiver); +} diff --git a/translator/src/org/jetbrains/k2js/translate/operation/IntrinsicAssignmentTranslator.java b/translator/src/org/jetbrains/k2js/translate/operation/IntrinsicAssignmentTranslator.java new file mode 100644 index 00000000000..e845b34a175 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/operation/IntrinsicAssignmentTranslator.java @@ -0,0 +1,102 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.operation; + +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.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetBinaryExpression; +import org.jetbrains.jet.lang.types.expressions.OperatorConventions; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.reference.ReferenceAccessTranslator; + +import static org.jetbrains.k2js.translate.utils.PsiUtils.getOperationToken; +import static org.jetbrains.k2js.translate.utils.PsiUtils.isAssignment; + +/** + * @author Pavel Talanov + */ +public final class IntrinsicAssignmentTranslator extends AssignmentTranslator { + + + @NotNull + public static JsExpression translate(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + return (new IntrinsicAssignmentTranslator(expression, context)).translate(); + } + + private IntrinsicAssignmentTranslator(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + super(expression, context); + } + + @NotNull + protected JsExpression translate() { + if (isAssignment(getOperationToken(expression))) { + return translateAsPlainAssignment(); + } + return translateAsAssignmentOperation(); + } + + @NotNull + private JsExpression translateAsAssignmentOperation() { + if (accessTranslator instanceof ReferenceAccessTranslator) { + return translateAsPlainAssignmentOperation(); + } + return translateAsAssignToCounterpart(); + } + + @NotNull + private JsExpression translateAsAssignToCounterpart() { + JsBinaryOperator operator = getCounterpartOperator(); + JsBinaryOperation counterpartOperation = + new JsBinaryOperation(operator, accessTranslator.translateAsGet(), right); + return accessTranslator.translateAsSet(counterpartOperation); + } + + @NotNull + private JsBinaryOperator getCounterpartOperator() { + JetToken assignmentOperationToken = getOperationToken(expression); + assert OperatorConventions.ASSIGNMENT_OPERATIONS.containsKey(assignmentOperationToken); + JetToken counterpartToken = OperatorConventions.ASSIGNMENT_OPERATION_COUNTERPARTS.get(assignmentOperationToken); + assert OperatorTable.hasCorrespondingBinaryOperator(counterpartToken) : + "Unsupported token encountered: " + counterpartToken.toString(); + return OperatorTable.getBinaryOperator(counterpartToken); + } + + @NotNull + private JsExpression translateAsPlainAssignmentOperation() { + JsBinaryOperator operator = getAssignmentOperator(); + return new JsBinaryOperation(operator, accessTranslator.translateAsGet(), right); + } + + @NotNull + private JsBinaryOperator getAssignmentOperator() { + JetToken token = getOperationToken(expression); + assert OperatorConventions.ASSIGNMENT_OPERATIONS.containsKey(token); + assert OperatorTable.hasCorrespondingBinaryOperator(token) : + "Unsupported token encountered: " + token.toString(); + return OperatorTable.getBinaryOperator(token); + } + + @NotNull + private JsExpression translateAsPlainAssignment() { + return accessTranslator.translateAsSet(right); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/operation/IntrinsicIncrementTranslator.java b/translator/src/org/jetbrains/k2js/translate/operation/IntrinsicIncrementTranslator.java new file mode 100644 index 00000000000..f400ac44af3 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/operation/IntrinsicIncrementTranslator.java @@ -0,0 +1,90 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.operation; + +import com.google.dart.compiler.backend.js.ast.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetUnaryExpression; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.jet.lexer.JetTokens; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.reference.ReferenceAccessTranslator; + +import static org.jetbrains.k2js.translate.utils.PsiUtils.getOperationToken; +import static org.jetbrains.k2js.translate.utils.PsiUtils.isPrefix; + + +/** + * @author Pavel Talanov + */ +public final class IntrinsicIncrementTranslator extends IncrementTranslator { + + + @NotNull + public static JsExpression translate(@NotNull JetUnaryExpression expression, + @NotNull TranslationContext context) { + return (new IntrinsicIncrementTranslator(expression, context)) + .translate(); + } + + private IntrinsicIncrementTranslator(@NotNull JetUnaryExpression expression, + @NotNull TranslationContext context) { + super(expression, context); + } + + @NotNull + protected JsExpression translate() { + if (isPrimitiveExpressionIncrement()) { + return jsUnaryExpression(); + } + return translateAsMethodCall(); + } + + private boolean isPrimitiveExpressionIncrement() { + return accessTranslator instanceof ReferenceAccessTranslator; + } + + @NotNull + private JsExpression jsUnaryExpression() { + JsUnaryOperator operator = OperatorTable.getUnaryOperator(getOperationToken(expression)); + JsExpression getExpression = accessTranslator.translateAsGet(); + if (isPrefix(expression)) { + return new JsPrefixOperation(operator, getExpression); + } else { + return new JsPostfixOperation(operator, getExpression); + } + } + + @Override + @NotNull + protected JsExpression operationExpression(@NotNull JsExpression receiver) { + return unaryAsBinary(receiver); + } + + public JsBinaryOperation unaryAsBinary(@NotNull JsExpression leftExpression) { + JsNumberLiteral oneLiteral = context().program().getNumberLiteral(1); + JetToken token = getOperationToken(expression); + if (token.equals(JetTokens.PLUSPLUS)) { + return new JsBinaryOperation(JsBinaryOperator.ADD, leftExpression, oneLiteral); + } + if (token.equals(JetTokens.MINUSMINUS)) { + return new JsBinaryOperation(JsBinaryOperator.SUB, leftExpression, oneLiteral); + } + throw new AssertionError("This method should be called only for increment and decrement operators"); + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/operation/OperatorTable.java b/translator/src/org/jetbrains/k2js/translate/operation/OperatorTable.java new file mode 100644 index 00000000000..25405b9042b --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/operation/OperatorTable.java @@ -0,0 +1,85 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.operation; + +import com.google.dart.compiler.backend.js.ast.JsBinaryOperator; +import com.google.dart.compiler.backend.js.ast.JsUnaryOperator; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.jet.lexer.JetTokens; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Pavel Talanov + */ + +//TODO: refactor using guava builders +public final class OperatorTable { + + private static final Map binaryOperatorsMap = new HashMap(); + private static final Map unaryOperatorsMap = new HashMap(); + + static { + unaryOperatorsMap.put(JetTokens.PLUSPLUS, JsUnaryOperator.INC); //++ + unaryOperatorsMap.put(JetTokens.MINUSMINUS, JsUnaryOperator.DEC); //-- + unaryOperatorsMap.put(JetTokens.EXCL, JsUnaryOperator.NOT); //! + unaryOperatorsMap.put(JetTokens.MINUS, JsUnaryOperator.NEG); //- + unaryOperatorsMap.put(JetTokens.PLUS, JsUnaryOperator.POS); //+ + } + + //TODO : not all operators , add and test bit operators + static { + binaryOperatorsMap.put(JetTokens.PLUS, JsBinaryOperator.ADD); + binaryOperatorsMap.put(JetTokens.MINUS, JsBinaryOperator.SUB); + binaryOperatorsMap.put(JetTokens.MUL, JsBinaryOperator.MUL); + binaryOperatorsMap.put(JetTokens.DIV, JsBinaryOperator.DIV); + binaryOperatorsMap.put(JetTokens.EQ, JsBinaryOperator.ASG); + binaryOperatorsMap.put(JetTokens.GT, JsBinaryOperator.GT); + binaryOperatorsMap.put(JetTokens.GTEQ, JsBinaryOperator.GTE); + binaryOperatorsMap.put(JetTokens.LT, JsBinaryOperator.LT); + binaryOperatorsMap.put(JetTokens.LTEQ, JsBinaryOperator.LTE); + binaryOperatorsMap.put(JetTokens.EQEQ, JsBinaryOperator.REF_EQ); + binaryOperatorsMap.put(JetTokens.ANDAND, JsBinaryOperator.AND); + binaryOperatorsMap.put(JetTokens.OROR, JsBinaryOperator.OR); + binaryOperatorsMap.put(JetTokens.EXCLEQ, JsBinaryOperator.NEQ); + binaryOperatorsMap.put(JetTokens.PERC, JsBinaryOperator.MOD); + binaryOperatorsMap.put(JetTokens.PLUSEQ, JsBinaryOperator.ASG_ADD); + binaryOperatorsMap.put(JetTokens.MINUSEQ, JsBinaryOperator.ASG_SUB); + binaryOperatorsMap.put(JetTokens.DIVEQ, JsBinaryOperator.ASG_DIV); + binaryOperatorsMap.put(JetTokens.MULTEQ, JsBinaryOperator.ASG_MUL); + binaryOperatorsMap.put(JetTokens.PERCEQ, JsBinaryOperator.ASG_MOD); + } + + + public static boolean hasCorrespondingBinaryOperator(@NotNull JetToken token) { + return binaryOperatorsMap.containsKey(token); + } + + @NotNull + static public JsBinaryOperator getBinaryOperator(@NotNull JetToken token) { + assert JetTokens.OPERATIONS.contains(token) : "Token should represent an operation!"; + return binaryOperatorsMap.get(token); + } + + @NotNull + static public JsUnaryOperator getUnaryOperator(@NotNull JetToken token) { + assert JetTokens.OPERATIONS.contains(token) : "Token should represent an operation!"; + return unaryOperatorsMap.get(token); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/operation/OverloadedAssignmentTranslator.java b/translator/src/org/jetbrains/k2js/translate/operation/OverloadedAssignmentTranslator.java new file mode 100644 index 00000000000..b51a05e360f --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/operation/OverloadedAssignmentTranslator.java @@ -0,0 +1,67 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.operation; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetBinaryExpression; +import org.jetbrains.k2js.translate.context.TranslationContext; + +import static org.jetbrains.k2js.translate.utils.TranslationUtils.getMethodReferenceForOverloadedOperation; + +/** + * @author Pavel Talanov + */ +public final class OverloadedAssignmentTranslator extends AssignmentTranslator { + + @NotNull + public static JsExpression translate(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + return (new OverloadedAssignmentTranslator(expression, context)).translate(); + } + + @NotNull + private final JsNameRef operationReference; + + private OverloadedAssignmentTranslator(@NotNull JetBinaryExpression expression, + @NotNull TranslationContext context) { + super(expression, context); + this.operationReference = getMethodReferenceForOverloadedOperation(context, expression); + } + + @NotNull + protected JsExpression translate() { + if (isVariableReassignment) { + return reassignment(); + } + return overloadedMethodInvocation(); + } + + @NotNull + private JsExpression reassignment() { + return accessTranslator.translateAsSet(overloadedMethodInvocation()); + } + + @NotNull + private JsExpression overloadedMethodInvocation() { + AstUtil.setQualifier(operationReference, accessTranslator.translateAsGet()); + return AstUtil.newInvocation(operationReference, right); + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/operation/OverloadedIncrementTranslator.java b/translator/src/org/jetbrains/k2js/translate/operation/OverloadedIncrementTranslator.java new file mode 100644 index 00000000000..bbeea97e9b0 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/operation/OverloadedIncrementTranslator.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.operation; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetUnaryExpression; +import org.jetbrains.k2js.translate.context.TranslationContext; + +import static org.jetbrains.k2js.translate.utils.TranslationUtils.getMethodReferenceForOverloadedOperation; + +/** + * @author Pavel Talanov + */ +public final class OverloadedIncrementTranslator extends IncrementTranslator { + + @NotNull + public static JsExpression translate(@NotNull JetUnaryExpression expression, + @NotNull TranslationContext context) { + return (new OverloadedIncrementTranslator(expression, context)) + .translate(); + } + + @NotNull + private final JsNameRef operationReference; + + private OverloadedIncrementTranslator(@NotNull JetUnaryExpression expression, + @NotNull TranslationContext context) { + super(expression, context); + this.operationReference = getMethodReferenceForOverloadedOperation(context, expression); + } + + @NotNull + protected JsExpression translate() { + return translateAsMethodCall(); + } + + @Override + @NotNull + protected JsExpression operationExpression(@NotNull JsExpression receiver) { + AstUtil.setQualifier(operationReference, receiver); + return AstUtil.newInvocation(operationReference); + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/operation/UnaryOperationTranslator.java b/translator/src/org/jetbrains/k2js/translate/operation/UnaryOperationTranslator.java new file mode 100644 index 00000000000..f6e9f1fc060 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/operation/UnaryOperationTranslator.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.operation; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetUnaryExpression; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.reference.CallBuilder; +import org.jetbrains.k2js.translate.reference.CallType; +import org.jetbrains.k2js.translate.utils.TranslationUtils; + +import java.util.Collections; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.getResolvedCall; + +/** + * @author Pavel Talanov + */ + +public final class UnaryOperationTranslator { + + @NotNull + public static JsExpression translate(@NotNull JetUnaryExpression expression, + @NotNull TranslationContext context) { + if (IncrementTranslator.isIncrement(expression)) { + return IncrementTranslator.translate(expression, context); + } + return translateAsCall(expression, context); + } + + @NotNull + private static JsExpression translateAsCall(@NotNull JetUnaryExpression expression, + @NotNull TranslationContext context) { + return CallBuilder.build(context) + .receiver(TranslationUtils.translateBaseExpression(context, expression)) + .args(Collections.emptyList()) + .resolvedCall(getResolvedCall(context.bindingContext(), expression.getOperationReference())) + .type(CallType.NORMAL).translate(); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/reference/AccessTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/AccessTranslator.java new file mode 100644 index 00000000000..33a59596c2b --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/AccessTranslator.java @@ -0,0 +1,68 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; + +/** + * @author Pavel Talanov + *

+ * Abstract entity for language constructs that you can get/set. Also dispatches to the real implemntation. + */ +public abstract class AccessTranslator extends AbstractTranslator { + + //TODO: this piece of code represents dangerously convoluted logic, think of the ways it can be improved + @NotNull + public static AccessTranslator getAccessTranslator(@NotNull JetExpression referenceExpression, + @NotNull TranslationContext context) { + assert ((referenceExpression instanceof JetReferenceExpression) || + (referenceExpression instanceof JetQualifiedExpression)); + if (PropertyAccessTranslator.canBePropertyAccess(referenceExpression, context)) { + if (referenceExpression instanceof JetQualifiedExpression) { + return QualifiedExpressionTranslator.getAccessTranslator((JetQualifiedExpression) referenceExpression, context); + } + assert referenceExpression instanceof JetSimpleNameExpression; + return PropertyAccessTranslator.newInstance((JetSimpleNameExpression) referenceExpression, + null, CallType.NORMAL, context); + } + if (referenceExpression instanceof JetArrayAccessExpression) { + return ArrayAccessTranslator.newInstance((JetArrayAccessExpression) referenceExpression, context); + } + return ReferenceAccessTranslator.newInstance((JetSimpleNameExpression) referenceExpression, context); + } + + + @NotNull + public static JsExpression translateAsGet(@NotNull JetReferenceExpression expression, + @NotNull TranslationContext context) { + return (getAccessTranslator(expression, context)).translateAsGet(); + } + + + protected AccessTranslator(@Deprecated TranslationContext context) { + super(context); + } + + public abstract JsExpression translateAsGet(); + + public abstract JsExpression translateAsSet(@NotNull JsExpression setTo); + +} diff --git a/translator/src/org/jetbrains/k2js/translate/reference/ArrayAccessTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/ArrayAccessTranslator.java new file mode 100644 index 00000000000..fe6a0c9c721 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/ArrayAccessTranslator.java @@ -0,0 +1,96 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; +import org.jetbrains.jet.lang.psi.JetArrayAccessExpression; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.Translation; +import org.jetbrains.k2js.translate.utils.BindingUtils; +import org.jetbrains.k2js.translate.utils.TranslationUtils; + +import java.util.List; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.getDescriptorForReferenceExpression; + +/** + * @author Pavel Talanov + */ + +//TODO: inspect not clear how the class handles set and get operations differently +public final class ArrayAccessTranslator extends AccessTranslator { + + /*package*/ + static ArrayAccessTranslator newInstance(@NotNull JetArrayAccessExpression expression, + @NotNull TranslationContext context) { + return new ArrayAccessTranslator(expression, context); + } + + @NotNull + private final JetArrayAccessExpression expression; + @NotNull + private final FunctionDescriptor methodDescriptor; + + private ArrayAccessTranslator(@NotNull JetArrayAccessExpression expression, + @NotNull TranslationContext context) { + super(context); + this.expression = expression; + //TODO: that is strange + this.methodDescriptor = (FunctionDescriptor) + getDescriptorForReferenceExpression(context.bindingContext(), expression); + } + + @Override + @NotNull + public JsExpression translateAsGet() { + List arguments = translateIndexExpressions(); + return translateAsMethodCall(arguments); + } + + @Override + @NotNull + public JsExpression translateAsSet(@NotNull JsExpression expression) { + + List arguments = translateIndexExpressions(); + arguments.add(expression); + return translateAsMethodCall(arguments); + } + + @NotNull + private JsExpression translateAsMethodCall(@NotNull List arguments) { + return CallBuilder.build(context()) + .receiver(translateArrayExpression()) + .args(arguments) + .resolvedCall(BindingUtils.getResolvedCall(context().bindingContext(), expression)) + .descriptor(methodDescriptor) + .translate(); + } + + @NotNull + private List translateIndexExpressions() { + return TranslationUtils.translateExpressionList(context(), expression.getIndexExpressions()); + } + + @NotNull + private JsExpression translateArrayExpression() { + return Translation.translateAsExpression(expression.getArrayExpression(), context()); + } + + +} diff --git a/translator/src/org/jetbrains/k2js/translate/reference/CallBuilder.java b/translator/src/org/jetbrains/k2js/translate/reference/CallBuilder.java new file mode 100644 index 00000000000..fb8d82ea3a9 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/CallBuilder.java @@ -0,0 +1,208 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.common.collect.Lists; +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.CallableDescriptor; +import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; +import org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl; +import org.jetbrains.k2js.translate.context.TranslationContext; + +import java.util.Arrays; +import java.util.List; + +/** + * @author Pavel Talanov + */ +public final class CallBuilder { + + public static CallBuilder build(@NotNull TranslationContext context) { + return new CallBuilder(context); + } + + @NotNull + private final TranslationContext context; + @Nullable + private /*var*/ JsExpression receiver = null; + @NotNull + private final List args = Lists.newArrayList(); + @NotNull + private /*var*/ CallType callType = CallType.NORMAL; + @Nullable + private /*var*/ ResolvedCall resolvedCall = null; + @Nullable + private /*var*/ CallableDescriptor descriptor = null; + @Nullable + private /*var*/ JsExpression callee = null; + + + private CallBuilder(@NotNull TranslationContext context) { + this.context = context; + } + + @NotNull + public CallBuilder receiver(@Nullable JsExpression receiver) { + this.receiver = receiver; + return this; + } + + @NotNull + public CallBuilder args(@NotNull List args) { + assert this.args.isEmpty(); + this.args.addAll(args); + return this; + } + + @NotNull + public CallBuilder args(@NotNull JsExpression... args) { + return args(Arrays.asList(args)); + } + + @NotNull + public CallBuilder descriptor(@NotNull CallableDescriptor descriptor) { + this.descriptor = descriptor; + return this; + } + + @NotNull + public CallBuilder callee(@Nullable JsExpression callee) { + this.callee = callee; + return this; + } + + @NotNull + public CallBuilder resolvedCall(@NotNull ResolvedCall call) { + this.resolvedCall = call; + return this; + } + + @NotNull + public CallBuilder type(@NotNull CallType type) { + this.callType = type; + return this; + } + + //TODO: must be private + @NotNull + public CallTranslator finish() { + if (resolvedCall == null) { + assert descriptor != null; + resolvedCall = ResolvedCallImpl.create(descriptor); + } + if (descriptor == null) { + descriptor = resolvedCall.getCandidateDescriptor().getOriginal(); + } + assert resolvedCall != null; + return new CallTranslator(receiver, callee, args, resolvedCall, descriptor, callType, context); + } + + @NotNull + public JsExpression translate() { + return finish().translate(); + } + /* + @NotNull + private CallTranslator buildFromUnary(@NotNull JetUnaryExpression unaryExpression) { + JsExpression receiver = TranslationUtils.translateBaseExpression(context, unaryExpression); + List arguments = Collections.emptyList(); + ResolvedCall resolvedCall = + getResolvedCall(context.bindingContext(), unaryExpression.getOperationReference()); + return new CallTranslator(receiver, null, arguments, resolvedCall, null, CallType.NORMAL, context); + } + + //TODO: method too long + @NotNull + private CallTranslator buildFromBinary(@NotNull JetBinaryExpression binaryExpression, + boolean swapReceiverAndArgument) { + + JsExpression leftExpression = translateLeftExpression(context, binaryExpression); + JsExpression rightExpression = translateRightExpression(context, binaryExpression); + + JsExpression receiver; + List arguments; + if (swapReceiverAndArgument) { + receiver = rightExpression; + arguments = Arrays.asList(leftExpression); + } else { + receiver = leftExpression; + arguments = Arrays.asList(rightExpression); + } + + ResolvedCall resolvedCall = + getResolvedCall(context.bindingContext(), binaryExpression.getOperationReference()); + return new CallTranslator(receiver, null, arguments, resolvedCall, null, CallType.NORMAL, context); + } + + @NotNull + private CallTranslator buildFromCallExpression(@NotNull JetCallExpression callExpression, + @Nullable JsExpression receiver, + @NotNull CallType callType) { + ResolvedCall resolvedCall = getResolvedCallForCallExpression(context.bindingContext(), callExpression); + List arguments = translateArgumentsForCallExpression(callExpression, context); + JsExpression callee = null; + if (resolvedCall.getCandidateDescriptor() instanceof ExpressionAsFunctionDescriptor) { + callee = Translation.translateAsExpression(getCallee(callExpression), context); + } + return new CallTranslator(receiver, callee, arguments, resolvedCall, null, callType, context); + } + + @NotNull + private List translateArgumentsForCallExpression(@NotNull JetCallExpression callExpression, + @NotNull TranslationContext context) { + List result = new ArrayList(); + ResolvedCall resolvedCall = getResolvedCallForCallExpression(context.bindingContext(), callExpression); + Map formalToActualArguments = resolvedCall.getValueArguments(); + for (ValueParameterDescriptor parameterDescriptor : resolvedCall.getResultingDescriptor().getValueParameters()) { + ResolvedValueArgument actualArgument = formalToActualArguments.get(parameterDescriptor); + result.add(translateSingleArgument(actualArgument, parameterDescriptor)); + } + return result; + } + + + //TODO: refactor + @NotNull + private JsExpression translateSingleArgument(@NotNull ResolvedValueArgument actualArgument, + @NotNull ValueParameterDescriptor parameterDescriptor) { + List argumentExpressions = actualArgument.getArgumentExpressions(); + if (actualArgument instanceof VarargValueArgument) { + return translateVarargArgument(argumentExpressions); + } + if (actualArgument instanceof DefaultValueArgument) { + JetExpression defaultArgument = getDefaultArgument(context.bindingContext(), parameterDescriptor); + return Translation.translateAsExpression(defaultArgument, context); + } + assert actualArgument instanceof ExpressionValueArgument; + assert argumentExpressions.size() == 1; + return Translation.translateAsExpression(argumentExpressions.get(0), context); + } + + @NotNull + private JsExpression translateVarargArgument(@NotNull List arguments) { + JsArrayLiteral varargArgument = new JsArrayLiteral(); + for (JetExpression argument : arguments) { + varargArgument.getExpressions().add(Translation.translateAsExpression(argument, context)); + } + return varargArgument; + } + */ + + +} diff --git a/translator/src/org/jetbrains/k2js/translate/reference/CallExpressionTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/CallExpressionTranslator.java new file mode 100644 index 00000000000..9f9d65e4581 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/CallExpressionTranslator.java @@ -0,0 +1,116 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsArrayLiteral; +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; +import org.jetbrains.jet.lang.psi.JetCallExpression; +import org.jetbrains.jet.lang.psi.JetExpression; +import org.jetbrains.jet.lang.resolve.calls.*; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.general.Translation; + +import java.util.ArrayList; +import java.util.List; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.getDefaultArgument; +import static org.jetbrains.k2js.translate.utils.BindingUtils.getResolvedCallForCallExpression; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getCallee; + +/** + * @author Pavel Talanov + */ +public final class CallExpressionTranslator extends AbstractTranslator { + + @NotNull + public static JsExpression translate(@NotNull JetCallExpression expression, + @Nullable JsExpression receiver, + @NotNull CallType callType, + @NotNull TranslationContext context) { + return (new CallExpressionTranslator(expression, context)).translate(receiver, callType); + } + + @NotNull + private final JetCallExpression expression; + + private CallExpressionTranslator(@NotNull JetCallExpression expression, + @NotNull TranslationContext context) { + super(context); + this.expression = expression; + } + + @NotNull + private JsExpression translate(@Nullable JsExpression receiver, + @NotNull CallType callType) { + ResolvedCall resolvedCall = getResolvedCallForCallExpression(context().bindingContext(), expression); + return CallBuilder.build(context()) + .receiver(receiver) + .callee(getCalleeExpression(resolvedCall)) + .args(translateArguments()) + .resolvedCall(resolvedCall) + .type(callType) + .translate(); + } + + @Nullable + private JsExpression getCalleeExpression(@NotNull ResolvedCall resolvedCall) { + if (resolvedCall.getCandidateDescriptor() instanceof ExpressionAsFunctionDescriptor) { + return Translation.translateAsExpression(getCallee(expression), context()); + } + return null; + } + + @NotNull + private List translateArguments() { + List result = new ArrayList(); + ResolvedCall resolvedCall = getResolvedCallForCallExpression(context().bindingContext(), expression); + for (ValueParameterDescriptor parameterDescriptor : resolvedCall.getResultingDescriptor().getValueParameters()) { + ResolvedValueArgument actualArgument = resolvedCall.getValueArgumentsByIndex().get(parameterDescriptor.getIndex()); + result.add(translateSingleArgument(actualArgument, parameterDescriptor)); + } + return result; + } + + @NotNull + private JsExpression translateSingleArgument(@NotNull ResolvedValueArgument actualArgument, + @NotNull ValueParameterDescriptor parameterDescriptor) { + List argumentExpressions = actualArgument.getArgumentExpressions(); + if (actualArgument instanceof VarargValueArgument) { + return translateVarargArgument(argumentExpressions); + } + if (actualArgument instanceof DefaultValueArgument) { + JetExpression defaultArgument = getDefaultArgument(context().bindingContext(), parameterDescriptor); + return Translation.translateAsExpression(defaultArgument, context()); + } + assert actualArgument instanceof ExpressionValueArgument; + assert argumentExpressions.size() == 1; + return Translation.translateAsExpression(argumentExpressions.get(0), context()); + } + + @NotNull + private JsExpression translateVarargArgument(@NotNull List arguments) { + JsArrayLiteral varargArgument = new JsArrayLiteral(); + for (JetExpression argument : arguments) { + varargArgument.getExpressions().add(Translation.translateAsExpression(argument, context())); + } + return varargArgument; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java new file mode 100644 index 00000000000..199d9e4b446 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java @@ -0,0 +1,296 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsInvocation; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.backend.js.ast.JsNew; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.resolve.calls.ExpressionAsFunctionDescriptor; +import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; +import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.AbstractTranslator; +import org.jetbrains.k2js.translate.intrinsic.FunctionIntrinsic; +import org.jetbrains.k2js.translate.utils.AnnotationsUtils; +import org.jetbrains.k2js.translate.utils.TranslationUtils; + +import java.util.ArrayList; +import java.util.List; + +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.*; +import static org.jetbrains.k2js.translate.utils.TranslationUtils.getThisObject; + +/** + * @author Pavel Talanov + */ +//TODO: write tests on calling backing fields as functions +public final class CallTranslator extends AbstractTranslator { + + private static class CallParameters { + + public CallParameters(@Nullable JsExpression receiver, @NotNull JsExpression functionReference) { + this.receiver = receiver; + this.functionReference = functionReference; + } + + @Nullable + public /*var*/ JsExpression receiver; + @NotNull + public /*var*/ JsExpression functionReference; + } + + //NOTE: receiver may mean this object as well + @Nullable + private /*var*/ JsExpression receiver; + + @Nullable + private final JsExpression callee; + + @NotNull + private final List arguments; + + @NotNull + private final ResolvedCall resolvedCall; + + @NotNull + private final CallableDescriptor descriptor; + + @NotNull + private final CallType callType; + + /*package*/ CallTranslator(@Nullable JsExpression receiver, @Nullable JsExpression callee, + @NotNull List arguments, + @NotNull ResolvedCall resolvedCall, + @NotNull CallableDescriptor descriptorToCall, + @NotNull CallType callType, + @NotNull TranslationContext context) { + super(context); + this.receiver = receiver; + this.arguments = arguments; + this.resolvedCall = resolvedCall; + this.callType = callType; + this.descriptor = descriptorToCall; + this.callee = callee; + } + + @NotNull + /*package*/ JsExpression translate() { + //NOTE: treat native extension function calls as usual calls + if (isIntrinsic()) { + return intrinsicInvocation(); + } + if (isConstructor()) { + return constructorCall(); + } + if (isNative()) { + return methodCall(); + } + if (isExtensionFunctionLiteral()) { + return extensionFunctionLiteralCall(); + } + if (isExtensionFunction()) { + return extensionFunctionCall(); + } + return methodCall(); + } + + private boolean isIntrinsic() { + return context().intrinsics().isIntrinsic(descriptor); + } + + @NotNull + private JsExpression intrinsicInvocation() { + assert descriptor instanceof FunctionDescriptor; + FunctionIntrinsic functionIntrinsic = + context().intrinsics().getFunctionIntrinsic((FunctionDescriptor) descriptor); + JsExpression receiverExpression = resolveThisObject(/*do not get qualifier*/false); + return functionIntrinsic.apply(receiverExpression, arguments, context()); + } + + private boolean isConstructor() { + return isConstructorDescriptor(descriptor); + } + + @NotNull + private JsExpression constructorCall() { + JsExpression constructorReference = translateAsFunctionWithNoThisObject(descriptor); + JsNew constructorCall = new JsNew(constructorReference); + constructorCall.setArguments(arguments); + return constructorCall; + } + + @NotNull + private JsExpression translateAsFunctionWithNoThisObject(@NotNull DeclarationDescriptor descriptor) { + return ReferenceTranslator.translateAsFQReference(descriptor, context()); + } + + private boolean isNative() { + return AnnotationsUtils.isNativeObject(descriptor); + } + + private boolean isExtensionFunctionLiteral() { + boolean isLiteral = descriptor instanceof VariableAsFunctionDescriptor + || descriptor instanceof ExpressionAsFunctionDescriptor; + return isExtensionFunction() && isLiteral; + } + + @NotNull + private JsExpression extensionFunctionLiteralCall() { + JsExpression realReceiver = getExtensionFunctionCallReceiver(); + return callType.constructCall(realReceiver, new CallType.CallConstructor() { + @NotNull + @Override + public JsExpression construct(@Nullable JsExpression receiver) { + assert receiver != null : "Could not be null for extensions"; + return constructExtensionLiteralCall(receiver); + } + }, context()); + } + + @NotNull + private JsExpression constructExtensionLiteralCall(@NotNull JsExpression realReceiver) { + List callArguments = generateExtensionCallArgumentList(realReceiver); + JsInvocation callMethodInvocation = generateCallMethodInvocation(); + callMethodInvocation.setArguments(callArguments); + return callMethodInvocation; + } + + @NotNull + private JsInvocation generateCallMethodInvocation() { + JsNameRef callMethodNameRef = AstUtil.newQualifiedNameRef("call"); + JsInvocation callMethodInvocation = new JsInvocation(); + callMethodInvocation.setQualifier(callMethodNameRef); + AstUtil.setQualifier(callMethodInvocation, callParameters().functionReference); + return callMethodInvocation; + } + + @SuppressWarnings("UnnecessaryLocalVariable") + private boolean isExtensionFunction() { + boolean hasReceiver = resolvedCall.getReceiverArgument().exists(); + return hasReceiver; + } + + @NotNull + private JsExpression extensionFunctionCall() { + JsExpression realReceiver = getExtensionFunctionCallReceiver(); + return callType.constructCall(realReceiver, new CallType.CallConstructor() { + @NotNull + @Override + public JsExpression construct(@Nullable JsExpression receiver) { + assert receiver != null : "Could not be null for extensions"; + return constructExtensionFunctionCall(receiver); + } + }, context()); + } + + @NotNull + private JsExpression getExtensionFunctionCallReceiver() { + if (receiver != null) { + JsExpression result = receiver; + //Now the rest of the code can work as if it was simple method invocation + receiver = null; + return result; + } + DeclarationDescriptor expectedReceiverDescriptor = getExpectedReceiverDescriptor(descriptor); + assert expectedReceiverDescriptor != null; + return getThisObject(context(), expectedReceiverDescriptor); + } + + @NotNull + private JsExpression constructExtensionFunctionCall(@NotNull JsExpression receiver) { + List argumentList = generateExtensionCallArgumentList(receiver); + JsExpression functionReference = callParameters().functionReference; + AstUtil.setQualifier(functionReference, callParameters().receiver); + return AstUtil.newInvocation(functionReference, argumentList); + } + + @NotNull + private List generateExtensionCallArgumentList(@NotNull JsExpression receiver) { + List argumentList = new ArrayList(); + assert this.receiver == null : "Should be null at that point"; + argumentList.add(receiver); + argumentList.addAll(arguments); + return argumentList; + } + + @NotNull + private JsExpression methodCall() { + final CallParameters callParameters = callParameters(); + return callType.constructCall(callParameters.receiver, new CallType.CallConstructor() { + @NotNull + @Override + public JsExpression construct(@Nullable JsExpression receiver) { + JsExpression functionReference = callParameters.functionReference; + if (receiver != null) { + AstUtil.setQualifier(functionReference, receiver); + } + return AstUtil.newInvocation(functionReference, arguments); + } + }, context()); + } + + @NotNull + private CallParameters callParameters() { + if (callee != null) { + return new CallParameters(null, callee); + } + JsExpression thisObject = resolveThisObject(/*just get qualifier if null*/ true); + JsExpression functionReference = functionReference(); + return new CallParameters(thisObject, functionReference); + } + + @NotNull + private JsExpression functionReference() { + if (!isVariableAsFunction(descriptor)) { + return ReferenceTranslator.translateAsLocalNameReference(descriptor, context()); + } + VariableDescriptor variableDescriptor = + getVariableDescriptorForVariableAsFunction((VariableAsFunctionDescriptor) descriptor); + if (variableDescriptor instanceof PropertyDescriptor) { + return getterCall((PropertyDescriptor) variableDescriptor); + } + return ReferenceTranslator.translateAsLocalNameReference(variableDescriptor, context()); + } + + @NotNull + private JsExpression getterCall(@NotNull PropertyDescriptor variableDescriptor) { + //TODO: call type? + return PropertyAccessTranslator.translateAsPropertyGetterCall(variableDescriptor, resolvedCall, context()); + } + + //TODO: refactor + @Nullable + private JsExpression resolveThisObject(boolean getQualifierIfNull) { + if (receiver != null) { + return receiver; + } + ReceiverDescriptor thisObject = resolvedCall.getThisObject(); + if (thisObject.exists()) { + DeclarationDescriptor expectedThisDescriptor = getDeclarationDescriptorForReceiver(thisObject); + return TranslationUtils.getThisObject(context(), expectedThisDescriptor); + } + if (getQualifierIfNull) { + return context().getQualifierForDescriptor(descriptor); + } + return null; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/reference/CallType.java b/translator/src/org/jetbrains/k2js/translate/reference/CallType.java new file mode 100644 index 00000000000..cc8f14b0960 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/CallType.java @@ -0,0 +1,82 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsBinaryOperation; +import com.google.dart.compiler.backend.js.ast.JsConditional; +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNullLiteral; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression; +import org.jetbrains.jet.lang.psi.JetQualifiedExpression; +import org.jetbrains.jet.lang.psi.JetSafeQualifiedExpression; +import org.jetbrains.k2js.translate.context.TemporaryVariable; +import org.jetbrains.k2js.translate.context.TranslationContext; + +import static com.google.dart.compiler.util.AstUtil.newSequence; + +/** + * @author Pavel Talanov + */ +public enum CallType { + SAFE { + @NotNull + @Override + JsExpression constructCall(@Nullable JsExpression receiver, @NotNull CallConstructor constructor, + @NotNull TranslationContext context) { + assert receiver != null; + TemporaryVariable temporaryVariable = context.declareTemporary(receiver); + JsNullLiteral nullLiteral = context.program().getNullLiteral(); + //TODO: find similar not null checks + JsBinaryOperation notNullCheck = AstUtil.notEqual(temporaryVariable.nameReference(), nullLiteral); + JsConditional callMethodIfNotNullElseNull = + new JsConditional(notNullCheck, constructor.construct(temporaryVariable.nameReference()), nullLiteral); + return newSequence(temporaryVariable.assignmentExpression(), callMethodIfNotNullElseNull); + } + }, + //TODO: bang qualifier is not implemented in frontend for now + // BANG, + NORMAL { + @NotNull + @Override + JsExpression constructCall(@Nullable JsExpression receiver, @NotNull CallConstructor constructor, + @NotNull TranslationContext context) { + return constructor.construct(receiver); + } + }; + + @NotNull + abstract JsExpression constructCall(@Nullable JsExpression receiver, @NotNull CallConstructor constructor, + @NotNull TranslationContext context); + + @NotNull + public static CallType getCallTypeForQualifiedExpression(@NotNull JetQualifiedExpression expression) { + if (expression instanceof JetSafeQualifiedExpression) { + return SAFE; + } + assert expression instanceof JetDotQualifiedExpression; + return NORMAL; + } + + public interface CallConstructor { + @NotNull + JsExpression construct(@Nullable JsExpression receiver); + } + +} \ No newline at end of file diff --git a/translator/src/org/jetbrains/k2js/translate/reference/KotlinPropertyAccessTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/KotlinPropertyAccessTranslator.java new file mode 100644 index 00000000000..fb35e37f667 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/KotlinPropertyAccessTranslator.java @@ -0,0 +1,84 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; +import org.jetbrains.jet.lang.descriptors.PropertyGetterDescriptor; +import org.jetbrains.jet.lang.descriptors.PropertySetterDescriptor; +import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; +import org.jetbrains.k2js.translate.context.TranslationContext; + +/** + * @author Pavel Talanov + *

+ * For properies /w accessors. + */ +public final class KotlinPropertyAccessTranslator extends PropertyAccessTranslator { + + @Nullable + private final JsExpression qualifier; + @NotNull + private final PropertyDescriptor propertyDescriptor; + @NotNull + ResolvedCall resolvedCall; + + //TODO: too many params in constructor + /*package*/ KotlinPropertyAccessTranslator(@NotNull PropertyDescriptor descriptor, + @Nullable JsExpression qualifier, + @NotNull ResolvedCall resolvedCall, + @NotNull TranslationContext context) { + super(context); + this.qualifier = qualifier; + this.propertyDescriptor = descriptor.getOriginal(); + this.resolvedCall = resolvedCall; + } + + @Override + @NotNull + public JsExpression translateAsGet() { + //TODO: check for duplication + PropertyGetterDescriptor getter = propertyDescriptor.getGetter(); + assert getter != null : "Getter for kotlin properties should bot be null."; + return callBuilderForAccessor() + .descriptor(getter) + .translate(); + } + + @Override + @NotNull + public JsExpression translateAsSet(@NotNull JsExpression toSetTo) { + //TODO: check for duplication + PropertySetterDescriptor setter = propertyDescriptor.getSetter(); + assert setter != null : "Getter for kotlin properties should bot be null."; + return callBuilderForAccessor() + .args(toSetTo) + .descriptor(setter) + .translate(); + } + + @NotNull + private CallBuilder callBuilderForAccessor() { + return CallBuilder.build(context()) + .receiver(qualifier) + .resolvedCall(resolvedCall) + .type(getCallType()); + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/reference/NativePropertyAccessTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/NativePropertyAccessTranslator.java new file mode 100644 index 00000000000..f6744be776c --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/NativePropertyAccessTranslator.java @@ -0,0 +1,84 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsName; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.utils.TranslationUtils; + +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getExpectedThisDescriptor; + +/** + * @author Pavel Talanov + *

+ * For native apis that use .property notation for access. + */ +public final class NativePropertyAccessTranslator extends PropertyAccessTranslator { + + + @Nullable + private final JsExpression qualifier; + @NotNull + private final PropertyDescriptor propertyDescriptor; + + /*package*/ + NativePropertyAccessTranslator(@NotNull PropertyDescriptor descriptor, + @Nullable JsExpression qualifier, + @NotNull TranslationContext context) { + super(context); + this.qualifier = qualifier; + this.propertyDescriptor = descriptor.getOriginal(); + } + + + @Override + @NotNull + public JsExpression translateAsGet() { + JsName nativePropertyName = context().getNameForDescriptor(propertyDescriptor); + JsExpression realQualifier = getQualifier(); + if (realQualifier != null) { + return AstUtil.qualified(nativePropertyName, realQualifier); + } else { + return nativePropertyName.makeRef(); + } + } + + @Override + @NotNull + public JsExpression translateAsSet(@NotNull JsExpression setTo) { + return AstUtil.assignment(translateAsGet(), setTo); + } + + @Nullable + public JsExpression getQualifier() { + if (qualifier != null) { + return qualifier; + } + assert !propertyDescriptor.getReceiverParameter().exists() : "Cant have native extension properties."; + DeclarationDescriptor expectedThisDescriptor = getExpectedThisDescriptor(propertyDescriptor); + if (expectedThisDescriptor == null) { + return null; + } + return TranslationUtils.getThisObject(context(), expectedThisDescriptor); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/reference/PropertyAccessTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/PropertyAccessTranslator.java new file mode 100644 index 00000000000..4de16989916 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/PropertyAccessTranslator.java @@ -0,0 +1,143 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; +import org.jetbrains.jet.lang.psi.JetExpression; +import org.jetbrains.jet.lang.psi.JetQualifiedExpression; +import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; +import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; +import org.jetbrains.k2js.translate.context.TranslationContext; + +import static org.jetbrains.k2js.translate.utils.AnnotationsUtils.isNativeObject; +import static org.jetbrains.k2js.translate.utils.BindingUtils.getDescriptorForReferenceExpression; +import static org.jetbrains.k2js.translate.utils.BindingUtils.getResolvedCall; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getSelectorAsSimpleName; +import static org.jetbrains.k2js.translate.utils.PsiUtils.isBackingFieldReference; + +/** + * @author Pavel Talanov + */ +public abstract class PropertyAccessTranslator extends AccessTranslator { + + @NotNull + public static PropertyAccessTranslator newInstance(@NotNull PropertyDescriptor descriptor, + @NotNull ResolvedCall resolvedCall, + @NotNull TranslationContext context) { + if (isNativeObject(descriptor)) { + return new NativePropertyAccessTranslator(descriptor, /*qualifier = */ null, context); + } else { + return new KotlinPropertyAccessTranslator(descriptor, /*qualifier = */ null, resolvedCall, context); + } + } + + @NotNull + public static PropertyAccessTranslator newInstance(@NotNull JetSimpleNameExpression expression, + @Nullable JsExpression qualifier, + @NotNull CallType callType, + @NotNull TranslationContext context) { + PropertyAccessTranslator result; + PropertyDescriptor propertyDescriptor = getPropertyDescriptor(expression, context); + if (isNativeObject(propertyDescriptor) || isBackingFieldReference(expression)) { + result = new NativePropertyAccessTranslator(propertyDescriptor, qualifier, context); + } else { + ResolvedCall resolvedCall = getResolvedCall(context.bindingContext(), expression); + result = new KotlinPropertyAccessTranslator(propertyDescriptor, qualifier, resolvedCall, context); + } + result.setCallType(callType); + return result; + } + + @NotNull + /*package*/ static PropertyDescriptor getPropertyDescriptor(@NotNull JetSimpleNameExpression expression, + @NotNull TranslationContext context) { + DeclarationDescriptor descriptor = + getDescriptorForReferenceExpression(context.bindingContext(), expression); + assert descriptor instanceof PropertyDescriptor : "Must be a property descriptor."; + return (PropertyDescriptor) descriptor; + } + + + @NotNull + /*package*/ + static JsExpression translateAsPropertyGetterCall(@NotNull PropertyDescriptor descriptor, + @NotNull ResolvedCall resolvedCall, + @NotNull TranslationContext context) { + return (newInstance(descriptor, resolvedCall, context)) + .translateAsGet(); + } + + @NotNull + public static JsExpression translateAsPropertyGetterCall(@NotNull JetSimpleNameExpression expression, + @Nullable JsExpression qualifier, + @NotNull CallType callType, + @NotNull TranslationContext context) { + return (newInstance(expression, qualifier, callType, context)) + .translateAsGet(); + } + + + public static boolean canBePropertyGetterCall(@NotNull JetQualifiedExpression expression, + @NotNull TranslationContext context) { + JetSimpleNameExpression selector = getSelectorAsSimpleName(expression); + assert selector != null : "Only names are allowed after the dot"; + return canBePropertyGetterCall(selector, context); + } + + public static boolean canBePropertyGetterCall(@NotNull JetSimpleNameExpression expression, + @NotNull TranslationContext context) { + return (getDescriptorForReferenceExpression + (context.bindingContext(), expression) instanceof PropertyDescriptor); + } + + public static boolean canBePropertyGetterCall(@NotNull JetExpression expression, + @NotNull TranslationContext context) { + if (expression instanceof JetQualifiedExpression) { + return canBePropertyGetterCall((JetQualifiedExpression) expression, context); + } + if (expression instanceof JetSimpleNameExpression) { + return canBePropertyGetterCall((JetSimpleNameExpression) expression, context); + } + return false; + } + + public static boolean canBePropertyAccess(@NotNull JetExpression expression, + @NotNull TranslationContext context) { + return canBePropertyGetterCall(expression, context); + } + + //TODO: we use normal by default but may cause bugs + private /*var*/ CallType callType = CallType.NORMAL; + + protected PropertyAccessTranslator(@NotNull TranslationContext context) { + super(context); + } + + public void setCallType(@NotNull CallType callType) { + this.callType = callType; + } + + @NotNull + protected CallType getCallType() { + assert callType != null : "CallType not set"; + return callType; + } +} \ No newline at end of file diff --git a/translator/src/org/jetbrains/k2js/translate/reference/QualifiedExpressionTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/QualifiedExpressionTranslator.java new file mode 100644 index 00000000000..be4321a95a0 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/QualifiedExpressionTranslator.java @@ -0,0 +1,82 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetCallExpression; +import org.jetbrains.jet.lang.psi.JetExpression; +import org.jetbrains.jet.lang.psi.JetQualifiedExpression; +import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; +import org.jetbrains.k2js.translate.context.TranslationContext; + +import static org.jetbrains.k2js.translate.general.Translation.translateAsExpression; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getNotNullSimpleNameSelector; +import static org.jetbrains.k2js.translate.utils.PsiUtils.getSelector; + +/** + * @author Pavel Talanov + */ +public final class QualifiedExpressionTranslator { + + private QualifiedExpressionTranslator() { + } + + @NotNull + public static AccessTranslator getAccessTranslator(@NotNull JetQualifiedExpression expression, + @NotNull TranslationContext context) { + + JsExpression receiver = translateReceiver(expression, context); + PropertyAccessTranslator result = + PropertyAccessTranslator.newInstance(getNotNullSimpleNameSelector(expression), receiver, + CallType.getCallTypeForQualifiedExpression(expression), context); + result.setCallType(CallType.getCallTypeForQualifiedExpression(expression)); + return result; + } + + @NotNull + public static JsExpression translateQualifiedExpression(@NotNull JetQualifiedExpression expression, + @NotNull TranslationContext context) { + JsExpression receiver = translateReceiver(expression, context); + JetExpression selector = getSelector(expression); + CallType callType = CallType.getCallTypeForQualifiedExpression(expression); + return dispatchToCorrectTranslator(receiver, selector, callType, context); + } + + @NotNull + private static JsExpression dispatchToCorrectTranslator(@NotNull JsExpression receiver, + @NotNull JetExpression selector, + @NotNull CallType callType, + @NotNull TranslationContext context) { + if (PropertyAccessTranslator.canBePropertyGetterCall(selector, context)) { + assert selector instanceof JetSimpleNameExpression : "Selectors for properties must be simple names."; + return PropertyAccessTranslator.translateAsPropertyGetterCall + ((JetSimpleNameExpression) selector, receiver, callType, context); + } + if (selector instanceof JetCallExpression) { + return CallExpressionTranslator.translate((JetCallExpression) selector, receiver, callType, context); + } + throw new AssertionError("Unexpected qualified expression"); + } + + //TODO: if has duplications + @NotNull + private static JsExpression translateReceiver(@NotNull JetQualifiedExpression expression, + @NotNull TranslationContext context) { + return translateAsExpression(expression.getReceiverExpression(), context); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/reference/ReferenceAccessTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/ReferenceAccessTranslator.java new file mode 100644 index 00000000000..a80842e8ec0 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/ReferenceAccessTranslator.java @@ -0,0 +1,62 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsNameRef; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; +import org.jetbrains.k2js.translate.context.TranslationContext; + +/** + * @author Pavel Talanov + */ +public final class ReferenceAccessTranslator extends AccessTranslator { + + @NotNull + /*package*/ static ReferenceAccessTranslator newInstance(@NotNull JetSimpleNameExpression expression, + @NotNull TranslationContext context) { + return new ReferenceAccessTranslator(expression, context); + } + + @NotNull + private final JetSimpleNameExpression expression; + + private ReferenceAccessTranslator(@NotNull JetSimpleNameExpression expression, + @NotNull TranslationContext context) { + super(context); + this.expression = expression; + } + + @Override + @NotNull + public JsExpression translateAsGet() { + //TODO: consider evaluating only once + return ReferenceTranslator.translateSimpleName(expression, context()); + } + + @Override + @NotNull + public JsExpression translateAsSet(@NotNull JsExpression toSetTo) { + //TODO: consider evaluating only once + JsExpression reference = ReferenceTranslator.translateSimpleName(expression, context()); + assert reference instanceof JsNameRef; + return AstUtil.newAssignment((JsNameRef) reference, toSetTo); + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/reference/ReferenceTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/ReferenceTranslator.java new file mode 100644 index 00000000000..34c0f453f54 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/reference/ReferenceTranslator.java @@ -0,0 +1,62 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.reference; + +import com.google.dart.compiler.backend.js.ast.JsExpression; +import com.google.dart.compiler.backend.js.ast.JsName; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; +import org.jetbrains.k2js.translate.context.TranslationContext; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.getDescriptorForReferenceExpression; + +/** + * @author Pavel Talanov + */ +public final class ReferenceTranslator { + + @NotNull + public static JsExpression translateSimpleName(@NotNull JetSimpleNameExpression expression, + @NotNull TranslationContext context) { + if (PropertyAccessTranslator.canBePropertyGetterCall(expression, context)) { + return PropertyAccessTranslator.translateAsPropertyGetterCall(expression, null, CallType.NORMAL, context); + } + DeclarationDescriptor referencedDescriptor = + getDescriptorForReferenceExpression(context.bindingContext(), expression); + return translateAsLocalNameReference(referencedDescriptor, context); + } + + @NotNull + public static JsExpression translateAsFQReference(@NotNull DeclarationDescriptor referencedDescriptor, + @NotNull TranslationContext context) { + JsExpression qualifier = context.getQualifierForDescriptor(referencedDescriptor); + if (qualifier == null) { + return translateAsLocalNameReference(referencedDescriptor, context); + } + JsName referencedName = context.getNameForDescriptor(referencedDescriptor); + return AstUtil.qualified(referencedName, qualifier); + } + + @NotNull + public static JsExpression translateAsLocalNameReference(@NotNull DeclarationDescriptor referencedDescriptor, + @NotNull TranslationContext context) { + JsName referencedName = context.getNameForDescriptor(referencedDescriptor); + return referencedName.makeRef(); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/utils/AnnotationsUtils.java b/translator/src/org/jetbrains/k2js/translate/utils/AnnotationsUtils.java new file mode 100644 index 00000000000..d169f11ac6e --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/utils/AnnotationsUtils.java @@ -0,0 +1,111 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.utils; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.ClassDescriptor; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.DescriptorUtils; +import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; + +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getContainingClass; + +/** + * @author Pavel Talanov + */ +public final class AnnotationsUtils { + + @NotNull + public static final String NATIVE_ANNOTATION_FQNAME = "js.native"; + @NotNull + public static final String LIBRARY_ANNOTATION_FQNAME = "js.library"; + + private AnnotationsUtils() { + } + + //TODO: make public, use when necessary + private static boolean hasAnnotation(@NotNull DeclarationDescriptor descriptor, + @NotNull String annotationFQNAme) { + return getAnnotationByName(descriptor, annotationFQNAme) != null; + } + + @NotNull + public static String getAnnotationStringParameter(@NotNull DeclarationDescriptor declarationDescriptor, + @NotNull String annotationFQName) { + AnnotationDescriptor annotationDescriptor = + getAnnotationByName(declarationDescriptor, annotationFQName); + assert annotationDescriptor != null; + //TODO: this is a quick fix for unsupported default args problem + if (annotationDescriptor.getValueArguments().isEmpty()) { + return ""; + } + CompileTimeConstant constant = annotationDescriptor.getValueArguments().iterator().next(); + //TODO: this is a quick fix for unsupported default args problem + if (constant == null) { + return ""; + } + Object value = constant.getValue(); + assert value instanceof String : "Native function annotation should have one String parameter"; + return (String) value; + } + + @Nullable + public static AnnotationDescriptor getAnnotationByName(@NotNull DeclarationDescriptor descriptor, + @NotNull String FQName) { + for (AnnotationDescriptor annotationDescriptor : descriptor.getAnnotations()) { + String annotationClassFQName = getAnnotationClassFQName(annotationDescriptor); + if (annotationClassFQName.equals(FQName)) { + return annotationDescriptor; + } + } + return null; + } + + @NotNull + private static String getAnnotationClassFQName(@NotNull AnnotationDescriptor annotationDescriptor) { + DeclarationDescriptor annotationDeclaration = + annotationDescriptor.getType().getConstructor().getDeclarationDescriptor(); + assert annotationDeclaration != null : "Annotation supposed to have a declaration"; + return DescriptorUtils.getFQName(annotationDeclaration); + } + + public static boolean isNativeObject(@NotNull DeclarationDescriptor descriptor) { + return hasAnnotationOrInsideAnnotatedClass(descriptor, NATIVE_ANNOTATION_FQNAME); + } + + public static boolean isLibraryObject(@NotNull DeclarationDescriptor descriptor) { + return hasAnnotationOrInsideAnnotatedClass(descriptor, LIBRARY_ANNOTATION_FQNAME); + } + + //TODO: the use of this method is splattered across the code which can be hard to track + public static boolean isPredefinedObject(@NotNull DeclarationDescriptor descriptor) { + return isLibraryObject(descriptor) || isNativeObject(descriptor); + } + + private static boolean hasAnnotationOrInsideAnnotatedClass(DeclarationDescriptor descriptor, String annotationFQName) { + if (getAnnotationByName(descriptor, annotationFQName) != null) { + return true; + } + ClassDescriptor containingClass = getContainingClass(descriptor); + if (containingClass == null) { + return false; + } + return (getAnnotationByName(containingClass, annotationFQName) != null); + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java b/translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java new file mode 100644 index 00000000000..eb319974ee6 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java @@ -0,0 +1,333 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.utils; + +import com.google.common.collect.Sets; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; +import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; +import org.jetbrains.jet.lang.types.JetStandardClasses; +import org.jetbrains.jet.lang.types.JetType; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.*; + +/** + * @author Pavel Talanov + *

+ * This class contains some code related to BindingContext use. Intention is not to pollute other classes. + * Every call to BindingContext.get() is supposed to be wrapped by this utility class. + */ +public final class BindingUtils { + + private BindingUtils() { + } + + @NotNull + static private + D getDescriptorForExpression(@NotNull BindingContext context, @NotNull E expression, Class descriptorClass) { + DeclarationDescriptor descriptor = context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, expression); + assert descriptor != null; + assert descriptorClass.isInstance(descriptor) + : expression.toString() + " expected to have of type" + descriptorClass.toString(); + //noinspection unchecked + return (D) descriptor; + } + + @NotNull + public static ClassDescriptor getClassDescriptor(@NotNull BindingContext context, + @NotNull JetClassOrObject declaration) { + return getDescriptorForExpression(context, declaration, ClassDescriptor.class); + } + + @NotNull + public static NamespaceDescriptor getNamespaceDescriptor(@NotNull BindingContext context, + @NotNull JetFile declaration) { + NamespaceDescriptor namespaceDescriptor = + context.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, JetPsiUtil.getFQName(declaration)); + assert namespaceDescriptor != null : "File should have a namespace descriptor."; + return namespaceDescriptor; + } + + @NotNull + public static FunctionDescriptor getFunctionDescriptor(@NotNull BindingContext context, + @NotNull JetDeclarationWithBody declaration) { + return getDescriptorForExpression(context, declaration, FunctionDescriptor.class); + } + + //TODO: + @NotNull + public static PropertyAccessorDescriptor getPropertyAccessorDescriptor(@NotNull BindingContext context, + @NotNull JetPropertyAccessor declaration) { + return getDescriptorForExpression(context, declaration, PropertyAccessorDescriptor.class); + } + + @NotNull + public static PropertyDescriptor getPropertyDescriptor(@NotNull BindingContext context, + @NotNull JetProperty declaration) { + return getDescriptorForExpression(context, declaration, PropertyDescriptor.class); + } + + @NotNull + public static JetClass getClassForDescriptor(@NotNull BindingContext context, + @NotNull ClassDescriptor descriptor) { + PsiElement result = context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor); + assert result instanceof JetClass : "ClassDescriptor should have declaration of type JetClass"; + return (JetClass) result; + } + + @NotNull + public static List getDeclarationsForNamespace(@NotNull BindingContext bindingContext, + @NotNull NamespaceDescriptor namespace) { + List declarations = new ArrayList(); + for (DeclarationDescriptor descriptor : namespace.getMemberScope().getAllDescriptors()) { + if (AnnotationsUtils.isPredefinedObject(descriptor)) { + continue; + } + //TODO: + if (descriptor instanceof NamespaceDescriptor) { + continue; + } + JetDeclaration declaration = BindingUtils.getDeclarationForDescriptor(bindingContext, descriptor); + if (declaration != null) { + declarations.add(declaration); + } + } + return declarations; + } + + @Nullable + private static JetDeclaration getDeclarationForDescriptor(@NotNull BindingContext context, + @NotNull DeclarationDescriptor descriptor) { + PsiElement result = context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor); + if (result == null) { + //TODO: never get there + return null; + } + assert result instanceof JetDeclaration : "Descriptor should correspond to an element."; + return (JetDeclaration) result; + } + + @NotNull + private static JetParameter getParameterForDescriptor(@NotNull BindingContext context, + @NotNull ValueParameterDescriptor descriptor) { + PsiElement result = context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor); + assert result instanceof JetParameter : "ValueParameterDescriptor should have corresponding JetParameter."; + return (JetParameter) result; + } + + public static boolean hasAncestorClass(@NotNull BindingContext context, @NotNull JetClassOrObject classDeclaration) { + ClassDescriptor classDescriptor = getClassDescriptor(context, classDeclaration); + List superclassDescriptors = getSuperclassDescriptors(classDescriptor); + return (DescriptorUtils.findAncestorClass(superclassDescriptors) != null); + } + + public static boolean isStatement(@NotNull BindingContext context, @NotNull JetExpression expression) { + Boolean isStatement = context.get(BindingContext.STATEMENT, expression); + assert isStatement != null : "Invalid behaviour of get(BindingContext.STATEMENT)"; + return isStatement; + // return IsStatement.isStatement(expression); + } + + @NotNull + public static JetType getTypeByReference(@NotNull BindingContext context, + @NotNull JetTypeReference typeReference) { + JetType result = context.get(BindingContext.TYPE, typeReference); + assert result != null : "TypeReference should reference a type"; + return result; + } + + @NotNull + public static ClassDescriptor getClassDescriptorForTypeReference(@NotNull BindingContext context, + @NotNull JetTypeReference typeReference) { + return getClassDescriptorForType(getTypeByReference(context, typeReference)); + } + + @Nullable + public static PropertyDescriptor getPropertyDescriptorForConstructorParameter(@NotNull BindingContext context, + @NotNull JetParameter parameter) { + return context.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter); + } + + @Nullable + public static JetProperty getPropertyForDescriptor(@NotNull BindingContext context, + @NotNull PropertyDescriptor property) { + PsiElement result = context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, property); + if (!(result instanceof JetProperty)) { + return null; + } + return (JetProperty) result; + } + + @NotNull + public static DeclarationDescriptor getDescriptorForReferenceExpression(@NotNull BindingContext context, + @NotNull JetReferenceExpression reference) { + DeclarationDescriptor referencedDescriptor = getNullableDescriptorForReferenceExpression(context, reference); + assert referencedDescriptor != null : "Reference expression must reference a descriptor."; + return referencedDescriptor; + } + + @Nullable + private static DeclarationDescriptor getNullableDescriptorForReferenceExpression(@NotNull BindingContext context, + @NotNull JetReferenceExpression reference) { + DeclarationDescriptor referencedDescriptor = context.get(BindingContext.REFERENCE_TARGET, reference); + if (isVariableAsFunction(referencedDescriptor)) { + assert referencedDescriptor != null; + return getVariableDescriptorForVariableAsFunction((VariableAsFunctionDescriptor) referencedDescriptor); + } + return referencedDescriptor; + } + + public static boolean isNotAny(@NotNull DeclarationDescriptor superClassDescriptor) { + return !superClassDescriptor.equals(JetStandardClasses.getAny()); + } + + + //TODO: check where we use there, suspicious + public static boolean isOwnedByNamespace(@NotNull DeclarationDescriptor descriptor) { + if (descriptor instanceof ConstructorDescriptor) { + DeclarationDescriptor classDescriptor = descriptor.getContainingDeclaration(); + assert classDescriptor != null; + return isOwnedByNamespace(classDescriptor); + } + return (descriptor.getContainingDeclaration() instanceof NamespaceDescriptor); + } + + public static boolean isOwnedByClass(@NotNull DeclarationDescriptor descriptor) { + if (descriptor instanceof ConstructorDescriptor) { + DeclarationDescriptor classDescriptor = descriptor.getContainingDeclaration(); + assert classDescriptor != null; + return isOwnedByClass(classDescriptor); + } + return (descriptor.getContainingDeclaration() instanceof ClassDescriptor); + } + + @NotNull + public static ResolvedCall getResolvedCall(@NotNull BindingContext context, + @NotNull JetExpression expression) { + ResolvedCall resolvedCall = context.get(BindingContext.RESOLVED_CALL, expression); + assert resolvedCall != null : "Must resolve to a call."; + return resolvedCall; + } + + @NotNull + public static ResolvedCall getResolvedCallForCallExpression(@NotNull BindingContext context, + @NotNull JetCallExpression expression) { + JetExpression calleeExpression = PsiUtils.getCallee(expression); + return getResolvedCall(context, calleeExpression); + } + + public static boolean isVariableReassignment(@NotNull BindingContext context, @NotNull JetExpression expression) { + Boolean result = context.get(BindingContext.VARIABLE_REASSIGNMENT, expression); + assert result != null; + return result; + } + + + @Nullable + public static FunctionDescriptor getFunctionDescriptorForOperationExpression(@NotNull BindingContext context, + @NotNull JetOperationExpression expression) { + DeclarationDescriptor descriptorForReferenceExpression = getNullableDescriptorForReferenceExpression + (context, expression.getOperationReference()); + + if (descriptorForReferenceExpression == null) return null; + + assert descriptorForReferenceExpression instanceof FunctionDescriptor + : "Operation should resolve to function descriptor."; + return (FunctionDescriptor) descriptorForReferenceExpression; + } + + @NotNull + public static DeclarationDescriptor getDescriptorForElement(@NotNull BindingContext context, + @NotNull PsiElement element) { + DeclarationDescriptor descriptor = context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element); + assert descriptor != null : element + " doesn't have a descriptor."; + return descriptor; + } + + @Nullable + public static Object getCompileTimeValue(@NotNull BindingContext context, @NotNull JetExpression expression) { + CompileTimeConstant compileTimeValue = context.get(BindingContext.COMPILE_TIME_VALUE, expression); + if (compileTimeValue != null) { + return compileTimeValue.getValue(); + } + return null; + } + + @NotNull + public static JetExpression getDefaultArgument(@NotNull BindingContext context, + @NotNull ValueParameterDescriptor parameterDescriptor) { + assert parameterDescriptor.hasDefaultValue() : "Unsupplied parameter must have default value."; + JetParameter psiParameter = getParameterForDescriptor(context, parameterDescriptor); + JetExpression defaultValue = psiParameter.getDefaultValue(); + assert defaultValue != null : "No default value found in PSI."; + return defaultValue; + } + + @NotNull + public static FunctionDescriptor getIteratorFunction(@NotNull BindingContext context, + @NotNull JetExpression rangeExpression) { + FunctionDescriptor functionDescriptor = context.get(BindingContext.LOOP_RANGE_ITERATOR, rangeExpression); + assert functionDescriptor != null : "Range expression must have a descriptor for iterator function."; + return functionDescriptor; + } + + @NotNull + public static FunctionDescriptor getNextFunction(@NotNull BindingContext context, + @NotNull JetExpression rangeExpression) { + FunctionDescriptor functionDescriptor = context.get(BindingContext.LOOP_RANGE_NEXT, rangeExpression); + assert functionDescriptor != null : "Range expression must have a descriptor for next function."; + return functionDescriptor; + } + + @NotNull + public static CallableDescriptor getHasNextCallable(@NotNull BindingContext context, + @NotNull JetExpression rangeExpression) { + CallableDescriptor hasNextDescriptor = context.get(BindingContext.LOOP_RANGE_HAS_NEXT, rangeExpression); + assert hasNextDescriptor != null : "Range expression must have a descriptor for hasNext function or property."; + return hasNextDescriptor; + } + + @NotNull + public static PropertyDescriptor getPropertyDescriptorForObjectDeclaration(@NotNull BindingContext context, + @NotNull JetObjectDeclarationName name) { + PropertyDescriptor propertyDescriptor = context.get(BindingContext.OBJECT_DECLARATION, name); + assert propertyDescriptor != null; + return propertyDescriptor; + } + + @NotNull + public static Set getAllNonNativeNamespaceDescriptors(@NotNull BindingContext context, + @NotNull List files) { + Set descriptorSet = Sets.newHashSet(); + for (JetFile file : files) { + NamespaceDescriptor namespaceDescriptor = getNamespaceDescriptor(context, file); + if (!AnnotationsUtils.isPredefinedObject(namespaceDescriptor)) { + descriptorSet.add(namespaceDescriptor); + } + } + return descriptorSet; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/utils/ClassSorter.java b/translator/src/org/jetbrains/k2js/translate/utils/ClassSorter.java new file mode 100644 index 00000000000..2ad048cd13c --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/utils/ClassSorter.java @@ -0,0 +1,141 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.utils; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.ClassDescriptor; +import org.jetbrains.jet.lang.psi.JetClass; +import org.jetbrains.jet.lang.resolve.BindingContext; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getSuperclassDescriptors; + + +//TODO: can optimise using less dumb implementation +//TODO: pass list of descriptors here, not the list of jet classes + +/** + * @author Pavel Talanov + */ +public final class ClassSorter { + + @NotNull + private final List descriptorList; + @NotNull + private final List classesWithNoAncestors; + @NotNull + private final Map classWasInheritedCount = new HashMap(); + @NotNull + private final BindingContext bindingContext; + + @NotNull + public static List sortUsingInheritanceOrder(@NotNull List original, + @NotNull BindingContext bindingContext) { + ClassSorter sorter = new ClassSorter(original, bindingContext); + return sorter.sortUsingInheritanceOrder(); + } + + private ClassSorter(@NotNull List original, @NotNull BindingContext bindingContext) { + this.bindingContext = bindingContext; + this.descriptorList = getDescriptorList(original); + this.classesWithNoAncestors = new ArrayList(descriptorList); + setInitialCount(); + } + + @NotNull + private List sortUsingInheritanceOrder() { + List sortedClasses = new ArrayList(); + while (!classesWithNoAncestors.isEmpty()) { + ClassDescriptor classDescriptor = getNextClass(); + sortedClasses.add(BindingUtils.getClassForDescriptor(bindingContext, classDescriptor)); + } + assert sortedClasses.size() == descriptorList.size(); + return sortedClasses; + } + + @NotNull + private ClassDescriptor getNextClass() { + ClassDescriptor result = popFromList(); + decreaseCountForDerivedClasses(result); + classWasInheritedCount.remove(result); + return result; + } + + private void decreaseCountForDerivedClasses(@NotNull ClassDescriptor result) { + for (ClassDescriptor derived : descriptorList) { + if (isDerivedClass(result, derived)) { + decreaseCountForDerivedClass(derived); + } + } + } + + private void decreaseCountForDerivedClass(@NotNull ClassDescriptor derived) { + Integer timesInherited = classWasInheritedCount.get(derived); + assert timesInherited != null; + assert timesInherited > 0; + int newCount = timesInherited - 1; + classWasInheritedCount.put(derived, newCount); + if (newCount == 0) { + classesWithNoAncestors.add(derived); + } + } + + private boolean isDerivedClass(@NotNull ClassDescriptor ancestor, @NotNull ClassDescriptor derived) { + return (getSuperclassDescriptors(derived).contains(ancestor)); + } + + @NotNull + private ClassDescriptor popFromList() { + assert !classesWithNoAncestors.isEmpty(); + ClassDescriptor result = classesWithNoAncestors.get(classesWithNoAncestors.size() - 1); + ClassDescriptor removed = classesWithNoAncestors.remove(classesWithNoAncestors.size() - 1); + assert removed != null; + return result; + } + + + @NotNull + private List getDescriptorList(@NotNull List classesToSort) { + List descriptorList = new ArrayList(); + for (JetClass jetClass : classesToSort) { + descriptorList.add(BindingUtils.getClassDescriptor(bindingContext, jetClass)); + } + return descriptorList; + } + + private void setInitialCount() { + for (ClassDescriptor descriptor : descriptorList) { + List superclasses = getSuperclassDescriptors(descriptor); + int count = 0; + for (ClassDescriptor superclassDescriptor : superclasses) { + if (descriptorList.contains(superclassDescriptor)) { + count++; + } + } + classWasInheritedCount.put(descriptor, superclasses.size()); + if (count > 0) { + boolean success = classesWithNoAncestors.remove(descriptor); + assert success; + } + } + } + +} diff --git a/translator/src/org/jetbrains/k2js/translate/utils/DescriptorUtils.java b/translator/src/org/jetbrains/k2js/translate/utils/DescriptorUtils.java new file mode 100644 index 00000000000..19fc3588871 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/utils/DescriptorUtils.java @@ -0,0 +1,222 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.utils; + +import com.google.common.collect.Lists; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.resolve.scopes.JetScope; +import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; +import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.expressions.OperatorConventions; +import org.jetbrains.k2js.translate.context.Namer; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.isNotAny; + +/** + * @author Pavel Talanov + */ +public final class DescriptorUtils { + + private DescriptorUtils() { + } + + private static int valueParametersCount(@NotNull FunctionDescriptor functionDescriptor) { + return functionDescriptor.getValueParameters().size(); + } + + public static boolean hasParameters(@NotNull FunctionDescriptor functionDescriptor) { + return (valueParametersCount(functionDescriptor) > 0); + } + + public static boolean isEquals(@NotNull FunctionDescriptor functionDescriptor) { + return (functionDescriptor.getName().equals(OperatorConventions.EQUALS)); + } + + public static boolean isCompareTo(@NotNull FunctionDescriptor functionDescriptor) { + return (functionDescriptor.getName().equals(OperatorConventions.COMPARE_TO)); + } + + public static boolean isConstructorDescriptor(@NotNull CallableDescriptor descriptor) { + return (descriptor instanceof ConstructorDescriptor); + } + + @NotNull + public static FunctionDescriptor getFunctionByName(@NotNull JetScope scope, + @NotNull String name) { + Set functionDescriptors = scope.getFunctions(name); + assert functionDescriptors.size() == 1 : + "In scope " + scope + " supposed to be exactly one " + name + " function.\n" + + "Found: " + functionDescriptors.size(); + //noinspection LoopStatementThatDoesntLoop + for (FunctionDescriptor descriptor : functionDescriptors) { + return descriptor; + } + throw new AssertionError("In scope " + scope + + " supposed to be exactly one " + name + " function."); + } + + //TODO: some stange stuff happening to this method + @NotNull + public static PropertyDescriptor getPropertyByName(@NotNull JetScope scope, + @NotNull String name) { + VariableDescriptor variable = scope.getLocalVariable(name); + if (variable == null) { + variable = scope.getPropertyByFieldReference("$" + name); + } + Set variables = scope.getProperties(name); + assert variables.size() == 1 : "Actual size: " + variables.size(); + variable = variables.iterator().next(); + PropertyDescriptor descriptor = (PropertyDescriptor) variable; + assert descriptor != null : "Must have a descriptor."; + return descriptor; + } + + @Nullable + public static ClassDescriptor findAncestorClass(@NotNull List superclassDescriptors) { + for (ClassDescriptor descriptor : superclassDescriptors) { + if (descriptor.getKind() == ClassKind.CLASS) { + return descriptor; + } + } + return null; + } + + @NotNull + public static List getSuperclassDescriptors(@NotNull ClassDescriptor classDescriptor) { + Collection superclassTypes = classDescriptor.getTypeConstructor().getSupertypes(); + List superClassDescriptors = new ArrayList(); + for (JetType type : superclassTypes) { + ClassDescriptor result = getClassDescriptorForType(type); + if (isNotAny(result)) { + superClassDescriptors.add(result); + } + } + return superClassDescriptors; + } + + @Nullable + public static ClassDescriptor getSuperclass(@NotNull ClassDescriptor classDescriptor) { + return findAncestorClass(getSuperclassDescriptors(classDescriptor)); + } + + @NotNull + public static ClassDescriptor getClassDescriptorForType(@NotNull JetType type) { + DeclarationDescriptor superClassDescriptor = + type.getConstructor().getDeclarationDescriptor(); + assert superClassDescriptor instanceof ClassDescriptor + : "Superclass descriptor of a type should be of type ClassDescriptor"; + return (ClassDescriptor) superClassDescriptor; + } + + @NotNull + public static VariableDescriptor getVariableDescriptorForVariableAsFunction + (@NotNull VariableAsFunctionDescriptor descriptor) { + VariableDescriptor functionVariable = descriptor.getVariableDescriptor(); + assert functionVariable != null; + return functionVariable; + } + + + public static boolean isVariableAsFunction(@Nullable DeclarationDescriptor referencedDescriptor) { + return referencedDescriptor instanceof VariableAsFunctionDescriptor; + } + + @NotNull + public static DeclarationDescriptor getContainingDeclaration(@NotNull DeclarationDescriptor descriptor) { + DeclarationDescriptor containing = descriptor.getContainingDeclaration(); + assert containing != null : "Should be called on objects that have containing declaration."; + return containing; + } + + public static boolean isExtensionFunction(@NotNull CallableDescriptor functionDescriptor) { + return (functionDescriptor.getReceiverParameter().exists()); + } + + @NotNull + public static String getNameForNamespace(@NotNull NamespaceDescriptor descriptor) { + String name = descriptor.getName(); + if (name.equals("")) { + return Namer.getAnonymousNamespaceName(); + } + return name; + } + + //TODO: why callable descriptor + @Nullable + public static DeclarationDescriptor getExpectedThisDescriptor(@NotNull CallableDescriptor callableDescriptor) { + ReceiverDescriptor expectedThisObject = callableDescriptor.getExpectedThisObject(); + if (!expectedThisObject.exists()) { + return null; + } + return getDeclarationDescriptorForReceiver(expectedThisObject); + } + + @NotNull + public static DeclarationDescriptor getDeclarationDescriptorForReceiver + (@NotNull ReceiverDescriptor receiverParameter) { + DeclarationDescriptor declarationDescriptor = + receiverParameter.getType().getConstructor().getDeclarationDescriptor(); + //TODO: WHY assert? + assert declarationDescriptor != null; + return declarationDescriptor.getOriginal(); + } + + @Nullable + public static DeclarationDescriptor getExpectedReceiverDescriptor(@NotNull CallableDescriptor callableDescriptor) { + ReceiverDescriptor receiverParameter = callableDescriptor.getReceiverParameter(); + if (!receiverParameter.exists()) { + return null; + } + return getDeclarationDescriptorForReceiver(receiverParameter); + } + + //TODO: maybe we have similar routine + @Nullable + public static ClassDescriptor getContainingClass(@NotNull DeclarationDescriptor descriptor) { + DeclarationDescriptor containing = descriptor.getContainingDeclaration(); + while (containing != null) { + if (containing instanceof ClassDescriptor) { + return (ClassDescriptor) containing; + } + containing = containing.getContainingDeclaration(); + } + return null; + } + + @NotNull + public static List getAllClassesDefinedInNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) { + List classDescriptors = Lists.newArrayList(); + for (DeclarationDescriptor descriptor : namespaceDescriptor.getMemberScope().getAllDescriptors()) { + if (AnnotationsUtils.isPredefinedObject(descriptor)) { + continue; + } + if (descriptor instanceof ClassDescriptor) { + classDescriptors.add((ClassDescriptor) descriptor); + } + } + return classDescriptors; + } + + +} diff --git a/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java b/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java new file mode 100644 index 00000000000..41940ad61cf --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java @@ -0,0 +1,156 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.utils; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.tree.IElementType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.jet.lexer.JetTokens; +import org.jetbrains.k2js.translate.context.Namer; + +import java.util.Collections; +import java.util.List; + +/** + * @author Pavel Talanov + */ +public final class PsiUtils { + + private PsiUtils() { + } + + @Nullable + public static JetSimpleNameExpression getSelectorAsSimpleName(@NotNull JetQualifiedExpression expression) { + JetExpression selectorExpression = getSelector(expression); + if (!(selectorExpression instanceof JetSimpleNameExpression)) { + return null; + } + return (JetSimpleNameExpression) selectorExpression; + } + + @NotNull + public static JetExpression getSelector(@NotNull JetQualifiedExpression expression) { + JetExpression selectorExpression = expression.getSelectorExpression(); + assert selectorExpression != null : "Selector should not be null."; + return selectorExpression; + } + + @NotNull + public static JetSimpleNameExpression getNotNullSimpleNameSelector(@NotNull JetQualifiedExpression expression) { + JetSimpleNameExpression selectorAsSimpleName = getSelectorAsSimpleName(expression); + assert selectorAsSimpleName != null; + return selectorAsSimpleName; + } + + @NotNull + public static JetToken getOperationToken(@NotNull JetOperationExpression expression) { + JetSimpleNameExpression operationExpression = expression.getOperationReference(); + IElementType elementType = operationExpression.getReferencedNameElementType(); + assert elementType instanceof JetToken : "Unary expression should have operation token of type JetToken"; + return (JetToken) elementType; + } + + @NotNull + public static JetExpression getBaseExpression(@NotNull JetUnaryExpression expression) { + JetExpression baseExpression = expression.getBaseExpression(); + assert baseExpression != null; + return baseExpression; + } + + public static boolean isPrefix(@NotNull JetUnaryExpression expression) { + return (expression instanceof JetPrefixExpression); + } + + public static boolean isAssignment(JetToken token) { + return (token == JetTokens.EQ); + } + + public static boolean isBackingFieldReference(@NotNull JetSimpleNameExpression expression) { + return expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER; + } + + public static boolean isInOrNotInOperation(@NotNull JetBinaryExpression binaryExpression) { + return isInOperation(binaryExpression) || isNotInOperation(binaryExpression); + } + + public static boolean isNotInOperation(@NotNull JetBinaryExpression binaryExpression) { + return (binaryExpression.getOperationToken() == JetTokens.NOT_IN); + } + + private static boolean isInOperation(@NotNull JetBinaryExpression binaryExpression) { + return (binaryExpression.getOperationToken() == JetTokens.IN_KEYWORD); + } + + @NotNull + public static JetExpression getCallee(@NotNull JetCallExpression expression) { + JetExpression calleeExpression = expression.getCalleeExpression(); + assert calleeExpression != null; + return calleeExpression; + } + + @NotNull + public static JetExpression getLoopBody(@NotNull JetLoopExpression expression) { + JetExpression body = expression.getBody(); + assert body != null : "Loops cannot have null bodies."; + return body; + } + + @NotNull + public static JetParameter getLoopParameter(@NotNull JetForExpression expression) { + JetParameter loopParameter = expression.getLoopParameter(); + assert loopParameter != null; + return loopParameter; + } + + @NotNull + public static List getPrimaryConstructorParameters(@NotNull JetClassOrObject classDeclaration) { + if (classDeclaration instanceof JetClass) { + return ((JetClass) classDeclaration).getPrimaryConstructorParameters(); + } + return Collections.emptyList(); + } + + @NotNull + public static JetObjectDeclaration getObjectDeclarationForName(@NotNull JetObjectDeclarationName name) { + PsiElement parent = name.getParent(); + assert parent instanceof JetObjectDeclaration : + "ObjectDeclarationName should have a parent of type ObjectDeclaration."; + return (JetObjectDeclaration) parent; + } + + @NotNull + public static JetObjectDeclarationName getObjectDeclarationName(@NotNull JetObjectDeclaration objectDeclaration) { + //TODO: util + JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration(); + assert nameAsDeclaration != null; + return nameAsDeclaration; + } + + @NotNull + public static String getNamespaceName(@NotNull JetFile psiFile) { + JetNamespaceHeader namespaceHeader = psiFile.getNamespaceHeader(); + String name = namespaceHeader.getName(); + assert name != null : "NamespaceHeader must have a name"; + if (name.equals("")) { + return Namer.getAnonymousNamespaceName(); + } + return name; + } +} diff --git a/translator/src/org/jetbrains/k2js/translate/utils/TranslationUtils.java b/translator/src/org/jetbrains/k2js/translate/utils/TranslationUtils.java new file mode 100644 index 00000000000..d0832046e8e --- /dev/null +++ b/translator/src/org/jetbrains/k2js/translate/utils/TranslationUtils.java @@ -0,0 +1,233 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.translate.utils; + +import com.google.dart.compiler.backend.js.ast.*; +import com.google.dart.compiler.util.AstUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.k2js.translate.context.NamingScope; +import org.jetbrains.k2js.translate.context.TemporaryVariable; +import org.jetbrains.k2js.translate.context.TranslationContext; +import org.jetbrains.k2js.translate.general.Translation; + +import java.util.ArrayList; +import java.util.List; + +import static org.jetbrains.k2js.translate.utils.BindingUtils.*; +import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getExpectedReceiverDescriptor; + +/** + * @author Pavel Talanov + */ +public final class TranslationUtils { + + @NotNull + public static JsBinaryOperation notNullCheck(@NotNull TranslationContext context, + @NotNull JsExpression expressionToCheck) { + JsNullLiteral nullLiteral = context.program().getNullLiteral(); + return AstUtil.notEqual(expressionToCheck, nullLiteral); + } + + @NotNull + public static JsBinaryOperation isNullCheck(@NotNull TranslationContext context, + @NotNull JsExpression expressionToCheck) { + JsNullLiteral nullLiteral = context.program().getNullLiteral(); + return AstUtil.equals(expressionToCheck, nullLiteral); + } + + @NotNull + public static List translateArgumentList(@NotNull TranslationContext context, + @NotNull List jetArguments) { + List jsArguments = new ArrayList(); + for (ValueArgument argument : jetArguments) { + jsArguments.add(translateArgument(context, argument)); + } + return jsArguments; + } + + @NotNull + private static JsExpression translateArgument(@NotNull TranslationContext context, @NotNull ValueArgument argument) { + JetExpression jetExpression = argument.getArgumentExpression(); + assert jetExpression != null : "Argument with no expression"; + return Translation.translateAsExpression(jetExpression, context); + } + + //TODO: refactor backing field reference generation to use the generic way + @NotNull + public static JsNameRef backingFieldReference(@NotNull TranslationContext context, + @NotNull JetProperty expression) { + PropertyDescriptor propertyDescriptor = getPropertyDescriptor(context.bindingContext(), expression); + return backingFieldReference(context, propertyDescriptor); + } + + @NotNull + public static JsNameRef backingFieldReference(@NotNull TranslationContext context, + @NotNull PropertyDescriptor descriptor) { + JsName backingFieldName = context.getNameForDescriptor(descriptor); + if (isOwnedByClass(descriptor)) { + return AstUtil.qualified(backingFieldName, new JsThisRef()); + } + assert isOwnedByNamespace(descriptor) + : "Only classes and namespaces may own backing fields."; + JsNameRef qualifier = context.getQualifierForDescriptor(descriptor); + return AstUtil.qualified(backingFieldName, qualifier); + } + + @NotNull + public static JsStatement assignmentToBackingField(@NotNull TranslationContext context, + @NotNull PropertyDescriptor descriptor, + @NotNull JsExpression assignTo) { + JsNameRef backingFieldReference = backingFieldReference(context, descriptor); + return AstUtil.newAssignmentStatement(backingFieldReference, assignTo); + } + + @Nullable + public static JsExpression translateInitializerForProperty(@NotNull JetProperty declaration, + @NotNull TranslationContext context) { + JsExpression jsInitExpression = null; + JetExpression initializer = declaration.getInitializer(); + if (initializer != null) { + jsInitExpression = Translation.translateAsExpression(initializer, context); + } + return jsInitExpression; + } + + @NotNull + public static JsNameRef getQualifiedReference(@NotNull TranslationContext context, + @NotNull DeclarationDescriptor descriptor) { + JsName name = context.getNameForDescriptor(descriptor); + JsNameRef reference = name.makeRef(); + JsNameRef qualifier = context.getQualifierForDescriptor(descriptor); + if (qualifier != null) { + AstUtil.setQualifier(reference, qualifier); + } + return reference; + } + + //TODO: refactor + @NotNull + public static JsExpression getThisObject(@NotNull TranslationContext context, + @NotNull DeclarationDescriptor correspondingDeclaration) { + JsExpression thisRef = null; + if (correspondingDeclaration instanceof ClassDescriptor) { + if (context.aliaser().hasAliasForThis(correspondingDeclaration)) { + thisRef = context.aliaser().getAliasForThis(correspondingDeclaration); + } + } + if (correspondingDeclaration instanceof CallableDescriptor) { + DeclarationDescriptor receiverDescriptor = + getExpectedReceiverDescriptor((CallableDescriptor) correspondingDeclaration); + assert receiverDescriptor != null; + if (context.aliaser().hasAliasForThis(receiverDescriptor)) { + thisRef = context.aliaser().getAliasForThis(receiverDescriptor); + } + } + if (thisRef != null) { + return thisRef; + } + return new JsThisRef(); + } + + @NotNull + public static List translateExpressionList(@NotNull TranslationContext context, + @NotNull List expressions) { + List result = new ArrayList(); + for (JetExpression expression : expressions) { + result.add(Translation.translateAsExpression(expression, context)); + } + return result; + } + + @NotNull + public static JsExpression translateBaseExpression(@NotNull TranslationContext context, + @NotNull JetUnaryExpression expression) { + JetExpression baseExpression = PsiUtils.getBaseExpression(expression); + return Translation.translateAsExpression(baseExpression, context); + } + + //TODO: + @NotNull + public static JsExpression translateReceiver(@NotNull TranslationContext context, + @NotNull JetDotQualifiedExpression expression) { + return Translation.translateAsExpression(expression.getReceiverExpression(), context); + } + + + @NotNull + public static JsExpression translateLeftExpression(@NotNull TranslationContext context, + @NotNull JetBinaryExpression expression) { + return Translation.translateAsExpression(expression.getLeft(), context); + } + + @NotNull + public static JsExpression translateRightExpression(@NotNull TranslationContext context, + @NotNull JetBinaryExpression expression) { + JetExpression rightExpression = expression.getRight(); + assert rightExpression != null : "Binary expression should have a right expression"; + return Translation.translateAsExpression(rightExpression, context); + } + + public static boolean isIntrinsicOperation(@NotNull TranslationContext context, + @NotNull JetOperationExpression expression) { + FunctionDescriptor operationDescriptor = + BindingUtils.getFunctionDescriptorForOperationExpression(context.bindingContext(), expression); + + if (operationDescriptor == null) return true; + if (context.intrinsics().isIntrinsic(operationDescriptor)) return true; + + return false; + } + + @NotNull + public static JsNameRef getMethodReferenceForOverloadedOperation(@NotNull TranslationContext context, + @NotNull JetOperationExpression expression) { + FunctionDescriptor overloadedOperationDescriptor = getFunctionDescriptorForOperationExpression + (context.bindingContext(), expression); + assert overloadedOperationDescriptor != null; + JsNameRef overloadedOperationReference = context.getNameForDescriptor(overloadedOperationDescriptor).makeRef(); + assert overloadedOperationReference != null; + return overloadedOperationReference; + } + + @NotNull + public static JsFunction functionWithScope(@NotNull NamingScope scope) { + return JsFunction.getAnonymousFunctionWithScope(scope.jsScope()); + } + + @NotNull + public static JsNumberLiteral zeroLiteral(@NotNull TranslationContext context) { + return context.program().getNumberLiteral(0); + } + + @NotNull + public static TemporaryVariable newAliasForThis(@NotNull TranslationContext context, + @NotNull DeclarationDescriptor descriptor) { + JsExpression thisQualifier = getThisObject(context, descriptor); + TemporaryVariable aliasForThis = context.declareTemporary(thisQualifier); + context.aliaser().setAliasForThis(descriptor, aliasForThis.name()); + return aliasForThis; + } + + public static void removeAliasForThis(@NotNull TranslationContext context, + @NotNull DeclarationDescriptor descriptor) { + context.aliaser().removeAliasForThis(descriptor); + } + +} diff --git a/translator/src/org/jetbrains/k2js/utils/GenerationUtils.java b/translator/src/org/jetbrains/k2js/utils/GenerationUtils.java new file mode 100644 index 00000000000..ae96b635c59 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/utils/GenerationUtils.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.utils; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +//TODO: very thin class + +/** + * @author Pavel Talanov + */ +public final class GenerationUtils { + + @NotNull + public static String generateCallToMain(@NotNull String namespaceName, @NotNull List arguments) { + String constructArguments = "var args = [];\n"; + int index = 0; + for (String argument : arguments) { + constructArguments = constructArguments + "args[" + index + "]= \"" + argument + "\";\n"; + index++; + } + String callMain = namespaceName + ".main(args);\n"; + return constructArguments + callMain; + } + + +} diff --git a/translator/src/org/jetbrains/k2js/utils/JetFileUtils.java b/translator/src/org/jetbrains/k2js/utils/JetFileUtils.java new file mode 100644 index 00000000000..76d2f7ebba9 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/utils/JetFileUtils.java @@ -0,0 +1,89 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.utils; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.CharsetToolkit; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiFileFactory; +import com.intellij.psi.impl.PsiFileFactoryImpl; +import com.intellij.testFramework.LightVirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.jet.plugin.JetLanguage; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Pavel Talanov + */ +public final class JetFileUtils { + + @NotNull + public static String loadFile(@NotNull String path) throws IOException { + return doLoadFile(path); + } + + @NotNull + private static String doLoadFile(@NotNull String path) throws IOException { + String text = FileUtil.loadFile(new File(path), CharsetToolkit.UTF8).trim(); + text = StringUtil.convertLineSeparators(text); + return text; + } + + @NotNull + public static JetFile createPsiFile(@NotNull String name, + @NotNull String text, + @NotNull Project project) { + return (JetFile) createFile(name + ".jet", text, project); + } + + @NotNull + public static JetFile loadPsiFile(@NotNull String name, @NotNull Project project) { + try { + return createPsiFile(name, loadFile(name), project); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @NotNull + private static PsiFile createFile(@NotNull String name, @NotNull String text, @NotNull Project project) { + LightVirtualFile virtualFile = new LightVirtualFile(name, JetLanguage.INSTANCE, text); + virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET); + PsiFile result = ((PsiFileFactoryImpl) PsiFileFactory.getInstance(project)) + .trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false); + assert result != null; + return result; + } + + + @NotNull + public static List createPsiFileList(@NotNull List inputFiles, + @NotNull Project project) { + List psiFiles = new ArrayList(); + for (String inputFile : inputFiles) { + psiFiles.add(JetFileUtils.loadPsiFile(inputFile, project)); + } + return psiFiles; + } +} diff --git a/translator/src/org/jetbrains/k2js/utils/JetTestUtils.java b/translator/src/org/jetbrains/k2js/utils/JetTestUtils.java new file mode 100644 index 00000000000..b9f3b05be11 --- /dev/null +++ b/translator/src/org/jetbrains/k2js/utils/JetTestUtils.java @@ -0,0 +1,178 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.utils; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; +import org.jetbrains.jet.lang.diagnostics.Diagnostic; +import org.jetbrains.jet.lang.diagnostics.Severity; +import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnostic; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.BindingTrace; +import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade; +import org.jetbrains.jet.util.slicedmap.ReadOnlySlice; +import org.jetbrains.jet.util.slicedmap.SlicedMap; +import org.jetbrains.jet.util.slicedmap.WritableSlice; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; + +/** + * @author abreslav + */ +public class JetTestUtils { + public static final BindingTrace DUMMY_TRACE = new BindingTrace() { + + + @Override + public BindingContext getBindingContext() { + return new BindingContext() { + + @Override + public Collection getDiagnostics() { + throw new UnsupportedOperationException(); // TODO + } + + @Override + public V get(ReadOnlySlice slice, K key) { + return DUMMY_TRACE.get(slice, key); + } + + @NotNull + @Override + public Collection getKeys(WritableSlice slice) { + return DUMMY_TRACE.getKeys(slice); + } + }; + } + + @Override + public void record(WritableSlice slice, K key, V value) { + } + + @Override + public void record(WritableSlice slice, K key) { + } + + @Override + public V get(ReadOnlySlice slice, K key) { + if (slice == BindingContext.PROCESSED) return (V) Boolean.FALSE; + return SlicedMap.DO_NOTHING.get(slice, key); + } + + @NotNull + @Override + public Collection getKeys(WritableSlice slice) { + assert slice.isCollective(); + return Collections.emptySet(); + } + + @Override + public void report(@NotNull Diagnostic diagnostic) { + if (diagnostic instanceof UnresolvedReferenceDiagnostic) { + UnresolvedReferenceDiagnostic unresolvedReferenceDiagnostic = (UnresolvedReferenceDiagnostic) diagnostic; + throw new IllegalStateException("Unresolved: " + unresolvedReferenceDiagnostic.getPsiElement().getText()); + } + } + }; + + public static BindingTrace DUMMY_EXCEPTION_ON_ERROR_TRACE = new BindingTrace() { + @Override + public BindingContext getBindingContext() { + return new BindingContext() { + @Override + public Collection getDiagnostics() { + throw new UnsupportedOperationException(); + } + + @Override + public V get(ReadOnlySlice slice, K key) { + return DUMMY_EXCEPTION_ON_ERROR_TRACE.get(slice, key); + } + + @NotNull + @Override + public Collection getKeys(WritableSlice slice) { + return DUMMY_EXCEPTION_ON_ERROR_TRACE.getKeys(slice); + } + }; + } + + @Override + public void record(WritableSlice slice, K key, V value) { + } + + @Override + public void record(WritableSlice slice, K key) { + } + + @Override + public V get(ReadOnlySlice slice, K key) { + return null; + } + + @NotNull + @Override + public Collection getKeys(WritableSlice slice) { + assert slice.isCollective(); + return Collections.emptySet(); + } + + @Override + public void report(@NotNull Diagnostic diagnostic) { + if (diagnostic.getSeverity() == Severity.ERROR) { + throw new IllegalStateException(diagnostic.getMessage()); + } + } + }; + + public static BindingContext analyzeNamespace(@NotNull JetFile file, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) { + return AnalyzerFacade.analyzeOneFileWithJavaIntegration(file, flowDataTraceFactory); + } + + + public static void mkdirs(File file) throws IOException { + if (file.isDirectory()) { + return; + } + if (!file.mkdirs()) { + throw new IOException(); + } + } + + public static void rmrf(File file) { + if (file != null) { + File[] children = file.listFiles(); + if (children != null) { + for (File child : children) { + rmrf(child); + } + } + file.delete(); + } + } + + public static void recreateDirectory(File file) throws IOException { + rmrf(file); + mkdirs(file); + } + + +} diff --git a/translator/testFiles/canvas_helper.js b/translator/testFiles/canvas_helper.js new file mode 100644 index 00000000000..90d9287df1f --- /dev/null +++ b/translator/testFiles/canvas_helper.js @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function getContext() { + return getCanvas().getContext('2d'); +} + +function getCanvas() { + return document.getElementsByTagName('canvas')[0]; +} + +function getKotlinLogo() { + return document.getElementsByTagName('img')[0]; +} \ No newline at end of file diff --git a/translator/testFiles/class/cases/classWithoutNamespace.kt b/translator/testFiles/class/cases/classWithoutNamespace.kt new file mode 100644 index 00000000000..4aceb233099 --- /dev/null +++ b/translator/testFiles/class/cases/classWithoutNamespace.kt @@ -0,0 +1,7 @@ +class A(var a : Int) { + { + $a=3 + } +} + +fun box() = (A(1).a == 3) \ No newline at end of file diff --git a/translator/testFiles/examples/cases/closureWithParameter.jet b/translator/testFiles/examples/cases/closureWithParameter.jet new file mode 100644 index 00000000000..e0b5d616951 --- /dev/null +++ b/translator/testFiles/examples/cases/closureWithParameter.jet @@ -0,0 +1,7 @@ +fun box() : String { + return apply( "OK", {(arg: String) -> arg } ) +} + +fun apply(arg : String, f : (p:String) -> String) : String { + return f(arg) +} diff --git a/translator/testFiles/examples/cases/closureWithParameterAndBoxing.jet b/translator/testFiles/examples/cases/closureWithParameterAndBoxing.jet new file mode 100644 index 00000000000..2b64a547d29 --- /dev/null +++ b/translator/testFiles/examples/cases/closureWithParameterAndBoxing.jet @@ -0,0 +1,7 @@ +fun box() : String { + return if (apply( 5, {(arg: Int) -> arg + 13 } ) == 18) "OK" else "fail" +} + +fun apply(arg : Int, f : (p:Int) -> Int) : Int { + return f(arg) +} diff --git a/translator/testFiles/examples/cases/diamondInheritance.jet b/translator/testFiles/examples/cases/diamondInheritance.jet new file mode 100644 index 00000000000..210aecafedc --- /dev/null +++ b/translator/testFiles/examples/cases/diamondInheritance.jet @@ -0,0 +1,24 @@ +// Changed when traits were introduced. May not make sense any more + +open class Base() { + public var v : Int = 0 +} + +open class Left() : Base() {} +trait Right : Base {} + +class D() : Left(), Right + +fun vl(l : Left) : Int = l.v +fun vr(r : Right) : Int = r.v + +fun box() : String { + val d = D() + d.v = 42 + + if (d.v != 42) return "Fail #1" + if (vl(d) != 42) return "Fail #2" + if (vr(d) != 42) return "Fail #3" + + return "OK" +} \ No newline at end of file diff --git a/translator/testFiles/examples/cases/doubleEnclosedLocalVariable.jet b/translator/testFiles/examples/cases/doubleEnclosedLocalVariable.jet new file mode 100644 index 00000000000..96ac7f2ef19 --- /dev/null +++ b/translator/testFiles/examples/cases/doubleEnclosedLocalVariable.jet @@ -0,0 +1,8 @@ +fun box() : String { + val cl = 39 + return if (sum(200, { val ff = {cl}; ff() }) == 239) "OK" else "FAIL" +} + +fun sum(arg:Int, f : () -> Int) : Int { + return arg + f() +} diff --git a/translator/testFiles/examples/cases/enclosingLocalVariable.jet b/translator/testFiles/examples/cases/enclosingLocalVariable.jet new file mode 100644 index 00000000000..01e1a103ff2 --- /dev/null +++ b/translator/testFiles/examples/cases/enclosingLocalVariable.jet @@ -0,0 +1,8 @@ +fun box() : String { + val cl = 39 + return if (sum(200, { val m = { val r = { cl }; r() }; m() }) == 239) "OK" else "FAIL" +} + +fun sum(arg:Int, f : () -> Int) : Int { + return arg + f() +} diff --git a/translator/testFiles/examples/cases/extensionClosure.jet b/translator/testFiles/examples/cases/extensionClosure.jet new file mode 100644 index 00000000000..21307ea42ab --- /dev/null +++ b/translator/testFiles/examples/cases/extensionClosure.jet @@ -0,0 +1,13 @@ +class Point(val x : Int, val y : Int) + +fun box() : String { + val answer = apply(Point(3, 5), { Point.(scalar : Int) : Point -> + Point(x * scalar, y * scalar) + }) + + return if (answer.x == 6 && answer.y == 10) "OK" else "FAIL" +} + +fun apply(arg:Point, f : Point.(scalar : Int) -> Point) : Point { + return arg.f(2) +} diff --git a/translator/testFiles/examples/cases/funDelegation.jet b/translator/testFiles/examples/cases/funDelegation.jet new file mode 100644 index 00000000000..10a1f408b09 --- /dev/null +++ b/translator/testFiles/examples/cases/funDelegation.jet @@ -0,0 +1,17 @@ +open class Base() { + fun n(n : Int) : Int = n + 1 +} + +trait Abstract {} + +class Derived1() : Base(), Abstract {} +class Derived2() : Abstract, Base() {} + +fun test(s : Base) : Boolean = s.n(238) == 239 + +fun box() : String { + if (!test(Base())) return "Fail #1" + if (!test(Derived1())) return "Fail #2" + if (!test(Derived2())) return "Fail #3" + return "OK" +} \ No newline at end of file diff --git a/translator/testFiles/examples/cases/incrementProperty.kt b/translator/testFiles/examples/cases/incrementProperty.kt new file mode 100644 index 00000000000..29123dbcaf3 --- /dev/null +++ b/translator/testFiles/examples/cases/incrementProperty.kt @@ -0,0 +1,14 @@ +class Slot() { + var vitality: Int = 10000 + + fun increaseVitality(delta: Int) { + vitality = vitality + delta + if (vitality > 65535) vitality = 65535; + } +} + +fun box(): String { + val s = Slot() + s.increaseVitality(1000) + if (s.vitality == 11000) return "OK" else return "fail" +} diff --git a/translator/testFiles/examples/cases/inheritedMethod.jet b/translator/testFiles/examples/cases/inheritedMethod.jet new file mode 100644 index 00000000000..97d432077a8 --- /dev/null +++ b/translator/testFiles/examples/cases/inheritedMethod.jet @@ -0,0 +1,13 @@ +open class Foo() { + fun xyzzy(): String = "xyzzy" +} + +class Bar(): Foo() { + fun test(): String = xyzzy() +} + +fun box() : String { + val bar = Bar() + val f = bar.test() + return if (f == "xyzzy") "OK" else "fail" +} diff --git a/translator/testFiles/examples/cases/initializerBlock.jet b/translator/testFiles/examples/cases/initializerBlock.jet new file mode 100644 index 00000000000..c89deeda87d --- /dev/null +++ b/translator/testFiles/examples/cases/initializerBlock.jet @@ -0,0 +1,13 @@ +class C() { + public var f: Int + + { + $f = 610 + } +} + +fun box(): String { + val c = C() + if (c.f != 610) return "fail" + return "OK" +} diff --git a/translator/testFiles/examples/cases/kt242.jet b/translator/testFiles/examples/cases/kt242.jet new file mode 100644 index 00000000000..4e2de93cff3 --- /dev/null +++ b/translator/testFiles/examples/cases/kt242.jet @@ -0,0 +1,19 @@ +fun box() : String { + val i: Int? = 7 + val j: Int? = null + val k = 7 + + //verify errors + if (i == 7) {} + if (7 == i) {} + + if (j == 7) {} + if (7 == j) {} + + if (i == k) {} + if (k == i) {} + + if (j == k) {} + if (k == j) {} + return "OK" +} \ No newline at end of file diff --git a/translator/testFiles/examples/cases/newInstanceDefaultConstructor.jet b/translator/testFiles/examples/cases/newInstanceDefaultConstructor.jet new file mode 100644 index 00000000000..6cd0ebd954b --- /dev/null +++ b/translator/testFiles/examples/cases/newInstanceDefaultConstructor.jet @@ -0,0 +1,11 @@ +class SimpleClass() { + fun foo() = 610 +} + +fun box() : String { + val c = SimpleClass() + if (c.foo() == 610) { + return "OK" + } + return "FAIL" +} diff --git a/translator/testFiles/examples/cases/overloadBinaryOperator.jet b/translator/testFiles/examples/cases/overloadBinaryOperator.jet new file mode 100644 index 00000000000..bee66062979 --- /dev/null +++ b/translator/testFiles/examples/cases/overloadBinaryOperator.jet @@ -0,0 +1,25 @@ +import java.util.* + +class ArrayWrapper() { + val contents = ArrayList() + + fun add(item: T) { + contents.add(item) + } + + fun plus(b: ArrayWrapper): ArrayWrapper { + val result = ArrayWrapper() + result.contents.addAll(contents) + result.contents.addAll(b.contents) + return result + } +} + +fun box(): String { + val v1 = ArrayWrapper() + val v2 = ArrayWrapper() + v1.add("foo") + v2.add("bar") + val v3 = v1 + v2 + return if (v3.contents.size() == 2) "OK" else "fail" +} diff --git a/translator/testFiles/examples/cases/overloadPlusAssignReturn.jet b/translator/testFiles/examples/cases/overloadPlusAssignReturn.jet new file mode 100644 index 00000000000..b6d0c3c0282 --- /dev/null +++ b/translator/testFiles/examples/cases/overloadPlusAssignReturn.jet @@ -0,0 +1,27 @@ +import java.util.* + +class ArrayWrapper() { + val contents = ArrayList() + + fun add(item: T) { + contents.add(item) + } + + fun plusAssign(rhs: ArrayWrapper) { + contents.addAll(rhs.contents) + } + + fun get(index: Int): T { + return contents.get(index) + } +} + +fun box(): String { + var v1 = ArrayWrapper() + val v2 = ArrayWrapper() + v1.add("foo") + val v3 = v1 + v2.add("bar") + v1 += v2 + return if (v1.contents.size() == 2 && v3.contents.size() == 2) "OK" else "fail" +} diff --git a/translator/testFiles/examples/cases/overloadPlusToPlusAssign.jet b/translator/testFiles/examples/cases/overloadPlusToPlusAssign.jet new file mode 100644 index 00000000000..c5236b0ace4 --- /dev/null +++ b/translator/testFiles/examples/cases/overloadPlusToPlusAssign.jet @@ -0,0 +1,30 @@ +import java.util.* + +class ArrayWrapper() { + val contents = ArrayList() + + fun add(item: T) { + contents.add(item) + } + + fun plus(rhs: ArrayWrapper): ArrayWrapper { + val result = ArrayWrapper() + result.contents.addAll(contents) + result.contents.addAll(rhs.contents) + return result + } + + fun get(index: Int): T { + return contents.get(index) + } +} + +fun box(): String { + var v1 = ArrayWrapper() + val v2 = ArrayWrapper() + v1.add("foo") + val v3 = v1 + v2.add("bar") + v1 += v2 + return if (v1.contents.size() == 2 && v3.contents.size() == 1) "OK" else "fail" +} diff --git a/translator/testFiles/examples/cases/overloadUnaryOperator.jet b/translator/testFiles/examples/cases/overloadUnaryOperator.jet new file mode 100644 index 00000000000..2cbe1a27f3a --- /dev/null +++ b/translator/testFiles/examples/cases/overloadUnaryOperator.jet @@ -0,0 +1,31 @@ +import java.util.* + +class ArrayWrapper() { + val contents = ArrayList() + + fun add(item: T) { + contents.add(item) + } + + fun minus(): ArrayWrapper { + val result = ArrayWrapper() + result.contents.addAll(contents) + var i = contents.size(); + for (a in contents) { + result.contents[--i] = a; + } + return result + } + + fun get(index: Int): T { + return contents.get(index) + } +} + +fun box(): String { + val v1 = ArrayWrapper() + v1.add("foo") + v1.add("bar") + val v2 = -v1 + return if (v2[0] == "bar" && v2[1] == "foo") "OK" else "fail" +} diff --git a/translator/testFiles/examples/cases/propertyDelegation.jet b/translator/testFiles/examples/cases/propertyDelegation.jet new file mode 100644 index 00000000000..614c624f124 --- /dev/null +++ b/translator/testFiles/examples/cases/propertyDelegation.jet @@ -0,0 +1,33 @@ +open class Base() { + val plain = 239 + public val read : Int + get() = 239 + + public var readwrite : Int = 0 + get() = $readwrite + 1 + set(n : Int) { + $readwrite = n + } +} + +trait Abstract {} + +class Derived1() : Base(), Abstract {} +class Derived2() : Abstract, Base() {} + +fun code(s : Base) : Int { + if (s.plain != 239) return 1 + if (s.read != 239) return 2 + s.readwrite = 238 + if (s.readwrite != 239) return 3 + return 0 +} + +fun test(s : Base) : Boolean = code(s) == 0 + +fun box() : String { + if (!test(Base())) return "Fail #1" + if (!test(Derived1())) return "Fail #2" + if (!test(Derived2())) return "Fail #3" + return "OK" +} \ No newline at end of file diff --git a/translator/testFiles/examples/cases/rightHandOverride.jet b/translator/testFiles/examples/cases/rightHandOverride.jet new file mode 100644 index 00000000000..e99e60bd863 --- /dev/null +++ b/translator/testFiles/examples/cases/rightHandOverride.jet @@ -0,0 +1,20 @@ +// Changed when traits were introduced. May not make sense any more + +trait Left {} +open class Right() { + open fun f() = 42 +} + +class D() : Left, Right() { + override fun f() = 239 +} + +fun box() : String { + val r : Right = Right() + val d : D = D() + + if (r.f() != 42) return "Fail #1" + if (d.f() != 239) return "Fail #2" + + return "OK" +} \ No newline at end of file diff --git a/translator/testFiles/examples/cases/simplestClosure.jet b/translator/testFiles/examples/cases/simplestClosure.jet new file mode 100644 index 00000000000..7a9f3b439cf --- /dev/null +++ b/translator/testFiles/examples/cases/simplestClosure.jet @@ -0,0 +1,7 @@ +fun box() : String { + return invoker( {"OK"} ) +} + +fun invoker(gen : () -> String) : String { + return gen() +} diff --git a/translator/testFiles/examples/cases/simplestClosureAndBoxing.jet b/translator/testFiles/examples/cases/simplestClosureAndBoxing.jet new file mode 100644 index 00000000000..50f22fbeb8d --- /dev/null +++ b/translator/testFiles/examples/cases/simplestClosureAndBoxing.jet @@ -0,0 +1,7 @@ +fun box() : String { + return if (int_invoker( { 7 } ) == 7) "OK" else "fail" +} + +fun int_invoker(gen : () -> Int) : Int { + return gen() +} diff --git a/translator/testFiles/examples/sortedTests/unsupported/basicmethod.jet b/translator/testFiles/examples/sortedTests/unsupported/basicmethod.jet new file mode 100644 index 00000000000..9920bc3b69d --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/basicmethod.jet @@ -0,0 +1,21 @@ +import java.util.ArrayList + +trait Tr { + fun extra() : String = "_" +} + +class N() : ArrayList(), Tr { + override fun add(el: Any) : Boolean { + super.add(el) + return super.add(el.toString() + super.extra() + el + extra()) + } + + override fun extra() : String = super.extra() + super.extra() +} + +fun box(): String { + val n = N() + n.add("239") + if (n.get(0) == "239" && n.get(1) == "239_239__") return "OK"; + return "fail"; +} \ No newline at end of file diff --git a/translator/testFiles/examples/sortedTests/unsupported/basicproperty.jet b/translator/testFiles/examples/sortedTests/unsupported/basicproperty.jet new file mode 100644 index 00000000000..ae1cfa5618b --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/basicproperty.jet @@ -0,0 +1,22 @@ +open class M() { + open var b: Int = 0 +} + +class N() : M() { + val a : Int + get() { + super.b = super.b + 1 + return super.b + 1 + } + override var b: Int = a + 1 + + val superb : Int + get() = super.b +} + +fun box(): String { + val n = N() + println("a: " + n.a + " b: " + n.b + " superb: " + n.superb) + if (n.b == 3 && n.a == 4 && n.superb == 3) return "OK"; + return "fail"; +} \ No newline at end of file diff --git a/translator/testFiles/examples/sortedTests/unsupported/classObject.jet b/translator/testFiles/examples/sortedTests/unsupported/classObject.jet new file mode 100644 index 00000000000..76eff77c438 --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/classObject.jet @@ -0,0 +1,11 @@ +class C() { + class object { + fun create() = C() + } +} + +fun box(): String { + val c = C.create() + return if (c is C) "OK" else "fail" +} + diff --git a/translator/testFiles/examples/sortedTests/unsupported/classObjectInterface.jet b/translator/testFiles/examples/sortedTests/unsupported/classObjectInterface.jet new file mode 100644 index 00000000000..432bb37bee0 --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/classObjectInterface.jet @@ -0,0 +1,9 @@ +class C() { + fun getInstance(): Runnable = C + + class object: Runnable { + override fun run(): Unit { } + } +} + +fun foo() = C().getInstance() diff --git a/translator/testFiles/examples/sortedTests/unsupported/classObjectMethod.jet b/translator/testFiles/examples/sortedTests/unsupported/classObjectMethod.jet new file mode 100644 index 00000000000..d7d70a86d96 --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/classObjectMethod.jet @@ -0,0 +1,13 @@ +abstract open class Default { + abstract fun defaultValue(): Int +} + +class MyInt() { + class object : Default { + override fun defaultValue(): Int = 610 + } +} + +fun toDefault(t: T) where class object T: Default = T.defaultValue() + +fun box(): String = if (toDefault(MyInt()) == 610) "OK" else "fail" diff --git a/translator/testFiles/examples/sortedTests/unsupported/enclosed.jet b/translator/testFiles/examples/sortedTests/unsupported/enclosed.jet new file mode 100644 index 00000000000..705e0b602c2 --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/enclosed.jet @@ -0,0 +1,42 @@ +trait BK { + fun x() : Int = 50 +} + +trait K : BK { + override fun x() : Int = super.x() * 2 +} + +open class M() { + open fun x() : Int = 10 + + open var y = 500 +} + +open class N() : M(), K { + + override fun x() : Int = 20 + + override var y = 200 + + open class C() : K { + fun test1() = x() + fun test2() = super@N.x() + fun test3() = super@N.x() + fun test4() = super.x() + fun test5() = y + fun test6() : Int { + super@N.y += 200 + return super@N.y + } + } +} + +fun box(): String { + if (N().C().test1() != 100) return "test1 fail"; + if (N().C().test2() != 10) return "test2 fail"; + if (N().C().test3() != 100) return "test3 fail"; + if (N().C().test4() != 100) return "test4 fail"; + if (N().C().test5() != 200) return "test5 fail"; + if (N().C().test6() != 700) return "test6 fail"; + return "OK"; +} \ No newline at end of file diff --git a/translator/testFiles/examples/sortedTests/unsupported/forwardTypeParameter.jet b/translator/testFiles/examples/sortedTests/unsupported/forwardTypeParameter.jet new file mode 100644 index 00000000000..2e78cd3ae9c --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/forwardTypeParameter.jet @@ -0,0 +1,12 @@ +class Foo() { } +class Bar() { } + +fun isInstance(obj: Any?) = obj is T + +fun isInstance2(obj: Any?) = isInstance(obj) + +fun box(): String { + if (! isInstance2(Foo())) return "fail 1" + if (isInstance2(Foo())) return "fail 2" + return "OK" +} diff --git a/translator/testFiles/examples/sortedTests/unsupported/inheritance.jet b/translator/testFiles/examples/sortedTests/unsupported/inheritance.jet new file mode 100644 index 00000000000..0bfdb4e497f --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/inheritance.jet @@ -0,0 +1,41 @@ +// Changed when traits were introduced. May not make sense any more + +open class X(val x : Int) {} +trait Y { + abstract val y : Int +} + +class YImpl(override val y : Int) : Y {} + +class Point(x : Int, yy : Int) : X(x) , Y { + override val y : Int = yy +} + +trait Abstract {} + +class P1(x : Int, yy : Y) : Abstract, X(x), Y by yy {} +class P2(x : Int, yy : Y) : X(x), Abstract, Y by yy {} +class P3(x : Int, yy : Y) : X(x), Y by yy, Abstract {} +class P4(x : Int, yy : Y) : Y by yy, Abstract, X(x) {} + +fun box() : String { + if (X(239).x != 239) return "FAIL #1" + if (YImpl(239).y != 239) return "FAIL #2" + + val p = Point(240, -1) + if (p.x + p.y != 239) return "FAIL #3" + + val y = YImpl(-1) + val p1 = P1(240, y) + if (p1.x + p1.y != 239) return "FAIL #4" + val p2 = P2(240, y) + if (p2.x + p2.y != 239) return "FAIL #5" + + val p3 = P3(240, y) + if (p3.x + p3.y != 239) return "FAIL #6" + + val p4 = P4(240, y) + if (p4.x + p4.y != 239) return "FAIL #7" + + return "OK" +} \ No newline at end of file diff --git a/translator/testFiles/examples/sortedTests/unsupported/inheritedInnerClass.jet b/translator/testFiles/examples/sortedTests/unsupported/inheritedInnerClass.jet new file mode 100644 index 00000000000..4717bea55a8 --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/inheritedInnerClass.jet @@ -0,0 +1,14 @@ +class Outer() { + open class InnerBase() { + } + + class InnerDerived(): InnerBase() { + } + + public val foo: InnerBase? = InnerDerived() +} + +fun box() : String { + val o = Outer() + return if (o.foo === null) "fail" else "OK" +} diff --git a/translator/testFiles/examples/sortedTests/unsupported/initializerBlockDImpl.jet b/translator/testFiles/examples/sortedTests/unsupported/initializerBlockDImpl.jet new file mode 100644 index 00000000000..aa3d227c80f --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/initializerBlockDImpl.jet @@ -0,0 +1,20 @@ +import java.util.* +import java.io.* + +class World() { + public val items: ArrayList = ArrayList + + class Item() { + { + items.add(this) + } + } + + val foo = Item() +} + +fun box() : String { + val w = World() + if (w.items.size() != 1) return "fail" + return "OK" +} diff --git a/translator/testFiles/examples/sortedTests/unsupported/innerClass.jet b/translator/testFiles/examples/sortedTests/unsupported/innerClass.jet new file mode 100644 index 00000000000..df43f61e8bc --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/innerClass.jet @@ -0,0 +1,19 @@ +class Outer(val foo: StringBuilder) { + class Inner() { + fun len() : Int { + return foo.length() + } + } + + fun test() : Inner { + return Inner() + } +} + +fun box() : String { + val sb = StringBuilder("xyzzy") + val o = Outer(sb) + val i = o.test() + val l = i.len() + return if (l != 5) "fail" else "OK" +} diff --git a/translator/testFiles/examples/sortedTests/unsupported/propertyInInitializer.jet b/translator/testFiles/examples/sortedTests/unsupported/propertyInInitializer.jet new file mode 100644 index 00000000000..f6e84b15afd --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/propertyInInitializer.jet @@ -0,0 +1,16 @@ +class Outer() { + val s = "xyzzy" + + open class InnerBase(public val name: String) { + } + + class InnerDerived(): InnerBase(s) { + } + + val x = InnerDerived() +} + +fun box() : String { + val o = Outer() + return if (o.x.name != "xyzzy") "fail" else "OK" +} diff --git a/translator/testFiles/examples/sortedTests/unsupported/simpleBox.jet b/translator/testFiles/examples/sortedTests/unsupported/simpleBox.jet new file mode 100644 index 00000000000..be95d012d51 --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/simpleBox.jet @@ -0,0 +1,8 @@ +class Box(t: T) { + var value = t +} + +fun box(): String { + val box: Box = Box(1) + return if (box.value == 1) "OK" else "fail" +} diff --git a/translator/testFiles/examples/sortedTests/unsupported/traitproperty.jet b/translator/testFiles/examples/sortedTests/unsupported/traitproperty.jet new file mode 100644 index 00000000000..715d8d73d8b --- /dev/null +++ b/translator/testFiles/examples/sortedTests/unsupported/traitproperty.jet @@ -0,0 +1,29 @@ +trait M { + var backingB : Int + var b : Int + get() = backingB + set(value: Int) { + backingB = value + } +} + +class N() : M { + override var backingB : Int = 0 + + val a : Int + get() { + super.b = super.b + 1 + return super.b + 1 + } + override var b: Int = a + 1 + + val superb : Int + get() = super.b +} + +fun box(): String { + val n = N() + println("a: " + n.a + " b: " + n.b + " superb: " + n.superb) + if (n.b == 3 && n.a == 4 && n.superb == 3) return "OK"; + return "fail"; +} \ No newline at end of file diff --git a/translator/testFiles/examples/sortedTests/usesJava/exceptionConstructor.jet b/translator/testFiles/examples/sortedTests/usesJava/exceptionConstructor.jet new file mode 100644 index 00000000000..ab6117e266e --- /dev/null +++ b/translator/testFiles/examples/sortedTests/usesJava/exceptionConstructor.jet @@ -0,0 +1,7 @@ +class GameError(msg: String): Exception(msg) { +} + +fun box(): String { + val e = GameError("foo") + return if (e.getMessage() == "foo") "OK" else "fail" +} diff --git a/translator/testFiles/expression/conditional/cases/ifAsExpressionWithThrow.kt b/translator/testFiles/expression/conditional/cases/ifAsExpressionWithThrow.kt new file mode 100644 index 00000000000..f73f96b80dd --- /dev/null +++ b/translator/testFiles/expression/conditional/cases/ifAsExpressionWithThrow.kt @@ -0,0 +1,3 @@ +package foo + +fun box() = if (true) throw Exception() else false \ No newline at end of file diff --git a/translator/testFiles/expression/for/cases/forIteratesOverArray.kt b/translator/testFiles/expression/for/cases/forIteratesOverArray.kt new file mode 100644 index 00000000000..0b0cad9557b --- /dev/null +++ b/translator/testFiles/expression/for/cases/forIteratesOverArray.kt @@ -0,0 +1,19 @@ +package foo + +val a1 = Array(10) + +fun box() : Boolean { + var c = 0 + var d = 0 + a1[3] = 3 + a1[5] = 5 + + for (var a : Int? in a1) { + if (a != null) { + c += 1; + } else { + d += 1 + } + } + return (c == 2) && (d == 8) +} \ No newline at end of file diff --git a/translator/testFiles/expression/for/cases/forOnEmptyArray.kt b/translator/testFiles/expression/for/cases/forOnEmptyArray.kt new file mode 100644 index 00000000000..951265396c3 --- /dev/null +++ b/translator/testFiles/expression/for/cases/forOnEmptyArray.kt @@ -0,0 +1,10 @@ +package foo + +val a1 = Array(0) + +fun box() : Boolean { + for (a in a1) { + return false; + } + return true; +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/KT-921.kt b/translator/testFiles/expression/function/cases/KT-921.kt new file mode 100644 index 00000000000..7c41a0fc0c0 --- /dev/null +++ b/translator/testFiles/expression/function/cases/KT-921.kt @@ -0,0 +1,67 @@ +import java.util.* + +class Lifetime() { + val attached = ArrayList< Function0 >() + + public fun attach(action : ()->Unit) + { + attached.add(action) + } + + fun close() + { + for(x in attached) x() + attached.clear() + } +} + +public class Viewable() +{ + val items = ArrayList() + + fun add(item:T) + { + items.add(item) + } + + fun remove(item:T) + { + items.remove(item) + } + + fun view(lifetime: Lifetime, viewer: (itemLifetime:Lifetime, item:T) -> Unit) + { + for(item in items) + viewer(lifetime, item) + } +} + +fun lifetime(body: (Lifetime)->Unit) +{ + val l = Lifetime() + body(l) + l.close() +} + +fun Dump(items:ArrayList) +{ + for(item in items) + print(item.toString() + ", ") + println() +} + +fun main(args:Array) +{ + val v = Viewable() + val x = ArrayList() + v.add(1) + v.add(2) + lifetime( + { + v.view(it, {(itemLifetime, item)-> + x.add(item) + Dump(x) + itemLifetime.attach { x.remove(item as Any); Dump(x) } + }) + }) +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/adderClosure.kt b/translator/testFiles/expression/function/cases/adderClosure.kt new file mode 100644 index 00000000000..d7c053cbb87 --- /dev/null +++ b/translator/testFiles/expression/function/cases/adderClosure.kt @@ -0,0 +1,9 @@ +package foo + +fun box() : Boolean { + var sum = 0 + val adder = {(a: Int) -> sum += a } + adder(3) + adder(2) + return sum == 5 +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/closureWithParameter.kt b/translator/testFiles/expression/function/cases/closureWithParameter.kt new file mode 100644 index 00000000000..31c8e3f07c0 --- /dev/null +++ b/translator/testFiles/expression/function/cases/closureWithParameter.kt @@ -0,0 +1,9 @@ +package foo + +fun box() : String { + return apply( "OK", {(arg: String) -> arg } ) +} + +fun apply(arg : String, f : (p:String) -> String) : String { + return f(arg) +} diff --git a/translator/testFiles/expression/function/cases/closureWithParameterAndBoxing.jet b/translator/testFiles/expression/function/cases/closureWithParameterAndBoxing.jet new file mode 100644 index 00000000000..e5602935931 --- /dev/null +++ b/translator/testFiles/expression/function/cases/closureWithParameterAndBoxing.jet @@ -0,0 +1,9 @@ +package foo + +fun box() : String { + return if (apply( 5, {(arg: Int) -> arg + 13 } ) == 18) "OK" else "fail" +} + +fun apply(arg : Int, f : (p:Int) -> Int) : Int { + return f(arg) +} diff --git a/translator/testFiles/expression/function/cases/defaultParameters.kt b/translator/testFiles/expression/function/cases/defaultParameters.kt new file mode 100644 index 00000000000..73945d0780a --- /dev/null +++ b/translator/testFiles/expression/function/cases/defaultParameters.kt @@ -0,0 +1,15 @@ +package foo + + +fun f(a : Int = 2, b : Int = 3) = a + b + +fun box() : Boolean +{ + if (f(1,2) != 3) return false; + if (f(1,3) != 4) return false; + if (f(3) != 6) return false; + if (f() != 5) return false; + + return true; +} + diff --git a/translator/testFiles/expression/function/cases/enclosingThis.kt b/translator/testFiles/expression/function/cases/enclosingThis.kt new file mode 100644 index 00000000000..d227b3a2cc9 --- /dev/null +++ b/translator/testFiles/expression/function/cases/enclosingThis.kt @@ -0,0 +1,12 @@ +class Point(val x:Int, val y:Int) { + fun mul() : (scalar:Int)->Point { + return { (scalar:Int):Point -> Point(x * scalar, y * scalar) } + } +} + +val m = Point(2, 3).mul() : (scalar:Int)->Point + +fun box() : String { + val answer = m(5) + return if (answer.x == 10 && answer.y == 15) "OK" else "FAIL" +} diff --git a/translator/testFiles/expression/function/cases/expressionAsFunction.kt b/translator/testFiles/expression/function/cases/expressionAsFunction.kt new file mode 100644 index 00000000000..a2f0685ae29 --- /dev/null +++ b/translator/testFiles/expression/function/cases/expressionAsFunction.kt @@ -0,0 +1,42 @@ +package foo + +import java.util.*; + +val d = {(a : Int) -> a + 1} +val p = {(a : Int) -> a * 3} + +val list = ArrayList>(); + +fun chain(start : Int) : Int { + var res = start; + for (func in list) { + res = (func)(res); + } + return res; +} + +fun box() : Boolean { + if (chain(0) != 0) { + return false; + } + list.add(d); + if (list.get(0)(0) != 1) { + return false; + } + list.add(p); + if (list.get(1)(10) != 30) { + return false; + } + if (chain(0) != 3) { + return false; + } + list.add({it * it}); + list.add({it - 100}); + if (chain(2) != -19) { + return false; + } + if (({(a : Int) -> a * a}(3)) != 9) { + return false; + } + return true; +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/functionInsideFunction.kt b/translator/testFiles/expression/function/cases/functionInsideFunction.kt new file mode 100644 index 00000000000..fcb2a69895f --- /dev/null +++ b/translator/testFiles/expression/function/cases/functionInsideFunction.kt @@ -0,0 +1,19 @@ +package foo + + +fun box() : Boolean{ + fun f() = 3 + + return (((f() + f()) == 6) && (b() == 24)) +} + + +fun b() : Int { + + fun a() : Int { + fun c() = 4 + return c() * 3 + } + val a = 2 + return a() * a +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/functionLiteral.kt b/translator/testFiles/expression/function/cases/functionLiteral.kt new file mode 100644 index 00000000000..e27b2e273f9 --- /dev/null +++ b/translator/testFiles/expression/function/cases/functionLiteral.kt @@ -0,0 +1,8 @@ +package foo + +fun box() : Boolean { + var sum = 0 + val addFive = {(a: Int) -> a + 5 } + sum = addFive(sum) + return sum == 5 +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/functionLiteralAsLastParameter.kt b/translator/testFiles/expression/function/cases/functionLiteralAsLastParameter.kt new file mode 100644 index 00000000000..6be5be64eb6 --- /dev/null +++ b/translator/testFiles/expression/function/cases/functionLiteralAsLastParameter.kt @@ -0,0 +1,14 @@ +package foo + +fun f(a: (Int) -> Int) = a(1) + +fun box() : Boolean { + + if (f() { + it + 2 + } != 3) return false + + if (f() {(a : Int) -> a * 300} != 300) return false; + + return true +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/functionLiteralAsParameter.kt b/translator/testFiles/expression/function/cases/functionLiteralAsParameter.kt new file mode 100644 index 00000000000..3fb7b7ae0e4 --- /dev/null +++ b/translator/testFiles/expression/function/cases/functionLiteralAsParameter.kt @@ -0,0 +1,10 @@ +package foo + +fun apply(f : (Int) -> Int, t : Int) : Int { + return f(t) +} + + +fun box() : Boolean { + return apply({(a: Int) -> a + 5 }, 3) == 8 +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/functionUsedBeforeDeclaration.kt b/translator/testFiles/expression/function/cases/functionUsedBeforeDeclaration.kt new file mode 100644 index 00000000000..a093c854230 --- /dev/null +++ b/translator/testFiles/expression/function/cases/functionUsedBeforeDeclaration.kt @@ -0,0 +1,13 @@ +package foo + + +fun box() : Boolean +{ + return f() +} + +fun f() : Boolean { + return true +} + + diff --git a/translator/testFiles/expression/function/cases/functionWithTwoParametersCall.kt b/translator/testFiles/expression/function/cases/functionWithTwoParametersCall.kt new file mode 100644 index 00000000000..4c82f64892f --- /dev/null +++ b/translator/testFiles/expression/function/cases/functionWithTwoParametersCall.kt @@ -0,0 +1,9 @@ +package foo + +fun sum(param1 : Int, param2 : Int) : Int { + return param1 + param2; +} + +fun box() : Boolean { + return (sum(1, 5) == 6) +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/implicitItParameter.kt b/translator/testFiles/expression/function/cases/implicitItParameter.kt new file mode 100644 index 00000000000..ecfbeb19844 --- /dev/null +++ b/translator/testFiles/expression/function/cases/implicitItParameter.kt @@ -0,0 +1,12 @@ +package foo + +fun test(f : (Int) -> Boolean, p : Int) = f(p) + +fun box() : Boolean { + if (!test({it + 1 == 2}, 1)) return false; + + if (!test({it > 1}, 3)) return false; + + return (test({((it < 1) == false)}, 1)) + +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/loopClosure.kt b/translator/testFiles/expression/function/cases/loopClosure.kt new file mode 100644 index 00000000000..1cf3f038528 --- /dev/null +++ b/translator/testFiles/expression/function/cases/loopClosure.kt @@ -0,0 +1,17 @@ +package foo + +var b = 0 + +fun loop(var times : Int) { + while(times > 0) { + val u = {(value : Int) -> + b = b + 1 + } + u(times--) + } +} + +fun box() : Boolean { + loop(5) + return b == 5 +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/namedArguments.kt b/translator/testFiles/expression/function/cases/namedArguments.kt new file mode 100644 index 00000000000..5511e10825f --- /dev/null +++ b/translator/testFiles/expression/function/cases/namedArguments.kt @@ -0,0 +1,16 @@ +package foo + +fun test(x: Int, y: Int) = y - x + +fun box() : Boolean { + if (test(1,2) != 1) { + return false; + } + if (test(x=1, y=2) != 1) { + return false; + } + if (test(y=2, x=1) != 1) { + return false; + } + return true +} \ No newline at end of file diff --git a/translator/testFiles/expression/function/cases/vararg.kt b/translator/testFiles/expression/function/cases/vararg.kt new file mode 100644 index 00000000000..d3ab09ec173 --- /dev/null +++ b/translator/testFiles/expression/function/cases/vararg.kt @@ -0,0 +1,17 @@ +package foo + +fun testSize(expectedSize : Int, vararg i : Int) : Boolean { + return (i.size == expectedSize) +} + +fun testSum(expectedSum : Int, vararg i : Int) : Boolean { + var sum = 0 + for (j in i) { + sum += j + } + + return (expectedSum == sum) +} + +fun box() = testSize(0) && testSum(0) && testSize(3, 1, 1, 1) && testSum(3, 1, 1, 1) && testSize(6, 1, 1, 1, 2, 3, 4) && + testSum(30, 10, 20, 0) \ No newline at end of file diff --git a/translator/testFiles/expression/misc/cases/intRange.kt b/translator/testFiles/expression/misc/cases/intRange.kt new file mode 100644 index 00000000000..73d578db692 --- /dev/null +++ b/translator/testFiles/expression/misc/cases/intRange.kt @@ -0,0 +1,112 @@ +package foo + +import js.* + +class RangeIterator(val start : Int, var count : Int, val reversed : Boolean) { + + var i = start + + fun next() : Int { + --count + if (reversed) { + i-- + return i + 1 + } else { + i++ + return i - 1 + } + } + + + fun hasNext() = (count > 0); +} + +class NumberRange(val start : Int, val size : Int, val reversed : Boolean) { + + val end : Int + get() = if (reversed) start - size + 1 else start + size - 1 + + fun contains(number : Int) : Boolean { + if (reversed) { + return (number <= start) && (number > start - size); + } else { + return (number >= start) && (number < start + size); + } + } + + fun iterator() = RangeIterator(start, size, reversed); +} + + + +fun box() = testRange() && testReversedRange(); + +fun testRange() : Boolean { + + val oneToFive = NumberRange(1, 4, false); + if (oneToFive.contains(5)) return false; + if (oneToFive.contains(0)) return false; + if (oneToFive.contains(-100)) return false; + if (oneToFive.contains(10)) return false; + if (!oneToFive.contains(1)) return false; + if (!oneToFive.contains(2)) return false; + if (!oneToFive.contains(3)) return false; + if (!oneToFive.contains(4)) return false; + if (!(oneToFive.start == 1)) return false; + if (!(oneToFive.size == 4)) return false; + if (!(oneToFive.end == 4)) return false; + + var sum = 0; + for (i in oneToFive) { + sum += i; + } + for (i in oneToFive) { + print(i) + } + + if (sum != 10) return false; + + return true; + +} + +fun testReversedRange() : Boolean { + + println("Testing reversed range."); + + val tenToFive = NumberRange(10, 5, true); + + if (tenToFive.contains(5)) return false; + if (tenToFive.contains(11)) return false; + if (tenToFive.contains(-100)) return false; + if (tenToFive.contains(1000)) return false; + if (!tenToFive.contains(6)) return false; + if (!tenToFive.contains(7)) return false; + if (!tenToFive.contains(8)) return false; + if (!tenToFive.contains(9)) return false; + if (!tenToFive.contains(10)) return false; + + if (!(tenToFive.start == 10)) return false; + if (!(tenToFive.size == 5)) return false; + if (!(tenToFive.end == 6)) return false; + + for (i in tenToFive) { + println(i) + } + + + var sum = 0; + for (i in tenToFive) { + sum += i; + } + + if (sum != 40) { + return false; + } + + return true; +} + +fun main(args : Array) { + println(box()) +} \ No newline at end of file diff --git a/translator/testFiles/expression/misc/cases/jquery.kt b/translator/testFiles/expression/misc/cases/jquery.kt new file mode 100644 index 00000000000..4b4c94c8273 --- /dev/null +++ b/translator/testFiles/expression/misc/cases/jquery.kt @@ -0,0 +1,8 @@ +package foo + +import jquery.*; + +fun box() : String { + val aa = jq("a").attr("a"); + return "OK" +} \ No newline at end of file diff --git a/translator/testFiles/expression/misc/cases/localProperty.jet b/translator/testFiles/expression/misc/cases/localProperty.jet new file mode 100644 index 00000000000..2f69f45afba --- /dev/null +++ b/translator/testFiles/expression/misc/cases/localProperty.jet @@ -0,0 +1,15 @@ +package foo + +val y = 3 + +fun f(a:Int) : Int { + val x = 42 + val y = 50 + + return y +} + +fun box() : Int +{ + return f(y) +} diff --git a/translator/testFiles/expression/misc/cases/safecallComputesExpressionOnlyOnce.kt b/translator/testFiles/expression/misc/cases/safecallComputesExpressionOnlyOnce.kt new file mode 100644 index 00000000000..e48f4d2da46 --- /dev/null +++ b/translator/testFiles/expression/misc/cases/safecallComputesExpressionOnlyOnce.kt @@ -0,0 +1,14 @@ +package foo + +var i = 0 + +fun test() : Int? = i++ + +fun box() : Boolean { + if (i != 0) return false + test()?.plus(1) + if (i != 1) return false + test()?.minus(2) + if (i != 2) return false + return true +} \ No newline at end of file diff --git a/translator/testFiles/expression/string/cases/intInTemplate.kt b/translator/testFiles/expression/string/cases/intInTemplate.kt new file mode 100644 index 00000000000..2fa031bd831 --- /dev/null +++ b/translator/testFiles/expression/string/cases/intInTemplate.kt @@ -0,0 +1,7 @@ +package foo + +fun box() : String { + var number = 3 + return ("my age is $number"); +} + diff --git a/translator/testFiles/expression/string/cases/multipleExpressionsInTemplate.kt b/translator/testFiles/expression/string/cases/multipleExpressionsInTemplate.kt new file mode 100644 index 00000000000..cede8ae7ef9 --- /dev/null +++ b/translator/testFiles/expression/string/cases/multipleExpressionsInTemplate.kt @@ -0,0 +1,8 @@ +package foo + +fun box() : String { + var right = 2 + var left = 3 + return ("left = $left\nright = $right\nsum = ${left + right}\n"); +} + diff --git a/translator/testFiles/expression/string/cases/objectToStringCallInTemplate.kt b/translator/testFiles/expression/string/cases/objectToStringCallInTemplate.kt new file mode 100644 index 00000000000..7eab5902391 --- /dev/null +++ b/translator/testFiles/expression/string/cases/objectToStringCallInTemplate.kt @@ -0,0 +1,18 @@ +package foo + +class A(var i : Int) { + fun toString() = "a$i" +} + +fun box() : Boolean { + var p = A(2); + var n = A(1); + if ("$p$n" != "a2a1") { + return false; + } + if ("${A(10)}" != "a10") { + return false; + } + return true; +} + diff --git a/translator/testFiles/expression/string/cases/stringAssignment.kt b/translator/testFiles/expression/string/cases/stringAssignment.kt new file mode 100644 index 00000000000..9f3c327965f --- /dev/null +++ b/translator/testFiles/expression/string/cases/stringAssignment.kt @@ -0,0 +1,10 @@ +package foo + +fun box() : Boolean { + + val a = "bar"; + var b = "foo"; + b = a; + return (b == "bar"); +} + diff --git a/translator/testFiles/expression/string/cases/stringConstant.kt b/translator/testFiles/expression/string/cases/stringConstant.kt new file mode 100644 index 00000000000..9961104c902 --- /dev/null +++ b/translator/testFiles/expression/string/cases/stringConstant.kt @@ -0,0 +1,8 @@ +package foo + +fun box() : Boolean { + + val a = "String"; + return true; +} + diff --git a/translator/testFiles/expression/string/cases/stringInTemplate.kt b/translator/testFiles/expression/string/cases/stringInTemplate.kt new file mode 100644 index 00000000000..5a021f9aec2 --- /dev/null +++ b/translator/testFiles/expression/string/cases/stringInTemplate.kt @@ -0,0 +1,7 @@ +package foo + +fun box() : String { + var name = "Hello" + return ("o${name}o"); +} + diff --git a/translator/testFiles/extensionFunction/cases/extensionFunctionOnExpression.kt b/translator/testFiles/extensionFunction/cases/extensionFunctionOnExpression.kt new file mode 100644 index 00000000000..7b3c4b004da --- /dev/null +++ b/translator/testFiles/extensionFunction/cases/extensionFunctionOnExpression.kt @@ -0,0 +1,13 @@ +package foo + +fun Int.same() : Int { + return this +} + +fun Int.quadruple() : Int { + return same() * 4; +} + +fun box(): Boolean { + return ((3 + 4).quadruple() == 28) +} diff --git a/translator/testFiles/extensionFunction/cases/extensionInsideFunctionLiteral.kt b/translator/testFiles/extensionFunction/cases/extensionInsideFunctionLiteral.kt new file mode 100644 index 00000000000..9d69e2fd859 --- /dev/null +++ b/translator/testFiles/extensionFunction/cases/extensionInsideFunctionLiteral.kt @@ -0,0 +1,22 @@ +package foo + +class M() { + var m = 0 + + fun eval() { + var d = { + var c = {Int.() -> this + 3} + m += 3.c() + } + d(); + } +} + +fun box() : Boolean { + var a = M() + if (a.m != 0) return false; + a.eval() + if (a.m != 6) return false; + + return true; +} \ No newline at end of file diff --git a/translator/testFiles/extensionFunction/cases/extensionLiteralPassedToFunction.kt b/translator/testFiles/extensionFunction/cases/extensionLiteralPassedToFunction.kt new file mode 100644 index 00000000000..62bd16300a2 --- /dev/null +++ b/translator/testFiles/extensionFunction/cases/extensionLiteralPassedToFunction.kt @@ -0,0 +1,7 @@ +package foo + +fun apply(i : Int, f : Int.(Int) -> Int) = i.f(1); + +fun box() : Boolean { + return (apply(1, {i -> i + this})) == 2 +} \ No newline at end of file diff --git a/translator/testFiles/extensionFunction/cases/extensionUsedInsideClass.kt b/translator/testFiles/extensionFunction/cases/extensionUsedInsideClass.kt new file mode 100644 index 00000000000..7e345e3ad93 --- /dev/null +++ b/translator/testFiles/extensionFunction/cases/extensionUsedInsideClass.kt @@ -0,0 +1,15 @@ +package foo + +class A(var a : Int) { + fun eval() = f(); +} + +fun A.f() : Int { + a = 3 + return 10 +} + +fun box(): Boolean { + val a = A(4) + return (a.eval() == 10) && (a.a == 3) +} diff --git a/translator/testFiles/extensionFunction/cases/extensionWithImplicitReceiver.kt b/translator/testFiles/extensionFunction/cases/extensionWithImplicitReceiver.kt new file mode 100644 index 00000000000..ccab0e9f2f5 --- /dev/null +++ b/translator/testFiles/extensionFunction/cases/extensionWithImplicitReceiver.kt @@ -0,0 +1,13 @@ +package foo + +fun Int.same() : Int { + return this +} + +fun Int.quadruple() : Int { + return same() * 4; +} + +fun box(): Boolean { + return (3.quadruple() == 12) +} \ No newline at end of file diff --git a/translator/testFiles/extensionFunction/cases/generic.kt b/translator/testFiles/extensionFunction/cases/generic.kt new file mode 100644 index 00000000000..d13147d5d22 --- /dev/null +++ b/translator/testFiles/extensionFunction/cases/generic.kt @@ -0,0 +1,24 @@ +package foo + +import java.util.* + +fun ArrayList.findAll(predicate: (T) -> Boolean): ArrayList { + val result = ArrayList() + for(val t in this) { + if (predicate(t)) result.add(t) + } + return result +} + + +fun box(): String { + val list: ArrayList = ArrayList() + + list.add(2) + list.add(3) + list.add(5) + + + val m: ArrayList = list.findAll({(name: Int) -> name < 4}) + return if (m.size() == 2) "OK" else "fail" +} diff --git a/translator/testFiles/extensionFunction/cases/intExtension.kt b/translator/testFiles/extensionFunction/cases/intExtension.kt new file mode 100644 index 00000000000..884014c87aa --- /dev/null +++ b/translator/testFiles/extensionFunction/cases/intExtension.kt @@ -0,0 +1,9 @@ +package foo + +fun Int.quadruple() : Int { + return this * 4; +} + +fun box(): Boolean { + return (3.quadruple() == 12) +} diff --git a/translator/testFiles/extensionFunction/cases/virtualExtension.kt b/translator/testFiles/extensionFunction/cases/virtualExtension.kt new file mode 100644 index 00000000000..383c0191f5f --- /dev/null +++ b/translator/testFiles/extensionFunction/cases/virtualExtension.kt @@ -0,0 +1,15 @@ +package foo + +class A(var a : Int) { + + fun Int.modify() : Int { + return this * 3; + } + + fun eval() = a.modify(); +} + +fun box(): Boolean { + val a = A(4) + return (a.eval() == 12) +} diff --git a/translator/testFiles/extensionFunction/cases/virtualExtensionOverride.kt b/translator/testFiles/extensionFunction/cases/virtualExtensionOverride.kt new file mode 100644 index 00000000000..78646fb4b38 --- /dev/null +++ b/translator/testFiles/extensionFunction/cases/virtualExtensionOverride.kt @@ -0,0 +1,20 @@ +package foo + +open class A(var a : Int) { + + open fun Int.modify() : Int { + return this * 3; + } + + fun eval() = a.modify(); +} + +class B(a : Int) : A(a) { + override fun Int.modify() : Int { + return this - 2; + } +} + +fun box(): Boolean { + return (A(4).eval() == 12) && (A(2).eval() == 6) && (B(3).eval() == 1) +} diff --git a/translator/testFiles/extensionProperty/cases/absExtension.kt b/translator/testFiles/extensionProperty/cases/absExtension.kt new file mode 100644 index 00000000000..d0399758498 --- /dev/null +++ b/translator/testFiles/extensionProperty/cases/absExtension.kt @@ -0,0 +1,11 @@ +package foo; + +val Double.abs : Double + get() = if (this > 0) this else -this + +fun box() : Boolean { + if (4.0.abs != 4.0) return false; + if ((-5.2).abs != 5.2) return false; + + return true; +} diff --git a/translator/testFiles/extensionProperty/cases/propertyWithGetterAndSetter.kt b/translator/testFiles/extensionProperty/cases/propertyWithGetterAndSetter.kt new file mode 100644 index 00000000000..aba51251279 --- /dev/null +++ b/translator/testFiles/extensionProperty/cases/propertyWithGetterAndSetter.kt @@ -0,0 +1,23 @@ +package foo + +class Test() { + var a = 0 +} + +var Test.b : Int + get() = a * 3 + set(c : Int) { + a = c - 1 + } + +fun box() : Boolean { + val c = Test() + if (c.a != 0) return false; + if (c.b != 0) return false; + c.a = 3; + if (c.b != 9) return false; + c.b = 10; + if (c.a != 9) return false; + if (c.b != 27) return false; + return true; +} \ No newline at end of file diff --git a/translator/testFiles/extensionProperty/cases/simplePropertyWithGetter.kt b/translator/testFiles/extensionProperty/cases/simplePropertyWithGetter.kt new file mode 100644 index 00000000000..f073c5ce546 --- /dev/null +++ b/translator/testFiles/extensionProperty/cases/simplePropertyWithGetter.kt @@ -0,0 +1,17 @@ +package foo + +val String.size : Int + get() = length + +val Int.quadruple : Int + get() = this * 4 + +fun box() : Boolean +{ + if ("1".size != 1) return false; + if ("11".size != 2) return false; + if (("121" + "123").size != 6) return false; + if (1.quadruple != 4) return false; + if (0.quadruple != 0) return false; + return true; +} \ No newline at end of file diff --git a/translator/testFiles/inheritance/cases/baseClassDefinedAfterDerived.kt b/translator/testFiles/inheritance/cases/baseClassDefinedAfterDerived.kt new file mode 100644 index 00000000000..53a23fdc56e --- /dev/null +++ b/translator/testFiles/inheritance/cases/baseClassDefinedAfterDerived.kt @@ -0,0 +1,13 @@ +package foo + + +class A() : B() { + +} + +open class B() { + + val a = 3 +} + +fun box() = (A().a == 3) \ No newline at end of file diff --git a/translator/testFiles/inheritance/cases/complexInitializationOrder.kt b/translator/testFiles/inheritance/cases/complexInitializationOrder.kt new file mode 100644 index 00000000000..9004131ad03 --- /dev/null +++ b/translator/testFiles/inheritance/cases/complexInitializationOrder.kt @@ -0,0 +1,37 @@ +package foo + +open class A() { + + var order = "" + { + order = order + "A" + } +} + +open class B() : A() { + { + order = order + "B" + } +} + +class C() : B() { + { + order = order + "C" + } +} + +class D() : B() { + { + order = order + "D" + } +} + +class E() : A() { + { + order = order + "E" + } +} + +fun box() : Boolean { + return (C().order == "ABC") && (D().order == "ABD") && (E().order == "AE") +} \ No newline at end of file diff --git a/translator/testFiles/inheritance/cases/definitionOrder.kt b/translator/testFiles/inheritance/cases/definitionOrder.kt new file mode 100644 index 00000000000..12e3f7b045c --- /dev/null +++ b/translator/testFiles/inheritance/cases/definitionOrder.kt @@ -0,0 +1,37 @@ +package foo + +class C() : B() { + { + order = order + "C" + } +} + +class D() : B() { + { + order = order + "D" + } +} + +class E() : A() { + { + order = order + "E" + } +} + +open class B() : A() { + { + order = order + "B" + } +} + +open class A() { + + var order = "" + { + order = order + "A" + } +} + +fun box() : Boolean { + return (C().order == "ABC") && (D().order == "ABD") && (E().order == "AE") +} \ No newline at end of file diff --git a/translator/testFiles/inheritance/cases/initializationOrder.kt b/translator/testFiles/inheritance/cases/initializationOrder.kt new file mode 100644 index 00000000000..faf44b8ab6e --- /dev/null +++ b/translator/testFiles/inheritance/cases/initializationOrder.kt @@ -0,0 +1,26 @@ +package foo + +open class A() { + + var order = "" + { + order = order + "A" + } +} + +open class B() : A() { + { + order = order + "B" + } + +} + +class C() : B() { + { + order = order + "C" + } +} + +fun box() : Boolean { + return (C().order == "ABC") && (B().order == "AB") && (A().order == "A") +} \ No newline at end of file diff --git a/translator/testFiles/inheritance/cases/initializersOfBasicClassExecute.kt b/translator/testFiles/inheritance/cases/initializersOfBasicClassExecute.kt new file mode 100644 index 00000000000..52176e10fbe --- /dev/null +++ b/translator/testFiles/inheritance/cases/initializersOfBasicClassExecute.kt @@ -0,0 +1,13 @@ +package foo + +open class A() { + var a = 3; +} + +class B() : A() { + +} + +fun box() : Int { + return (B().a) +} diff --git a/translator/testFiles/inheritance/cases/methodOverride.kt b/translator/testFiles/inheritance/cases/methodOverride.kt new file mode 100644 index 00000000000..62feff89b9b --- /dev/null +++ b/translator/testFiles/inheritance/cases/methodOverride.kt @@ -0,0 +1,15 @@ +package foo + +open class C() { + open fun f(): Any = "C f" +} + +class D() : C() { + override fun f(): String = "D f" +} + +fun box(): Boolean { + val d : C = D() + if(d.f() != "D f") return false + return true +} \ No newline at end of file diff --git a/translator/testFiles/inheritance/cases/valuePassedToAncestorConstructor.kt b/translator/testFiles/inheritance/cases/valuePassedToAncestorConstructor.kt new file mode 100644 index 00000000000..97795d7210f --- /dev/null +++ b/translator/testFiles/inheritance/cases/valuePassedToAncestorConstructor.kt @@ -0,0 +1,12 @@ +package foo + +open class C(a : Int) { + val b = a +} + +class D(c : Int) : C(c + 2) { +} + +fun box(): Boolean { + return (D(0).b == 2) +} \ No newline at end of file diff --git a/translator/testFiles/java/arrayList/cases/access.kt b/translator/testFiles/java/arrayList/cases/access.kt new file mode 100644 index 00000000000..58c151430c2 --- /dev/null +++ b/translator/testFiles/java/arrayList/cases/access.kt @@ -0,0 +1,10 @@ +package foo + + import java.util.ArrayList; + + fun box() : Boolean { + val a = ArrayList(); + a.add(1) + a.add(2) + return (a.size() == 2) && (a.get(1) == 2) && (a.get(0) == 1); + } \ No newline at end of file diff --git a/translator/testFiles/java/arrayList/cases/arrayAccess.kt b/translator/testFiles/java/arrayList/cases/arrayAccess.kt new file mode 100644 index 00000000000..b47cfa6e040 --- /dev/null +++ b/translator/testFiles/java/arrayList/cases/arrayAccess.kt @@ -0,0 +1,11 @@ +package foo + +import java.util.ArrayList; + +fun box() : Boolean { + val a = ArrayList(); + a.add(1) + a.add(2) + a[1] = 100 + return (a.size() == 2) && (a[1] == 100) && (a[0] == 1); +} \ No newline at end of file diff --git a/translator/testFiles/java/arrayList/cases/emptyList.kt b/translator/testFiles/java/arrayList/cases/emptyList.kt new file mode 100644 index 00000000000..ec624c39ad9 --- /dev/null +++ b/translator/testFiles/java/arrayList/cases/emptyList.kt @@ -0,0 +1,8 @@ +package foo + +import java.util.ArrayList; + +fun box() : Boolean { + val a = ArrayList(); + return a.size() == 0; +} \ No newline at end of file diff --git a/translator/testFiles/java/arrayList/cases/indexOOB.kt b/translator/testFiles/java/arrayList/cases/indexOOB.kt new file mode 100644 index 00000000000..52d1f6936a7 --- /dev/null +++ b/translator/testFiles/java/arrayList/cases/indexOOB.kt @@ -0,0 +1,12 @@ +package foo + +import java.util.ArrayList; + +fun box() : Boolean { + val arr = ArrayList(); + var i = 0; + while (i++ < 10) { + arr.add(i); + } + return (arr[10] == 11) +} \ No newline at end of file diff --git a/translator/testFiles/java/arrayList/cases/isEmpty.kt b/translator/testFiles/java/arrayList/cases/isEmpty.kt new file mode 100644 index 00000000000..7f9c7283f87 --- /dev/null +++ b/translator/testFiles/java/arrayList/cases/isEmpty.kt @@ -0,0 +1,9 @@ +package foo + +import java.util.ArrayList; + +fun box() : Boolean { + val a = ArrayList(); + a.add(3) + return !(a.isEmpty()) && (ArrayList().isEmpty()); +} \ No newline at end of file diff --git a/translator/testFiles/java/arrayList/cases/iterate.kt b/translator/testFiles/java/arrayList/cases/iterate.kt new file mode 100644 index 00000000000..74da14b2f0a --- /dev/null +++ b/translator/testFiles/java/arrayList/cases/iterate.kt @@ -0,0 +1,16 @@ +package foo + +import java.util.ArrayList; + +fun box() : Boolean { + var i = 0 + val arr = ArrayList(); + while (i++ < 10) { + arr.add(i); + } + var sum = 0 + for (a in arr) { + sum += a; + } + return (sum == 55) && (arr.size() == 10) +} \ No newline at end of file diff --git a/translator/testFiles/java/arrayList/cases/max.kt b/translator/testFiles/java/arrayList/cases/max.kt new file mode 100644 index 00000000000..50098e82059 --- /dev/null +++ b/translator/testFiles/java/arrayList/cases/max.kt @@ -0,0 +1,8 @@ +package foo + +import java.util.Collection; +import java.util.Comparator. + +fun max(col :Collection, ) { + +} \ No newline at end of file diff --git a/translator/testFiles/java/arrayList/cases/remove.kt b/translator/testFiles/java/arrayList/cases/remove.kt new file mode 100644 index 00000000000..20095823895 --- /dev/null +++ b/translator/testFiles/java/arrayList/cases/remove.kt @@ -0,0 +1,17 @@ +package foo + +import java.util.ArrayList; + +fun box() : Boolean { + var i = 0 + val arr = ArrayList(); + while (i++ < 10) { + arr.add(i); + } + arr.remove(2) + var sum = 0 + for (a in arr) { + sum += a; + } + return ((sum == 52) && (arr[1] == 2) && (arr[2] == 4) && (arr[3] == 5) && (arr[4] == 6) && (arr[8] == 10)) +} \ No newline at end of file diff --git a/translator/testFiles/kotlinLib/cases/array.js b/translator/testFiles/kotlinLib/cases/array.js new file mode 100644 index 00000000000..0d2083c480c --- /dev/null +++ b/translator/testFiles/kotlinLib/cases/array.js @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function test() { + var a = Kotlin.arrayFromFun(3, function () { + return 3 + }); + return (a[0] == 3) && (a[2] == 3) && (a[1] == 3); +} \ No newline at end of file diff --git a/translator/testFiles/kotlinLib/cases/commaExpression.js b/translator/testFiles/kotlinLib/cases/commaExpression.js new file mode 100644 index 00000000000..f3990bf315d --- /dev/null +++ b/translator/testFiles/kotlinLib/cases/commaExpression.js @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +a = 0 +f = (t = a, t1 = t, a = ++t1, t) + +test = function () { + return (f == 0) && (a == 1) +} \ No newline at end of file diff --git a/translator/testFiles/kotlinLib/cases/hashMap.js b/translator/testFiles/kotlinLib/cases/hashMap.js new file mode 100644 index 00000000000..5b195c7600d --- /dev/null +++ b/translator/testFiles/kotlinLib/cases/hashMap.js @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var map = new Kotlin.HashMap() + +map.put(3, 4) +map.put(6, 3) + +function test() { + if (map.containsKey(4) || map.containsKey(5)) return false; + if (map.containsKey({}) || map.containsKey(11)) return false; + if (!map.containsKey(3) || !map.containsKey(6)) return false; + var obj = map.get(3); + if (obj !== 4) return false; + obj = map.get(6); + if (obj !== 3) return false; + if (map.size() !== 2) return false; + map.put(2, 3); + if (map.size() !== 3) return false; + if (!map.containsKey(2) || !map.containsKey(3) || !map.containsKey(6)) return false; + if (!map.containsValue(4) || !map.containsValue(3)) return false; + map.put(2, 1000); + if (map.size() !== 3) return false; + if (map.get(2)!== 1000) return false; + + + return true; +} \ No newline at end of file diff --git a/translator/testFiles/kotlinLib/cases/isAncestorType.js b/translator/testFiles/kotlinLib/cases/isAncestorType.js new file mode 100644 index 00000000000..255b5891326 --- /dev/null +++ b/translator/testFiles/kotlinLib/cases/isAncestorType.js @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var A = Kotlin.Class.create(); +var B = Kotlin.Class.create(A); +var b = new B; + +test = function() { + return (Kotlin.isType(b, A) && Kotlin.isType(b, B)); +} \ No newline at end of file diff --git a/translator/testFiles/kotlinLib/cases/isComplexTest.js b/translator/testFiles/kotlinLib/cases/isComplexTest.js new file mode 100644 index 00000000000..92a4a2f29ff --- /dev/null +++ b/translator/testFiles/kotlinLib/cases/isComplexTest.js @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var A = Kotlin.Class.create(); +var B = Kotlin.Class.create(A); +var b = new B; +var C = Kotlin.Class.create(B); +var c = new C; +var E = Kotlin.Class.create(A) +var e = new E; + +test1 = function() { + b2 = b + return (Kotlin.isType(b, A) && Kotlin.isType(b, B)); +} + +test2 = function() { + return (Kotlin.isType(c, C) && Kotlin.isType(c, B) && Kotlin.isType(c, A) && (!Kotlin.isType(c, E))); +} + +test3 = function() { + return Kotlin.isType(e, E) && !Kotlin.isType(e, B) && !Kotlin.isType(e, C) && Kotlin.isType(e, A) +} + +test = function() { + return test1() && test2() && test3() +} \ No newline at end of file diff --git a/translator/testFiles/kotlinLib/cases/isNotOtherType.js b/translator/testFiles/kotlinLib/cases/isNotOtherType.js new file mode 100644 index 00000000000..b33ad3afab2 --- /dev/null +++ b/translator/testFiles/kotlinLib/cases/isNotOtherType.js @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var A = Kotlin.Class.create(); +var B = Kotlin.Class.create(A); +var C = Kotlin.Class.create(); +var c = new C; + +test = function() { + return ((!isType(c, A)) && !isType(c, B)); +} \ No newline at end of file diff --git a/translator/testFiles/kotlinLib/cases/isSameType.js b/translator/testFiles/kotlinLib/cases/isSameType.js new file mode 100644 index 00000000000..cb333db25c5 --- /dev/null +++ b/translator/testFiles/kotlinLib/cases/isSameType.js @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var A = Kotlin.Class.create(); +var a = new A; + +test = function() { + return Kotlin.isType(a, A); +} \ No newline at end of file diff --git a/translator/testFiles/kotlinLib/cases/namespace.js b/translator/testFiles/kotlinLib/cases/namespace.js new file mode 100644 index 00000000000..eeb677033eb --- /dev/null +++ b/translator/testFiles/kotlinLib/cases/namespace.js @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +foo = Kotlin.Namespace.create({initialize:function(){ +} +, box:function(){ + return !false; +} +}); + +function test() { + return foo.box() +} diff --git a/translator/testFiles/kotlinLib/cases/namespaceWithClasses.js b/translator/testFiles/kotlinLib/cases/namespaceWithClasses.js new file mode 100644 index 00000000000..0571b39e660 --- /dev/null +++ b/translator/testFiles/kotlinLib/cases/namespaceWithClasses.js @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + classes = function(){ + var A = Kotlin.Class.create({initialize:function(){ + this.$order = ''; + { + this.set_order(this.get_order() + 'A'); + } + } + , set_order:function(tmp$0){ + this.$order = tmp$0; + } + , get_order:function(){ + return this.$order; + } + }); + var B = Kotlin.Class.create(A, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'B'); + } + } + }); + var C = Kotlin.Class.create(B, {initialize:function(){ + this.super_init(); + { + this.set_order(this.get_order() + 'C'); + } + } + }); + return {A:A, B:B, C:C}; + } + (); + foo = Kotlin.Namespace.create(classes, {initialize:function(){ + } + , box:function(){ + return (new foo.C).get_order() === 'ABC' && (new foo.B).get_order() === 'AB' && (new foo.A).get_order() === 'A'; + } + }); +} + +function test() { + return foo.box() +} diff --git a/translator/testFiles/kotlinLib/cases/trait.js b/translator/testFiles/kotlinLib/cases/trait.js new file mode 100644 index 00000000000..628dbbd52f2 --- /dev/null +++ b/translator/testFiles/kotlinLib/cases/trait.js @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +foo = {}; +(function(foo){ + foo.Test = Kotlin.Trait.create({addFoo:function(s){ + return s + 'FOO'; + } + }); + foo.ExtendedTest = Kotlin.Trait.create(foo.Test, {hooray:function(){ + return 'hooray'; + } + }); +} +(foo)); diff --git a/translator/testFiles/kotlin_lib.js b/translator/testFiles/kotlin_lib.js new file mode 100644 index 00000000000..2d155d5a78c --- /dev/null +++ b/translator/testFiles/kotlin_lib.js @@ -0,0 +1,1079 @@ +/** + * Copyright 2010 Tim Down. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Prototype JavaScript framework, version 1.6.1 + * (c) 2005-2009 Sam Stephenson + * + * Prototype is freely distributable under the terms of an MIT-style license. + * For details, see the Prototype web site: http://www.prototypejs.org/ + * + *--------------------------------------------------------------------------*/ +(function () { + + function $A(iterable) { + if (!iterable) return []; + if ('toArray' in Object(iterable)) return iterable.toArray(); + var length = iterable.length || 0, results = new Array(length); + while (length--) results[length] = iterable[length]; + return results; + } + + (function () { + + + function extend(destination, source) { + for (var property in source) + destination[property] = source[property]; + return destination; + } + + + function keys(object) { + if (Type(object) !== OBJECT_TYPE) { + throw new TypeError(); + } + var results = []; + for (var property in object) { + if (object.hasOwnProperty(property)) { + results.push(property); + } + } + return results; + } + + function values(object) { + var results = []; + for (var property in object) + results.push(object[property]); + return results; + } + + extend(Object, { + extend:extend, + keys:Object.keys || keys, + values:values + }); + })(); + + + Object.extend(Function.prototype, (function () { + var slice = Array.prototype.slice; + + function update(array, args) { + var arrayLength = array.length, length = args.length; + while (length--) array[arrayLength + length] = args[length]; + return array; + } + + function merge(array, args) { + array = slice.call(array, 0); + return update(array, args); + } + + function argumentNames() { + var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1] + .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '') + .replace(/\s+/g, '').split(','); + return names.length == 1 && !names[0] ? [] : names; + } + + function bind(context) { + if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; + var __method = this, args = slice.call(arguments, 1); + return function () { + var a = merge(args, arguments); + return __method.apply(context, a); + } + } + + function bindAsEventListener(context) { + var __method = this, args = slice.call(arguments, 1); + return function (event) { + var a = update([event || window.event], args); + return __method.apply(context, a); + } + } + + function wrap(wrapper) { + var __method = this; + return function () { + var a = update([__method.bind(this)], arguments); + return wrapper.apply(this, a); + } + } + + return { + argumentNames:argumentNames, + bind:bind, + bindAsEventListener:bindAsEventListener, + wrap:wrap + } + })()); + + var isType = function (object, klass) { + current = object.get_class(); + while (current !== klass) { + if (current === null) { + return false; + } + current = current.superclass; + } + return true; + }; + + var emptyFunction = function () { + }; + + var Class = (function () { + + function subclass() { + } + ; + function create() { + var parent = null, properties = $A(arguments); + if (typeof (properties[0]) == "function") { + parent = properties.shift(); + } + + function klass() { + this.initializing = klass; + this.initialize.apply(this, arguments); + } + + Object.extend(klass, Class.Methods); + klass.superclass = parent; + klass.subclasses = []; + + if (parent) { + subclass.prototype = parent.prototype; + klass.prototype = new subclass; + parent.subclasses.push(klass); + } + + klass.addMethods( + { + get_class:function () { + return klass; + } + }); + + if (parent != null) { + klass.addMethods( + { + super_init:function () { + this.initializing = this.initializing.superclass; + this.initializing.prototype.initialize.apply(this, arguments) + } + }); + } + + for (var i = 0, length = properties.length; i < length; i++) + klass.addMethods(properties[i]); + + if (!klass.prototype.initialize) { + klass.prototype.initialize = emptyFunction; + } + + klass.prototype.constructor = klass; + return klass; + } + + function addMethods(source) { + var ancestor = this.superclass && this.superclass.prototype, + properties = Object.keys(source); + + + for (var i = 0, length = properties.length; i < length; i++) { + var property = properties[i], value = source[property]; + if (ancestor && (typeof (value) == "function") && + value.argumentNames()[0] == "$super") { + var method = value; + value = (function (m) { + return function () { + return ancestor[m].apply(this, arguments); + }; + })(property).wrap(method); + + } + this.prototype[property] = value; + } + + return this; + } + + return { + create:create, + Methods:{ + addMethods:addMethods + } + }; + })(); + + var Trait = (function () { + + function add(object, source) { + var properties = Object.keys(source); + for (var i = 0, length = properties.length; i < length; i++) { + var property = properties[i]; + var value = source[property]; + object[property] = value; + } + return this; + } + + function create() { + + result = {} + for (var i = 0, length = arguments.length; i < length; i++) { + add(result, arguments[i]); + } + return result; + } + + return { + create:create + }; + })(); + + + var Namespace = (function () { + + function create() { + return Trait.create.apply(Trait, arguments); + } + + return { + create:create + }; + })(); + + var object = (function () { + function create() { + var singletonClass = Class.create.apply(Class, arguments); + return new singletonClass; + } + return { + create:create + }; + })(); + + Kotlin = {}; + Kotlin.Class = Class; + Kotlin.Namespace = Namespace; + Kotlin.Trait = Trait; + Kotlin.isType = isType; + Kotlin.object = object; + + Kotlin.equals = function (obj1, obj2) { + if (typeof obj1 == "object") { + if (obj1.equals != undefined) { + return obj1.equals(obj2); + } + } + return (obj1 === obj2); + }; + + Kotlin.Exceptions = {} + Kotlin.Exception = Kotlin.Class.create(); + Kotlin.Exceptions.IndexOutOfBounds = {} + + + Kotlin.ArrayList = Class.create({ + initialize:function () { + this.array = []; + this.$size = 0; + }, + get:function (index) { + if ((index < 0) || (index >= this.$size)) { + throw Kotlin.Exceptions.IndexOutOfBounds; + } + return (this.array)[index]; + }, + set:function (index, value) { + if ((index < 0) || (index >= this.$size)) { + throw Kotlin.Exceptions.IndexOutOfBounds; + } + (this.array)[index] = value; + }, + size:function () { + return this.$size; + }, + iterator:function () { + return new Kotlin.ArrayIterator(this); + }, + isEmpty:function () { + return (this.$size == 0); + }, + add:function (element) { + this.array[this.$size++] = element; + }, + addAll:function (collection) { + var it = collection.iterator(); + while (it.hasNext()) { + this.add(it.next()); + } + }, + remove:function (index) { + for (var i = index; i < this.$size - 1; ++i) { + this.array[i] = this.array[i + 1]; + } + this.$size--; + }, + clear:function () { + this.array = []; + this.$size = 0; + }, + contains:function (obj) { + for (var i = 0; i < this.$size; ++i) { + if (Kotlin.equals(this.array[i], obj)) { + return true; + } + } + return false; + } + }); + + + Kotlin.parseInt = + function (str) { + return parseInt(str); + } + ; + + Kotlin.System = function () { + var output = ""; + + var print = function (obj) { + if (obj !== undefined) { + if (obj == null || typeof obj != "object") { + output += obj; + } + else { + output += obj.toString(); + } + } + }; + var println = function (obj) { + this.print(obj); + output += "\n"; + }; + + return { + out:function () { + return { + print:print, + println:println + }; + }, + output:function () { + return output; + }, + flush:function () { + output = ""; + } + }; + }(); + + Kotlin.println = function (s) { + Kotlin.System.out().println(s); + } + + Kotlin.print = function (s) { + Kotlin.System.out().print(s); + } + + Kotlin.AbstractFunctionInvokationError = Class.create(); + + Kotlin.Iterator = Class.create({ + initialize:function () { + }, + next:function () { + throw new Kotlin.AbstractFunctionInvokationError(); + }, + hasNext:function () { + throw new Kotlin.AbstractFunctionInvokationError(); + } + }); + + Kotlin.ArrayIterator = Class.create(Kotlin.Iterator, { + initialize:function (array) { + this.array = array; + this.index = 0; + }, + next:function () { + return this.array.get(this.index++); + }, + hasNext:function () { + return (this.array.size() > this.index); + }, + get_hasNext:function () { + return this.hasNext(); + } + }); + + Kotlin.RangeIterator = Kotlin.Class.create(Kotlin.Iterator, { + initialize:function (start, count, reversed) { + this.$start = start; + this.$count = count; + this.$reversed = reversed; + this.$i = this.get_start(); + }, get_start:function () { + return this.$start; + }, get_count:function () { + return this.$count; + }, set_count:function (tmp$0) { + this.$count = tmp$0; + }, get_reversed:function () { + return this.$reversed; + }, get_i:function () { + return this.$i; + }, set_i:function (tmp$0) { + this.$i = tmp$0; + }, next:function () { + this.set_count(this.get_count() - 1); + if (this.get_reversed()) { + this.set_i(this.get_i() - 1); + return this.get_i() + 1; + } + else { + this.set_i(this.get_i() + 1); + return this.get_i() - 1; + } + }, hasNext:function () { + return this.get_count() > 0; + }, get_hasNext:function () { + return this.hasNext(); + } + }); + + Kotlin.NumberRange = Kotlin.Class.create({initialize:function (start, size, reversed) { + this.$start = start; + this.$size = size; + this.$reversed = reversed; + }, get_start:function () { + return this.$start; + }, get_size:function () { + return this.$size; + }, get_reversed:function () { + return this.$reversed; + }, get_end:function () { + return this.get_reversed() ? this.get_start() - this.get_size() + 1 : this.get_start() + this.get_size() - 1; + }, contains:function (number) { + if (this.get_reversed()) { + return number <= this.get_start() && number > this.get_start() - this.get_size(); + } + else { + return number >= this.get_start() && number < this.get_start() + this.get_size(); + } + }, iterator:function () { + return new Kotlin.RangeIterator(this.get_start(), this.get_size(), this.get_reversed()); + } + }); + + Kotlin.Comparator = Kotlin.Class.create( + { + initialize:function () { + }, + compare:function (el1, el2) { + throw new Kotlin.AbstractFunctionInvokationError(); + } + } + ); + + Kotlin.comparator = function(f) { + var result = new Kotlin.Comparator; + result.compare = function(el1, el2) { + return f(el1, el2); + }; + return result; + }; + + Kotlin.collectionsMax = function (col, comp) { + var it = col.iterator(); + if (col.isEmpty()) { + //TODO: which exception? + throw Kotlin.Exception(); + } + var max = it.next(); + while (it.hasNext()) { + var el = it.next(); + if (comp.compare(max, el) < 0) { + max = el; + } + } + return max; + }; + + Kotlin.StringBuilder = Kotlin.Class.create( + { + initialize:function () { + this.string = ""; + }, + append:function (obj) { + this.string = this.string + obj.toString(); + }, + toString:function () { + return this.string; + } + } + ); + + Kotlin.splitString = function(str, regex) { + return str.split(regex); + }; + + Kotlin.nullArray = function (size) { + var res = []; + var i = size; + while (i > 0) { + res[--i] = null; + } + return res; + }; + + Kotlin.arrayFromFun = function (size, initFun) { + var res = []; + var i = size; + while (i > 0) { + res[--i] = initFun(i); + } + return res; + }; + + Kotlin.arrayIndices = function (arr) { + return new Kotlin.NumberRange(0, arr.length); + }; + + var intrinsicArrayIterator = Kotlin.Class.create( + Kotlin.Iterator, + { + initialize:function (arr) { + this.arr = arr; + this.len = arr.length; + this.i = 0; + }, + hasNext:function () { + return (this.i < this.len); + }, + next:function () { + return this.arr[this.i++]; + }, + get_hasNext:function () { + return this.hasNext() + } + } + ); + + Kotlin.arrayIterator = function (arr) { + return new intrinsicArrayIterator(arr); + }; + + Kotlin.toString = function (obj) { + return obj.toString(); + }; + + Kotlin.jsonFromTuples = function (pairArr) { + var i = pairArr.length; + var res = {}; + while (i > 0) { + --i; + res[pairArr[i][0]] = pairArr[i][1]; + } + return res; + }; + + Kotlin.jsonSet = function (obj, attrName, value) { + obj[attrName] = value; + }; + + Kotlin.jsonGet = function (obj, attrName) { + return obj[attrName]; + }; + + + Kotlin.sure = function(obj) { + return obj; + }; + + (function () { + var FUNCTION = "function"; + + var arrayRemoveAt = (typeof Array.prototype.splice == FUNCTION) ? + function (arr, idx) { + arr.splice(idx, 1); + } : + + function (arr, idx) { + var itemsAfterDeleted, i, len; + if (idx === arr.length - 1) { + arr.length = idx; + } + else { + itemsAfterDeleted = arr.slice(idx + 1); + arr.length = idx; + for (i = 0, len = itemsAfterDeleted.length; i < len; ++i) { + arr[idx + i] = itemsAfterDeleted[i]; + } + } + }; + + function hashObject(obj) { + var hashCode; + if (typeof obj == "string") { + return obj; + } else if (typeof obj.hashCode == FUNCTION) { + // Check the hashCode method really has returned a string + hashCode = obj.hashCode(); + return (typeof hashCode == "string") ? hashCode : hashObject(hashCode); + } else if (typeof obj.toString == FUNCTION) { + return obj.toString(); + } + else { + try { + return String(obj); + } catch (ex) { + // For host objects (such as ActiveObjects in IE) that have no toString() method and throw an error when + // passed to String() + return Object.prototype.toString.call(obj); + } + } + } + + function equals_fixedValueHasEquals(fixedValue, variableValue) { + return fixedValue.equals(variableValue); + } + + function equals_fixedValueNoEquals(fixedValue, variableValue) { + return (typeof variableValue.equals == FUNCTION) ? + variableValue.equals(fixedValue) : (fixedValue === variableValue); + } + + function createKeyValCheck(kvStr) { + return function (kv) { + if (kv === null) { + throw new Error("null is not a valid " + kvStr); + } else if (typeof kv == "undefined") { + throw new Error(kvStr + " must not be undefined"); + } + }; + } + + var checkKey = createKeyValCheck("key"), checkValue = createKeyValCheck("value"); + + /*----------------------------------------------------------------------------------------------------------------*/ + + function Bucket(hash, firstKey, firstValue, equalityFunction) { + this[0] = hash; + this.entries = []; + this.addEntry(firstKey, firstValue); + + if (equalityFunction !== null) { + this.getEqualityFunction = function () { + return equalityFunction; + }; + } + } + + var EXISTENCE = 0, ENTRY = 1, ENTRY_INDEX_AND_VALUE = 2; + + function createBucketSearcher(mode) { + return function (key) { + var i = this.entries.length, entry, equals = this.getEqualityFunction(key); + while (i--) { + entry = this.entries[i]; + if (equals(key, entry[0])) { + switch (mode) { + case EXISTENCE: + return true; + case ENTRY: + return entry; + case ENTRY_INDEX_AND_VALUE: + return [ i, entry[1] ]; + } + } + } + return false; + }; + } + + function createBucketLister(entryProperty) { + return function (aggregatedArr) { + var startIndex = aggregatedArr.length; + for (var i = 0, len = this.entries.length; i < len; ++i) { + aggregatedArr[startIndex + i] = this.entries[i][entryProperty]; + } + }; + } + + Bucket.prototype = { + getEqualityFunction:function (searchValue) { + return (typeof searchValue.equals == FUNCTION) ? equals_fixedValueHasEquals : equals_fixedValueNoEquals; + }, + + getEntryForKey:createBucketSearcher(ENTRY), + + getEntryAndIndexForKey:createBucketSearcher(ENTRY_INDEX_AND_VALUE), + + removeEntryForKey:function (key) { + var result = this.getEntryAndIndexForKey(key); + if (result) { + arrayRemoveAt(this.entries, result[0]); + return result[1]; + } + return null; + }, + + addEntry:function (key, value) { + this.entries[this.entries.length] = [key, value]; + }, + + keys:createBucketLister(0), + + values:createBucketLister(1), + + getEntries:function (entries) { + var startIndex = entries.length; + for (var i = 0, len = this.entries.length; i < len; ++i) { + // Clone the entry stored in the bucket before adding to array + entries[startIndex + i] = this.entries[i].slice(0); + } + }, + + containsKey:createBucketSearcher(EXISTENCE), + + containsValue:function (value) { + var i = this.entries.length; + while (i--) { + if (value === this.entries[i][1]) { + return true; + } + } + return false; + } + }; + + /*----------------------------------------------------------------------------------------------------------------*/ + + // Supporting functions for searching hashtable buckets + + function searchBuckets(buckets, hash) { + var i = buckets.length, bucket; + while (i--) { + bucket = buckets[i]; + if (hash === bucket[0]) { + return i; + } + } + return null; + } + + function getBucketForHash(bucketsByHash, hash) { + var bucket = bucketsByHash[hash]; + + // Check that this is a genuine bucket and not something inherited from the bucketsByHash's prototype + return ( bucket && (bucket instanceof Bucket) ) ? bucket : null; + } + + /*----------------------------------------------------------------------------------------------------------------*/ + + var Hashtable = function (hashingFunctionParam, equalityFunctionParam) { + var that = this; + var buckets = []; + var bucketsByHash = {}; + + var hashingFunction = (typeof hashingFunctionParam == FUNCTION) ? hashingFunctionParam : hashObject; + var equalityFunction = (typeof equalityFunctionParam == FUNCTION) ? equalityFunctionParam : null; + + this.put = function (key, value) { + checkKey(key); + checkValue(value); + var hash = hashingFunction(key), bucket, bucketEntry, oldValue = null; + + // Check if a bucket exists for the bucket key + bucket = getBucketForHash(bucketsByHash, hash); + if (bucket) { + // Check this bucket to see if it already contains this key + bucketEntry = bucket.getEntryForKey(key); + if (bucketEntry) { + // This bucket entry is the current mapping of key to value, so replace old value and we're done. + oldValue = bucketEntry[1]; + bucketEntry[1] = value; + } + else { + // The bucket does not contain an entry for this key, so add one + bucket.addEntry(key, value); + } + } + else { + // No bucket exists for the key, so create one and put our key/value mapping in + bucket = new Bucket(hash, key, value, equalityFunction); + buckets[buckets.length] = bucket; + bucketsByHash[hash] = bucket; + } + return oldValue; + }; + + this.get = function (key) { + checkKey(key); + + var hash = hashingFunction(key); + + // Check if a bucket exists for the bucket key + var bucket = getBucketForHash(bucketsByHash, hash); + if (bucket) { + // Check this bucket to see if it contains this key + var bucketEntry = bucket.getEntryForKey(key); + if (bucketEntry) { + // This bucket entry is the current mapping of key to value, so return the value. + return bucketEntry[1]; + } + } + return null; + }; + + this.containsKey = function (key) { + checkKey(key); + var bucketKey = hashingFunction(key); + + // Check if a bucket exists for the bucket key + var bucket = getBucketForHash(bucketsByHash, bucketKey); + + return bucket ? bucket.containsKey(key) : false; + }; + + this.containsValue = function (value) { + checkValue(value); + var i = buckets.length; + while (i--) { + if (buckets[i].containsValue(value)) { + return true; + } + } + return false; + }; + + this.clear = function () { + buckets.length = 0; + bucketsByHash = {}; + }; + + this.isEmpty = function () { + return !buckets.length; + }; + + var createBucketAggregator = function (bucketFuncName) { + return function () { + var aggregated = [], i = buckets.length; + while (i--) { + buckets[i][bucketFuncName](aggregated); + } + return aggregated; + }; + }; + + this.keys = createBucketAggregator("keys"); + this.values = createBucketAggregator("values"); + this.entries = createBucketAggregator("getEntries"); + + this.remove = function (key) { + checkKey(key); + + var hash = hashingFunction(key), bucketIndex, oldValue = null; + + // Check if a bucket exists for the bucket key + var bucket = getBucketForHash(bucketsByHash, hash); + + if (bucket) { + // Remove entry from this bucket for this key + oldValue = bucket.removeEntryForKey(key); + if (oldValue !== null) { + // Entry was removed, so check if bucket is empty + if (!bucket.entries.length) { + // Bucket is empty, so remove it from the bucket collections + bucketIndex = searchBuckets(buckets, hash); + arrayRemoveAt(buckets, bucketIndex); + delete bucketsByHash[hash]; + } + } + } + return oldValue; + }; + + this.size = function () { + var total = 0, i = buckets.length; + while (i--) { + total += buckets[i].entries.length; + } + return total; + }; + + this.each = function (callback) { + var entries = that.entries(), i = entries.length, entry; + while (i--) { + entry = entries[i]; + callback(entry[0], entry[1]); + } + }; + + + this.putAll = function (hashtable, conflictCallback) { + var entries = hashtable.entries(); + var entry, key, value, thisValue, i = entries.length; + var hasConflictCallback = (typeof conflictCallback == FUNCTION); + while (i--) { + entry = entries[i]; + key = entry[0]; + value = entry[1]; + + // Check for a conflict. The default behaviour is to overwrite the value for an existing key + if (hasConflictCallback && (thisValue = that.get(key))) { + value = conflictCallback(key, thisValue, value); + } + that.put(key, value); + } + }; + + this.clone = function () { + var clone = new Hashtable(hashingFunctionParam, equalityFunctionParam); + clone.putAll(that); + return clone; + }; + + this.keySet = function () { + var res = new Kotlin.HashSet(); + var keys = this.keys(); + var i = keys.length; + while (i--) { + res.add(keys[i]); + } + return res; + } + }; + + Kotlin.HashTable = Hashtable; + })(); + + Kotlin.HashMap = Kotlin.Class.create( + { + initialize:function () { + Kotlin.HashTable.call(this); + } + } + ); + + + + + (function () { + function HashSet(hashingFunction, equalityFunction) { + var hashTable = new Kotlin.HashTable(hashingFunction, equalityFunction); + + this.add = function (o) { + hashTable.put(o, true); + }; + + this.addAll = function (arr) { + var i = arr.length; + while (i--) { + hashTable.put(arr[i], true); + } + }; + + this.values = function () { + return hashTable.keys(); + }; + + this.iterator = function () { + var list = new Kotlin.ArrayList(); + var values = this.values(); + var i = values.length; + while (i--) { + list.add(values[i]); + } + return list.iterator(); + }; + + this.remove = function (o) { + return hashTable.remove(o) ? o : null; + }; + + this.contains = function (o) { + return hashTable.containsKey(o); + }; + + this.clear = function () { + hashTable.clear(); + }; + + this.size = function () { + return hashTable.size(); + }; + + this.isEmpty = function () { + return hashTable.isEmpty(); + }; + + this.clone = function () { + var h = new HashSet(hashingFunction, equalityFunction); + h.addAll(hashTable.keys()); + return h; + }; + + this.intersection = function (hashSet) { + var intersection = new HashSet(hashingFunction, equalityFunction); + var values = hashSet.values(), i = values.length, val; + while (i--) { + val = values[i]; + if (hashTable.containsKey(val)) { + intersection.add(val); + } + } + return intersection; + }; + + this.union = function (hashSet) { + var union = this.clone(); + var values = hashSet.values(), i = values.length, val; + while (i--) { + val = values[i]; + if (!hashTable.containsKey(val)) { + union.add(val); + } + } + return union; + }; + + this.isSubsetOf = function (hashSet) { + var values = hashTable.keys(), i = values.length; + while (i--) { + if (!hashSet.contains(values[i])) { + return false; + } + } + return true; + }; + } + + Kotlin.HashSet = Kotlin.Class.create( + { + initialize:function () { + HashSet.call(this); + } + } + ) + }()); + +})(); diff --git a/translator/testFiles/libImplementations/jQuery.js b/translator/testFiles/libImplementations/jQuery.js new file mode 100644 index 00000000000..3c9ea9e5649 --- /dev/null +++ b/translator/testFiles/libImplementations/jQuery.js @@ -0,0 +1,9300 @@ +/*! + * jQuery JavaScript Library v1.7 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Thu Nov 3 16:18:21 2011 -0400 + */ +(function( window, undefined ) { + +// Use the correct document accordingly with window argument (sandbox) +var document = window.document, + navigator = window.navigator, + location = window.location; +var jQuery = (function() { + +// Define a local copy of jQuery +var jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // A central reference to the root jQuery(document) + rootjQuery, + + // A simple way to check for HTML strings or ID strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + + // Check if a string has a non-whitespace character in it + rnotwhite = /\S/, + + // Used for trimming whitespace + trimLeft = /^\s+/, + trimRight = /\s+$/, + + // Check for digits + rdigit = /\d/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + + // Useragent RegExp + rwebkit = /(webkit)[ \/]([\w.]+)/, + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, + rmsie = /(msie) ([\w.]+)/, + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + + // Matches dashed string for camelizing + rdashAlpha = /-([a-z]|[0-9])/ig, + rmsPrefix = /^-ms-/, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + + // Keep a UserAgent string for use with jQuery.browser + userAgent = navigator.userAgent, + + // For matching the engine and version of the browser + browserMatch, + + // The deferred used on DOM ready + readyList, + + // The ready event handler + DOMContentLoaded, + + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + push = Array.prototype.push, + slice = Array.prototype.slice, + trim = String.prototype.trim, + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; + +jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), or $(undefined) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context && document.body ) { + this.context = document; + this[0] = document.body; + this.selector = selector; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = quickExpr.exec( selector ); + } + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = ( context ? context.ownerDocument || context : document ); + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + ret = rsingleTag.exec( selector ); + + if ( ret ) { + if ( jQuery.isPlainObject( context ) ) { + selector = [ document.createElement( ret[1] ) ]; + jQuery.fn.attr.call( selector, context, true ); + + } else { + selector = [ doc.createElement( ret[1] ) ]; + } + + } else { + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); + selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; + } + + return jQuery.merge( this, selector ); + + // HANDLE: $("#id") + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.7", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return slice.call( this, 0 ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = this.constructor(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Attach the listeners + jQuery.bindReady(); + + // Add the callback + readyList.add( fn ); + + return this; + }, + + eq: function( i ) { + return i === -1 ? + this.slice( i ) : + this.slice( i, +i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ), + "slice", slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + // Either a released hold or an DOMready/load event and not yet ready + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.fireWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).unbind( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyList ) { + return; + } + + readyList = jQuery.Callbacks( "once memory" ); + + // Catch cases where $(document).ready() is called after the + // browser event has already occurred. + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 1 ); + } + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", DOMContentLoaded ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var toplevel = false; + + try { + toplevel = window.frameElement == null; + } catch(e) {} + + if ( document.documentElement.doScroll && toplevel ) { + doScrollCheck(); + } + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + // A crude way of determining if an object is a window + isWindow: function( obj ) { + return obj && typeof obj === "object" && "setInterval" in obj; + }, + + isNumeric: function( obj ) { + return obj != null && rdigit.test( obj ) && !isNaN( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + for ( var name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw msg; + }, + + parseJSON: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return ( new Function( "return " + data ) )(); + + } + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, + length = object.length, + isObj = length === undefined || jQuery.isFunction( object ); + + if ( args ) { + if ( isObj ) { + for ( name in object ) { + if ( callback.apply( object[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( object[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in object ) { + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + break; + } + } + } + } + + return object; + }, + + // Use native String.trim function wherever possible + trim: trim ? + function( text ) { + return text == null ? + "" : + trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + }, + + // results is for internal usage only + makeArray: function( array, results ) { + var ret = results || []; + + if ( array != null ) { + // The window, strings (and functions) also have 'length' + // The extra typeof function check is to prevent crashes + // in Safari 2 (See: #3039) + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + var type = jQuery.type( array ); + + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { + push.call( ret, array ); + } else { + jQuery.merge( ret, array ); + } + } + + return ret; + }, + + inArray: function( elem, array, i ) { + var len; + + if ( array ) { + if ( indexOf ) { + return indexOf.call( array, elem, i ); + } + + len = array.length; + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; + + for ( ; i < len; i++ ) { + // Skip accessing in sparse arrays + if ( i in array && array[ i ] === elem ) { + return i; + } + } + } + + return -1; + }, + + merge: function( first, second ) { + var i = first.length, + j = 0; + + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var ret = [], retVal; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, key, ret = [], + i = 0, + length = elems.length, + // jquery objects are treated as arrays + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( key in elems ) { + value = callback( elems[ key ], key, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + if ( typeof context === "string" ) { + var tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + var args = slice.call( arguments, 2 ), + proxy = function() { + return fn.apply( context, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + + return proxy; + }, + + // Mutifunctional method to get and set values to a collection + // The value/s can optionally be executed if it's a function + access: function( elems, key, value, exec, fn, pass ) { + var length = elems.length; + + // Setting many attributes + if ( typeof key === "object" ) { + for ( var k in key ) { + jQuery.access( elems, k, key[k], exec, fn, value ); + } + return elems; + } + + // Setting one attribute + if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = !pass && exec && jQuery.isFunction(value); + + for ( var i = 0; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + + return elems; + } + + // Getting an attribute + return length ? fn( elems[0], key ) : undefined; + }, + + now: function() { + return ( new Date() ).getTime(); + }, + + // Use of jQuery.browser is frowned upon. + // More details: http://docs.jquery.com/Utilities/jQuery.browser + uaMatch: function( ua ) { + ua = ua.toLowerCase(); + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }, + + sub: function() { + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); + }; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; + }, + + browser: {} +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +browserMatch = jQuery.uaMatch( userAgent ); +if ( browserMatch.browser ) { + jQuery.browser[ browserMatch.browser ] = true; + jQuery.browser.version = browserMatch.version; +} + +// Deprecated, use jQuery.browser.webkit instead +if ( jQuery.browser.webkit ) { + jQuery.browser.safari = true; +} + +// IE doesn't match non-breaking spaces with \s +if ( rnotwhite.test( "\xA0" ) ) { + trimLeft = /^[\s\xA0]+/; + trimRight = /[\s\xA0]+$/; +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); + +// Cleanup functions for the document ready method +if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + }; + +} else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }; +} + +// The DOM ready check for Internet Explorer +function doScrollCheck() { + if ( jQuery.isReady ) { + return; + } + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch(e) { + setTimeout( doScrollCheck, 1 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); +} + +// Expose jQuery as an AMD module, but only for AMD loaders that +// understand the issues with loading multiple versions of jQuery +// in a page that all might call define(). The loader will indicate +// they have special allowances for multiple jQuery versions by +// specifying define.amd.jQuery = true. Register as a named module, +// since jQuery can be concatenated with other files that may use define, +// but not use a proper concatenation script that understands anonymous +// AMD modules. A named AMD is safest and most robust way to register. +// Lowercase jquery is used because AMD module names are derived from +// file names, and jQuery is normally delivered in a lowercase file name. +if ( typeof define === "function" && define.amd && define.amd.jQuery ) { + define( "jquery", [], function () { return jQuery; } ); +} + +return jQuery; + +})(); + + +// String to Object flags format cache +var flagsCache = {}; + +// Convert String-formatted flags into Object-formatted ones and store in cache +function createFlags( flags ) { + var object = flagsCache[ flags ] = {}, + i, length; + flags = flags.split( /\s+/ ); + for ( i = 0, length = flags.length; i < length; i++ ) { + object[ flags[i] ] = true; + } + return object; +} + +/* + * Create a callback list using the following parameters: + * + * flags: an optional list of space-separated flags that will change how + * the callback list behaves + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible flags: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( flags ) { + + // Convert flags from String-formatted to Object-formatted + // (we check in cache first) + flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; + + var // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = [], + // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Add one or several callbacks to the list + add = function( args ) { + var i, + length, + elem, + type, + actual; + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + // Inspect recursively + add( elem ); + } else if ( type === "function" ) { + // Add if not in unique mode and callback is not in + if ( !flags.unique || !self.has( elem ) ) { + list.push( elem ); + } + } + } + }, + // Fire callbacks + fire = function( context, args ) { + args = args || []; + memory = !flags.memory || [ context, args ]; + firing = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { + memory = true; // Mark as halted + break; + } + } + firing = false; + if ( list ) { + if ( !flags.once ) { + if ( stack && stack.length ) { + memory = stack.shift(); + self.fireWith( memory[ 0 ], memory[ 1 ] ); + } + } else if ( memory === true ) { + self.disable(); + } else { + list = []; + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + var length = list.length; + add( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away, unless previous + // firing was halted (stopOnFalse) + } else if ( memory && memory !== true ) { + firingStart = length; + fire( memory[ 0 ], memory[ 1 ] ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + var args = arguments, + argIndex = 0, + argLength = args.length; + for ( ; argIndex < argLength ; argIndex++ ) { + for ( var i = 0; i < list.length; i++ ) { + if ( args[ argIndex ] === list[ i ] ) { + // Handle firingIndex and firingLength + if ( firing ) { + if ( i <= firingLength ) { + firingLength--; + if ( i <= firingIndex ) { + firingIndex--; + } + } + } + // Remove the element + list.splice( i--, 1 ); + // If we have some unicity property then + // we only need to do this once + if ( flags.unique ) { + break; + } + } + } + } + } + return this; + }, + // Control if a given callback is in the list + has: function( fn ) { + if ( list ) { + var i = 0, + length = list.length; + for ( ; i < length; i++ ) { + if ( fn === list[ i ] ) { + return true; + } + } + } + return false; + }, + // Remove all callbacks from the list + empty: function() { + list = []; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory || memory === true ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( stack ) { + if ( firing ) { + if ( !flags.once ) { + stack.push( [ context, args ] ); + } + } else if ( !( flags.once && memory ) ) { + fire( context, args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!memory; + } + }; + + return self; +}; + + + + +var // Static reference to slice + sliceDeferred = [].slice; + +jQuery.extend({ + + Deferred: function( func ) { + var doneList = jQuery.Callbacks( "once memory" ), + failList = jQuery.Callbacks( "once memory" ), + progressList = jQuery.Callbacks( "memory" ), + state = "pending", + lists = { + resolve: doneList, + reject: failList, + notify: progressList + }, + promise = { + done: doneList.add, + fail: failList.add, + progress: progressList.add, + + state: function() { + return state; + }, + + // Deprecated + isResolved: doneList.fired, + isRejected: failList.fired, + + then: function( doneCallbacks, failCallbacks, progressCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); + return this; + }, + always: function() { + return deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); + }, + pipe: function( fnDone, fnFail, fnProgress ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ], + progress: [ fnProgress, "notify" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + }); + } else { + deferred[ handler ]( newDefer[ action ] ); + } + }); + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + obj = promise; + } else { + for ( var key in promise ) { + obj[ key ] = promise[ key ]; + } + } + return obj; + } + }, + deferred = promise.promise({}), + key; + + for ( key in lists ) { + deferred[ key ] = lists[ key ].fire; + deferred[ key + "With" ] = lists[ key ].fireWith; + } + + // Handle state + deferred.done( function() { + state = "resolved"; + }, failList.disable, progressList.lock ).fail( function() { + state = "rejected"; + }, doneList.disable, progressList.lock ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = sliceDeferred.call( arguments, 0 ), + i = 0, + length = args.length, + pValues = new Array( length ), + count = length, + pCount = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(), + promise = deferred.promise(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + deferred.resolveWith( deferred, args ); + } + }; + } + function progressFunc( i ) { + return function( value ) { + pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + deferred.notifyWith( promise, pValues ); + }; + } + if ( length > 1 ) { + for ( ; i < length; i++ ) { + if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return promise; + } +}); + + + + +jQuery.support = (function() { + + var div = document.createElement( "div" ), + documentElement = document.documentElement, + all, + a, + select, + opt, + input, + marginDiv, + support, + fragment, + body, + testElementParent, + testElement, + testElementStyle, + tds, + events, + eventName, + i, + isSupported; + + // Preliminary tests + div.setAttribute("className", "t"); + div.innerHTML = "
a

"; + + + all = div.getElementsByTagName( "*" ); + a = div.getElementsByTagName( "a" )[ 0 ]; + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return {}; + } + + // First batch of supports tests + select = document.createElement( "select" ); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName( "input" )[ 0 ]; + + support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: ( div.firstChild.nodeType === 3 ), + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName( "tbody" ).length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName( "link" ).length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: ( a.getAttribute( "href" ) === "/a" ), + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.55/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure unknown elements (like HTML5 elems) are handled appropriately + unknownElems: !!div.getElementsByTagName( "nav" ).length, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: ( input.value === "on" ), + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // Tests for enctype support on a form(#6743) + enctype: !!document.createElement("form").enctype, + + // Will be defined later + submitBubbles: true, + changeBubbles: true, + focusinBubbles: false, + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true + }; + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { + div.attachEvent( "onclick", function() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + }); + div.cloneNode( true ).fireEvent( "onclick" ); + } + + // Check if a radio maintains its value + // after being appended to the DOM + input = document.createElement("input"); + input.value = "t"; + input.setAttribute("type", "radio"); + support.radioValue = input.value === "t"; + + input.setAttribute("checked", "checked"); + div.appendChild( input ); + fragment = document.createDocumentFragment(); + fragment.appendChild( div.lastChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + div.innerHTML = ""; + + // Figure out if the W3C box model works as expected + div.style.width = div.style.paddingLeft = "1px"; + + // We don't want to do body-related feature tests on frameset + // documents, which lack a body. So we use + // document.getElementsByTagName("body")[0], which is undefined in + // frameset documents, while document.body isn’t. (7398) + body = document.getElementsByTagName("body")[ 0 ]; + // We use our own, invisible, body unless the body is already present + // in which case we use a div (#9239) + testElement = document.createElement( body ? "div" : "body" ); + testElementStyle = { + visibility: "hidden", + width: 0, + height: 0, + border: 0, + margin: 0, + background: "none" + }; + if ( body ) { + jQuery.extend( testElementStyle, { + position: "absolute", + left: "-999px", + top: "-999px" + }); + } + for ( i in testElementStyle ) { + testElement.style[ i ] = testElementStyle[ i ]; + } + testElement.appendChild( div ); + testElementParent = body || documentElement; + testElementParent.insertBefore( testElement, testElementParent.firstChild ); + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + support.boxModel = div.offsetWidth === 2; + + if ( "zoom" in div.style ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.style.display = "inline"; + div.style.zoom = 1; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = ""; + div.innerHTML = "
"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); + } + + div.innerHTML = "
t
"; + tds = div.getElementsByTagName( "td" ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE < 8 fail this test) + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + div.innerHTML = ""; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + if ( document.defaultView && document.defaultView.getComputedStyle ) { + marginDiv = document.createElement( "div" ); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; + } + + // Technique from Juriy Zaytsev + // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( div.attachEvent ) { + for( i in { + submit: 1, + change: 1, + focusin: 1 + } ) { + eventName = "on" + i; + isSupported = ( eventName in div ); + if ( !isSupported ) { + div.setAttribute( eventName, "return;" ); + isSupported = ( typeof div[ eventName ] === "function" ); + } + support[ i + "Bubbles" ] = isSupported; + } + } + + // Run fixed position tests at doc ready to avoid a crash + // related to the invisible body in IE8 + jQuery(function() { + var container, outer, inner, table, td, offsetSupport, + conMarginTop = 1, + ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;", + vb = "visibility:hidden;border:0;", + style = "style='" + ptlm + "border:5px solid #000;padding:0;'", + html = "
" + + "" + + "
"; + + // Reconstruct a container + body = document.getElementsByTagName("body")[0]; + if ( !body ) { + // Return for frameset docs that don't have a body + // These tests cannot be done + return; + } + + container = document.createElement("div"); + container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; + body.insertBefore( container, body.firstChild ); + + // Construct a test element + testElement = document.createElement("div"); + testElement.style.cssText = ptlm + vb; + + testElement.innerHTML = html; + container.appendChild( testElement ); + outer = testElement.firstChild; + inner = outer.firstChild; + td = outer.nextSibling.firstChild.firstChild; + + offsetSupport = { + doesNotAddBorder: ( inner.offsetTop !== 5 ), + doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) + }; + + inner.style.position = "fixed"; + inner.style.top = "20px"; + + // safari subtracts parent border width here which is 5px + offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); + inner.style.position = inner.style.top = ""; + + outer.style.overflow = "hidden"; + outer.style.position = "relative"; + + offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); + offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); + + body.removeChild( container ); + testElement = container = null; + + jQuery.extend( support, offsetSupport ); + }); + + testElement.innerHTML = ""; + testElementParent.removeChild( testElement ); + + // Null connected elements to avoid leaks in IE + testElement = fragment = select = opt = body = marginDiv = div = input = null; + + return support; +})(); + +// Keep track of boxModel +jQuery.boxModel = jQuery.support.boxModel; + + + + +var rbrace = /^(?:\{.*\}|\[.*\])$/, + rmultiDash = /([A-Z])/g; + +jQuery.extend({ + cache: {}, + + // Please use with caution + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var privateCache, thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando, + isEvents = name === "events"; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ jQuery.expando ] = id = ++jQuery.uuid; + } else { + id = jQuery.expando; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ] = jQuery.extend( cache[ id ], name ); + } else { + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + } + } + + privateCache = thisCache = cache[ id ]; + + // jQuery data() is stored in a separate object inside the object's internal data + // cache in order to avoid key collisions between internal data and user-defined + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; + } + + thisCache = thisCache.data; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // Users should not attempt to inspect the internal events object using jQuery.data, + // it is undocumented and subject to change. But does anyone listen? No. + if ( isEvents && !thisCache[ name ] ) { + return privateCache.events; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, i, l, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + + // See jQuery.data for more information + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ] : cache[ id ].data; + + if ( thisCache ) { + + // Support space separated names + if ( jQuery.isArray( name ) ) { + name = name; + } else if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split( " " ); + } + } + + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject(cache[ id ]) ) { + return; + } + } + + // Browsers that fail expando deletion also refuse to delete expandos on + // the window, but it will allow it on all other JS objects; other browsers + // don't care + // Ensure that `cache` is not a window object #10080 + if ( jQuery.support.deleteExpando || !cache.setInterval ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the cache and need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + if ( isNode ) { + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( jQuery.support.deleteExpando ) { + delete elem[ jQuery.expando ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( jQuery.expando ); + } else { + elem[ jQuery.expando ] = null; + } + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + if ( elem.nodeName ) { + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; + + if ( match ) { + return !(match === true || elem.getAttribute("classid") !== match); + } + } + + return true; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var parts, attr, name, + data = null; + + if ( typeof key === "undefined" ) { + if ( this.length ) { + data = jQuery.data( this[0] ); + + if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) { + attr = this[0].attributes; + for ( var i = 0, l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.substring(5) ); + + dataAttr( this[0], name, data[ name ] ); + } + } + jQuery._data( this[0], "parsedAttrs", true ); + } + } + + return data; + + } else if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + + if ( value === undefined ) { + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + // Try to fetch any internally stored data first + if ( data === undefined && this.length ) { + data = jQuery.data( this[0], key ); + data = dataAttr( this[0], key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + + } else { + return this.each(function() { + var $this = jQuery( this ), + args = [ parts[0], value ]; + + $this.triggerHandler( "setData" + parts[1] + "!", args ); + jQuery.data( this, key, value ); + $this.triggerHandler( "changeData" + parts[1] + "!", args ); + }); + } + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + jQuery.isNumeric( data ) ? parseFloat( data ) : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + +// checks a cache object for emptiness +function isEmptyDataObject( obj ) { + for ( var name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} + + + + +function handleQueueMarkDefer( elem, type, src ) { + var deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + defer = jQuery._data( elem, deferDataKey ); + if ( defer && + ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && + ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { + // Give room for hard-coded callbacks to fire first + // and eventually mark/queue something else on the element + setTimeout( function() { + if ( !jQuery._data( elem, queueDataKey ) && + !jQuery._data( elem, markDataKey ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.fire(); + } + }, 0 ); + } +} + +jQuery.extend({ + + _mark: function( elem, type ) { + if ( elem ) { + type = ( type || "fx" ) + "mark"; + jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); + } + }, + + _unmark: function( force, elem, type ) { + if ( force !== true ) { + type = elem; + elem = force; + force = false; + } + if ( elem ) { + type = type || "fx"; + var key = type + "mark", + count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); + if ( count ) { + jQuery._data( elem, key, count ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } + } + }, + + queue: function( elem, type, data ) { + var q; + if ( elem ) { + type = ( type || "fx" ) + "queue"; + q = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !q || jQuery.isArray(data) ) { + q = jQuery._data( elem, type, jQuery.makeArray(data) ); + } else { + q.push( data ); + } + } + return q || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(), + hooks = {}; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + } + + if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + jQuery._data( elem, type + ".run", hooks ); + fn.call( elem, function() { + jQuery.dequeue( elem, type ); + }, hooks ); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue " + type + ".run", true ); + handleQueueMarkDefer( elem, type, "queue" ); + } + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + } + + if ( data === undefined ) { + return jQuery.queue( this[0], type ); + } + return this.each(function() { + var queue = jQuery.queue( this, type, data ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, object ) { + if ( typeof type !== "string" ) { + object = type; + type = undefined; + } + type = type || "fx"; + var defer = jQuery.Deferred(), + elements = this, + i = elements.length, + count = 1, + deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + tmp; + function resolve() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + } + while( i-- ) { + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && + jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { + count++; + tmp.add( resolve ); + } + } + resolve(); + return defer.promise(); + } +}); + + + + +var rclass = /[\n\t\r]/g, + rspace = /\s+/, + rreturn = /\r/g, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea)?$/i, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + getSetAttribute = jQuery.support.getSetAttribute, + nodeHook, boolHook, fixSpecified; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.attr ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.prop ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); + }); + } + + if ( value && typeof value === "string" ) { + classNames = value.split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className && classNames.length === 1 ) { + elem.className = value; + + } else { + setClass = " " + elem.className + " "; + + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { + setClass += classNames[ c ] + " "; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classNames, i, l, elem, className, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + classNames = ( value || "" ).split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + className = (" " + elem.className + " ").replace( rclass, " " ); + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[ c ] + " ", " "); + } + elem.className = jQuery.trim( className ); + + } else { + elem.className = ""; + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( rspace ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space seperated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, isFunction, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return undefined; + } + + isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var self = jQuery(this), val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, i, max, option, + index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + i = one ? index : 0; + max = one ? index + 1 : options.length; + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attrFn: { + val: true, + css: true, + html: true, + text: true, + data: true, + width: true, + height: true, + offset: true + }, + + attr: function( elem, name, value, pass ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return undefined; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery( elem )[ name ]( value ); + } + + // Fallback to prop when attributes are not supported + if ( !("getAttribute" in elem) ) { + return jQuery.prop( elem, name, value ); + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( notxml ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return undefined; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, "" + value ); + return value; + } + + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, value ) { + var propName, attrNames, name, l, + i = 0; + + if ( elem.nodeType === 1 ) { + attrNames = ( value || "" ).split( rspace ); + l = attrNames.length; + + for ( ; i < l; i++ ) { + name = attrNames[ i ].toLowerCase(); + propName = jQuery.propFix[ name ] || name; + + // See #9699 for explanation of this approach (setting first, then removal) + jQuery.attr( elem, name, "" ); + elem.removeAttribute( getSetAttribute ? name : propName ); + + // Set corresponding property to false for boolean attributes + if ( rboolean.test( name ) && propName in elem ) { + elem[ propName ] = false; + } + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + // This is for element creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return undefined; + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return ( elem[ name ] = value ); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } +}); + +// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) +jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; + +// Hook for boolean attributes +boolHook = { + get: function( elem, name ) { + // Align boolean attributes with corresponding properties + // Fall back to attribute presence where some booleans are not supported + var attrNode, + property = jQuery.prop( elem, name ); + return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + var propName; + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + // value is true since we know at this point it's type boolean and not false + // Set boolean attributes to the same name and set the DOM property + propName = jQuery.propFix[ name ] || name; + if ( propName in elem ) { + // Only set the IDL specifically if it already exists on the element + elem[ propName ] = true; + } + + elem.setAttribute( name, name.toLowerCase() ); + } + return name; + } +}; + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !getSetAttribute ) { + + fixSpecified = { + name: true, + id: true + }; + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + ret = elem.getAttributeNode( name ); + return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? + ret.nodeValue : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); + } + return ( ret.nodeValue = value + "" ); + } + }; + + // Apply the nodeHook to tabindex + jQuery.attrHooks.tabindex.set = nodeHook.set; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); + + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + if ( value === "" ) { + value = "false"; + } + nodeHook.set( elem, value, name ); + } + }; +} + + +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret === null ? undefined : ret; + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; + }, + set: function( elem, value ) { + return ( elem.style.cssText = "" + value ); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); +} + +// IE6/7 call enctype encoding +if ( !jQuery.support.enctype ) { + jQuery.propFix.enctype = "encoding"; +} + +// Radios and checkboxes getter/setter +if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); +} +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + } + } + }); +}); + + + + +var rnamespaces = /\.(.*)$/, + rformElems = /^(?:textarea|input|select)$/i, + rperiod = /\./g, + rspaces = / /g, + rescape = /[^\w\s.|`]/g, + rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, + rhoverHack = /\bhover(\.\S+)?/, + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, + quickParse = function( selector ) { + var quick = rquickIs.exec( selector ); + if ( quick ) { + // 0 1 2 3 + // [ _, tag, id, class ] + quick[1] = ( quick[1] || "" ).toLowerCase(); + quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); + } + return quick; + }, + quickIs = function( elem, m ) { + return ( + (!m[1] || elem.nodeName.toLowerCase() === m[1]) && + (!m[2] || elem.id === m[2]) && + (!m[3] || m[3].test( elem.className )) + ); + }, + hoverHack = function( events ) { + return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); + }; + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + add: function( elem, types, handler, data, selector ) { + + var elemData, eventHandle, events, + t, tns, type, namespaces, handleObj, + handleObjIn, quick, handlers, special; + + // Don't attach events to noData or text/comment nodes (allow plain objects tho) + if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + events = elemData.events; + if ( !events ) { + elemData.events = events = {}; + } + eventHandle = elemData.handle; + if ( !eventHandle ) { + elemData.handle = eventHandle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = hoverHack(types).split( " " ); + for ( t = 0; t < types.length; t++ ) { + + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = ( tns[2] || "" ).split( "." ).sort(); + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: tns[1], + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + namespace: namespaces.join(".") + }, handleObjIn ); + + // Delegated event; pre-analyze selector so it's processed quickly on event dispatch + if ( selector ) { + handleObj.quick = quickParse( selector ); + if ( !handleObj.quick && jQuery.expr.match.POS.test( selector ) ) { + handleObj.isPositional = true; + } + } + + // Init the event handler queue if we're the first + handlers = events[ type ]; + if ( !handlers ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener/attachEvent if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector ) { + + var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + t, tns, type, namespaces, origCount, + j, events, special, handle, eventType, handleObj; + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = hoverHack( types || "" ).split(" "); + for ( t = 0; t < types.length; t++ ) { + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = tns[2]; + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + namespaces = namespaces? "." + namespaces : ""; + for ( j in events ) { + jQuery.event.remove( elem, j + namespaces, handler, selector ); + } + return; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector? special.delegateType : special.bindType ) || type; + eventType = events[ type ] || []; + origCount = eventType.length; + namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + + // Only need to loop for special events or selective removal + if ( handler || namespaces || selector || special.remove ) { + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( !handler || handler.guid === handleObj.guid ) { + if ( !namespaces || namespaces.test( handleObj.namespace ) ) { + if ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) { + eventType.splice( j--, 1 ); + + if ( handleObj.selector ) { + eventType.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + } + } + } else { + // Removing all events + eventType.length = 0; + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( eventType.length === 0 && origCount !== eventType.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery.removeData( elem, [ "events", "handle" ], true ); + } + }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, + + trigger: function( event, data, elem, onlyHandlers ) { + // Don't do events on text and comment nodes + if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { + return; + } + + // Event object or event type + var type = event.type || event, + namespaces = [], + cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; + + if ( type.indexOf( "!" ) >= 0 ) { + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; + } + + if ( type.indexOf( "." ) >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + new jQuery.Event( type, event ) : + // Just the event type (string) + new jQuery.Event( type ); + + event.type = type; + event.isTrigger = true; + event.exclusive = exclusive; + event.namespace = namespaces.join( "." ); + event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; + + // triggerHandler() and global events don't bubble or run the default action + if ( onlyHandlers || !elem ) { + event.preventDefault(); + } + + // Handle a global trigger + if ( !elem ) { + + // TODO: Stop taunting the data cache; remove global events and always attach to document + cache = jQuery.cache; + for ( i in cache ) { + if ( cache[ i ].events && cache[ i ].events[ type ] ) { + jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); + } + } + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data != null ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + eventPath = [[ elem, special.bindType || type ]]; + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + old = null; + for ( cur = elem.parentNode; cur; cur = cur.parentNode ) { + eventPath.push([ cur, bubbleType ]); + old = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( old && old === elem.ownerDocument ) { + eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); + } + } + + // Fire handlers on the event path + for ( i = 0; i < eventPath.length; i++ ) { + + cur = eventPath[i][0]; + event.type = eventPath[i][1]; + + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) ) { + handle.apply( cur, data ); + } + + if ( event.isPropagationStopped() ) { + break; + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction() check here because IE6/7 fails that test. + // Don't do default actions on window, that's where global variables be (#6170) + // IE<9 dies on focus/blur to hidden element (#1486) + if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( old ) { + elem[ ontype ] = old; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event || window.event ); + + var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), + delegateCount = handlers.delegateCount, + args = [].slice.call( arguments, 0 ), + run_all = !event.exclusive && !event.namespace, + specialHandle = ( jQuery.event.special[ event.type ] || {} ).handle, + handlerQueue = [], + i, j, cur, ret, selMatch, matched, matches, handleObj, sel, hit, related; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Determine handlers that should run if there are delegated events + // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) + if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { + + for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { + selMatch = {}; + matches = []; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + sel = handleObj.selector; + hit = selMatch[ sel ]; + + if ( handleObj.isPositional ) { + // Since .is() does not work for positionals; see http://jsfiddle.net/eJ4yd/3/ + hit = ( hit || (selMatch[ sel ] = jQuery( sel )) ).index( cur ) >= 0; + } else if ( hit === undefined ) { + hit = selMatch[ sel ] = ( handleObj.quick ? quickIs( cur, handleObj.quick ) : jQuery( cur ).is( sel ) ); + } + if ( hit ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, matches: matches }); + } + } + } + + // Add the remaining (directly-bound) handlers + if ( handlers.length > delegateCount ) { + handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); + } + + // Run delegates first; they may want to stop propagation beneath us + for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { + matched = handlerQueue[ i ]; + event.currentTarget = matched.elem; + + for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { + handleObj = matched.matches[ j ]; + + // Triggered event must either 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { + + event.data = handleObj.data; + event.handleObj = handleObj; + + ret = ( specialHandle || handleObj.handler ).apply( matched.elem, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + return event.result; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement wheelDelta".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, + originalEvent = event, + fixHook = jQuery.event.fixHooks[ event.type ] || {}, + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = jQuery.Event( originalEvent ); + + for ( i = copy.length; i; ) { + prop = copy[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) + if ( !event.target ) { + event.target = originalEvent.srcElement || document; + } + + // Target should not be a text node (#504, Safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) + if ( event.metaKey === undefined ) { + event.metaKey = event.ctrlKey; + } + + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady + }, + + focus: { + delegateType: "focusin", + noBubble: true + }, + blur: { + delegateType: "focusout", + noBubble: true + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +// Some plugins are using, but it's undocumented/deprecated and will be removed. +// The 1.7 special event interface should provide all the hooks needed now. +jQuery.event.handle = jQuery.event.dispatch; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + if ( elem.detachEvent ) { + elem.detachEvent( "on" + type, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = jQuery.event.special[ fix ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var target = this, + related = event.relatedTarget, + handleObj = event.handleObj, + selector = handleObj.selector, + oldType, ret; + + // For a real mouseover/out, always call the handler; for + // mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || handleObj.origType === event.type || (related !== target && !jQuery.contains( target, related )) ) { + oldType = event.type; + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = oldType; + } + return ret; + } + }; +}); + +// IE submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !form._submit_attached ) { + jQuery.event.add( form, "submit._submit", function( event ) { + // Form was submitted, bubble the event up the tree + if ( this.parentNode ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + }); + form._submit_attached = true; + } + }); + // return undefined since we don't need an event listener + }, + + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); + } + }; +} + +// IE change delegation and checkbox/radio fix +if ( !jQuery.support.changeBubbles ) { + + jQuery.event.special.change = { + + setup: function() { + + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed ) { + this._just_changed = false; + jQuery.event.simulate( "change", this, event, true ); + } + }); + } + return false; + } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; + + if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + elem._change_attached = true; + } + }); + }, + + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); + + return rformElems.test( this.nodeName ); + } + }; +} + +// Create "bubbling" focus and blur events +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on.call( this, types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + var handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( var type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + bind: function( types, data, fn ) { + return this.on( types, null, data, fn ); + }, + unbind: function( types, fn ) { + return this.off( types, null, fn ); + }, + + live: function( types, data, fn ) { + jQuery( this.context ).on( types, this.selector, data, fn ); + return this; + }, + die: function( types, fn ) { + jQuery( this.context ).off( types, this.selector || "**", fn ); + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.on( types, selector, data, fn ); + }, + undelegate: function( selector, types, fn ) { + // ( namespace ) or ( selector, types [, fn] ) + return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + if ( this[0] ) { + return jQuery.event.trigger( type, data, this[0], true ); + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; + + // link all the functions, so any of them can unbind this click handler + toggler.guid = guid; + while ( i < args.length ) { + args[ i++ ].guid = guid; + } + + return this.click( toggler ); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +}); + +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.bind( name, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } + + if ( rkeyEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; + } + + if ( rmouseEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; + } +}); + + + +/*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){ + +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + expando = "sizcache" + (Math.random() + '').replace('.', ''), + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true, + rBackslash = /\\/g, + rReturn = /\r\n/g, + rNonWord = /\W/; + +// Here we check if the JavaScript engine is using some sort of +// optimization where it does not always call our comparision +// function. If that is the case, discard the hasDuplicate value. +// Thus far that includes Google Chrome. +[0, 0].sort(function() { + baseHasDuplicate = false; + return 0; +}); + +var Sizzle = function( selector, context, results, seed ) { + results = results || []; + context = context || document; + + var origContext = context; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { + return []; + } + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var m, set, checkSet, extra, ret, cur, pop, i, + prune = true, + contextXML = Sizzle.isXML( context ), + parts = [], + soFar = selector; + + // Reset the position of the chunker regexp (start from head) + do { + chunker.exec( "" ); + m = chunker.exec( soFar ); + + if ( m ) { + soFar = m[3]; + + parts.push( m[1] ); + + if ( m[2] ) { + extra = m[3]; + break; + } + } + } while ( m ); + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context, seed ); + + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) { + selector += parts.shift(); + } + + set = posProcess( selector, set, seed ); + } + } + + } else { + // Take a shortcut and set the context if the root selector is an ID + // (but not if it'll be faster if the inner selector is an ID) + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + + ret = Sizzle.find( parts.shift(), context, contextXML ); + context = ret.expr ? + Sizzle.filter( ret.expr, ret.set )[0] : + ret.set[0]; + } + + if ( context ) { + ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + + set = ret.expr ? + Sizzle.filter( ret.expr, ret.set ) : + ret.set; + + if ( parts.length > 0 ) { + checkSet = makeArray( set ); + + } else { + prune = false; + } + + while ( parts.length ) { + cur = parts.pop(); + pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, contextXML ); + } + + } else { + checkSet = parts = []; + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + Sizzle.error( cur || selector ); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + + } else if ( context && context.nodeType === 1 ) { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + + } else { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } + + return results; +}; + +Sizzle.uniqueSort = function( results ) { + if ( sortOrder ) { + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + } + + return results; +}; + +Sizzle.matches = function( expr, set ) { + return Sizzle( expr, null, null, set ); +}; + +Sizzle.matchesSelector = function( node, expr ) { + return Sizzle( expr, null, null, [node] ).length > 0; +}; + +Sizzle.find = function( expr, context, isXML ) { + var set, i, len, match, type, left; + + if ( !expr ) { + return []; + } + + for ( i = 0, len = Expr.order.length; i < len; i++ ) { + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + left = match[1]; + match.splice( 1, 1 ); + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace( rBackslash, "" ); + set = Expr.find[ type ]( match, context, isXML ); + + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( "*" ) : + []; + } + + return { set: set, expr: expr }; +}; + +Sizzle.filter = function( expr, set, inplace, not ) { + var match, anyFound, + type, found, item, filter, left, + i, pass, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + filter = Expr.filter[ type ]; + left = match[1]; + + anyFound = false; + + match.splice(1,1); + + if ( left.substr( left.length - 1 ) === "\\" ) { + continue; + } + + if ( curLoop === result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + + if ( !match ) { + anyFound = found = true; + + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + pass = not ^ found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + + } else { + curLoop[i] = false; + } + + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + // Improper expression + if ( expr === old ) { + if ( anyFound == null ) { + Sizzle.error( expr ); + + } else { + break; + } + } + + old = expr; + } + + return curLoop; +}; + +Sizzle.error = function( msg ) { + throw "Syntax error, unrecognized expression: " + msg; +}; + +/** + * Utility function for retreiving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +var getText = Sizzle.getText = function( elem ) { + var i, node, + nodeType = elem.nodeType, + ret = ""; + + if ( nodeType ) { + if ( nodeType === 1 ) { + // Use textContent || innerText for elements + if ( typeof elem.textContent === 'string' ) { + return elem.textContent; + } else if ( typeof elem.innerText === 'string' ) { + // Replace IE's carriage returns + return elem.innerText.replace( rReturn, '' ); + } else { + // Traverse it's children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + } else { + + // If no nodeType, this is expected to be an array + for ( i = 0; (node = elem[i]); i++ ) { + // Do not traverse comment nodes + if ( node.nodeType !== 8 ) { + ret += getText( node ); + } + } + } + return ret; +}; + +var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + + match: { + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + }, + + leftMatch: {}, + + attrMap: { + "class": "className", + "for": "htmlFor" + }, + + attrHandle: { + href: function( elem ) { + return elem.getAttribute( "href" ); + }, + type: function( elem ) { + return elem.getAttribute( "type" ); + } + }, + + relative: { + "+": function(checkSet, part){ + var isPartStr = typeof part === "string", + isTag = isPartStr && !rNonWord.test( part ), + isPartStrNotTag = isPartStr && !isTag; + + if ( isTag ) { + part = part.toLowerCase(); + } + + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { + if ( (elem = checkSet[i]) ) { + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? + elem || false : + elem === part; + } + } + + if ( isPartStrNotTag ) { + Sizzle.filter( part, checkSet, true ); + } + }, + + ">": function( checkSet, part ) { + var elem, + isPartStr = typeof part === "string", + i = 0, + l = checkSet.length; + + if ( isPartStr && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; + } + } + + } else { + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + checkSet[i] = isPartStr ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( isPartStr ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + + "": function(checkSet, part, isXML){ + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + }, + + "~": function( checkSet, part, isXML ) { + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); + } + }, + + find: { + ID: function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }, + + NAME: function( match, context ) { + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = [], + results = context.getElementsByName( match[1] ); + + for ( var i = 0, l = results.length; i < l; i++ ) { + if ( results[i].getAttribute("name") === match[1] ) { + ret.push( results[i] ); + } + } + + return ret.length === 0 ? null : ret; + } + }, + + TAG: function( match, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( match[1] ); + } + } + }, + preFilter: { + CLASS: function( match, curLoop, inplace, result, not, isXML ) { + match = " " + match[1].replace( rBackslash, "" ) + " "; + + if ( isXML ) { + return match; + } + + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { + if ( !inplace ) { + result.push( elem ); + } + + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + + ID: function( match ) { + return match[1].replace( rBackslash, "" ); + }, + + TAG: function( match, curLoop ) { + return match[1].replace( rBackslash, "" ).toLowerCase(); + }, + + CHILD: function( match ) { + if ( match[1] === "nth" ) { + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + match[2] = match[2].replace(/^\+|\s*/g, ''); + + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + // TODO: Move to normal caching system + match[0] = done++; + + return match; + }, + + ATTR: function( match, curLoop, inplace, result, not, isXML ) { + var name = match[1] = match[1].replace( rBackslash, "" ); + + if ( !isXML && Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + // Handle if an un-quoted value was used + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + + PSEUDO: function( match, curLoop, inplace, result, not ) { + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { + match[3] = Sizzle(match[3], null, null, curLoop); + + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + + if ( !inplace ) { + result.push.apply( result, ret ); + } + + return false; + } + + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { + return true; + } + + return match; + }, + + POS: function( match ) { + match.unshift( true ); + + return match; + } + }, + + filters: { + enabled: function( elem ) { + return elem.disabled === false && elem.type !== "hidden"; + }, + + disabled: function( elem ) { + return elem.disabled === true; + }, + + checked: function( elem ) { + return elem.checked === true; + }, + + selected: function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + parent: function( elem ) { + return !!elem.firstChild; + }, + + empty: function( elem ) { + return !elem.firstChild; + }, + + has: function( elem, i, match ) { + return !!Sizzle( match[3], elem ).length; + }, + + header: function( elem ) { + return (/h\d/i).test( elem.nodeName ); + }, + + text: function( elem ) { + var attr = elem.getAttribute( "type" ), type = elem.type; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); + }, + + radio: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; + }, + + checkbox: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; + }, + + file: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; + }, + + password: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + }, + + submit: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "submit" === elem.type; + }, + + image: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; + }, + + reset: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "reset" === elem.type; + }, + + button: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && "button" === elem.type || name === "button"; + }, + + input: function( elem ) { + return (/input|select|textarea|button/i).test( elem.nodeName ); + }, + + focus: function( elem ) { + return elem === elem.ownerDocument.activeElement; + } + }, + setFilters: { + first: function( elem, i ) { + return i === 0; + }, + + last: function( elem, i, match, array ) { + return i === array.length - 1; + }, + + even: function( elem, i ) { + return i % 2 === 0; + }, + + odd: function( elem, i ) { + return i % 2 === 1; + }, + + lt: function( elem, i, match ) { + return i < match[3] - 0; + }, + + gt: function( elem, i, match ) { + return i > match[3] - 0; + }, + + nth: function( elem, i, match ) { + return match[3] - 0 === i; + }, + + eq: function( elem, i, match ) { + return match[3] - 0 === i; + } + }, + filter: { + PSEUDO: function( elem, match, i, array ) { + var name = match[1], + filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; + + } else if ( name === "not" ) { + var not = match[3]; + + for ( var j = 0, l = not.length; j < l; j++ ) { + if ( not[j] === elem ) { + return false; + } + } + + return true; + + } else { + Sizzle.error( name ); + } + }, + + CHILD: function( elem, match ) { + var first, last, + doneName, parent, cache, + count, diff, + type = match[1], + node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + + case "nth": + first = match[2]; + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + doneName = match[0]; + parent = elem.parentNode; + + if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { + count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent[ expando ] = doneName; + } + + diff = elem.nodeIndex - last; + + if ( first === 0 ) { + return diff === 0; + + } else { + return ( diff % first === 0 && diff / first >= 0 ); + } + } + }, + + ID: function( elem, match ) { + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + + TAG: function( elem, match ) { + return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = Sizzle.attr ? + Sizzle.attr( elem, name ) : + Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + + return result == null ? + type === "!=" : + !type && Sizzle.attr ? + result != null : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !check ? + value && result !== false : + type === "!=" ? + value !== check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + + POS: function( elem, match, i, array ) { + var name = match[2], + filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } +}; + +var origPOS = Expr.match.POS, + fescape = function(all, num){ + return "\\" + (num - 0 + 1); + }; + +for ( var type in Expr.match ) { + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); +} + +var makeArray = function( array, results ) { + array = Array.prototype.slice.call( array, 0 ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; +}; + +// Perform a simple check to determine if the browser is capable of +// converting a NodeList to an array using builtin methods. +// Also verifies that the returned array holds DOM nodes +// (which is not the case in the Blackberry browser) +try { + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + +// Provide a fallback method if it does not work +} catch( e ) { + makeArray = function( array, results ) { + var i = 0, + ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + + } else { + if ( typeof array.length === "number" ) { + for ( var l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + + } else { + for ( ; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; +} + +var sortOrder, siblingCheck; + +if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { + return a.compareDocumentPosition ? -1 : 1; + } + + return a.compareDocumentPosition(b) & 4 ? -1 : 1; + }; + +} else { + sortOrder = function( a, b ) { + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Fallback to using sourceIndex (in IE) if it's available on both nodes + } else if ( a.sourceIndex && b.sourceIndex ) { + return a.sourceIndex - b.sourceIndex; + } + + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // If the nodes are siblings (or identical) we can do a quick check + if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + + siblingCheck = function( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; + }; +} + +// Check to see if the browser returns elements by name when +// querying by getElementById (and provide a workaround) +(function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("div"), + id = "script" + (new Date()).getTime(), + root = document.documentElement; + + form.innerHTML = ""; + + // Inject it into the root element, check its status, and remove it quickly + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( document.getElementById( id ) ) { + Expr.find.ID = function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + + return m ? + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? + [m] : + undefined : + []; + } + }; + + Expr.filter.ID = function( elem, match ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); + + // release memory in IE + root = form = null; +})(); + +(function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function( match, context ) { + var results = context.getElementsByTagName( match[1] ); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = ""; + + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && + div.firstChild.getAttribute("href") !== "#" ) { + + Expr.attrHandle.href = function( elem ) { + return elem.getAttribute( "href", 2 ); + }; + } + + // release memory in IE + div = null; +})(); + +if ( document.querySelectorAll ) { + (function(){ + var oldSizzle = Sizzle, + div = document.createElement("div"), + id = "__sizzle__"; + + div.innerHTML = "

"; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function( query, context, extra, seed ) { + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && !Sizzle.isXML(context) ) { + // See if we find a selector to speed up + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { + // Speed-up: Sizzle("TAG") + if ( match[1] ) { + return makeArray( context.getElementsByTagName( query ), extra ); + + // Speed-up: Sizzle(".CLASS") + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { + return makeArray( context.getElementsByClassName( match[2] ), extra ); + } + } + + if ( context.nodeType === 9 ) { + // Speed-up: Sizzle("body") + // The body element only exists once, optimize finding it + if ( query === "body" && context.body ) { + return makeArray( [ context.body ], extra ); + + // Speed-up: Sizzle("#ID") + } else if ( match && match[3] ) { + var elem = context.getElementById( match[3] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id === match[3] ) { + return makeArray( [ elem ], extra ); + } + + } else { + return makeArray( [], extra ); + } + } + + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(qsaError) {} + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + var oldContext = context, + old = context.getAttribute( "id" ), + nid = old || id, + hasParent = context.parentNode, + relativeHierarchySelector = /^\s*[+~]/.test( query ); + + if ( !old ) { + context.setAttribute( "id", nid ); + } else { + nid = nid.replace( /'/g, "\\$&" ); + } + if ( relativeHierarchySelector && hasParent ) { + context = context.parentNode; + } + + try { + if ( !relativeHierarchySelector || hasParent ) { + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); + } + + } catch(pseudoError) { + } finally { + if ( !old ) { + oldContext.removeAttribute( "id" ); + } + } + } + } + + return oldSizzle(query, context, extra, seed); + }; + + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + // release memory in IE + div = null; + })(); +} + +(function(){ + var html = document.documentElement, + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; + + if ( matches ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9 fails this) + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), + pseudoWorks = false; + + try { + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( document.documentElement, "[test!='']:sizzle" ); + + } catch( pseudoError ) { + pseudoWorks = true; + } + + Sizzle.matchesSelector = function( node, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + + if ( !Sizzle.isXML( node ) ) { + try { + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { + var ret = matches.call( node, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || !disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9, so check for that + node.document && node.document.nodeType !== 11 ) { + return ret; + } + } + } catch(e) {} + } + + return Sizzle(expr, null, null, [node]).length > 0; + }; + } +})(); + +(function(){ + var div = document.createElement("div"); + + div.innerHTML = "
"; + + // Opera can't find a second classname (in 9.6) + // Also, make sure that getElementsByClassName actually exists + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { + return; + } + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) { + return; + } + + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function( match, context, isXML ) { + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { + return context.getElementsByClassName(match[1]); + } + }; + + // release memory in IE + div = null; +})(); + +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( elem.nodeName.toLowerCase() === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +if ( document.documentElement.contains ) { + Sizzle.contains = function( a, b ) { + return a !== b && (a.contains ? a.contains(b) : true); + }; + +} else if ( document.documentElement.compareDocumentPosition ) { + Sizzle.contains = function( a, b ) { + return !!(a.compareDocumentPosition(b) & 16); + }; + +} else { + Sizzle.contains = function() { + return false; + }; +} + +Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; + + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +var posProcess = function( selector, context, seed ) { + var match, + tmpSet = [], + later = "", + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet, seed ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +// Override sizzle attribute retrieval +Sizzle.attr = jQuery.attr; +Sizzle.selectors.attrMap = {}; +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.filters; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})(); + + +var runtil = /Until$/, + rparentsprev = /^(?:parents|prevUntil|prevAll)/, + // Note: This RegExp should be improved, or likely pulled from Sizzle + rmultiselector = /,/, + isSimple = /^.[^:#\[\.,]*$/, + slice = Array.prototype.slice, + POS = jQuery.expr.match.POS, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var self = this, + i, l; + + if ( typeof selector !== "string" ) { + return jQuery( selector ).filter(function() { + for ( i = 0, l = self.length; i < l; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }); + } + + var ret = this.pushStack( "", "find", selector ), + length, n, r; + + for ( i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( n = length; n < ret.length; n++ ) { + for ( r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && ( + typeof selector === "string" ? + // If this is a positional selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + POS.test( selector ) ? + jQuery( selector, this.context ).index( this[0] ) >= 0 : + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + // Array (deprecated as of jQuery 1.7) + if ( jQuery.isArray( selectors ) ) { + var level = 1; + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( i = 0; i < selectors.length; i++ ) { + + if ( jQuery( cur ).is( selectors[ i ] ) ) { + ret.push({ selector: selectors[ i ], elem: cur, level: level }); + } + } + + cur = cur.parentNode; + level++; + } + + return ret; + } + + // String + var pos = POS.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; + + while ( cur ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + + } else { + cur = cur.parentNode; + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { + break; + } + } + } + } + + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + andSelf: function() { + return this.add( this.prevObject ); + } +}); + +// A painfully simple check to see if an element is disconnected +// from a document (should be improved, where feasible). +function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return jQuery.nth( elem, 2, "nextSibling" ); + }, + prev: function( elem ) { + return jQuery.nth( elem, 2, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( elem.parentNode.firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.makeArray( elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ), + // The variable 'args' was introduced in + // https://github.com/jquery/jquery/commit/52a0238 + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. + // http://code.google.com/p/v8/issues/detail?id=1050 + args = slice.call(arguments); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, args.join(",") ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + nth: function( cur, result, dir, elem ) { + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) { + if ( cur.nodeType === 1 && ++num === result ) { + break; + } + } + + return cur; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return ( elem === qualifier ) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; + }); +} + + + + +function createSafeFragment( document ) { + var list = nodeNames.split( " " ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; +} + +var nodeNames = "abbr article aside audio canvas datalist details figcaption figure footer " + + "header hgroup mark meter nav output progress section summary time video", + rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, + rtagName = /<([\w:]+)/, + rtbody = /", "" ], + legend: [ 1, "
", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + col: [ 2, "", "
" ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }, + safeFragment = createSafeFragment( document ); + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and