JS: change how declarations are exported from modules. Change how parts of kotlin.js merged
This commit is contained in:
@@ -368,20 +368,9 @@
|
||||
|
||||
<sources dir="${js.stdlib.output.dir}">
|
||||
<file name="builtins.js"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${stdlib.js.dir}">
|
||||
<file name="merge-builtins.js"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${js.stdlib.output.dir}">
|
||||
<file name="${compiled.stdlib.js}"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${stdlib.js.dir}">
|
||||
<file name="merge.js"/>
|
||||
</sources>
|
||||
|
||||
<externs dir="${stdlib.js.dir}">
|
||||
<file name="externs.js"/>
|
||||
</externs>
|
||||
@@ -412,6 +401,15 @@
|
||||
<move file="${js.stdlib.output.dir}/tmp/kotlin" todir="${js.stdlib.output.dir}" />
|
||||
<move file="${js.stdlib.output.dir}/tmp/${compiled.stdlib.meta.js}" tofile="${js.stdlib.output.dir}/${compiled.stdlib.meta.js}" />
|
||||
|
||||
<replaceregexp file="${js.stdlib.output.dir}/builtins.js"
|
||||
match="module.exports,\s*require\([^)]+\)"
|
||||
replace="Kotlin, Kotlin"
|
||||
byline="true" encoding="UTF-8" />
|
||||
<replaceregexp file="${js.stdlib.output.dir}/${compiled.stdlib.js}"
|
||||
match="module.exports,\s*require\([^)]+\)"
|
||||
replace="Kotlin, Kotlin"
|
||||
byline="true" encoding="UTF-8" />
|
||||
|
||||
<condition property="jdk17" value="${env.JDK_17}" else="${env.JAVA_HOME}">
|
||||
<isset property="env.JDK_17" />
|
||||
</condition>
|
||||
|
||||
@@ -39,7 +39,6 @@ import org.jetbrains.kotlin.js.translate.intrinsic.Intrinsics;
|
||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
@@ -145,15 +144,12 @@ public final class StaticContext {
|
||||
@NotNull
|
||||
private final Set<ClassDescriptor> classes = new HashSet<ClassDescriptor>();
|
||||
|
||||
@NotNull
|
||||
private final ExportedPackage rootPackage = new ExportedPackage("");
|
||||
|
||||
@NotNull
|
||||
private final JsObjectLiteral exportObject = rootPackage.objectLiteral;
|
||||
|
||||
@NotNull
|
||||
private final Set<MemberDescriptor> exportedDeclarations = new HashSet<MemberDescriptor>();
|
||||
|
||||
@NotNull
|
||||
private final Map<FqName, JsName> localPackageNames = new HashMap<FqName, JsName>();
|
||||
|
||||
//TODO: too many parameters in constructor
|
||||
private StaticContext(
|
||||
@NotNull JsProgram program,
|
||||
@@ -665,11 +661,7 @@ public final class StaticContext {
|
||||
exportedDeclarations.add(descriptor);
|
||||
|
||||
if (container instanceof PackageFragmentDescriptor) {
|
||||
PackageFragmentDescriptor packageDescriptor = (PackageFragmentDescriptor) container;
|
||||
ExportedPackage exportedPackage = rootPackage;
|
||||
for (Name packageName : packageDescriptor.getFqName().pathSegments()) {
|
||||
exportedPackage = exportedPackage.getSubpackage(packageName.asString());
|
||||
}
|
||||
JsExpression packageRef = getLocalPackageReference(((PackageFragmentDescriptor) container).getFqName());
|
||||
|
||||
JsExpression initializerExpr = DeclarationExporter.exportDeclaration(this, descriptor, exportStatements);
|
||||
if (initializerExpr != null) {
|
||||
@@ -679,8 +671,7 @@ public final class StaticContext {
|
||||
MetadataProperties.setStaticRef(propertyName, initializerExpr);
|
||||
}
|
||||
}
|
||||
JsPropertyInitializer initializer = new JsPropertyInitializer(propertyName.makeRef(), initializerExpr);
|
||||
exportedPackage.objectLiteral.getPropertyInitializers().add(initializer);
|
||||
exportStatements.add(JsAstUtils.assignment(new JsNameRef(propertyName, packageRef), initializerExpr).makeStmt());
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -689,6 +680,24 @@ public final class StaticContext {
|
||||
}
|
||||
}
|
||||
|
||||
private JsExpression getLocalPackageReference(FqName packageName) {
|
||||
if (packageName.isRoot()) {
|
||||
return rootFunction.getScope().declareName(Namer.getRootPackageName()).makeRef();
|
||||
}
|
||||
JsName name = localPackageNames.get(packageName);
|
||||
if (name == null) {
|
||||
name = rootFunction.getScope().declareFreshName("package$" + packageName.shortName().asString());
|
||||
localPackageNames.put(packageName, name);
|
||||
|
||||
JsExpression parentRef = getLocalPackageReference(packageName.parent());
|
||||
JsExpression selfRef = new JsNameRef(packageName.shortName().asString(), parentRef);
|
||||
JsExpression rhs = JsAstUtils.or(selfRef, JsAstUtils.assignment(selfRef.deepCopy(), new JsObjectLiteral(false)));
|
||||
|
||||
exportStatements.add(JsAstUtils.newVar(name, rhs));
|
||||
}
|
||||
return name.makeRef();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public NameSuggestion getNameSuggestion() {
|
||||
return nameSuggestion;
|
||||
@@ -704,11 +713,7 @@ public final class StaticContext {
|
||||
rootFunction.getBody().getStatements().addAll(importStatements);
|
||||
addClassPrototypes();
|
||||
rootFunction.getBody().getStatements().addAll(declarationStatements);
|
||||
|
||||
JsName rootPackageName = rootFunction.getScope().declareName(Namer.getRootPackageName());
|
||||
rootFunction.getBody().getStatements().add(JsAstUtils.newVar(rootPackageName, exportObject));
|
||||
rootFunction.getBody().getStatements().addAll(exportStatements);
|
||||
|
||||
rootFunction.getBody().getStatements().addAll(topLevelStatements);
|
||||
}
|
||||
|
||||
@@ -753,25 +758,4 @@ public final class StaticContext {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class ExportedPackage {
|
||||
@NotNull final String name;
|
||||
@NotNull final Map<String, ExportedPackage> subpackages = new HashMap<String, ExportedPackage>();
|
||||
@NotNull final JsObjectLiteral objectLiteral = new JsObjectLiteral(true);
|
||||
|
||||
public ExportedPackage(@NotNull String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExportedPackage getSubpackage(@NotNull String name) {
|
||||
ExportedPackage subpackage = subpackages.get(name);
|
||||
if (subpackage == null) {
|
||||
subpackage = new ExportedPackage(name);
|
||||
subpackages.put(name, subpackage);
|
||||
objectLiteral.getPropertyInitializers().add(new JsPropertyInitializer(new JsNameRef(name), subpackage.objectLiteral));
|
||||
}
|
||||
return subpackage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-8
@@ -55,7 +55,7 @@ object ModuleWrapperTranslation {
|
||||
|
||||
val amdBody = JsBlock(wrapAmd(moduleId, factoryName.makeRef(), importedModules, program))
|
||||
val commonJsBody = JsBlock(wrapCommonJs(factoryName.makeRef(), importedModules, program))
|
||||
val plainInvocation = makePlainInvocation(factoryName.makeRef(), importedModules, program)
|
||||
val plainInvocation = makePlainInvocation(moduleId, factoryName.makeRef(), importedModules, program)
|
||||
|
||||
val lhs: JsExpression = if (Namer.requiresEscaping(moduleId)) {
|
||||
JsArrayAccess(rootName.makeRef(), program.getStringLiteral(moduleId))
|
||||
@@ -79,7 +79,7 @@ object ModuleWrapperTranslation {
|
||||
val defineName = scope.declareName("define")
|
||||
val invocationArgs = listOf(
|
||||
program.getStringLiteral(moduleId),
|
||||
JsArrayLiteral(importedModules.map { program.getStringLiteral(it) }),
|
||||
JsArrayLiteral(listOf(program.getStringLiteral("exports")) + importedModules.map { program.getStringLiteral(it) }),
|
||||
function
|
||||
)
|
||||
|
||||
@@ -93,16 +93,15 @@ object ModuleWrapperTranslation {
|
||||
val requireName = scope.declareName("require")
|
||||
|
||||
val invocationArgs = importedModules.map { JsInvocation(requireName.makeRef(), program.getStringLiteral(it)) }
|
||||
val invocation = JsInvocation(function, invocationArgs)
|
||||
val assignment = JsAstUtils.assignment(JsNameRef("exports", moduleName.makeRef()), invocation)
|
||||
return listOf(assignment.makeStmt())
|
||||
val invocation = JsInvocation(function, listOf(JsNameRef("exports", moduleName.makeRef())) + invocationArgs)
|
||||
return listOf(invocation.makeStmt())
|
||||
}
|
||||
|
||||
private fun wrapPlain(
|
||||
moduleId: String, function: JsExpression,
|
||||
importedModules: List<String>, program: JsProgram
|
||||
): List<JsStatement> {
|
||||
val invocation = makePlainInvocation(function, importedModules, program)
|
||||
val invocation = makePlainInvocation(moduleId, function, importedModules, program)
|
||||
|
||||
val statement = if (Namer.requiresEscaping(moduleId)) {
|
||||
JsAstUtils.assignment(makePlainModuleRef(moduleId, program), invocation).makeStmt()
|
||||
@@ -114,9 +113,18 @@ object ModuleWrapperTranslation {
|
||||
return listOf(statement)
|
||||
}
|
||||
|
||||
private fun makePlainInvocation(function: JsExpression, importedModules: List<String>, program: JsProgram): JsInvocation {
|
||||
private fun makePlainInvocation(
|
||||
moduleId: String,
|
||||
function: JsExpression,
|
||||
importedModules: List<String>,
|
||||
program: JsProgram
|
||||
): JsInvocation {
|
||||
val invocationArgs = importedModules.map { makePlainModuleRef(it, program) }
|
||||
return JsInvocation(function, invocationArgs)
|
||||
val moduleRef = makePlainModuleRef(moduleId, program)
|
||||
val testModuleDefined = JsAstUtils.typeOfIs(moduleRef, program.getStringLiteral("undefined"))
|
||||
val selfArg = JsConditional(testModuleDefined, JsObjectLiteral(false), moduleRef.deepCopy())
|
||||
|
||||
return JsInvocation(function, listOf(selfArg) + invocationArgs)
|
||||
}
|
||||
|
||||
private fun makePlainModuleRef(moduleId: String, program: JsProgram): JsExpression {
|
||||
|
||||
@@ -269,6 +269,9 @@ public final class Translation {
|
||||
|
||||
mayBeGenerateTests(files, config, rootBlock, context);
|
||||
|
||||
JsName rootPackageName = program.getRootScope().declareName(Namer.getRootPackageName());
|
||||
rootFunction.getParameters().add(new JsParameter((rootPackageName)));
|
||||
|
||||
// Invoke function passing modules as arguments
|
||||
// This should help minifier tool to recognize references to these modules as local variables and make them shorter.
|
||||
List<String> importedModuleList = new ArrayList<String>();
|
||||
@@ -288,7 +291,7 @@ public final class Translation {
|
||||
}
|
||||
}
|
||||
|
||||
statements.add(new JsReturn(program.getRootScope().declareName(Namer.getRootPackageName()).makeRef()));
|
||||
statements.add(new JsReturn(rootPackageName.makeRef()));
|
||||
|
||||
JsBlock block = program.getGlobalBlock();
|
||||
block.getStatements().addAll(wrapIfNecessary(config.getModuleId(), rootFunction, importedModuleList, program,
|
||||
|
||||
+2
-5
@@ -8,11 +8,8 @@
|
||||
}
|
||||
}(this, function () {
|
||||
var Kotlin = {};
|
||||
function require() {
|
||||
return Kotlin;
|
||||
}
|
||||
var module = {};
|
||||
|
||||
%output%
|
||||
Kotlin.modules.kotlin = Kotlin;
|
||||
|
||||
return Kotlin;
|
||||
}));
|
||||
+418
-422
@@ -14,90 +14,87 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function (Kotlin) {
|
||||
"use strict";
|
||||
// Shims for String
|
||||
if (typeof String.prototype.startsWith === "undefined") {
|
||||
String.prototype.startsWith = function(searchString, position) {
|
||||
position = position || 0;
|
||||
return this.lastIndexOf(searchString, position) === position;
|
||||
};
|
||||
}
|
||||
if (typeof String.prototype.endsWith === "undefined") {
|
||||
String.prototype.endsWith = function(searchString, position) {
|
||||
var subjectString = this.toString();
|
||||
if (position === undefined || position > subjectString.length) {
|
||||
position = subjectString.length;
|
||||
}
|
||||
position -= searchString.length;
|
||||
var lastIndex = subjectString.indexOf(searchString, position);
|
||||
return lastIndex !== -1 && lastIndex === position;
|
||||
};
|
||||
}
|
||||
|
||||
// Shims for String
|
||||
if (typeof String.prototype.startsWith === "undefined") {
|
||||
String.prototype.startsWith = function(searchString, position) {
|
||||
position = position || 0;
|
||||
return this.lastIndexOf(searchString, position) === position;
|
||||
};
|
||||
}
|
||||
if (typeof String.prototype.endsWith === "undefined") {
|
||||
String.prototype.endsWith = function(searchString, position) {
|
||||
var subjectString = this.toString();
|
||||
if (position === undefined || position > subjectString.length) {
|
||||
position = subjectString.length;
|
||||
}
|
||||
position -= searchString.length;
|
||||
var lastIndex = subjectString.indexOf(searchString, position);
|
||||
return lastIndex !== -1 && lastIndex === position;
|
||||
};
|
||||
String.prototype.contains = function (s) {
|
||||
return this.indexOf(s) !== -1;
|
||||
};
|
||||
|
||||
// Kotlin stdlib
|
||||
|
||||
Kotlin.equals = function (obj1, obj2) {
|
||||
if (obj1 == null) {
|
||||
return obj2 == null;
|
||||
}
|
||||
|
||||
String.prototype.contains = function (s) {
|
||||
return this.indexOf(s) !== -1;
|
||||
};
|
||||
if (obj2 == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Kotlin stdlib
|
||||
if (typeof obj1 == "object" && typeof obj1.equals_za3rmp$ === "function") {
|
||||
return obj1.equals_za3rmp$(obj2);
|
||||
}
|
||||
|
||||
Kotlin.equals = function (obj1, obj2) {
|
||||
if (obj1 == null) {
|
||||
return obj2 == null;
|
||||
}
|
||||
return obj1 === obj2;
|
||||
};
|
||||
|
||||
if (obj2 == null) {
|
||||
return false;
|
||||
}
|
||||
Kotlin.hashCode = function (obj) {
|
||||
if (obj == null) {
|
||||
return 0;
|
||||
}
|
||||
if ("function" == typeof obj.hashCode) {
|
||||
return obj.hashCode();
|
||||
}
|
||||
var objType = typeof obj;
|
||||
if ("object" == objType || "function" == objType) {
|
||||
return getObjectHashCode(obj);
|
||||
} else if ("number" == objType) {
|
||||
// TODO: a more elaborate code is needed for floating point values.
|
||||
return obj | 0;
|
||||
} if ("boolean" == objType) {
|
||||
return Number(obj)
|
||||
}
|
||||
|
||||
if (typeof obj1 == "object" && typeof obj1.equals_za3rmp$ === "function") {
|
||||
return obj1.equals_za3rmp$(obj2);
|
||||
}
|
||||
var str = String(obj);
|
||||
return getStringHashCode(str);
|
||||
};
|
||||
|
||||
return obj1 === obj2;
|
||||
};
|
||||
Kotlin.toString = function (o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
else if (Array.isArray(o)) {
|
||||
return "[...]";
|
||||
}
|
||||
else {
|
||||
return o.toString();
|
||||
}
|
||||
};
|
||||
|
||||
Kotlin.hashCode = function (obj) {
|
||||
if (obj == null) {
|
||||
return 0;
|
||||
}
|
||||
if ("function" == typeof obj.hashCode) {
|
||||
return obj.hashCode();
|
||||
}
|
||||
var objType = typeof obj;
|
||||
if ("object" == objType || "function" == objType) {
|
||||
return getObjectHashCode(obj);
|
||||
} else if ("number" == objType) {
|
||||
// TODO: a more elaborate code is needed for floating point values.
|
||||
return obj | 0;
|
||||
} if ("boolean" == objType) {
|
||||
return Number(obj)
|
||||
}
|
||||
Kotlin.arrayToString = function (a) {
|
||||
return "[" + a.map(Kotlin.toString).join(", ") + "]";
|
||||
};
|
||||
|
||||
var str = String(obj);
|
||||
return getStringHashCode(str);
|
||||
};
|
||||
|
||||
Kotlin.toString = function (o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
else if (Array.isArray(o)) {
|
||||
return "[...]";
|
||||
}
|
||||
else {
|
||||
return o.toString();
|
||||
}
|
||||
};
|
||||
|
||||
Kotlin.arrayToString = function (a) {
|
||||
return "[" + a.map(Kotlin.toString).join(", ") + "]";
|
||||
};
|
||||
|
||||
Kotlin.arrayDeepToString = function (a, visited) {
|
||||
visited = visited || [a];
|
||||
return "[" + a.map(function(e) {
|
||||
Kotlin.arrayDeepToString = function (a, visited) {
|
||||
visited = visited || [a];
|
||||
return "[" + a.map(function(e) {
|
||||
if (Array.isArray(e) && visited.indexOf(e) < 0) {
|
||||
visited.push(e);
|
||||
var result = Kotlin.arrayDeepToString(e, visited);
|
||||
@@ -108,396 +105,395 @@
|
||||
return Kotlin.toString(e);
|
||||
}
|
||||
}).join(", ") + "]";
|
||||
};
|
||||
};
|
||||
|
||||
Kotlin.compareTo = function (a, b) {
|
||||
var typeA = typeof a;
|
||||
var typeB = typeof a;
|
||||
if (Kotlin.isChar(a) && typeB == "number") {
|
||||
return Kotlin.primitiveCompareTo(a.charCodeAt(0), b);
|
||||
}
|
||||
if (typeA == "number" && Kotlin.isChar(b)) {
|
||||
return Kotlin.primitiveCompareTo(a, b.charCodeAt(0));
|
||||
}
|
||||
if (typeA == "number" || typeA == "string") {
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
}
|
||||
return a.compareTo_za3rmp$(b);
|
||||
};
|
||||
|
||||
Kotlin.primitiveCompareTo = function (a, b) {
|
||||
Kotlin.compareTo = function (a, b) {
|
||||
var typeA = typeof a;
|
||||
var typeB = typeof a;
|
||||
if (Kotlin.isChar(a) && typeB == "number") {
|
||||
return Kotlin.primitiveCompareTo(a.charCodeAt(0), b);
|
||||
}
|
||||
if (typeA == "number" && Kotlin.isChar(b)) {
|
||||
return Kotlin.primitiveCompareTo(a, b.charCodeAt(0));
|
||||
}
|
||||
if (typeA == "number" || typeA == "string") {
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
};
|
||||
}
|
||||
return a.compareTo_za3rmp$(b);
|
||||
};
|
||||
|
||||
Kotlin.isNumber = function (a) {
|
||||
return typeof a == "number" || a instanceof Kotlin.Long;
|
||||
};
|
||||
Kotlin.primitiveCompareTo = function (a, b) {
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
};
|
||||
|
||||
Kotlin.isChar = function (value) {
|
||||
return (typeof value) == "string" && value.length == 1;
|
||||
};
|
||||
Kotlin.isNumber = function (a) {
|
||||
return typeof a == "number" || a instanceof Kotlin.Long;
|
||||
};
|
||||
|
||||
Kotlin.isComparable = function (value) {
|
||||
var type = typeof value;
|
||||
Kotlin.isChar = function (value) {
|
||||
return (typeof value) == "string" && value.length == 1;
|
||||
};
|
||||
|
||||
return type === "string" ||
|
||||
type === "boolean" ||
|
||||
Kotlin.isNumber(value) ||
|
||||
Kotlin.isType(value, Kotlin.kotlin.Comparable);
|
||||
};
|
||||
|
||||
Kotlin.isCharSequence = function (value) {
|
||||
return typeof value === "string" || Kotlin.isType(value, Kotlin.kotlin.CharSequence);
|
||||
};
|
||||
Kotlin.isComparable = function (value) {
|
||||
var type = typeof value;
|
||||
|
||||
Kotlin.charInc = function (value) {
|
||||
return String.fromCharCode(value.charCodeAt(0)+1);
|
||||
};
|
||||
return type === "string" ||
|
||||
type === "boolean" ||
|
||||
Kotlin.isNumber(value) ||
|
||||
Kotlin.isType(value, Kotlin.kotlin.Comparable);
|
||||
};
|
||||
|
||||
Kotlin.charDec = function (value) {
|
||||
return String.fromCharCode(value.charCodeAt(0)-1);
|
||||
};
|
||||
Kotlin.isCharSequence = function (value) {
|
||||
return typeof value === "string" || Kotlin.isType(value, Kotlin.kotlin.CharSequence);
|
||||
};
|
||||
|
||||
Kotlin.toShort = function (a) {
|
||||
return (a & 0xFFFF) << 16 >> 16;
|
||||
};
|
||||
Kotlin.charInc = function (value) {
|
||||
return String.fromCharCode(value.charCodeAt(0)+1);
|
||||
};
|
||||
|
||||
Kotlin.toByte = function (a) {
|
||||
return (a & 0xFF) << 24 >> 24;
|
||||
};
|
||||
Kotlin.charDec = function (value) {
|
||||
return String.fromCharCode(value.charCodeAt(0)-1);
|
||||
};
|
||||
|
||||
Kotlin.toChar = function (a) {
|
||||
return String.fromCharCode((((a | 0) % 65536) & 0xFFFF) << 16 >>> 16);
|
||||
};
|
||||
Kotlin.toShort = function (a) {
|
||||
return (a & 0xFFFF) << 16 >> 16;
|
||||
};
|
||||
|
||||
Kotlin.numberToLong = function (a) {
|
||||
return a instanceof Kotlin.Long ? a : Kotlin.Long.fromNumber(a);
|
||||
};
|
||||
Kotlin.toByte = function (a) {
|
||||
return (a & 0xFF) << 24 >> 24;
|
||||
};
|
||||
|
||||
Kotlin.numberToInt = function (a) {
|
||||
return a instanceof Kotlin.Long ? a.toInt() : (a | 0);
|
||||
};
|
||||
Kotlin.toChar = function (a) {
|
||||
return String.fromCharCode((((a | 0) % 65536) & 0xFFFF) << 16 >>> 16);
|
||||
};
|
||||
|
||||
Kotlin.numberToShort = function (a) {
|
||||
return Kotlin.toShort(Kotlin.numberToInt(a));
|
||||
};
|
||||
Kotlin.numberToLong = function (a) {
|
||||
return a instanceof Kotlin.Long ? a : Kotlin.Long.fromNumber(a);
|
||||
};
|
||||
|
||||
Kotlin.numberToByte = function (a) {
|
||||
return Kotlin.toByte(Kotlin.numberToInt(a));
|
||||
};
|
||||
Kotlin.numberToInt = function (a) {
|
||||
return a instanceof Kotlin.Long ? a.toInt() : (a | 0);
|
||||
};
|
||||
|
||||
Kotlin.numberToDouble = function (a) {
|
||||
return +a;
|
||||
};
|
||||
Kotlin.numberToShort = function (a) {
|
||||
return Kotlin.toShort(Kotlin.numberToInt(a));
|
||||
};
|
||||
|
||||
Kotlin.numberToChar = function (a) {
|
||||
return Kotlin.toChar(Kotlin.numberToInt(a));
|
||||
};
|
||||
Kotlin.numberToByte = function (a) {
|
||||
return Kotlin.toByte(Kotlin.numberToInt(a));
|
||||
};
|
||||
|
||||
Kotlin.intUpto = function (from, to) {
|
||||
return new Kotlin.kotlin.ranges.IntRange(from, to);
|
||||
};
|
||||
Kotlin.numberToDouble = function (a) {
|
||||
return +a;
|
||||
};
|
||||
|
||||
Kotlin.intDownto = function (from, to) {
|
||||
return new Kotlin.kotlin.ranges.IntProgression(from, to, -1);
|
||||
};
|
||||
Kotlin.numberToChar = function (a) {
|
||||
return Kotlin.toChar(Kotlin.numberToInt(a));
|
||||
};
|
||||
|
||||
Kotlin.Throwable = Error;
|
||||
Kotlin.intUpto = function (from, to) {
|
||||
return new Kotlin.kotlin.ranges.IntRange(from, to);
|
||||
};
|
||||
|
||||
Kotlin.throwNPE = function (message) {
|
||||
throw new Kotlin.kotlin.NullPointerException(message);
|
||||
};
|
||||
Kotlin.intDownto = function (from, to) {
|
||||
return new Kotlin.kotlin.ranges.IntProgression(from, to, -1);
|
||||
};
|
||||
|
||||
Kotlin.throwCCE = function () {
|
||||
throw new Kotlin.kotlin.ClassCastException("Illegal cast");
|
||||
};
|
||||
Kotlin.Throwable = Error;
|
||||
|
||||
/** @const */
|
||||
var POW_2_32 = 4294967296;
|
||||
// TODO: consider switching to Symbol type once we are on ES6.
|
||||
/** @const */
|
||||
var OBJECT_HASH_CODE_PROPERTY_NAME = "kotlinHashCodeValue$";
|
||||
Kotlin.throwNPE = function (message) {
|
||||
throw new Kotlin.kotlin.NullPointerException(message);
|
||||
};
|
||||
|
||||
function getObjectHashCode(obj) {
|
||||
if (!(OBJECT_HASH_CODE_PROPERTY_NAME in obj)) {
|
||||
var hash = (Math.random() * POW_2_32) | 0; // Make 32-bit singed integer.
|
||||
Object.defineProperty(obj, OBJECT_HASH_CODE_PROPERTY_NAME, { value: hash, enumerable: false });
|
||||
}
|
||||
return obj[OBJECT_HASH_CODE_PROPERTY_NAME];
|
||||
Kotlin.throwCCE = function () {
|
||||
throw new Kotlin.kotlin.ClassCastException("Illegal cast");
|
||||
};
|
||||
|
||||
/** @const */
|
||||
var POW_2_32 = 4294967296;
|
||||
// TODO: consider switching to Symbol type once we are on ES6.
|
||||
/** @const */
|
||||
var OBJECT_HASH_CODE_PROPERTY_NAME = "kotlinHashCodeValue$";
|
||||
|
||||
function getObjectHashCode(obj) {
|
||||
if (!(OBJECT_HASH_CODE_PROPERTY_NAME in obj)) {
|
||||
var hash = (Math.random() * POW_2_32) | 0; // Make 32-bit singed integer.
|
||||
Object.defineProperty(obj, OBJECT_HASH_CODE_PROPERTY_NAME, { value: hash, enumerable: false });
|
||||
}
|
||||
return obj[OBJECT_HASH_CODE_PROPERTY_NAME];
|
||||
}
|
||||
|
||||
function getStringHashCode(str) {
|
||||
var hash = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var code = str.charCodeAt(i);
|
||||
hash = (hash * 31 + code) | 0; // Keep it 32-bit.
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
Kotlin.PropertyMetadata = Kotlin.createClassNow(null,
|
||||
function (name) {
|
||||
this.name = name;
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.safeParseInt = function (str) {
|
||||
var r = parseInt(str, 10);
|
||||
return isNaN(r) ? null : r;
|
||||
};
|
||||
|
||||
Kotlin.safeParseDouble = function (str) {
|
||||
var r = parseFloat(str);
|
||||
return isNaN(r) ? null : r;
|
||||
};
|
||||
|
||||
Kotlin.arrayEquals = function (a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (!Array.isArray(b) || a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function getStringHashCode(str) {
|
||||
var hash = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var code = str.charCodeAt(i);
|
||||
hash = (hash * 31 + code) | 0; // Keep it 32-bit.
|
||||
for (var i = 0, n = a.length; i < n; i++) {
|
||||
if (!Kotlin.equals(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Kotlin.arrayDeepEquals = function (a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (!Array.isArray(b) || a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Kotlin.PropertyMetadata = Kotlin.createClassNow(null,
|
||||
function (name) {
|
||||
this.name = name;
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.safeParseInt = function (str) {
|
||||
var r = parseInt(str, 10);
|
||||
return isNaN(r) ? null : r;
|
||||
};
|
||||
|
||||
Kotlin.safeParseDouble = function (str) {
|
||||
var r = parseFloat(str);
|
||||
return isNaN(r) ? null : r;
|
||||
};
|
||||
|
||||
Kotlin.arrayEquals = function (a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (!Array.isArray(b) || a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0, n = a.length; i < n; i++) {
|
||||
if (!Kotlin.equals(a[i], b[i])) {
|
||||
for (var i = 0, n = a.length; i < n; i++) {
|
||||
if (Array.isArray(a[i])) {
|
||||
if (!Kotlin.arrayDeepEquals(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Kotlin.arrayDeepEquals = function (a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (!Array.isArray(b) || a.length !== b.length) {
|
||||
} else if (!Kotlin.equals(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
for (var i = 0, n = a.length; i < n; i++) {
|
||||
if (Array.isArray(a[i])) {
|
||||
if (!Kotlin.arrayDeepEquals(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
} else if (!Kotlin.equals(a[i], b[i])) {
|
||||
return false;
|
||||
Kotlin.arrayHashCode = function (arr) {
|
||||
var result = 1;
|
||||
for (var i = 0, n = arr.length; i < n; i++) {
|
||||
result = ((31 * result | 0) + Kotlin.hashCode(arr[i])) | 0;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
Kotlin.arrayDeepHashCode = function (arr) {
|
||||
var result = 1;
|
||||
for (var i = 0, n = arr.length; i < n; i++) {
|
||||
var e = arr[i];
|
||||
result = ((31 * result | 0) + (Array.isArray(e) ? Kotlin.arrayDeepHashCode(e) : Kotlin.hashCode(e))) | 0;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var BaseOutput = Kotlin.createClassNow(null, null, {
|
||||
println: function (a) {
|
||||
if (typeof a !== "undefined") this.print(a);
|
||||
this.print("\n");
|
||||
},
|
||||
flush: function () {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Kotlin.NodeJsOutput = Kotlin.createClassNow(BaseOutput,
|
||||
function(outputStream) {
|
||||
this.outputStream = outputStream;
|
||||
}, {
|
||||
print: function (a) {
|
||||
this.outputStream.write(a);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.OutputToConsoleLog = Kotlin.createClassNow(BaseOutput, null, {
|
||||
print: function (a) {
|
||||
console.log(a);
|
||||
},
|
||||
println: function (a) {
|
||||
this.print(typeof a !== "undefined" ? a : "");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.BufferedOutput = Kotlin.createClassNow(BaseOutput,
|
||||
function() {
|
||||
this.buffer = ""
|
||||
}, {
|
||||
print: function (a) {
|
||||
this.buffer += String(a);
|
||||
},
|
||||
flush: function () {
|
||||
this.buffer = "";
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.BufferedOutputToConsoleLog = Kotlin.createClassNow(Kotlin.BufferedOutput,
|
||||
function() {
|
||||
Kotlin.BufferedOutput.call(this);
|
||||
}, {
|
||||
print: function (a) {
|
||||
var s = String(a);
|
||||
|
||||
var i = s.lastIndexOf("\n");
|
||||
if (i != -1) {
|
||||
this.buffer += s.substr(0, i);
|
||||
|
||||
this.flush();
|
||||
|
||||
s = s.substr(i + 1);
|
||||
}
|
||||
|
||||
this.buffer += s;
|
||||
},
|
||||
flush: function () {
|
||||
console.log(this.buffer);
|
||||
this.buffer = "";
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
);
|
||||
Kotlin.out = function() {
|
||||
var isNode = typeof process !== 'undefined' && process.versions && !!process.versions.node;
|
||||
|
||||
Kotlin.arrayHashCode = function (arr) {
|
||||
var result = 1;
|
||||
for (var i = 0, n = arr.length; i < n; i++) {
|
||||
result = ((31 * result | 0) + Kotlin.hashCode(arr[i])) | 0;
|
||||
if (isNode) return new Kotlin.NodeJsOutput(process.stdout);
|
||||
|
||||
return new Kotlin.BufferedOutputToConsoleLog();
|
||||
}();
|
||||
|
||||
Kotlin.println = function (s) {
|
||||
Kotlin.out.println(s);
|
||||
};
|
||||
|
||||
Kotlin.print = function (s) {
|
||||
Kotlin.out.print(s);
|
||||
};
|
||||
|
||||
Kotlin.collectionsMax = function (c, comp) {
|
||||
if (c.isEmpty()) {
|
||||
//TODO: which exception?
|
||||
throw new Error();
|
||||
}
|
||||
var it = c.iterator();
|
||||
var max = it.next();
|
||||
while (it.hasNext()) {
|
||||
var el = it.next();
|
||||
if (comp.compare(max, el) < 0) {
|
||||
max = el;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
return max;
|
||||
};
|
||||
|
||||
Kotlin.arrayDeepHashCode = function (arr) {
|
||||
var result = 1;
|
||||
for (var i = 0, n = arr.length; i < n; i++) {
|
||||
var e = arr[i];
|
||||
result = ((31 * result | 0) + (Array.isArray(e) ? Kotlin.arrayDeepHashCode(e) : Kotlin.hashCode(e))) | 0;
|
||||
Kotlin.collectionsSort = function (mutableList, comparator) {
|
||||
var boundComparator = void 0;
|
||||
if (comparator !== void 0) {
|
||||
boundComparator = comparator.compare.bind(comparator);
|
||||
}
|
||||
|
||||
if (mutableList.size > 1) {
|
||||
var array = Kotlin.copyToArray(mutableList);
|
||||
|
||||
array.sort(boundComparator);
|
||||
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
mutableList.set_vux3hl$(i, array[i]);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Kotlin.primitiveArraySort = function(array) {
|
||||
array.sort(Kotlin.primitiveCompareTo)
|
||||
};
|
||||
|
||||
var BaseOutput = Kotlin.createClassNow(null, null, {
|
||||
println: function (a) {
|
||||
if (typeof a !== "undefined") this.print(a);
|
||||
this.print("\n");
|
||||
},
|
||||
flush: function () {
|
||||
}
|
||||
Kotlin.copyToArray = function (collection) {
|
||||
if (typeof collection.toArray !== "undefined") return collection.toArray();
|
||||
return Kotlin.copyToArrayImpl(collection);
|
||||
};
|
||||
|
||||
Kotlin.copyToArrayImpl = function (collection) {
|
||||
var array = [];
|
||||
var it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
array.push(it.next());
|
||||
}
|
||||
|
||||
return array;
|
||||
};
|
||||
|
||||
Kotlin.splitString = function (str, regex, limit) {
|
||||
return str.split(new RegExp(regex), limit);
|
||||
};
|
||||
|
||||
Kotlin.nullArray = function (size) {
|
||||
var res = [];
|
||||
var i = size;
|
||||
while (i > 0) {
|
||||
res[--i] = null;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
Kotlin.numberArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.charArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return '\0';
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.booleanArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.longArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return Kotlin.Long.ZERO;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.arrayFromFun = function (size, initFun) {
|
||||
var result = new Array(size);
|
||||
for (var i = 0; i < size; i++) {
|
||||
result[i] = initFun(i);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
Kotlin.deleteProperty = function (object, property) {
|
||||
delete object[property];
|
||||
};
|
||||
|
||||
Kotlin.jsonAddProperties = function (obj1, obj2) {
|
||||
for (var p in obj2) {
|
||||
if (obj2.hasOwnProperty(p)) {
|
||||
obj1[p] = obj2[p];
|
||||
}
|
||||
);
|
||||
}
|
||||
return obj1;
|
||||
};
|
||||
|
||||
Kotlin.NodeJsOutput = Kotlin.createClassNow(BaseOutput,
|
||||
function(outputStream) {
|
||||
this.outputStream = outputStream;
|
||||
}, {
|
||||
print: function (a) {
|
||||
this.outputStream.write(a);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.OutputToConsoleLog = Kotlin.createClassNow(BaseOutput, null, {
|
||||
print: function (a) {
|
||||
console.log(a);
|
||||
},
|
||||
println: function (a) {
|
||||
this.print(typeof a !== "undefined" ? a : "");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.BufferedOutput = Kotlin.createClassNow(BaseOutput,
|
||||
function() {
|
||||
this.buffer = ""
|
||||
}, {
|
||||
print: function (a) {
|
||||
this.buffer += String(a);
|
||||
},
|
||||
flush: function () {
|
||||
this.buffer = "";
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.BufferedOutputToConsoleLog = Kotlin.createClassNow(Kotlin.BufferedOutput,
|
||||
function() {
|
||||
Kotlin.BufferedOutput.call(this);
|
||||
}, {
|
||||
print: function (a) {
|
||||
var s = String(a);
|
||||
|
||||
var i = s.lastIndexOf("\n");
|
||||
if (i != -1) {
|
||||
this.buffer += s.substr(0, i);
|
||||
|
||||
this.flush();
|
||||
|
||||
s = s.substr(i + 1);
|
||||
}
|
||||
|
||||
this.buffer += s;
|
||||
},
|
||||
flush: function () {
|
||||
console.log(this.buffer);
|
||||
this.buffer = "";
|
||||
}
|
||||
}
|
||||
);
|
||||
Kotlin.out = function() {
|
||||
var isNode = typeof process !== 'undefined' && process.versions && !!process.versions.node;
|
||||
|
||||
if (isNode) return new Kotlin.NodeJsOutput(process.stdout);
|
||||
|
||||
return new Kotlin.BufferedOutputToConsoleLog();
|
||||
}();
|
||||
|
||||
Kotlin.println = function (s) {
|
||||
Kotlin.out.println(s);
|
||||
};
|
||||
|
||||
Kotlin.print = function (s) {
|
||||
Kotlin.out.print(s);
|
||||
};
|
||||
|
||||
Kotlin.collectionsMax = function (c, comp) {
|
||||
if (c.isEmpty()) {
|
||||
//TODO: which exception?
|
||||
throw new Error();
|
||||
}
|
||||
var it = c.iterator();
|
||||
var max = it.next();
|
||||
while (it.hasNext()) {
|
||||
var el = it.next();
|
||||
if (comp.compare(max, el) < 0) {
|
||||
max = el;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
};
|
||||
|
||||
Kotlin.collectionsSort = function (mutableList, comparator) {
|
||||
var boundComparator = void 0;
|
||||
if (comparator !== void 0) {
|
||||
boundComparator = comparator.compare.bind(comparator);
|
||||
}
|
||||
|
||||
if (mutableList.size > 1) {
|
||||
var array = Kotlin.copyToArray(mutableList);
|
||||
|
||||
array.sort(boundComparator);
|
||||
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
mutableList.set_vux3hl$(i, array[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Kotlin.primitiveArraySort = function(array) {
|
||||
array.sort(Kotlin.primitiveCompareTo)
|
||||
};
|
||||
|
||||
Kotlin.copyToArray = function (collection) {
|
||||
if (typeof collection.toArray !== "undefined") return collection.toArray();
|
||||
return Kotlin.copyToArrayImpl(collection);
|
||||
};
|
||||
|
||||
Kotlin.copyToArrayImpl = function (collection) {
|
||||
var array = [];
|
||||
var it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
array.push(it.next());
|
||||
}
|
||||
|
||||
return array;
|
||||
};
|
||||
|
||||
Kotlin.splitString = function (str, regex, limit) {
|
||||
return str.split(new RegExp(regex), limit);
|
||||
};
|
||||
|
||||
Kotlin.nullArray = function (size) {
|
||||
var res = [];
|
||||
var i = size;
|
||||
while (i > 0) {
|
||||
res[--i] = null;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
Kotlin.numberArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.charArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return '\0';
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.booleanArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.longArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return Kotlin.Long.ZERO;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.arrayFromFun = function (size, initFun) {
|
||||
var result = new Array(size);
|
||||
for (var i = 0; i < size; i++) {
|
||||
result[i] = initFun(i);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
Kotlin.deleteProperty = function (object, property) {
|
||||
delete object[property];
|
||||
};
|
||||
|
||||
Kotlin.jsonAddProperties = function (obj1, obj2) {
|
||||
for (var p in obj2) {
|
||||
if (obj2.hasOwnProperty(p)) {
|
||||
obj1[p] = obj2[p];
|
||||
}
|
||||
}
|
||||
return obj1;
|
||||
};
|
||||
|
||||
Kotlin.identityHashCode = getObjectHashCode;
|
||||
})(Kotlin);
|
||||
Kotlin.identityHashCode = getObjectHashCode;
|
||||
|
||||
|
||||
Vendored
+798
-802
File diff suppressed because it is too large
Load Diff
-12
@@ -1,12 +0,0 @@
|
||||
var require = (function () {
|
||||
var builtins = module.exports.kotlin;
|
||||
var propertyNames = Object.getOwnPropertyNames(builtins);
|
||||
Kotlin.kotlin = Kotlin.kotlin || {};
|
||||
for (var i = 0; i < propertyNames.length; ++i) {
|
||||
var propertyName = propertyNames[i];
|
||||
Kotlin.kotlin[propertyName] = builtins[propertyName];
|
||||
}
|
||||
return function() {
|
||||
return Kotlin;
|
||||
}
|
||||
})();
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
(function () {
|
||||
var stdlib = module.exports;
|
||||
function copyProperties(from, to) {
|
||||
var propertyNames = Object.getOwnPropertyNames(from);
|
||||
for (var i = 0; i < propertyNames.length; ++i) {
|
||||
var propertyName = propertyNames[i];
|
||||
if (propertyName in to) {
|
||||
copyProperties(from[propertyName], to[propertyName]);
|
||||
}
|
||||
else {
|
||||
to[propertyName] = from[propertyName];
|
||||
}
|
||||
}
|
||||
}
|
||||
copyProperties(stdlib, Kotlin);
|
||||
})();
|
||||
+25
-20
@@ -1,24 +1,29 @@
|
||||
|
||||
var emulatedModules = { kotlin: kotlin };
|
||||
var module = { exports: {} };
|
||||
var emulatedModules = { kotlin: kotlin };
|
||||
var module = { exports: {} };
|
||||
|
||||
function require(moduleId) {
|
||||
return emulatedModules[moduleId];
|
||||
function require(moduleId) {
|
||||
return emulatedModules[moduleId];
|
||||
}
|
||||
|
||||
function __beginModule__() {
|
||||
module.exports = {};
|
||||
}
|
||||
|
||||
function __endModule__(moduleId) {
|
||||
emulatedModules[moduleId] = module.exports;
|
||||
}
|
||||
|
||||
function define(moduleId, dependencies, body) {
|
||||
var resolvedDependencies = [];
|
||||
emulatedModules[moduleId] = {};
|
||||
for (var i = 0; i < dependencies.length; ++i) {
|
||||
var dependencyName = dependencies[i];
|
||||
resolvedDependencies.push(emulatedModules[dependencyName === 'exports' ? moduleId : dependencyName]);
|
||||
}
|
||||
|
||||
function __beginModule__() {
|
||||
module.exports = {};
|
||||
var result = body.apply(null, resolvedDependencies);
|
||||
if (result != null) {
|
||||
emulatedModules[moduleId] = result;
|
||||
}
|
||||
|
||||
function __endModule__(moduleId) {
|
||||
emulatedModules[moduleId] = module.exports;
|
||||
}
|
||||
|
||||
function define(moduleId, dependencies, body) {
|
||||
var resolvedDependencies = [];
|
||||
for (var i = 0; i < dependencies.length; ++i) {
|
||||
resolvedDependencies.push(emulatedModules[dependencies[i]]);
|
||||
}
|
||||
emulatedModules[moduleId] = body.apply(null, resolvedDependencies);
|
||||
}
|
||||
define.amd = {};
|
||||
}
|
||||
define.amd = {};
|
||||
|
||||
Reference in New Issue
Block a user