JS backend: remove ECMA 3, but several tests is broken.
Main reason: overload extention property: Int.bar = 1 String.bar = 2
This commit is contained in:
@@ -224,26 +224,7 @@
|
|||||||
<arg value="--js"/>
|
<arg value="--js"/>
|
||||||
<arg value="${basedir}/js/js.translator/testFiles/maps.js"/>
|
<arg value="${basedir}/js/js.translator/testFiles/maps.js"/>
|
||||||
<arg value="--js_output_file"/>
|
<arg value="--js_output_file"/>
|
||||||
<arg value="${kotlin-home}/lib/kotlinEcma5.js"/>
|
<arg value="${kotlin-home}/lib/kotlin.js"/>
|
||||||
</java>
|
|
||||||
<java classname="com.google.javascript.jscomp.CommandLineRunner" failonerror="true">
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="${basedir}/js/js.tests/testLib/closure-compiler.jar"/>
|
|
||||||
</classpath>
|
|
||||||
<arg value="--formatting"/>
|
|
||||||
<arg value="PRETTY_PRINT"/>
|
|
||||||
<arg value="--language_in"/>
|
|
||||||
<arg value="ECMASCRIPT3"/>
|
|
||||||
<arg value="--compilation_level"/>
|
|
||||||
<arg value="SIMPLE_OPTIMIZATIONS"/>
|
|
||||||
<arg value="--js"/>
|
|
||||||
<arg value="${basedir}/js/js.translator/testFiles/kotlin_lib_ecma3.js"/>
|
|
||||||
<arg value="--js"/>
|
|
||||||
<arg value="${basedir}/js/js.translator/testFiles/kotlin_lib.js"/>
|
|
||||||
<arg value="--js"/>
|
|
||||||
<arg value="${basedir}/js/js.translator/testFiles/maps.js"/>
|
|
||||||
<arg value="--js_output_file"/>
|
|
||||||
<arg value="${kotlin-home}/lib/kotlinEcma3.js"/>
|
|
||||||
</java>
|
</java>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,10 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Config getConfig(@NotNull K2JSCompilerArguments arguments, @NotNull Project project) {
|
private static Config getConfig(@NotNull K2JSCompilerArguments arguments, @NotNull Project project) {
|
||||||
EcmaVersion ecmaVersion = EcmaVersion.fromString(arguments.target);
|
if (arguments.target != null) {
|
||||||
|
assert arguments.target == "v5" : "Unsupported ECMA version: " + arguments.target;
|
||||||
|
}
|
||||||
|
EcmaVersion ecmaVersion = EcmaVersion.defaultVersion();
|
||||||
String moduleId = FileUtil.getNameWithoutExtension(new File(arguments.outputFile));
|
String moduleId = FileUtil.getNameWithoutExtension(new File(arguments.outputFile));
|
||||||
if (arguments.libraryFiles != null) {
|
if (arguments.libraryFiles != null) {
|
||||||
return new LibrarySourcesConfig(project, moduleId, Arrays.asList(arguments.libraryFiles), ecmaVersion, arguments.sourcemap);
|
return new LibrarySourcesConfig(project, moduleId, Arrays.asList(arguments.libraryFiles), ecmaVersion, arguments.sourcemap);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class K2JSCompilerArguments extends CompilerArguments {
|
|||||||
@Argument(value = "sourcemap", description = "Generate SourceMap")
|
@Argument(value = "sourcemap", description = "Generate SourceMap")
|
||||||
public boolean sourcemap;
|
public boolean sourcemap;
|
||||||
|
|
||||||
@Argument(value = "target", description = "Generate js files for specific ECMA version (3 or 5, default ECMA 3)")
|
@Argument(value = "target", description = "Generate js files for specific ECMA version (now support only ECMA 5)")
|
||||||
public String target;
|
public String target;
|
||||||
|
|
||||||
@Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag")
|
@Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag")
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class PathUtil {
|
|||||||
public static final String JPS_KOTLIN_HOME_PROPERTY = "jps.kotlin.home";
|
public static final String JPS_KOTLIN_HOME_PROPERTY = "jps.kotlin.home";
|
||||||
|
|
||||||
public static final String JS_LIB_JAR_NAME = "kotlin-jslib.jar";
|
public static final String JS_LIB_JAR_NAME = "kotlin-jslib.jar";
|
||||||
public static final String JS_LIB_JS_NAME = "kotlinEcma3.js";
|
public static final String JS_LIB_JS_NAME = "kotlin.js";
|
||||||
public static final String JDK_ANNOTATIONS_JAR = "kotlin-jdk-annotations.jar";
|
public static final String JDK_ANNOTATIONS_JAR = "kotlin-jdk-annotations.jar";
|
||||||
public static final String ANDROID_SDK_ANNOTATIONS_JAR = "kotlin-android-sdk-annotations.jar";
|
public static final String ANDROID_SDK_ANNOTATIONS_JAR = "kotlin-android-sdk-annotations.jar";
|
||||||
public static final String KOTLIN_JAVA_RUNTIME_JAR = "kotlin-runtime.jar";
|
public static final String KOTLIN_JAVA_RUNTIME_JAR = "kotlin-runtime.jar";
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import static org.jetbrains.k2js.test.utils.JsTestUtils.convertFileNameToDotJsFi
|
|||||||
|
|
||||||
public abstract class BasicTest extends KotlinTestWithEnvironment {
|
public abstract class BasicTest extends KotlinTestWithEnvironment {
|
||||||
// predictable order of ecma version in tests
|
// predictable order of ecma version in tests
|
||||||
protected static final Iterable<EcmaVersion> DEFAULT_ECMA_VERSIONS = Lists.newArrayList(EcmaVersion.v5, EcmaVersion.v3);
|
protected static final Iterable<EcmaVersion> DEFAULT_ECMA_VERSIONS = Lists.newArrayList(EcmaVersion.v5);
|
||||||
|
|
||||||
private static final boolean DELETE_OUT = false;
|
private static final boolean DELETE_OUT = false;
|
||||||
private static final String TEST_FILES = "js/js.translator/testFiles/";
|
private static final String TEST_FILES = "js/js.translator/testFiles/";
|
||||||
@@ -216,9 +216,4 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
|||||||
protected String expected(@NotNull String testName) {
|
protected String expected(@NotNull String testName) {
|
||||||
return getExpectedPath() + testName + ".out";
|
return getExpectedPath() + testName + ".out";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
protected static List<EcmaVersion> failOnEcma5() {
|
|
||||||
return Collections.singletonList(EcmaVersion.v3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import static org.jetbrains.jet.utils.ExceptionUtils.rethrow;
|
|||||||
import static org.jetbrains.k2js.test.BasicTest.pathToTestFilesRoot;
|
import static org.jetbrains.k2js.test.BasicTest.pathToTestFilesRoot;
|
||||||
|
|
||||||
public final class RhinoUtils {
|
public final class RhinoUtils {
|
||||||
private static final String KOTLIN_JS_LIB_ECMA_3 = pathToTestFilesRoot() + "kotlin_lib_ecma3.js";
|
|
||||||
private static final String KOTLIN_JS_LIB_ECMA_5 = pathToTestFilesRoot() + "kotlin_lib_ecma5.js";
|
private static final String KOTLIN_JS_LIB_ECMA_5 = pathToTestFilesRoot() + "kotlin_lib_ecma5.js";
|
||||||
|
|
||||||
private static final Set<String> IGNORED_JSHINT_WARNINGS = Sets.newHashSet();
|
private static final Set<String> IGNORED_JSHINT_WARNINGS = Sets.newHashSet();
|
||||||
@@ -212,7 +211,8 @@ public final class RhinoUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String getKotlinLibFile(@NotNull EcmaVersion ecmaVersion) {
|
public static String getKotlinLibFile(@NotNull EcmaVersion ecmaVersion) {
|
||||||
return ecmaVersion == EcmaVersion.v5 ? KOTLIN_JS_LIB_ECMA_5 : KOTLIN_JS_LIB_ECMA_3;
|
assert ecmaVersion == EcmaVersion.v5 : "Ecma 3 is deprecate";
|
||||||
|
return KOTLIN_JS_LIB_ECMA_5;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flushSystemOut(@NotNull Context context, @NotNull Scriptable scope) {
|
static void flushSystemOut(@NotNull Context context, @NotNull Scriptable scope) {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public abstract class JsUnitTestBase extends MultipleFilesTranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runTestFile(@NotNull String pathToTestFile) throws Exception {
|
public void runTestFile(@NotNull String pathToTestFile) throws Exception {
|
||||||
Iterable<EcmaVersion> versions = failOnEcma5();
|
Iterable<EcmaVersion> versions = DEFAULT_ECMA_VERSIONS;
|
||||||
String testName = pathToTestFile.substring(pathToTestFile.lastIndexOf("/"));
|
String testName = pathToTestFile.substring(pathToTestFile.lastIndexOf("/"));
|
||||||
generateJavaScriptFiles(Lists.newArrayList(pathToTestFile), testName, MainCallParameters.noCall(), versions,
|
generateJavaScriptFiles(Lists.newArrayList(pathToTestFile), testName, MainCallParameters.noCall(), versions,
|
||||||
TestConfigWithUnitTests.FACTORY);
|
TestConfigWithUnitTests.FACTORY);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public final class KotlinLibTest extends SingleFileTranslationTest {
|
|||||||
|
|
||||||
|
|
||||||
private void runJavascriptTest(@NotNull String filename) throws Exception {
|
private void runJavascriptTest(@NotNull String filename) throws Exception {
|
||||||
runRhinoTest(withAdditionalFiles(cases(filename), EcmaVersion.v3),
|
runRhinoTest(withAdditionalFiles(cases(filename), EcmaVersion.defaultVersion()),
|
||||||
new RhinoFunctionResultChecker("test", true));
|
new RhinoFunctionResultChecker("test", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,14 @@ public class RegressionMergeEcmaTest extends SingleFileTranslationTest {
|
|||||||
checkFooBoxIsOk();
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testOverloadFun() throws Exception {
|
||||||
|
checkFooBoxIsOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOverloadExtension() throws Exception {
|
||||||
|
checkFooBoxIsOk();
|
||||||
|
}
|
||||||
|
|
||||||
public void testClassInitializer() throws Exception {
|
public void testClassInitializer() throws Exception {
|
||||||
checkFooBoxIsOk();
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,10 +55,8 @@ public final class StandardClassesTest extends SingleFileTranslationTest {
|
|||||||
// fooBoxTest();
|
// fooBoxTest();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
//TODO: fails on ecma 5 because of ArrayIterator declaration: ecma 5 expects hasNext to be property while it is a function
|
|
||||||
public void testArraysIterator() throws Exception {
|
public void testArraysIterator() throws Exception {
|
||||||
fooBoxTest(failOnEcma5());
|
fooBoxTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testArrayFactoryMethods() throws Exception {
|
public void testArrayFactoryMethods() throws Exception {
|
||||||
|
|||||||
@@ -16,20 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.k2js.test.semantics;
|
package org.jetbrains.k2js.test.semantics;
|
||||||
|
|
||||||
import closurecompiler.internal.com.google.common.collect.Maps;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.jetbrains.k2js.config.EcmaVersion;
|
|
||||||
import org.jetbrains.k2js.test.rhino.CompositeRhinoResultsChecker;
|
|
||||||
import org.jetbrains.k2js.test.rhino.RhinoFunctionResultChecker;
|
|
||||||
import org.jetbrains.k2js.test.rhino.RhinoQUnitResultChecker;
|
|
||||||
import org.jetbrains.k2js.test.rhino.RhinoResultChecker;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.jetbrains.k2js.test.rhino.RhinoUtils.runRhinoTest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class StdLibJsArrayQUnitTest extends StdLibQUnitTestSupport {
|
public class StdLibJsArrayQUnitTest extends StdLibQUnitTestSupport {
|
||||||
@@ -41,8 +27,7 @@ public class StdLibJsArrayQUnitTest extends StdLibQUnitTestSupport {
|
|||||||
// when ran in batch
|
// when ran in batch
|
||||||
|
|
||||||
public void DISABLED_testArrayQUnitTest() throws Exception {
|
public void DISABLED_testArrayQUnitTest() throws Exception {
|
||||||
//performStdLibTest(EcmaVersion.all(),
|
performStdLibTest(DEFAULT_ECMA_VERSIONS,
|
||||||
performStdLibTest(EnumSet.of(EcmaVersion.v3),
|
|
||||||
"libraries/stdlib/test",
|
"libraries/stdlib/test",
|
||||||
"js/JsArrayTest.kt");
|
"js/JsArrayTest.kt");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import org.jetbrains.k2js.test.rhino.CompositeRhinoResultsChecker;
|
|||||||
import org.jetbrains.k2js.test.rhino.RhinoFunctionResultChecker;
|
import org.jetbrains.k2js.test.rhino.RhinoFunctionResultChecker;
|
||||||
import org.jetbrains.k2js.test.rhino.RhinoResultChecker;
|
import org.jetbrains.k2js.test.rhino.RhinoResultChecker;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.jetbrains.k2js.test.rhino.RhinoUtils.runRhinoTest;
|
import static org.jetbrains.k2js.test.rhino.RhinoUtils.runRhinoTest;
|
||||||
@@ -33,8 +31,7 @@ import static org.jetbrains.k2js.test.rhino.RhinoUtils.runRhinoTest;
|
|||||||
*/
|
*/
|
||||||
public class StdLibJsArrayScriptTest extends StdLibTestBase {
|
public class StdLibJsArrayScriptTest extends StdLibTestBase {
|
||||||
public void testArrayScriptTest() throws Exception {
|
public void testArrayScriptTest() throws Exception {
|
||||||
//performStdLibTest(EcmaVersion.all(),
|
performStdLibTest(DEFAULT_ECMA_VERSIONS,
|
||||||
performStdLibTest(EnumSet.of(EcmaVersion.v3),
|
|
||||||
"libraries/stdlib/test",
|
"libraries/stdlib/test",
|
||||||
"js/JsArrayScript.kt");
|
"js/JsArrayScript.kt");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
<link rel="stylesheet" href="qunit.css">
|
<link rel="stylesheet" href="qunit.css">
|
||||||
<script src="qunit.js"></script>
|
<script src="qunit.js"></script>
|
||||||
|
|
||||||
<script src="../testFiles/kotlin_lib_ecma3.js"></script>
|
<script src="../testFiles/kotlin_lib_ecma5.js"></script>
|
||||||
<script src="../testFiles/kotlin_lib.js"></script>
|
<script src="../testFiles/kotlin_lib.js"></script>
|
||||||
<script src="../testFiles/kotlin-js-library/out/GenerateTestCase.compiler_v3.js"></script>
|
<script src="../testFiles/kotlin-js-library/out/GenerateTestCase.compiler_v5.js"></script>
|
||||||
|
|
||||||
<script src="deepEqual.js"></script>
|
<script src="deepEqual.js"></script>
|
||||||
<script src="swarminject.js"></script>
|
<script src="swarminject.js"></script>
|
||||||
|
|||||||
@@ -16,20 +16,13 @@
|
|||||||
|
|
||||||
package org.jetbrains.k2js.config;
|
package org.jetbrains.k2js.config;
|
||||||
|
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public enum EcmaVersion {
|
public enum EcmaVersion {
|
||||||
v3, v5;
|
v3, v5;
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static EcmaVersion fromString(@Nullable String target) {
|
|
||||||
return StringUtil.compareVersionNumbers(target, "v5") >= 0 ? v5 : v3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static EcmaVersion defaultVersion() {
|
public static EcmaVersion defaultVersion() {
|
||||||
return v3;
|
return v5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,209 +0,0 @@
|
|||||||
/* 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/
|
|
||||||
*
|
|
||||||
*--------------------------------------------------------------------------*/
|
|
||||||
var Kotlin = {};
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
"use strict";
|
|
||||||
var emptyFunction = function () {
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!Array.isArray) {
|
|
||||||
Array.isArray = function (vArg) {
|
|
||||||
return Object.prototype.toString.call(vArg) === "[object Array]";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Function.prototype.bind) {
|
|
||||||
Function.prototype.bind = function (oThis) {
|
|
||||||
if (typeof this !== "function") {
|
|
||||||
// closest thing possible to the ECMAScript 5 internal IsCallable function
|
|
||||||
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
|
||||||
}
|
|
||||||
|
|
||||||
var aArgs = Array.prototype.slice.call(arguments, 1),
|
|
||||||
fToBind = this,
|
|
||||||
fNOP = function () {
|
|
||||||
},
|
|
||||||
fBound = function () {
|
|
||||||
return fToBind.apply(this instanceof fNOP && oThis
|
|
||||||
? this
|
|
||||||
: oThis,
|
|
||||||
aArgs.concat(Array.prototype.slice.call(arguments)));
|
|
||||||
};
|
|
||||||
|
|
||||||
fNOP.prototype = this.prototype;
|
|
||||||
fBound.prototype = new fNOP();
|
|
||||||
|
|
||||||
return fBound;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Kotlin.keys = Object.keys || function (o) {
|
|
||||||
var result = [];
|
|
||||||
var i = 0;
|
|
||||||
for (var p in o) {
|
|
||||||
if (o.hasOwnProperty(p)) {
|
|
||||||
result[i++] = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
function copyProperties(to, from) {
|
|
||||||
for (var p in from) {
|
|
||||||
if (from.hasOwnProperty(p)) {
|
|
||||||
to[p] = from[p];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Kotlin.isType = function (object, klass) {
|
|
||||||
if (object === null || object === undefined) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var current = object.get_class();
|
|
||||||
while (current !== klass) {
|
|
||||||
if (current === null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
current = current.superclass;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
Kotlin.createTrait = function () {
|
|
||||||
var n = arguments.length - 1;
|
|
||||||
var result = arguments[n] || {};
|
|
||||||
for (var i = 0; i < n; i++) {
|
|
||||||
copyProperties(result, arguments[i]);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
Kotlin.definePackage = function (members) {
|
|
||||||
return members === null ? {} : members;
|
|
||||||
};
|
|
||||||
|
|
||||||
Kotlin.createClass = (function () {
|
|
||||||
function subclass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
function create(parent, properties, staticProperties) {
|
|
||||||
var traits = null;
|
|
||||||
if (parent instanceof Array) {
|
|
||||||
traits = parent;
|
|
||||||
parent = parent[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
function klass() {
|
|
||||||
this.initializing = klass;
|
|
||||||
if (this.initialize) {
|
|
||||||
this.initialize.apply(this, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
klass.addMethods = addMethods;
|
|
||||||
klass.superclass = parent || null;
|
|
||||||
klass.subclasses = [];
|
|
||||||
klass.object$ = object$;
|
|
||||||
|
|
||||||
if (parent) {
|
|
||||||
if (typeof (parent) == "function") {
|
|
||||||
subclass.prototype = parent.prototype;
|
|
||||||
klass.prototype = new subclass();
|
|
||||||
parent.subclasses.push(klass);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// trait
|
|
||||||
klass.addMethods(parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (traits !== null) {
|
|
||||||
for (var i = 1, n = traits.length; i < n; i++) {
|
|
||||||
klass.addMethods(traits[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (properties !== null && properties !== undefined) {
|
|
||||||
klass.addMethods(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!klass.prototype.initialize) {
|
|
||||||
klass.prototype.initialize = emptyFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
klass.prototype.constructor = klass;
|
|
||||||
if (staticProperties !== null && staticProperties !== undefined) {
|
|
||||||
copyProperties(klass, staticProperties);
|
|
||||||
}
|
|
||||||
return klass;
|
|
||||||
}
|
|
||||||
|
|
||||||
function addMethods(source) {
|
|
||||||
copyProperties(this.prototype, source);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
function object$() {
|
|
||||||
if (typeof this.$object$ === "undefined") {
|
|
||||||
this.$object$ = this.object_initializer$();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.$object$;
|
|
||||||
}
|
|
||||||
|
|
||||||
return create;
|
|
||||||
})();
|
|
||||||
|
|
||||||
Kotlin.$createClass = function (parent, properties) {
|
|
||||||
if (parent !== null && typeof (parent) != "function") {
|
|
||||||
properties = parent;
|
|
||||||
parent = null;
|
|
||||||
}
|
|
||||||
return Kotlin.createClass(parent, properties, null);
|
|
||||||
};
|
|
||||||
|
|
||||||
Kotlin.createObjectWithPrototype = function (prototype) {
|
|
||||||
function C() {}
|
|
||||||
C.prototype = prototype;
|
|
||||||
return new C();
|
|
||||||
};
|
|
||||||
|
|
||||||
Kotlin.$new = function (f) {
|
|
||||||
var o = Kotlin.createObjectWithPrototype(f.prototype);
|
|
||||||
return function () {
|
|
||||||
f.apply(o, arguments);
|
|
||||||
return o;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
Kotlin.createObject = function () {
|
|
||||||
var singletonClass = Kotlin.createClass.apply(null, arguments);
|
|
||||||
return new singletonClass();
|
|
||||||
};
|
|
||||||
|
|
||||||
Kotlin.defineModule = function (id, module) {
|
|
||||||
if (id in Kotlin.modules) {
|
|
||||||
throw Kotlin.$new(Kotlin.IllegalArgumentException)();
|
|
||||||
}
|
|
||||||
|
|
||||||
Kotlin.modules[id] = module;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
fun Int.foo() {}
|
||||||
|
fun String.foo() {}
|
||||||
|
|
||||||
|
val Int.bar = 1
|
||||||
|
val String.bar = 2
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a = 43
|
||||||
|
if (a.bar != 1) return "a.bar != 1, it: ${a.bar}"
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
class A {
|
||||||
|
fun test(a: Int) {}
|
||||||
|
fun test() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript" src="src/js/jquery.js"></script>
|
<script type="text/javascript" src="src/js/jquery.js"></script>
|
||||||
<script src="../../../dist/kotlinc/lib/kotlinEcma3.js"></script>
|
<script src="../../../dist/kotlinc/lib/kotlin.js"></script>
|
||||||
<script type="text/javascript" src="target/js/browser-example.js"></script>
|
<script type="text/javascript" src="target/js/browser-example.js"></script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -87,9 +87,7 @@
|
|||||||
file="${kotlin-js-lib-srcdir}/../../js.translator/testFiles/maps.js"/>
|
file="${kotlin-js-lib-srcdir}/../../js.translator/testFiles/maps.js"/>
|
||||||
<copy tofile="${basedir}/target/generated-js-library/kotlin-lib.js"
|
<copy tofile="${basedir}/target/generated-js-library/kotlin-lib.js"
|
||||||
file="${kotlin-js-lib-srcdir}/../../js.translator/testFiles/kotlin_lib.js"/>
|
file="${kotlin-js-lib-srcdir}/../../js.translator/testFiles/kotlin_lib.js"/>
|
||||||
<copy tofile="${basedir}/target/generated-js-library/kotlin-lib-ecma3.js"
|
<copy tofile="${basedir}/target/generated-js-library/kotlin-lib-ecma5.js"
|
||||||
file="${kotlin-js-lib-srcdir}/../../js.translator/testFiles/kotlin_lib_ecma3.js"/>
|
|
||||||
<copy tofile="${basedir}/target/generated-js-library/kotlin-lib-ecma5.js"
|
|
||||||
file="${kotlin-js-lib-srcdir}/../../js.translator/testFiles/kotlin_lib_ecma5.js"/>
|
file="${kotlin-js-lib-srcdir}/../../js.translator/testFiles/kotlin_lib_ecma5.js"/>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<link rel="stylesheet" href="qunit.css">
|
<link rel="stylesheet" href="qunit.css">
|
||||||
<script src="qunit.js"></script>
|
<script src="qunit.js"></script>
|
||||||
|
|
||||||
<script src="../../../../../../dist/kotlinc/lib/kotlinEcma3.js"></script>
|
<script src="../../../../../../dist/kotlinc/lib/kotlin.js"></script>
|
||||||
<script src="../../../target/js/kotlin-js-tests.js"></script>
|
<script src="../../../target/js/kotlin-js-tests.js"></script>
|
||||||
|
|
||||||
<script src="deepEqual.js"></script>
|
<script src="deepEqual.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user