| Index: utils/tip/tip.js
|
| diff --git a/utils/tip/tip.js b/utils/tip/tip.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3c82905e7ae0edeb38b32b4cdcc915ce57b7c661
|
| --- /dev/null
|
| +++ b/utils/tip/tip.js
|
| @@ -0,0 +1,15530 @@
|
| +// ********** Library dart:core **************
|
| +// ********** Natives dart:core **************
|
| +/**
|
| + * Generates a dynamic call stub for a function.
|
| + * Our goal is to create a stub method like this on-the-fly:
|
| + * function($0, $1, capture) { return this($0, $1, true, capture); }
|
| + *
|
| + * This stub then replaces the dynamic one on Function, with one that is
|
| + * specialized for that particular function, taking into account its default
|
| + * arguments.
|
| + */
|
| +Function.prototype.$genStub = function(argsLength, names) {
|
| + // Fast path: if no named arguments and arg count matches
|
| + if (this.length == argsLength && !names) {
|
| + return this;
|
| + }
|
| +
|
| + function $throwArgMismatch() {
|
| + // TODO(jmesserly): better error message
|
| + $throw(new ClosureArgumentMismatchException());
|
| + }
|
| +
|
| + var paramsNamed = this.$optional ? (this.$optional.length / 2) : 0;
|
| + var paramsBare = this.length - paramsNamed;
|
| + var argsNamed = names ? names.length : 0;
|
| + var argsBare = argsLength - argsNamed;
|
| +
|
| + // Check we got the right number of arguments
|
| + if (argsBare < paramsBare || argsLength > this.length ||
|
| + argsNamed > paramsNamed) {
|
| + return $throwArgMismatch;
|
| + }
|
| +
|
| + // First, fill in all of the default values
|
| + var p = new Array(paramsBare);
|
| + if (paramsNamed) {
|
| + p = p.concat(this.$optional.slice(paramsNamed));
|
| + }
|
| + // Fill in positional args
|
| + var a = new Array(argsLength);
|
| + for (var i = 0; i < argsBare; i++) {
|
| + p[i] = a[i] = '$' + i;
|
| + }
|
| + // Then overwrite with supplied values for optional args
|
| + var lastParameterIndex;
|
| + var namesInOrder = true;
|
| + for (var i = 0; i < argsNamed; i++) {
|
| + var name = names[i];
|
| + a[i + argsBare] = name;
|
| + var j = this.$optional.indexOf(name);
|
| + if (j < 0 || j >= paramsNamed) {
|
| + return $throwArgMismatch;
|
| + } else if (lastParameterIndex && lastParameterIndex > j) {
|
| + namesInOrder = false;
|
| + }
|
| + p[j + paramsBare] = name;
|
| + lastParameterIndex = j;
|
| + }
|
| +
|
| + if (this.length == argsLength && namesInOrder) {
|
| + // Fast path #2: named arguments, but they're in order.
|
| + return this;
|
| + }
|
| +
|
| + // Note: using Function instead of 'eval' to get a clean scope.
|
| + // TODO(jmesserly): evaluate the performance of these stubs.
|
| + var f = 'function(' + a.join(',') + '){return $f(' + p.join(',') + ');}';
|
| + return new Function('$f', 'return ' + f + '').call(null, this);
|
| +}
|
| +function $throw(e) {
|
| + // If e is not a value, we can use V8's captureStackTrace utility method.
|
| + // TODO(jmesserly): capture the stack trace on other JS engines.
|
| + if (e && (typeof e == 'object') && Error.captureStackTrace) {
|
| + // TODO(jmesserly): this will clobber the e.stack property
|
| + Error.captureStackTrace(e, $throw);
|
| + }
|
| + throw e;
|
| +}
|
| +Object.prototype.$index = function(i) {
|
| + var proto = Object.getPrototypeOf(this);
|
| + if (proto !== Object) {
|
| + proto.$index = function(i) { return this[i]; }
|
| + }
|
| + return this[i];
|
| +}
|
| +Array.prototype.$index = function(i) { return this[i]; }
|
| +String.prototype.$index = function(i) { return this[i]; }
|
| +Object.prototype.$setindex = function(i, value) {
|
| + var proto = Object.getPrototypeOf(this);
|
| + if (proto !== Object) {
|
| + proto.$setindex = function(i, value) { return this[i] = value; }
|
| + }
|
| + return this[i] = value;
|
| +}
|
| +Array.prototype.$setindex = function(i, value) { return this[i] = value; }
|
| +function $wrap_call$0(fn) { return fn; }
|
| +function $wrap_call$1(fn) { return fn; }
|
| +function $eq(x, y) {
|
| + if (x == null) return y == null;
|
| + return (typeof(x) == 'number' && typeof(y) == 'number') ||
|
| + (typeof(x) == 'boolean' && typeof(y) == 'boolean') ||
|
| + (typeof(x) == 'string' && typeof(y) == 'string')
|
| + ? x == y : x.$eq(y);
|
| +}
|
| +// TODO(jimhug): Should this or should it not match equals?
|
| +Object.prototype.$eq = function(other) { return this === other; }
|
| +function $mod(x, y) {
|
| + if (typeof(x) == 'number' && typeof(y) == 'number') {
|
| + var result = x % y;
|
| + if (result == 0) {
|
| + return 0; // Make sure we don't return -0.0.
|
| + } else if (result < 0) {
|
| + if (y < 0) {
|
| + return result - y;
|
| + } else {
|
| + return result + y;
|
| + }
|
| + }
|
| + return result;
|
| + } else {
|
| + return x.$mod(y);
|
| + }
|
| +}
|
| +function $ne(x, y) {
|
| + if (x == null) return y != null;
|
| + return (typeof(x) == 'number' && typeof(y) == 'number') ||
|
| + (typeof(x) == 'boolean' && typeof(y) == 'boolean') ||
|
| + (typeof(x) == 'string' && typeof(y) == 'string')
|
| + ? x != y : !x.$eq(y);
|
| +}
|
| +function $truncdiv(x, y) {
|
| + if (typeof(x) == 'number' && typeof(y) == 'number') {
|
| + if (y == 0) $throw(new IntegerDivisionByZeroException());
|
| + var tmp = x / y;
|
| + return (tmp < 0) ? Math.ceil(tmp) : Math.floor(tmp);
|
| + } else {
|
| + return x.$truncdiv(y);
|
| + }
|
| +}
|
| +// ********** Code for Object **************
|
| +Object.prototype.get$dynamic = function() {
|
| + return this;
|
| +}
|
| +Object.prototype.noSuchMethod = function(name, args) {
|
| + $throw(new NoSuchMethodException(this, name, args));
|
| +}
|
| +Object.prototype._checkExtends$0 = function() {
|
| + return this.noSuchMethod("_checkExtends", []);
|
| +};
|
| +Object.prototype._checkNonStatic$1 = function($0) {
|
| + return this.noSuchMethod("_checkNonStatic", [$0]);
|
| +};
|
| +Object.prototype._get$3 = function($0, $1, $2) {
|
| + return this.noSuchMethod("_get", [$0, $1, $2]);
|
| +};
|
| +Object.prototype._get$3$isDynamic = function($0, $1, $2, isDynamic) {
|
| + return this.noSuchMethod("_get", [$0, $1, $2, isDynamic]);
|
| +};
|
| +Object.prototype._get$4 = function($0, $1, $2, $3) {
|
| + return this.noSuchMethod("_get", [$0, $1, $2, $3]);
|
| +};
|
| +Object.prototype._redraw$0 = function() {
|
| + return this.noSuchMethod("_redraw", []);
|
| +};
|
| +Object.prototype._set$4 = function($0, $1, $2, $3) {
|
| + return this.noSuchMethod("_set", [$0, $1, $2, $3]);
|
| +};
|
| +Object.prototype._set$4$isDynamic = function($0, $1, $2, $3, isDynamic) {
|
| + return this.noSuchMethod("_set", [$0, $1, $2, $3, isDynamic]);
|
| +};
|
| +Object.prototype._set$5 = function($0, $1, $2, $3, $4) {
|
| + return this.noSuchMethod("_set", [$0, $1, $2, $3, $4]);
|
| +};
|
| +Object.prototype._wrapDomCallback$2 = function($0, $1) {
|
| + return this.noSuchMethod("_wrapDomCallback", [$0, $1]);
|
| +};
|
| +Object.prototype.add$1 = function($0) {
|
| + return this.noSuchMethod("add", [$0]);
|
| +};
|
| +Object.prototype.addAll$1 = function($0) {
|
| + return this.noSuchMethod("addAll", [$0]);
|
| +};
|
| +Object.prototype.addDirectSubtype$1 = function($0) {
|
| + return this.noSuchMethod("addDirectSubtype", [$0]);
|
| +};
|
| +Object.prototype.addEventListener$3 = function($0, $1, $2) {
|
| + return this.noSuchMethod("addEventListener", [$0, $1, $2]);
|
| +};
|
| +Object.prototype.addMessage$1 = function($0) {
|
| + return this.noSuchMethod("addMessage", [$0]);
|
| +};
|
| +Object.prototype.addMethod$2 = function($0, $1) {
|
| + return this.noSuchMethod("addMethod", [$0, $1]);
|
| +};
|
| +Object.prototype.addSource$1 = function($0) {
|
| + return this.noSuchMethod("addSource", [$0]);
|
| +};
|
| +Object.prototype.appendChild$1 = function($0) {
|
| + return this.noSuchMethod("appendChild", [$0]);
|
| +};
|
| +Object.prototype.block$0 = function() {
|
| + return this.noSuchMethod("block", []);
|
| +};
|
| +Object.prototype.canInvoke$2 = function($0, $1) {
|
| + return this.noSuchMethod("canInvoke", [$0, $1]);
|
| +};
|
| +Object.prototype.checkFirstClass$1 = function($0) {
|
| + return this.noSuchMethod("checkFirstClass", [$0]);
|
| +};
|
| +Object.prototype.clear$0 = function() {
|
| + return this.noSuchMethod("clear", []);
|
| +};
|
| +Object.prototype.compareTo$1 = function($0) {
|
| + return this.noSuchMethod("compareTo", [$0]);
|
| +};
|
| +Object.prototype.compilationUnit$0 = function() {
|
| + return this.noSuchMethod("compilationUnit", []);
|
| +};
|
| +Object.prototype.computeValue$0 = function() {
|
| + return this.noSuchMethod("computeValue", []);
|
| +};
|
| +Object.prototype.contains$1 = function($0) {
|
| + return this.noSuchMethod("contains", [$0]);
|
| +};
|
| +Object.prototype.containsKey$1 = function($0) {
|
| + return this.noSuchMethod("containsKey", [$0]);
|
| +};
|
| +Object.prototype.convertTo$3 = function($0, $1, $2) {
|
| + return this.noSuchMethod("convertTo", [$0, $1, $2]);
|
| +};
|
| +Object.prototype.convertTo$4 = function($0, $1, $2, $3) {
|
| + return this.noSuchMethod("convertTo", [$0, $1, $2, $3]);
|
| +};
|
| +Object.prototype.copyWithNewType$2 = function($0, $1) {
|
| + return this.noSuchMethod("copyWithNewType", [$0, $1]);
|
| +};
|
| +Object.prototype.delete$2 = function($0, $1) {
|
| + return this.noSuchMethod("delete", [$0, $1]);
|
| +};
|
| +Object.prototype.end$0 = function() {
|
| + return this.noSuchMethod("end", []);
|
| +};
|
| +Object.prototype.endsWith$1 = function($0) {
|
| + return this.noSuchMethod("endsWith", [$0]);
|
| +};
|
| +Object.prototype.ensureSubtypeOf$3 = function($0, $1, $2) {
|
| + return this.noSuchMethod("ensureSubtypeOf", [$0, $1, $2]);
|
| +};
|
| +Object.prototype.every$1 = function($0) {
|
| + return this.noSuchMethod("every", [$0]);
|
| +};
|
| +Object.prototype.filter$1 = function($0) {
|
| + return this.noSuchMethod("filter", [$0]);
|
| +};
|
| +Object.prototype.findTypeByName$1 = function($0) {
|
| + return this.noSuchMethod("findTypeByName", [$0]);
|
| +};
|
| +Object.prototype.focus$0 = function() {
|
| + return this.noSuchMethod("focus", []);
|
| +};
|
| +Object.prototype.forEach$1 = function($0) {
|
| + return this.noSuchMethod("forEach", [$0]);
|
| +};
|
| +Object.prototype.genValue$2 = function($0, $1) {
|
| + return this.noSuchMethod("genValue", [$0, $1]);
|
| +};
|
| +Object.prototype.generate$1 = function($0) {
|
| + return this.noSuchMethod("generate", [$0]);
|
| +};
|
| +Object.prototype.getBoundingClientRect$0 = function() {
|
| + return this.noSuchMethod("getBoundingClientRect", []);
|
| +};
|
| +Object.prototype.getColumn$2 = function($0, $1) {
|
| + return this.noSuchMethod("getColumn", [$0, $1]);
|
| +};
|
| +Object.prototype.getConstructor$1 = function($0) {
|
| + return this.noSuchMethod("getConstructor", [$0]);
|
| +};
|
| +Object.prototype.getFactory$2 = function($0, $1) {
|
| + return this.noSuchMethod("getFactory", [$0, $1]);
|
| +};
|
| +Object.prototype.getKeys$0 = function() {
|
| + return this.noSuchMethod("getKeys", []);
|
| +};
|
| +Object.prototype.getLine$1 = function($0) {
|
| + return this.noSuchMethod("getLine", [$0]);
|
| +};
|
| +Object.prototype.getLineColumn$1 = function($0) {
|
| + return this.noSuchMethod("getLineColumn", [$0]);
|
| +};
|
| +Object.prototype.getMember$1 = function($0) {
|
| + return this.noSuchMethod("getMember", [$0]);
|
| +};
|
| +Object.prototype.getOrMakeConcreteType$1 = function($0) {
|
| + return this.noSuchMethod("getOrMakeConcreteType", [$0]);
|
| +};
|
| +Object.prototype.getPosition$2 = function($0, $1) {
|
| + return this.noSuchMethod("getPosition", [$0, $1]);
|
| +};
|
| +Object.prototype.getValues$0 = function() {
|
| + return this.noSuchMethod("getValues", []);
|
| +};
|
| +Object.prototype.get_$3 = function($0, $1, $2) {
|
| + return this.noSuchMethod("get_", [$0, $1, $2]);
|
| +};
|
| +Object.prototype.hasNext$0 = function() {
|
| + return this.noSuchMethod("hasNext", []);
|
| +};
|
| +Object.prototype.hashCode$0 = function() {
|
| + return this.noSuchMethod("hashCode", []);
|
| +};
|
| +Object.prototype.indexOf$1 = function($0) {
|
| + return this.noSuchMethod("indexOf", [$0]);
|
| +};
|
| +Object.prototype.insertBefore$2 = function($0, $1) {
|
| + return this.noSuchMethod("insertBefore", [$0, $1]);
|
| +};
|
| +Object.prototype.insertText$2 = function($0, $1) {
|
| + return this.noSuchMethod("insertText", [$0, $1]);
|
| +};
|
| +Object.prototype.instanceOf$3$isTrue$forceCheck = function($0, $1, $2, isTrue, forceCheck) {
|
| + return this.noSuchMethod("instanceOf", [$0, $1, $2, isTrue, forceCheck]);
|
| +};
|
| +Object.prototype.instanceOf$4 = function($0, $1, $2, $3) {
|
| + return this.noSuchMethod("instanceOf", [$0, $1, $2, $3]);
|
| +};
|
| +Object.prototype.invoke$4 = function($0, $1, $2, $3) {
|
| + return this.noSuchMethod("invoke", [$0, $1, $2, $3]);
|
| +};
|
| +Object.prototype.invoke$4$isDynamic = function($0, $1, $2, $3, isDynamic) {
|
| + return this.noSuchMethod("invoke", [$0, $1, $2, $3, isDynamic]);
|
| +};
|
| +Object.prototype.invoke$5 = function($0, $1, $2, $3, $4) {
|
| + return this.noSuchMethod("invoke", [$0, $1, $2, $3, $4]);
|
| +};
|
| +Object.prototype.is$List = function() {
|
| + return false;
|
| +};
|
| +Object.prototype.is$RegExp = function() {
|
| + return false;
|
| +};
|
| +Object.prototype.isAssignable$1 = function($0) {
|
| + return this.noSuchMethod("isAssignable", [$0]);
|
| +};
|
| +Object.prototype.isEmpty$0 = function() {
|
| + return this.noSuchMethod("isEmpty", []);
|
| +};
|
| +Object.prototype.isSubtypeOf$1 = function($0) {
|
| + return this.noSuchMethod("isSubtypeOf", [$0]);
|
| +};
|
| +Object.prototype.iterator$0 = function() {
|
| + return this.noSuchMethod("iterator", []);
|
| +};
|
| +Object.prototype.last$0 = function() {
|
| + return this.noSuchMethod("last", []);
|
| +};
|
| +Object.prototype.markUsed$0 = function() {
|
| + return this.noSuchMethod("markUsed", []);
|
| +};
|
| +Object.prototype.moveToOffset$1 = function($0) {
|
| + return this.noSuchMethod("moveToOffset", [$0]);
|
| +};
|
| +Object.prototype.namesInOrder$1 = function($0) {
|
| + return this.noSuchMethod("namesInOrder", [$0]);
|
| +};
|
| +Object.prototype.needsConversion$1 = function($0) {
|
| + return this.noSuchMethod("needsConversion", [$0]);
|
| +};
|
| +Object.prototype.next$0 = function() {
|
| + return this.noSuchMethod("next", []);
|
| +};
|
| +Object.prototype.offsetToPoint$1 = function($0) {
|
| + return this.noSuchMethod("offsetToPoint", [$0]);
|
| +};
|
| +Object.prototype.positionFromPoint$2 = function($0, $1) {
|
| + return this.noSuchMethod("positionFromPoint", [$0, $1]);
|
| +};
|
| +Object.prototype.provideFieldSyntax$0 = function() {
|
| + return this.noSuchMethod("provideFieldSyntax", []);
|
| +};
|
| +Object.prototype.providePropertySyntax$0 = function() {
|
| + return this.noSuchMethod("providePropertySyntax", []);
|
| +};
|
| +Object.prototype.removeChild$1 = function($0) {
|
| + return this.noSuchMethod("removeChild", [$0]);
|
| +};
|
| +Object.prototype.removeLast$0 = function() {
|
| + return this.noSuchMethod("removeLast", []);
|
| +};
|
| +Object.prototype.replaceAll$2 = function($0, $1) {
|
| + return this.noSuchMethod("replaceAll", [$0, $1]);
|
| +};
|
| +Object.prototype.replaceFirst$2 = function($0, $1) {
|
| + return this.noSuchMethod("replaceFirst", [$0, $1]);
|
| +};
|
| +Object.prototype.resolve$0 = function() {
|
| + return this.noSuchMethod("resolve", []);
|
| +};
|
| +Object.prototype.resolveTypeParams$1 = function($0) {
|
| + return this.noSuchMethod("resolveTypeParams", [$0]);
|
| +};
|
| +Object.prototype.select$0 = function() {
|
| + return this.noSuchMethod("select", []);
|
| +};
|
| +Object.prototype.setDefinition$1 = function($0) {
|
| + return this.noSuchMethod("setDefinition", [$0]);
|
| +};
|
| +Object.prototype.setProperty$2 = function($0, $1) {
|
| + return this.noSuchMethod("setProperty", [$0, $1]);
|
| +};
|
| +Object.prototype.set_$4 = function($0, $1, $2, $3) {
|
| + return this.noSuchMethod("set_", [$0, $1, $2, $3]);
|
| +};
|
| +Object.prototype.some$1 = function($0) {
|
| + return this.noSuchMethod("some", [$0]);
|
| +};
|
| +Object.prototype.sort$1 = function($0) {
|
| + return this.noSuchMethod("sort", [$0]);
|
| +};
|
| +Object.prototype.start$0 = function() {
|
| + return this.noSuchMethod("start", []);
|
| +};
|
| +Object.prototype.startsWith$1 = function($0) {
|
| + return this.noSuchMethod("startsWith", [$0]);
|
| +};
|
| +Object.prototype.substring$1 = function($0) {
|
| + return this.noSuchMethod("substring", [$0]);
|
| +};
|
| +Object.prototype.substring$2 = function($0, $1) {
|
| + return this.noSuchMethod("substring", [$0, $1]);
|
| +};
|
| +Object.prototype.toLeaf$0 = function() {
|
| + return this.noSuchMethod("toLeaf", []);
|
| +};
|
| +Object.prototype.toRoot$0 = function() {
|
| + return this.noSuchMethod("toRoot", []);
|
| +};
|
| +Object.prototype.toString$0 = function() {
|
| + return this.toString();
|
| +};
|
| +Object.prototype.tokenizeInto$2 = function($0, $1) {
|
| + return this.noSuchMethod("tokenizeInto", [$0, $1]);
|
| +};
|
| +Object.prototype.visit$1 = function($0) {
|
| + return this.noSuchMethod("visit", [$0]);
|
| +};
|
| +Object.prototype.visitBinaryExpression$1 = function($0) {
|
| + return this.noSuchMethod("visitBinaryExpression", [$0]);
|
| +};
|
| +Object.prototype.visitPostfixExpression$1 = function($0) {
|
| + return this.noSuchMethod("visitPostfixExpression", [$0]);
|
| +};
|
| +Object.prototype.visitSources$0 = function() {
|
| + return this.noSuchMethod("visitSources", []);
|
| +};
|
| +Object.prototype.writeDefinition$2 = function($0, $1) {
|
| + return this.noSuchMethod("writeDefinition", [$0, $1]);
|
| +};
|
| +// ********** Code for Clock **************
|
| +function Clock() {}
|
| +Clock.now = function() {
|
| + return new Date().getTime();
|
| +}
|
| +Clock.frequency = function() {
|
| + return 1000;
|
| +}
|
| +// ********** Code for IllegalAccessException **************
|
| +function IllegalAccessException() {
|
| + // Initializers done
|
| +}
|
| +IllegalAccessException.prototype.toString = function() {
|
| + return "Attempt to modify an immutable object";
|
| +}
|
| +IllegalAccessException.prototype.toString$0 = IllegalAccessException.prototype.toString;
|
| +// ********** Code for NoSuchMethodException **************
|
| +function NoSuchMethodException(_receiver, _functionName, _arguments) {
|
| + this._receiver = _receiver;
|
| + this._functionName = _functionName;
|
| + this._arguments = _arguments;
|
| + // Initializers done
|
| +}
|
| +NoSuchMethodException.prototype.toString = function() {
|
| + var sb = new StringBufferImpl("");
|
| + for (var i = 0;
|
| + i < this._arguments.length; i++) {
|
| + if (i > 0) {
|
| + sb.add(", ");
|
| + }
|
| + sb.add(this._arguments.$index(i));
|
| + }
|
| + sb.add("]");
|
| + return ("NoSuchMethodException - receiver: '" + this._receiver + "' ") + ("function name: '" + this._functionName + "' arguments: [" + sb + "]");
|
| +}
|
| +NoSuchMethodException.prototype.toString$0 = NoSuchMethodException.prototype.toString;
|
| +// ********** Code for ObjectNotClosureException **************
|
| +function ObjectNotClosureException() {
|
| + // Initializers done
|
| +}
|
| +ObjectNotClosureException.prototype.toString = function() {
|
| + return "Object is not closure";
|
| +}
|
| +ObjectNotClosureException.prototype.toString$0 = ObjectNotClosureException.prototype.toString;
|
| +// ********** Code for StackOverflowException **************
|
| +function StackOverflowException() {
|
| + // Initializers done
|
| +}
|
| +StackOverflowException.prototype.toString = function() {
|
| + return "Stack Overflow";
|
| +}
|
| +StackOverflowException.prototype.toString$0 = StackOverflowException.prototype.toString;
|
| +// ********** Code for BadNumberFormatException **************
|
| +function BadNumberFormatException() {}
|
| +BadNumberFormatException.prototype.toString = function() {
|
| + return ("BadNumberFormatException: '" + this._s + "'");
|
| +}
|
| +BadNumberFormatException.prototype.toString$0 = BadNumberFormatException.prototype.toString;
|
| +// ********** Code for NullPointerException **************
|
| +function NullPointerException() {
|
| + // Initializers done
|
| +}
|
| +NullPointerException.prototype.toString = function() {
|
| + return "NullPointerException";
|
| +}
|
| +NullPointerException.prototype.toString$0 = NullPointerException.prototype.toString;
|
| +// ********** Code for NoMoreElementsException **************
|
| +function NoMoreElementsException() {
|
| + // Initializers done
|
| +}
|
| +NoMoreElementsException.prototype.toString = function() {
|
| + return "NoMoreElementsException";
|
| +}
|
| +NoMoreElementsException.prototype.toString$0 = NoMoreElementsException.prototype.toString;
|
| +// ********** Code for EmptyQueueException **************
|
| +function EmptyQueueException() {
|
| + // Initializers done
|
| +}
|
| +EmptyQueueException.prototype.toString = function() {
|
| + return "EmptyQueueException";
|
| +}
|
| +EmptyQueueException.prototype.toString$0 = EmptyQueueException.prototype.toString;
|
| +// ********** Code for UnsupportedOperationException **************
|
| +function UnsupportedOperationException(_message) {
|
| + this._dart_core_message = _message;
|
| + // Initializers done
|
| +}
|
| +UnsupportedOperationException.prototype.toString = function() {
|
| + return ("UnsupportedOperationException: " + this._dart_core_message);
|
| +}
|
| +UnsupportedOperationException.prototype.toString$0 = UnsupportedOperationException.prototype.toString;
|
| +// ********** Code for Function **************
|
| +Function.prototype.to$call$0 = function() {
|
| + this.call$0 = this.$genStub(0);
|
| + this.to$call$0 = function() { return this.call$0; };
|
| + return this.call$0;
|
| +};
|
| +Function.prototype.call$0 = function() {
|
| + return this.to$call$0()();
|
| +};
|
| +function to$call$0(f) { return f && f.to$call$0(); }
|
| +Function.prototype.to$call$1 = function() {
|
| + this.call$1 = this.$genStub(1);
|
| + this.to$call$1 = function() { return this.call$1; };
|
| + return this.call$1;
|
| +};
|
| +Function.prototype.call$1 = function($0) {
|
| + return this.to$call$1()($0);
|
| +};
|
| +function to$call$1(f) { return f && f.to$call$1(); }
|
| +Function.prototype.to$call$2 = function() {
|
| + this.call$2 = this.$genStub(2);
|
| + this.to$call$2 = function() { return this.call$2; };
|
| + return this.call$2;
|
| +};
|
| +Function.prototype.call$2 = function($0, $1) {
|
| + return this.to$call$2()($0, $1);
|
| +};
|
| +function to$call$2(f) { return f && f.to$call$2(); }
|
| +// ********** Code for Math **************
|
| +Math.parseInt = function(str) {
|
| + var ret = parseInt(str);
|
| + if (isNaN(ret)) $throw(new BadNumberFormatException(str));
|
| + return ret;
|
| +}
|
| +Math.parseDouble = function(str) {
|
| + var ret = parseFloat(str);
|
| + if (isNaN(ret) && str != 'NaN') $throw(new BadNumberFormatException(str));
|
| + return ret;
|
| +}
|
| +Math.min = function(a, b) {
|
| + if (a == b) return a;
|
| + if (a < b) {
|
| + if (isNaN(b)) return b;
|
| + else return a;
|
| + }
|
| + if (isNaN(a)) return a;
|
| + else return b;
|
| +}
|
| +Math.max = function(a, b) {
|
| + return (a >= b) ? a : b;
|
| +}
|
| +// ********** Code for Strings **************
|
| +function Strings() {}
|
| +Strings.String$fromCharCodes$factory = function(charCodes) {
|
| + return StringBase.createFromCharCodes(charCodes);
|
| +}
|
| +Strings.join = function(strings, separator) {
|
| + return StringBase.join(strings, separator);
|
| +}
|
| +// ********** Code for top level **************
|
| +function print(obj) {
|
| + return _print(obj);
|
| +}
|
| +function _print(obj) {
|
| + if (typeof console == 'object') {
|
| + if (obj) obj = obj.toString();
|
| + console.log(obj);
|
| + } else {
|
| + write(obj);
|
| + write('\n');
|
| + }
|
| +}
|
| +function _map(itemsAndKeys) {
|
| + var ret = new LinkedHashMapImplementation();
|
| + for (var i = 0;
|
| + i < itemsAndKeys.length; ) {
|
| + ret.$setindex(itemsAndKeys.$index(i++), itemsAndKeys.$index(i++));
|
| + }
|
| + return ret;
|
| +}
|
| +function _constMap(itemsAndKeys) {
|
| + return new ImmutableMap(itemsAndKeys);
|
| +}
|
| +function _toDartException(e) {
|
| + function attachStack(dartEx) {
|
| + // TODO(jmesserly): setting the stack property is not a long term solution.
|
| + var stack = e.stack;
|
| + // The stack contains the error message, and the stack is all that is
|
| + // printed (the exception's toString() is never called). Make the Dart
|
| + // exception's toString() be the dominant message.
|
| + if (typeof stack == 'string') {
|
| + var message = dartEx.toString();
|
| + if (/^(Type|Range)Error:/.test(stack)) {
|
| + // Indent JS message (it can be helpful) so new message stands out.
|
| + stack = ' (' + stack.substring(0, stack.indexOf('\n')) + ')\n' +
|
| + stack.substring(stack.indexOf('\n') + 1);
|
| + }
|
| + stack = message + '\n' + stack;
|
| + }
|
| + dartEx.stack = stack;
|
| + return dartEx;
|
| + }
|
| +
|
| + if (e instanceof TypeError) {
|
| + switch(e.type) {
|
| + case 'property_not_function':
|
| + case 'called_non_callable':
|
| + if (e.arguments[0] == null) {
|
| + return attachStack(new NullPointerException());
|
| + } else {
|
| + return attachStack(new ObjectNotClosureException());
|
| + }
|
| + break;
|
| + case 'non_object_property_call':
|
| + case 'non_object_property_load':
|
| + return attachStack(new NullPointerException());
|
| + break;
|
| + case 'undefined_method':
|
| + var mname = e.arguments[0];
|
| + if (typeof(mname) == 'string' && (mname.indexOf('call$') == 0
|
| + || mname == 'call' || mname == 'apply')) {
|
| + return attachStack(new ObjectNotClosureException());
|
| + } else {
|
| + // TODO(jmesserly): fix noSuchMethod on operators so we don't hit this
|
| + return attachStack(new NoSuchMethodException('', e.arguments[0], []));
|
| + }
|
| + break;
|
| + }
|
| + } else if (e instanceof RangeError) {
|
| + if (e.message.indexOf('call stack') >= 0) {
|
| + return attachStack(new StackOverflowException());
|
| + }
|
| + }
|
| + return e;
|
| +}
|
| +// ********** Library dart:coreimpl **************
|
| +// ********** Code for ListFactory **************
|
| +ListFactory = Array;
|
| +ListFactory.prototype.is$List = function(){return true};
|
| +ListFactory.ListFactory$from$factory = function(other) {
|
| + var list = [];
|
| + for (var $$i = other.iterator(); $$i.hasNext$0(); ) {
|
| + var e = $$i.next$0();
|
| + list.add(e);
|
| + }
|
| + return list;
|
| +}
|
| +ListFactory.prototype.add = function(value) {
|
| + this.push(value);
|
| +}
|
| +ListFactory.prototype.addLast = function(value) {
|
| + this.push(value);
|
| +}
|
| +ListFactory.prototype.addAll = function(collection) {
|
| + for (var $$i = collection.iterator(); $$i.hasNext$0(); ) {
|
| + var item = $$i.next$0();
|
| + this.add(item);
|
| + }
|
| +}
|
| +ListFactory.prototype.clear = function() {
|
| + this.length = 0;
|
| +}
|
| +ListFactory.prototype.removeLast = function() {
|
| + return this.pop();
|
| +}
|
| +ListFactory.prototype.last = function() {
|
| + return this[this.length - 1];
|
| +}
|
| +ListFactory.prototype.getRange = function(start, length) {
|
| + return this.slice(start, start + length);
|
| +}
|
| +ListFactory.prototype.isEmpty = function() {
|
| + return this.length == 0;
|
| +}
|
| +ListFactory.prototype.iterator = function() {
|
| + return new ListIterator(this);
|
| +}
|
| +ListFactory.prototype.add$1 = ListFactory.prototype.add;
|
| +ListFactory.prototype.addAll$1 = ListFactory.prototype.addAll;
|
| +ListFactory.prototype.clear$0 = ListFactory.prototype.clear;
|
| +ListFactory.prototype.every$1 = function($0) {
|
| + return this.every(to$call$1($0));
|
| +};
|
| +ListFactory.prototype.filter$1 = function($0) {
|
| + return this.filter(to$call$1($0));
|
| +};
|
| +ListFactory.prototype.forEach$1 = function($0) {
|
| + return this.forEach(to$call$1($0));
|
| +};
|
| +ListFactory.prototype.indexOf$1 = ListFactory.prototype.indexOf;
|
| +ListFactory.prototype.isEmpty$0 = ListFactory.prototype.isEmpty;
|
| +ListFactory.prototype.iterator$0 = ListFactory.prototype.iterator;
|
| +ListFactory.prototype.last$0 = ListFactory.prototype.last;
|
| +ListFactory.prototype.removeLast$0 = ListFactory.prototype.removeLast;
|
| +ListFactory.prototype.some$1 = function($0) {
|
| + return this.some(to$call$1($0));
|
| +};
|
| +ListFactory.prototype.sort$1 = function($0) {
|
| + return this.sort(to$call$2($0));
|
| +};
|
| +ListFactory_E = ListFactory;
|
| +ListFactory_K = ListFactory;
|
| +ListFactory_String = ListFactory;
|
| +ListFactory_V = ListFactory;
|
| +ListFactory_int = ListFactory;
|
| +// ********** Code for ListIterator **************
|
| +function ListIterator(array) {
|
| + this._array = array;
|
| + this._dart_coreimpl_pos = 0;
|
| + // Initializers done
|
| +}
|
| +ListIterator.prototype.hasNext = function() {
|
| + return this._array.length > this._dart_coreimpl_pos;
|
| +}
|
| +ListIterator.prototype.next = function() {
|
| + if (!this.hasNext()) {
|
| + $throw(const$1/*const NoMoreElementsException()*/);
|
| + }
|
| + return this._array.$index(this._dart_coreimpl_pos++);
|
| +}
|
| +ListIterator.prototype.hasNext$0 = ListIterator.prototype.hasNext;
|
| +ListIterator.prototype.next$0 = ListIterator.prototype.next;
|
| +// ********** Code for ImmutableList **************
|
| +/** Implements extends for Dart classes on JavaScript prototypes. */
|
| +function $inherits(child, parent) {
|
| + if (child.prototype.__proto__) {
|
| + child.prototype.__proto__ = parent.prototype;
|
| + } else {
|
| + function tmp() {};
|
| + tmp.prototype = parent.prototype;
|
| + child.prototype = new tmp();
|
| + child.prototype.constructor = child;
|
| + }
|
| +}
|
| +$inherits(ImmutableList, ListFactory_E);
|
| +function ImmutableList(length) {
|
| + this._length = length;
|
| + // Initializers done
|
| + ListFactory_E.call(this, length);
|
| +}
|
| +ImmutableList.ImmutableList$from$factory = function(other) {
|
| + var list = new ImmutableList(other.length);
|
| + for (var i = 0;
|
| + i < other.length; i++) {
|
| + list._setindex(i, other.$index(i));
|
| + }
|
| + return list;
|
| +}
|
| +ImmutableList.prototype.get$length = function() {
|
| + return this._length;
|
| +}
|
| +ImmutableList.prototype.set$length = function(length) {
|
| + $throw(const$143/*const IllegalAccessException()*/);
|
| +}
|
| +Object.defineProperty(ImmutableList.prototype, "length", {
|
| + get: ImmutableList.prototype.get$length,
|
| + set: ImmutableList.prototype.set$length
|
| +});
|
| +ImmutableList.prototype._setindex = function(index, value) {
|
| + return this[index] = value;
|
| +}
|
| +ImmutableList.prototype.$setindex = function(index, value) {
|
| + $throw(const$143/*const IllegalAccessException()*/);
|
| +}
|
| +ImmutableList.prototype.sort = function(compare) {
|
| + $throw(const$143/*const IllegalAccessException()*/);
|
| +}
|
| +ImmutableList.prototype.add = function(element) {
|
| + $throw(const$143/*const IllegalAccessException()*/);
|
| +}
|
| +ImmutableList.prototype.addLast = function(element) {
|
| + $throw(const$143/*const IllegalAccessException()*/);
|
| +}
|
| +ImmutableList.prototype.addAll = function(elements) {
|
| + $throw(const$143/*const IllegalAccessException()*/);
|
| +}
|
| +ImmutableList.prototype.clear = function() {
|
| + $throw(const$143/*const IllegalAccessException()*/);
|
| +}
|
| +ImmutableList.prototype.removeLast = function() {
|
| + $throw(const$143/*const IllegalAccessException()*/);
|
| +}
|
| +ImmutableList.prototype.toString = function() {
|
| + return ListFactory.ListFactory$from$factory(this).toString();
|
| +}
|
| +ImmutableList.prototype.add$1 = ImmutableList.prototype.add;
|
| +ImmutableList.prototype.addAll$1 = ImmutableList.prototype.addAll;
|
| +ImmutableList.prototype.clear$0 = ImmutableList.prototype.clear;
|
| +ImmutableList.prototype.removeLast$0 = ImmutableList.prototype.removeLast;
|
| +ImmutableList.prototype.sort$1 = function($0) {
|
| + return this.sort(to$call$2($0));
|
| +};
|
| +ImmutableList.prototype.toString$0 = ImmutableList.prototype.toString;
|
| +// ********** Code for ImmutableMap **************
|
| +function ImmutableMap(keyValuePairs) {
|
| + this._internal = _map(keyValuePairs);
|
| + // Initializers done
|
| +}
|
| +ImmutableMap.prototype.$index = function(key) {
|
| + return this._internal.$index(key);
|
| +}
|
| +ImmutableMap.prototype.isEmpty = function() {
|
| + return this._internal.isEmpty();
|
| +}
|
| +ImmutableMap.prototype.get$length = function() {
|
| + return this._internal.get$length();
|
| +}
|
| +Object.defineProperty(ImmutableMap.prototype, "length", {
|
| + get: ImmutableMap.prototype.get$length
|
| +});
|
| +ImmutableMap.prototype.forEach = function(f) {
|
| + this._internal.forEach(f);
|
| +}
|
| +ImmutableMap.prototype.getKeys = function() {
|
| + return this._internal.getKeys();
|
| +}
|
| +ImmutableMap.prototype.getValues = function() {
|
| + return this._internal.getValues();
|
| +}
|
| +ImmutableMap.prototype.containsKey = function(key) {
|
| + return this._internal.containsKey(key);
|
| +}
|
| +ImmutableMap.prototype.$setindex = function(key, value) {
|
| + $throw(const$143/*const IllegalAccessException()*/);
|
| +}
|
| +ImmutableMap.prototype.clear = function() {
|
| + $throw(const$143/*const IllegalAccessException()*/);
|
| +}
|
| +ImmutableMap.prototype.clear$0 = ImmutableMap.prototype.clear;
|
| +ImmutableMap.prototype.containsKey$1 = ImmutableMap.prototype.containsKey;
|
| +ImmutableMap.prototype.forEach$1 = function($0) {
|
| + return this.forEach(to$call$2($0));
|
| +};
|
| +ImmutableMap.prototype.getKeys$0 = ImmutableMap.prototype.getKeys;
|
| +ImmutableMap.prototype.getValues$0 = ImmutableMap.prototype.getValues;
|
| +ImmutableMap.prototype.isEmpty$0 = ImmutableMap.prototype.isEmpty;
|
| +// ********** Code for NumImplementation **************
|
| +NumImplementation = Number;
|
| +NumImplementation.prototype.isNaN = function() {
|
| + return isNaN(this);
|
| +}
|
| +NumImplementation.prototype.isNegative = function() {
|
| + return this == 0 ? (1 / this) < 0 : this < 0;
|
| +}
|
| +NumImplementation.prototype.round = function() {
|
| + return Math.round(this);
|
| +}
|
| +NumImplementation.prototype.floor = function() {
|
| + return Math.floor(this);
|
| +}
|
| +NumImplementation.prototype.hashCode = function() {
|
| + return this & 0xFFFFFFF;
|
| +}
|
| +NumImplementation.prototype.toInt = function() {
|
| + if (isNaN(this)) throw new BadNumberFormatException("NaN");
|
| + if ((this == Infinity) || (this == -Infinity)) {
|
| + throw new BadNumberFormatException("Infinity");
|
| + }
|
| + var truncated = (this < 0) ? Math.ceil(this) : Math.floor(this);
|
| +
|
| + if (truncated == -0.0) return 0;
|
| + return truncated;
|
| +}
|
| +NumImplementation.prototype.toDouble = function() {
|
| + return this + 0;
|
| +}
|
| +NumImplementation.prototype.compareTo = function(other) {
|
| + var thisValue = this.toDouble();
|
| + if (thisValue < other) {
|
| + return -1;
|
| + }
|
| + else if (thisValue > other) {
|
| + return 1;
|
| + }
|
| + else if (thisValue == other) {
|
| + if (thisValue == 0) {
|
| + var thisIsNegative = this.isNegative();
|
| + var otherIsNegative = other.isNegative();
|
| + if ($eq(thisIsNegative, otherIsNegative)) return 0;
|
| + if (thisIsNegative) return -1;
|
| + return 1;
|
| + }
|
| + return 0;
|
| + }
|
| + else if (this.isNaN()) {
|
| + if (other.isNaN()) {
|
| + return 0;
|
| + }
|
| + return 1;
|
| + }
|
| + else {
|
| + return -1;
|
| + }
|
| +}
|
| +NumImplementation.prototype.compareTo$1 = NumImplementation.prototype.compareTo;
|
| +NumImplementation.prototype.hashCode$0 = NumImplementation.prototype.hashCode;
|
| +// ********** Code for HashMapImplementation **************
|
| +function HashMapImplementation() {
|
| + // Initializers done
|
| + this._numberOfEntries = 0;
|
| + this._numberOfDeleted = 0;
|
| + this._loadLimit = HashMapImplementation._computeLoadLimit(8/*HashMapImplementation._INITIAL_CAPACITY*/);
|
| + this._keys = new ListFactory(8/*HashMapImplementation._INITIAL_CAPACITY*/);
|
| + this._values = new ListFactory(8/*HashMapImplementation._INITIAL_CAPACITY*/);
|
| +}
|
| +HashMapImplementation.HashMapImplementation$from$factory = function(other) {
|
| + var result = new HashMapImplementation();
|
| + other.forEach((function (key, value) {
|
| + result.$setindex(key, value);
|
| + })
|
| + );
|
| + return result;
|
| +}
|
| +HashMapImplementation._computeLoadLimit = function(capacity) {
|
| + return $truncdiv((capacity * 3), 4);
|
| +}
|
| +HashMapImplementation._firstProbe = function(hashCode, length) {
|
| + return hashCode & (length - 1);
|
| +}
|
| +HashMapImplementation._nextProbe = function(currentProbe, numberOfProbes, length) {
|
| + return (currentProbe + numberOfProbes) & (length - 1);
|
| +}
|
| +HashMapImplementation.prototype._probeForAdding = function(key) {
|
| + var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.length);
|
| + var numberOfProbes = 1;
|
| + var initialHash = hash;
|
| + var insertionIndex = -1;
|
| + while (true) {
|
| + var existingKey = this._keys.$index(hash);
|
| + if (existingKey == null) {
|
| + if (insertionIndex < 0) return hash;
|
| + return insertionIndex;
|
| + }
|
| + else if ($eq(existingKey, key)) {
|
| + return hash;
|
| + }
|
| + else if ((insertionIndex < 0) && (const$3/*HashMapImplementation._DELETED_KEY*/ === existingKey)) {
|
| + insertionIndex = hash;
|
| + }
|
| + hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.length);
|
| + }
|
| +}
|
| +HashMapImplementation.prototype._probeForLookup = function(key) {
|
| + var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.length);
|
| + var numberOfProbes = 1;
|
| + var initialHash = hash;
|
| + while (true) {
|
| + var existingKey = this._keys.$index(hash);
|
| + if (existingKey == null) return -1;
|
| + if ($eq(existingKey, key)) return hash;
|
| + hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.length);
|
| + }
|
| +}
|
| +HashMapImplementation.prototype._ensureCapacity = function() {
|
| + var newNumberOfEntries = this._numberOfEntries + 1;
|
| + if (newNumberOfEntries >= this._loadLimit) {
|
| + this._grow(this._keys.length * 2);
|
| + return;
|
| + }
|
| + var capacity = this._keys.length;
|
| + var numberOfFreeOrDeleted = capacity - newNumberOfEntries;
|
| + var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted;
|
| + if (this._numberOfDeleted > numberOfFree) {
|
| + this._grow(this._keys.length);
|
| + }
|
| +}
|
| +HashMapImplementation._isPowerOfTwo = function(x) {
|
| + return ((x & (x - 1)) == 0);
|
| +}
|
| +HashMapImplementation.prototype._grow = function(newCapacity) {
|
| + var capacity = this._keys.length;
|
| + this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity);
|
| + var oldKeys = this._keys;
|
| + var oldValues = this._values;
|
| + this._keys = new ListFactory(newCapacity);
|
| + this._values = new ListFactory(newCapacity);
|
| + for (var i = 0;
|
| + i < capacity; i++) {
|
| + var key = oldKeys.$index(i);
|
| + if (key == null || key === const$3/*HashMapImplementation._DELETED_KEY*/) {
|
| + continue;
|
| + }
|
| + var value = oldValues.$index(i);
|
| + var newIndex = this._probeForAdding(key);
|
| + this._keys.$setindex(newIndex, key);
|
| + this._values.$setindex(newIndex, value);
|
| + }
|
| + this._numberOfDeleted = 0;
|
| +}
|
| +HashMapImplementation.prototype.clear = function() {
|
| + this._numberOfEntries = 0;
|
| + this._numberOfDeleted = 0;
|
| + var length = this._keys.length;
|
| + for (var i = 0;
|
| + i < length; i++) {
|
| + this._keys.$setindex(i);
|
| + this._values.$setindex(i);
|
| + }
|
| +}
|
| +HashMapImplementation.prototype.$setindex = function(key, value) {
|
| + this._ensureCapacity();
|
| + var index = this._probeForAdding(key);
|
| + if ((this._keys.$index(index) == null) || (this._keys.$index(index) === const$3/*HashMapImplementation._DELETED_KEY*/)) {
|
| + this._numberOfEntries++;
|
| + }
|
| + this._keys.$setindex(index, key);
|
| + this._values.$setindex(index, value);
|
| +}
|
| +HashMapImplementation.prototype.$index = function(key) {
|
| + var index = this._probeForLookup(key);
|
| + if (index < 0) return null;
|
| + return this._values.$index(index);
|
| +}
|
| +HashMapImplementation.prototype.remove = function(key) {
|
| + var index = this._probeForLookup(key);
|
| + if (index >= 0) {
|
| + this._numberOfEntries--;
|
| + var value = this._values.$index(index);
|
| + this._values.$setindex(index);
|
| + this._keys.$setindex(index, const$3/*HashMapImplementation._DELETED_KEY*/);
|
| + this._numberOfDeleted++;
|
| + return value;
|
| + }
|
| + return null;
|
| +}
|
| +HashMapImplementation.prototype.isEmpty = function() {
|
| + return this._numberOfEntries == 0;
|
| +}
|
| +HashMapImplementation.prototype.get$length = function() {
|
| + return this._numberOfEntries;
|
| +}
|
| +Object.defineProperty(HashMapImplementation.prototype, "length", {
|
| + get: HashMapImplementation.prototype.get$length
|
| +});
|
| +HashMapImplementation.prototype.forEach = function(f) {
|
| + var length = this._keys.length;
|
| + for (var i = 0;
|
| + i < length; i++) {
|
| + if ((this._keys.$index(i) != null) && (this._keys.$index(i) !== const$3/*HashMapImplementation._DELETED_KEY*/)) {
|
| + f(this._keys.$index(i), this._values.$index(i));
|
| + }
|
| + }
|
| +}
|
| +HashMapImplementation.prototype.getKeys = function() {
|
| + var list = new ListFactory(this.get$length());
|
| + var i = 0;
|
| + this.forEach(function _(key, value) {
|
| + list.$setindex(i++, key);
|
| + }
|
| + );
|
| + return list;
|
| +}
|
| +HashMapImplementation.prototype.getValues = function() {
|
| + var list = new ListFactory(this.get$length());
|
| + var i = 0;
|
| + this.forEach(function _(key, value) {
|
| + list.$setindex(i++, value);
|
| + }
|
| + );
|
| + return list;
|
| +}
|
| +HashMapImplementation.prototype.containsKey = function(key) {
|
| + return (this._probeForLookup(key) != -1);
|
| +}
|
| +HashMapImplementation.prototype.clear$0 = HashMapImplementation.prototype.clear;
|
| +HashMapImplementation.prototype.containsKey$1 = HashMapImplementation.prototype.containsKey;
|
| +HashMapImplementation.prototype.forEach$1 = function($0) {
|
| + return this.forEach(to$call$2($0));
|
| +};
|
| +HashMapImplementation.prototype.getKeys$0 = HashMapImplementation.prototype.getKeys;
|
| +HashMapImplementation.prototype.getValues$0 = HashMapImplementation.prototype.getValues;
|
| +HashMapImplementation.prototype.isEmpty$0 = HashMapImplementation.prototype.isEmpty;
|
| +// ********** Code for HashMapImplementation_E$E **************
|
| +$inherits(HashMapImplementation_E$E, HashMapImplementation);
|
| +function HashMapImplementation_E$E() {
|
| + // Initializers done
|
| + this._numberOfEntries = 0;
|
| + this._numberOfDeleted = 0;
|
| + this._loadLimit = HashMapImplementation._computeLoadLimit(8/*HashMapImplementation._INITIAL_CAPACITY*/);
|
| + this._keys = new ListFactory(8/*HashMapImplementation._INITIAL_CAPACITY*/);
|
| + this._values = new ListFactory(8/*HashMapImplementation._INITIAL_CAPACITY*/);
|
| +}
|
| +HashMapImplementation_E$E._computeLoadLimit = function(capacity) {
|
| + return $truncdiv((capacity * 3), 4);
|
| +}
|
| +HashMapImplementation_E$E._firstProbe = function(hashCode, length) {
|
| + return hashCode & (length - 1);
|
| +}
|
| +HashMapImplementation_E$E._nextProbe = function(currentProbe, numberOfProbes, length) {
|
| + return (currentProbe + numberOfProbes) & (length - 1);
|
| +}
|
| +HashMapImplementation_E$E.prototype._probeForAdding = function(key) {
|
| + var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.length);
|
| + var numberOfProbes = 1;
|
| + var initialHash = hash;
|
| + var insertionIndex = -1;
|
| + while (true) {
|
| + var existingKey = this._keys.$index(hash);
|
| + if (existingKey == null) {
|
| + if (insertionIndex < 0) return hash;
|
| + return insertionIndex;
|
| + }
|
| + else if ($eq(existingKey, key)) {
|
| + return hash;
|
| + }
|
| + else if ((insertionIndex < 0) && (const$3/*HashMapImplementation._DELETED_KEY*/ === existingKey)) {
|
| + insertionIndex = hash;
|
| + }
|
| + hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.length);
|
| + }
|
| +}
|
| +HashMapImplementation_E$E.prototype._probeForLookup = function(key) {
|
| + var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.length);
|
| + var numberOfProbes = 1;
|
| + var initialHash = hash;
|
| + while (true) {
|
| + var existingKey = this._keys.$index(hash);
|
| + if (existingKey == null) return -1;
|
| + if ($eq(existingKey, key)) return hash;
|
| + hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.length);
|
| + }
|
| +}
|
| +HashMapImplementation_E$E.prototype._ensureCapacity = function() {
|
| + var newNumberOfEntries = this._numberOfEntries + 1;
|
| + if (newNumberOfEntries >= this._loadLimit) {
|
| + this._grow(this._keys.length * 2);
|
| + return;
|
| + }
|
| + var capacity = this._keys.length;
|
| + var numberOfFreeOrDeleted = capacity - newNumberOfEntries;
|
| + var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted;
|
| + if (this._numberOfDeleted > numberOfFree) {
|
| + this._grow(this._keys.length);
|
| + }
|
| +}
|
| +HashMapImplementation_E$E._isPowerOfTwo = function(x) {
|
| + return ((x & (x - 1)) == 0);
|
| +}
|
| +HashMapImplementation_E$E.prototype._grow = function(newCapacity) {
|
| + var capacity = this._keys.length;
|
| + this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity);
|
| + var oldKeys = this._keys;
|
| + var oldValues = this._values;
|
| + this._keys = new ListFactory(newCapacity);
|
| + this._values = new ListFactory(newCapacity);
|
| + for (var i = 0;
|
| + i < capacity; i++) {
|
| + var key = oldKeys.$index(i);
|
| + if (key == null || key === const$3/*HashMapImplementation._DELETED_KEY*/) {
|
| + continue;
|
| + }
|
| + var value = oldValues.$index(i);
|
| + var newIndex = this._probeForAdding(key);
|
| + this._keys.$setindex(newIndex, key);
|
| + this._values.$setindex(newIndex, value);
|
| + }
|
| + this._numberOfDeleted = 0;
|
| +}
|
| +HashMapImplementation_E$E.prototype.clear = function() {
|
| + this._numberOfEntries = 0;
|
| + this._numberOfDeleted = 0;
|
| + var length = this._keys.length;
|
| + for (var i = 0;
|
| + i < length; i++) {
|
| + this._keys.$setindex(i);
|
| + this._values.$setindex(i);
|
| + }
|
| +}
|
| +HashMapImplementation_E$E.prototype.$setindex = function(key, value) {
|
| + this._ensureCapacity();
|
| + var index = this._probeForAdding(key);
|
| + if ((this._keys.$index(index) == null) || (this._keys.$index(index) === const$3/*HashMapImplementation._DELETED_KEY*/)) {
|
| + this._numberOfEntries++;
|
| + }
|
| + this._keys.$setindex(index, key);
|
| + this._values.$setindex(index, value);
|
| +}
|
| +HashMapImplementation_E$E.prototype.remove = function(key) {
|
| + var index = this._probeForLookup(key);
|
| + if (index >= 0) {
|
| + this._numberOfEntries--;
|
| + var value = this._values.$index(index);
|
| + this._values.$setindex(index);
|
| + this._keys.$setindex(index, const$3/*HashMapImplementation._DELETED_KEY*/);
|
| + this._numberOfDeleted++;
|
| + return value;
|
| + }
|
| + return null;
|
| +}
|
| +HashMapImplementation_E$E.prototype.isEmpty = function() {
|
| + return this._numberOfEntries == 0;
|
| +}
|
| +HashMapImplementation_E$E.prototype.forEach = function(f) {
|
| + var length = this._keys.length;
|
| + for (var i = 0;
|
| + i < length; i++) {
|
| + if ((this._keys.$index(i) != null) && (this._keys.$index(i) !== const$3/*HashMapImplementation._DELETED_KEY*/)) {
|
| + f(this._keys.$index(i), this._values.$index(i));
|
| + }
|
| + }
|
| +}
|
| +HashMapImplementation_E$E.prototype.getKeys = function() {
|
| + var list = new ListFactory(this.get$length());
|
| + var i = 0;
|
| + this.forEach(function _(key, value) {
|
| + list.$setindex(i++, key);
|
| + }
|
| + );
|
| + return list;
|
| +}
|
| +HashMapImplementation_E$E.prototype.containsKey = function(key) {
|
| + return (this._probeForLookup(key) != -1);
|
| +}
|
| +// ********** Code for HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePair_K$V **************
|
| +$inherits(HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePair_K$V, HashMapImplementation);
|
| +function HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePair_K$V() {}
|
| +// ********** Code for HashMapImplementation_String$EvaluatedValue **************
|
| +$inherits(HashMapImplementation_String$EvaluatedValue, HashMapImplementation);
|
| +function HashMapImplementation_String$EvaluatedValue() {}
|
| +// ********** Code for HashSetImplementation **************
|
| +function HashSetImplementation() {
|
| + // Initializers done
|
| + this._backingMap = new HashMapImplementation_E$E();
|
| +}
|
| +HashSetImplementation.HashSetImplementation$from$factory = function(other) {
|
| + var set = new HashSetImplementation();
|
| + for (var $$i = other.iterator(); $$i.hasNext$0(); ) {
|
| + var e = $$i.next$0();
|
| + set.add(e);
|
| + }
|
| + return set;
|
| +}
|
| +HashSetImplementation.prototype.clear = function() {
|
| + this._backingMap.clear();
|
| +}
|
| +HashSetImplementation.prototype.add = function(value) {
|
| + this._backingMap.$setindex(value, value);
|
| +}
|
| +HashSetImplementation.prototype.contains = function(value) {
|
| + return this._backingMap.containsKey(value);
|
| +}
|
| +HashSetImplementation.prototype.remove = function(value) {
|
| + if (!this._backingMap.containsKey(value)) return false;
|
| + this._backingMap.remove(value);
|
| + return true;
|
| +}
|
| +HashSetImplementation.prototype.addAll = function(collection) {
|
| + var $this = this; // closure support
|
| + collection.forEach(function _(value) {
|
| + $this.add(value);
|
| + }
|
| + );
|
| +}
|
| +HashSetImplementation.prototype.forEach = function(f) {
|
| + this._backingMap.forEach(function _(key, value) {
|
| + f(key);
|
| + }
|
| + );
|
| +}
|
| +HashSetImplementation.prototype.filter = function(f) {
|
| + var result = new HashSetImplementation();
|
| + this._backingMap.forEach(function _(key, value) {
|
| + if (f(key)) result.add(key);
|
| + }
|
| + );
|
| + return result;
|
| +}
|
| +HashSetImplementation.prototype.every = function(f) {
|
| + var keys = this._backingMap.getKeys();
|
| + return keys.every(f);
|
| +}
|
| +HashSetImplementation.prototype.some = function(f) {
|
| + var keys = this._backingMap.getKeys();
|
| + return keys.some(f);
|
| +}
|
| +HashSetImplementation.prototype.isEmpty = function() {
|
| + return this._backingMap.isEmpty();
|
| +}
|
| +HashSetImplementation.prototype.get$length = function() {
|
| + return this._backingMap.get$length();
|
| +}
|
| +Object.defineProperty(HashSetImplementation.prototype, "length", {
|
| + get: HashSetImplementation.prototype.get$length
|
| +});
|
| +HashSetImplementation.prototype.iterator = function() {
|
| + return new HashSetIterator_E(this);
|
| +}
|
| +HashSetImplementation.prototype.add$1 = HashSetImplementation.prototype.add;
|
| +HashSetImplementation.prototype.addAll$1 = HashSetImplementation.prototype.addAll;
|
| +HashSetImplementation.prototype.clear$0 = HashSetImplementation.prototype.clear;
|
| +HashSetImplementation.prototype.contains$1 = HashSetImplementation.prototype.contains;
|
| +HashSetImplementation.prototype.every$1 = function($0) {
|
| + return this.every(to$call$1($0));
|
| +};
|
| +HashSetImplementation.prototype.filter$1 = function($0) {
|
| + return this.filter(to$call$1($0));
|
| +};
|
| +HashSetImplementation.prototype.forEach$1 = function($0) {
|
| + return this.forEach(to$call$1($0));
|
| +};
|
| +HashSetImplementation.prototype.isEmpty$0 = HashSetImplementation.prototype.isEmpty;
|
| +HashSetImplementation.prototype.iterator$0 = HashSetImplementation.prototype.iterator;
|
| +HashSetImplementation.prototype.some$1 = function($0) {
|
| + return this.some(to$call$1($0));
|
| +};
|
| +// ********** Code for HashSetImplementation_E **************
|
| +$inherits(HashSetImplementation_E, HashSetImplementation);
|
| +function HashSetImplementation_E() {}
|
| +// ********** Code for HashSetImplementation_String **************
|
| +$inherits(HashSetImplementation_String, HashSetImplementation);
|
| +function HashSetImplementation_String() {}
|
| +// ********** Code for HashSetImplementation_Type **************
|
| +$inherits(HashSetImplementation_Type, HashSetImplementation);
|
| +function HashSetImplementation_Type() {}
|
| +// ********** Code for HashSetIterator **************
|
| +function HashSetIterator(set_) {
|
| + this._nextValidIndex = -1;
|
| + this._entries = set_._backingMap._keys;
|
| + // Initializers done
|
| + this._advance();
|
| +}
|
| +HashSetIterator.prototype.hasNext = function() {
|
| + if (this._nextValidIndex >= this._entries.length) return false;
|
| + if (this._entries.$index(this._nextValidIndex) === const$3/*HashMapImplementation._DELETED_KEY*/) {
|
| + this._advance();
|
| + }
|
| + return this._nextValidIndex < this._entries.length;
|
| +}
|
| +HashSetIterator.prototype.next = function() {
|
| + if (!this.hasNext()) {
|
| + $throw(const$1/*const NoMoreElementsException()*/);
|
| + }
|
| + var res = this._entries.$index(this._nextValidIndex);
|
| + this._advance();
|
| + return res;
|
| +}
|
| +HashSetIterator.prototype._advance = function() {
|
| + var length = this._entries.length;
|
| + var entry;
|
| + var deletedKey = const$3/*HashMapImplementation._DELETED_KEY*/;
|
| + do {
|
| + if (++this._nextValidIndex >= length) break;
|
| + entry = this._entries.$index(this._nextValidIndex);
|
| + }
|
| + while ((entry == null) || (entry === deletedKey))
|
| +}
|
| +HashSetIterator.prototype.hasNext$0 = HashSetIterator.prototype.hasNext;
|
| +HashSetIterator.prototype.next$0 = HashSetIterator.prototype.next;
|
| +// ********** Code for HashSetIterator_E **************
|
| +$inherits(HashSetIterator_E, HashSetIterator);
|
| +function HashSetIterator_E(set_) {
|
| + this._nextValidIndex = -1;
|
| + this._entries = set_._backingMap._keys;
|
| + // Initializers done
|
| + this._advance();
|
| +}
|
| +HashSetIterator_E.prototype._advance = function() {
|
| + var length = this._entries.length;
|
| + var entry;
|
| + var deletedKey = const$3/*HashMapImplementation._DELETED_KEY*/;
|
| + do {
|
| + if (++this._nextValidIndex >= length) break;
|
| + entry = this._entries.$index(this._nextValidIndex);
|
| + }
|
| + while ((entry == null) || (entry === deletedKey))
|
| +}
|
| +// ********** Code for _DeletedKeySentinel **************
|
| +function _DeletedKeySentinel() {
|
| + // Initializers done
|
| +}
|
| +// ********** Code for KeyValuePair **************
|
| +function KeyValuePair(key, value) {
|
| + this.key = key;
|
| + this.value = value;
|
| + // Initializers done
|
| +}
|
| +// ********** Code for KeyValuePair_K$V **************
|
| +$inherits(KeyValuePair_K$V, KeyValuePair);
|
| +function KeyValuePair_K$V(key, value) {
|
| + this.key = key;
|
| + this.value = value;
|
| + // Initializers done
|
| +}
|
| +// ********** Code for LinkedHashMapImplementation **************
|
| +function LinkedHashMapImplementation() {
|
| + // Initializers done
|
| + this._map = new HashMapImplementation();
|
| + this._list = new DoubleLinkedQueue_KeyValuePair_K$V();
|
| +}
|
| +LinkedHashMapImplementation.prototype.$setindex = function(key, value) {
|
| + if (this._map.containsKey(key)) {
|
| + this._map.$index(key).get$element().value = value;
|
| + }
|
| + else {
|
| + this._list.addLast(new KeyValuePair_K$V(key, value));
|
| + this._map.$setindex(key, this._list.lastEntry());
|
| + }
|
| +}
|
| +LinkedHashMapImplementation.prototype.$index = function(key) {
|
| + var entry = this._map.$index(key);
|
| + if (entry == null) return null;
|
| + return entry.get$element().value;
|
| +}
|
| +LinkedHashMapImplementation.prototype.getKeys = function() {
|
| + var list = new ListFactory(this.get$length());
|
| + var index = 0;
|
| + this._list.forEach(function _(entry) {
|
| + list.$setindex(index++, entry.key);
|
| + }
|
| + );
|
| + return list;
|
| +}
|
| +LinkedHashMapImplementation.prototype.getValues = function() {
|
| + var list = new ListFactory(this.get$length());
|
| + var index = 0;
|
| + this._list.forEach(function _(entry) {
|
| + list.$setindex(index++, entry.value);
|
| + }
|
| + );
|
| + return list;
|
| +}
|
| +LinkedHashMapImplementation.prototype.forEach = function(f) {
|
| + this._list.forEach(function _(entry) {
|
| + f(entry.key, entry.value);
|
| + }
|
| + );
|
| +}
|
| +LinkedHashMapImplementation.prototype.containsKey = function(key) {
|
| + return this._map.containsKey(key);
|
| +}
|
| +LinkedHashMapImplementation.prototype.get$length = function() {
|
| + return this._map.get$length();
|
| +}
|
| +Object.defineProperty(LinkedHashMapImplementation.prototype, "length", {
|
| + get: LinkedHashMapImplementation.prototype.get$length
|
| +});
|
| +LinkedHashMapImplementation.prototype.isEmpty = function() {
|
| + return this.get$length() == 0;
|
| +}
|
| +LinkedHashMapImplementation.prototype.clear = function() {
|
| + this._map.clear();
|
| + this._list.clear();
|
| +}
|
| +LinkedHashMapImplementation.prototype.clear$0 = LinkedHashMapImplementation.prototype.clear;
|
| +LinkedHashMapImplementation.prototype.containsKey$1 = LinkedHashMapImplementation.prototype.containsKey;
|
| +LinkedHashMapImplementation.prototype.forEach$1 = function($0) {
|
| + return this.forEach(to$call$2($0));
|
| +};
|
| +LinkedHashMapImplementation.prototype.getKeys$0 = LinkedHashMapImplementation.prototype.getKeys;
|
| +LinkedHashMapImplementation.prototype.getValues$0 = LinkedHashMapImplementation.prototype.getValues;
|
| +LinkedHashMapImplementation.prototype.isEmpty$0 = LinkedHashMapImplementation.prototype.isEmpty;
|
| +// ********** Code for DoubleLinkedQueueEntry **************
|
| +function DoubleLinkedQueueEntry(e) {
|
| + // Initializers done
|
| + this._element = e;
|
| +}
|
| +DoubleLinkedQueueEntry.prototype._link = function(p, n) {
|
| + this._next = n;
|
| + this._previous = p;
|
| + p._next = this;
|
| + n._previous = this;
|
| +}
|
| +DoubleLinkedQueueEntry.prototype.prepend = function(e) {
|
| + new DoubleLinkedQueueEntry_E(e)._link(this._previous, this);
|
| +}
|
| +DoubleLinkedQueueEntry.prototype.remove = function() {
|
| + this._previous._next = this._next;
|
| + this._next._previous = this._previous;
|
| + this._next = null;
|
| + this._previous = null;
|
| + return this._element;
|
| +}
|
| +DoubleLinkedQueueEntry.prototype._asNonSentinelEntry = function() {
|
| + return this;
|
| +}
|
| +DoubleLinkedQueueEntry.prototype.previousEntry = function() {
|
| + return this._previous._asNonSentinelEntry();
|
| +}
|
| +DoubleLinkedQueueEntry.prototype.get$element = function() {
|
| + return this._element;
|
| +}
|
| +// ********** Code for DoubleLinkedQueueEntry_E **************
|
| +$inherits(DoubleLinkedQueueEntry_E, DoubleLinkedQueueEntry);
|
| +function DoubleLinkedQueueEntry_E(e) {
|
| + // Initializers done
|
| + this._element = e;
|
| +}
|
| +DoubleLinkedQueueEntry_E.prototype._link = function(p, n) {
|
| + this._next = n;
|
| + this._previous = p;
|
| + p._next = this;
|
| + n._previous = this;
|
| +}
|
| +DoubleLinkedQueueEntry_E.prototype.prepend = function(e) {
|
| + new DoubleLinkedQueueEntry_E(e)._link(this._previous, this);
|
| +}
|
| +DoubleLinkedQueueEntry_E.prototype.remove = function() {
|
| + this._previous._next = this._next;
|
| + this._next._previous = this._previous;
|
| + this._next = null;
|
| + this._previous = null;
|
| + return this._element;
|
| +}
|
| +DoubleLinkedQueueEntry_E.prototype._asNonSentinelEntry = function() {
|
| + return this;
|
| +}
|
| +// ********** Code for DoubleLinkedQueueEntry_KeyValuePair_K$V **************
|
| +$inherits(DoubleLinkedQueueEntry_KeyValuePair_K$V, DoubleLinkedQueueEntry);
|
| +function DoubleLinkedQueueEntry_KeyValuePair_K$V(e) {
|
| + // Initializers done
|
| + this._element = e;
|
| +}
|
| +DoubleLinkedQueueEntry_KeyValuePair_K$V.prototype._link = function(p, n) {
|
| + this._next = n;
|
| + this._previous = p;
|
| + p._next = this;
|
| + n._previous = this;
|
| +}
|
| +DoubleLinkedQueueEntry_KeyValuePair_K$V.prototype.prepend = function(e) {
|
| + new DoubleLinkedQueueEntry_KeyValuePair_K$V(e)._link(this._previous, this);
|
| +}
|
| +DoubleLinkedQueueEntry_KeyValuePair_K$V.prototype._asNonSentinelEntry = function() {
|
| + return this;
|
| +}
|
| +DoubleLinkedQueueEntry_KeyValuePair_K$V.prototype.previousEntry = function() {
|
| + return this._previous._asNonSentinelEntry();
|
| +}
|
| +// ********** Code for _DoubleLinkedQueueEntrySentinel **************
|
| +$inherits(_DoubleLinkedQueueEntrySentinel, DoubleLinkedQueueEntry_E);
|
| +function _DoubleLinkedQueueEntrySentinel() {
|
| + // Initializers done
|
| + DoubleLinkedQueueEntry_E.call(this, null);
|
| + this._link(this, this);
|
| +}
|
| +_DoubleLinkedQueueEntrySentinel.prototype.remove = function() {
|
| + $throw(const$5/*const EmptyQueueException()*/);
|
| +}
|
| +_DoubleLinkedQueueEntrySentinel.prototype._asNonSentinelEntry = function() {
|
| + return null;
|
| +}
|
| +_DoubleLinkedQueueEntrySentinel.prototype.get$element = function() {
|
| + $throw(const$5/*const EmptyQueueException()*/);
|
| +}
|
| +// ********** Code for _DoubleLinkedQueueEntrySentinel_E **************
|
| +$inherits(_DoubleLinkedQueueEntrySentinel_E, _DoubleLinkedQueueEntrySentinel);
|
| +function _DoubleLinkedQueueEntrySentinel_E() {
|
| + // Initializers done
|
| + DoubleLinkedQueueEntry_E.call(this, null);
|
| + this._link(this, this);
|
| +}
|
| +// ********** Code for _DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V **************
|
| +$inherits(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, _DoubleLinkedQueueEntrySentinel);
|
| +function _DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V() {
|
| + // Initializers done
|
| + DoubleLinkedQueueEntry_KeyValuePair_K$V.call(this, null);
|
| + this._link(this, this);
|
| +}
|
| +// ********** Code for DoubleLinkedQueue **************
|
| +function DoubleLinkedQueue() {
|
| + // Initializers done
|
| + this._sentinel = new _DoubleLinkedQueueEntrySentinel_E();
|
| +}
|
| +DoubleLinkedQueue.prototype.addLast = function(value) {
|
| + this._sentinel.prepend(value);
|
| +}
|
| +DoubleLinkedQueue.prototype.add = function(value) {
|
| + this.addLast(value);
|
| +}
|
| +DoubleLinkedQueue.prototype.addAll = function(collection) {
|
| + for (var $$i = collection.iterator(); $$i.hasNext$0(); ) {
|
| + var e = $$i.next$0();
|
| + this.add(e);
|
| + }
|
| +}
|
| +DoubleLinkedQueue.prototype.removeLast = function() {
|
| + return this._sentinel._previous.remove();
|
| +}
|
| +DoubleLinkedQueue.prototype.last = function() {
|
| + return this._sentinel._previous.get$element();
|
| +}
|
| +DoubleLinkedQueue.prototype.get$length = function() {
|
| + var counter = 0;
|
| + this.forEach(function _(element) {
|
| + counter++;
|
| + }
|
| + );
|
| + return counter;
|
| +}
|
| +Object.defineProperty(DoubleLinkedQueue.prototype, "length", {
|
| + get: DoubleLinkedQueue.prototype.get$length
|
| +});
|
| +DoubleLinkedQueue.prototype.isEmpty = function() {
|
| + return (this._sentinel._next === this._sentinel);
|
| +}
|
| +DoubleLinkedQueue.prototype.clear = function() {
|
| + this._sentinel._next = this._sentinel;
|
| + this._sentinel._previous = this._sentinel;
|
| +}
|
| +DoubleLinkedQueue.prototype.forEach = function(f) {
|
| + var entry = this._sentinel._next;
|
| + while (entry !== this._sentinel) {
|
| + var nextEntry = entry._next;
|
| + f(entry._element);
|
| + entry = nextEntry;
|
| + }
|
| +}
|
| +DoubleLinkedQueue.prototype.every = function(f) {
|
| + var entry = this._sentinel._next;
|
| + while (entry !== this._sentinel) {
|
| + var nextEntry = entry._next;
|
| + if (!f(entry._element)) return false;
|
| + entry = nextEntry;
|
| + }
|
| + return true;
|
| +}
|
| +DoubleLinkedQueue.prototype.some = function(f) {
|
| + var entry = this._sentinel._next;
|
| + while (entry !== this._sentinel) {
|
| + var nextEntry = entry._next;
|
| + if (f(entry._element)) return true;
|
| + entry = nextEntry;
|
| + }
|
| + return false;
|
| +}
|
| +DoubleLinkedQueue.prototype.filter = function(f) {
|
| + var other = new DoubleLinkedQueue();
|
| + var entry = this._sentinel._next;
|
| + while (entry !== this._sentinel) {
|
| + var nextEntry = entry._next;
|
| + if (f(entry._element)) other.addLast(entry._element);
|
| + entry = nextEntry;
|
| + }
|
| + return other;
|
| +}
|
| +DoubleLinkedQueue.prototype.iterator = function() {
|
| + return new _DoubleLinkedQueueIterator_E(this._sentinel);
|
| +}
|
| +DoubleLinkedQueue.prototype.add$1 = DoubleLinkedQueue.prototype.add;
|
| +DoubleLinkedQueue.prototype.addAll$1 = DoubleLinkedQueue.prototype.addAll;
|
| +DoubleLinkedQueue.prototype.clear$0 = DoubleLinkedQueue.prototype.clear;
|
| +DoubleLinkedQueue.prototype.every$1 = function($0) {
|
| + return this.every(to$call$1($0));
|
| +};
|
| +DoubleLinkedQueue.prototype.filter$1 = function($0) {
|
| + return this.filter(to$call$1($0));
|
| +};
|
| +DoubleLinkedQueue.prototype.forEach$1 = function($0) {
|
| + return this.forEach(to$call$1($0));
|
| +};
|
| +DoubleLinkedQueue.prototype.isEmpty$0 = DoubleLinkedQueue.prototype.isEmpty;
|
| +DoubleLinkedQueue.prototype.iterator$0 = DoubleLinkedQueue.prototype.iterator;
|
| +DoubleLinkedQueue.prototype.last$0 = DoubleLinkedQueue.prototype.last;
|
| +DoubleLinkedQueue.prototype.removeLast$0 = DoubleLinkedQueue.prototype.removeLast;
|
| +DoubleLinkedQueue.prototype.some$1 = function($0) {
|
| + return this.some(to$call$1($0));
|
| +};
|
| +// ********** Code for DoubleLinkedQueue_E **************
|
| +$inherits(DoubleLinkedQueue_E, DoubleLinkedQueue);
|
| +function DoubleLinkedQueue_E() {}
|
| +// ********** Code for DoubleLinkedQueue_KeyValuePair_K$V **************
|
| +$inherits(DoubleLinkedQueue_KeyValuePair_K$V, DoubleLinkedQueue);
|
| +function DoubleLinkedQueue_KeyValuePair_K$V() {
|
| + // Initializers done
|
| + this._sentinel = new _DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V();
|
| +}
|
| +DoubleLinkedQueue_KeyValuePair_K$V.prototype.addLast = function(value) {
|
| + this._sentinel.prepend(value);
|
| +}
|
| +DoubleLinkedQueue_KeyValuePair_K$V.prototype.lastEntry = function() {
|
| + return this._sentinel.previousEntry();
|
| +}
|
| +DoubleLinkedQueue_KeyValuePair_K$V.prototype.clear = function() {
|
| + this._sentinel._next = this._sentinel;
|
| + this._sentinel._previous = this._sentinel;
|
| +}
|
| +DoubleLinkedQueue_KeyValuePair_K$V.prototype.forEach = function(f) {
|
| + var entry = this._sentinel._next;
|
| + while (entry !== this._sentinel) {
|
| + var nextEntry = entry._next;
|
| + f(entry._element);
|
| + entry = nextEntry;
|
| + }
|
| +}
|
| +// ********** Code for _DoubleLinkedQueueIterator **************
|
| +function _DoubleLinkedQueueIterator(_sentinel) {
|
| + this._sentinel = _sentinel;
|
| + // Initializers done
|
| + this._currentEntry = this._sentinel;
|
| +}
|
| +_DoubleLinkedQueueIterator.prototype.hasNext = function() {
|
| + return this._currentEntry._next !== this._sentinel;
|
| +}
|
| +_DoubleLinkedQueueIterator.prototype.next = function() {
|
| + if (!this.hasNext()) {
|
| + $throw(const$1/*const NoMoreElementsException()*/);
|
| + }
|
| + this._currentEntry = this._currentEntry._next;
|
| + return this._currentEntry.get$element();
|
| +}
|
| +_DoubleLinkedQueueIterator.prototype.hasNext$0 = _DoubleLinkedQueueIterator.prototype.hasNext;
|
| +_DoubleLinkedQueueIterator.prototype.next$0 = _DoubleLinkedQueueIterator.prototype.next;
|
| +// ********** Code for _DoubleLinkedQueueIterator_E **************
|
| +$inherits(_DoubleLinkedQueueIterator_E, _DoubleLinkedQueueIterator);
|
| +function _DoubleLinkedQueueIterator_E(_sentinel) {
|
| + this._sentinel = _sentinel;
|
| + // Initializers done
|
| + this._currentEntry = this._sentinel;
|
| +}
|
| +// ********** Code for StopwatchImplementation **************
|
| +function StopwatchImplementation() {
|
| + this._start = null;
|
| + this._stop = null;
|
| + // Initializers done
|
| +}
|
| +StopwatchImplementation.prototype.start = function() {
|
| + if (this._start == null) {
|
| + this._start = Clock.now();
|
| + }
|
| + else {
|
| + if (this._stop == null) {
|
| + return;
|
| + }
|
| + this._start = Clock.now() - (this._stop - this._start);
|
| + }
|
| +}
|
| +StopwatchImplementation.prototype.stop = function() {
|
| + if (this._start == null) {
|
| + return;
|
| + }
|
| + this._stop = Clock.now();
|
| +}
|
| +StopwatchImplementation.prototype.elapsed = function() {
|
| + if (this._start == null) {
|
| + return 0;
|
| + }
|
| + return (this._stop == null) ? (Clock.now() - this._start) : (this._stop - this._start);
|
| +}
|
| +StopwatchImplementation.prototype.elapsedInMs = function() {
|
| + return $truncdiv((this.elapsed() * 1000), this.frequency());
|
| +}
|
| +StopwatchImplementation.prototype.frequency = function() {
|
| + return Clock.frequency();
|
| +}
|
| +StopwatchImplementation.prototype.start$0 = StopwatchImplementation.prototype.start;
|
| +// ********** Code for StringBufferImpl **************
|
| +function StringBufferImpl(content) {
|
| + // Initializers done
|
| + this.clear();
|
| + this.add(content);
|
| +}
|
| +StringBufferImpl.prototype.get$length = function() {
|
| + return this._length;
|
| +}
|
| +Object.defineProperty(StringBufferImpl.prototype, "length", {
|
| + get: StringBufferImpl.prototype.get$length
|
| +});
|
| +StringBufferImpl.prototype.isEmpty = function() {
|
| + return this._length == 0;
|
| +}
|
| +StringBufferImpl.prototype.add = function(obj) {
|
| + var str = obj.toString();
|
| + if (str == null || str.isEmpty()) return this;
|
| + this._buffer.add(str);
|
| + this._length += str.length;
|
| + return this;
|
| +}
|
| +StringBufferImpl.prototype.addAll = function(objects) {
|
| + for (var $$i = objects.iterator(); $$i.hasNext$0(); ) {
|
| + var obj = $$i.next$0();
|
| + this.add(obj);
|
| + }
|
| + return this;
|
| +}
|
| +StringBufferImpl.prototype.clear = function() {
|
| + this._buffer = new ListFactory();
|
| + this._length = 0;
|
| + return this;
|
| +}
|
| +StringBufferImpl.prototype.toString = function() {
|
| + if (this._buffer.length == 0) return "";
|
| + if (this._buffer.length == 1) return this._buffer.$index(0);
|
| + var result = StringBase.concatAll(this._buffer);
|
| + this._buffer.clear();
|
| + this._buffer.add(result);
|
| + return result;
|
| +}
|
| +StringBufferImpl.prototype.add$1 = StringBufferImpl.prototype.add;
|
| +StringBufferImpl.prototype.addAll$1 = StringBufferImpl.prototype.addAll;
|
| +StringBufferImpl.prototype.clear$0 = StringBufferImpl.prototype.clear;
|
| +StringBufferImpl.prototype.isEmpty$0 = StringBufferImpl.prototype.isEmpty;
|
| +StringBufferImpl.prototype.toString$0 = StringBufferImpl.prototype.toString;
|
| +// ********** Code for StringBase **************
|
| +function StringBase() {}
|
| +StringBase.createFromCharCodes = function(charCodes) {
|
| + if (Object.getPrototypeOf(charCodes) !== Array.prototype) {
|
| + charCodes = new ListFactory.ListFactory$from$factory(charCodes);
|
| + }
|
| + return String.fromCharCode.apply(null, charCodes);
|
| +}
|
| +StringBase.join = function(strings, separator) {
|
| + if (strings.length == 0) return '';
|
| + var s = strings.$index(0);
|
| + for (var i = 1;
|
| + i < strings.length; i++) {
|
| + s = s + separator + strings.$index(i);
|
| + }
|
| + return s;
|
| +}
|
| +StringBase.concatAll = function(strings) {
|
| + return StringBase.join(strings, "");
|
| +}
|
| +// ********** Code for StringImplementation **************
|
| +StringImplementation = String;
|
| +StringImplementation.prototype.endsWith = function(other) {
|
| + if (other.length > this.length) return false;
|
| + return other == this.substring(this.length - other.length);
|
| +}
|
| +StringImplementation.prototype.startsWith = function(other) {
|
| + if (other.length > this.length) return false;
|
| + return other == this.substring(0, other.length);
|
| +}
|
| +StringImplementation.prototype.isEmpty = function() {
|
| + return this.length == 0;
|
| +}
|
| +StringImplementation.prototype.contains = function(pattern, startIndex) {
|
| + return this.indexOf(pattern, startIndex) >= 0;
|
| +}
|
| +StringImplementation.prototype._replaceFirst = function(from, to) {
|
| + return this.replace(from, to);
|
| +}
|
| +StringImplementation.prototype._replaceFirstRegExp = function(from, to) {
|
| + return this.replace(from.re, to);
|
| +}
|
| +StringImplementation.prototype.replaceFirst = function(from, to) {
|
| + if ((typeof(from) == 'string')) return this._replaceFirst(from, to);
|
| + if (!!(from && from.is$RegExp())) return this._replaceFirstRegExp(from, to);
|
| + var $$list = from.allMatches(this);
|
| + for (var $$i = from.allMatches(this).iterator(); $$i.hasNext$0(); ) {
|
| + var match = $$i.next$0();
|
| + return this.substring(0, match.start$0()) + to + this.substring(match.end$0());
|
| + }
|
| +}
|
| +StringImplementation.prototype.replaceAll = function(from, to) {
|
| + if (typeof(from) == 'string' || from instanceof String) {
|
| + from = new RegExp(from.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'g');
|
| + to = to.replace(/\$/g, '$$$$'); // Escape sequences are fun!
|
| + }
|
| + return this.replace(from, to);
|
| +}
|
| +StringImplementation.prototype.hashCode = function() {
|
| + if (this.hash_ === undefined) {
|
| + for (var i = 0; i < this.length; i++) {
|
| + var ch = this.charCodeAt(i);
|
| + this.hash_ += ch;
|
| + this.hash_ += this.hash_ << 10;
|
| + this.hash_ ^= this.hash_ >> 6;
|
| + }
|
| +
|
| + this.hash_ += this.hash_ << 3;
|
| + this.hash_ ^= this.hash_ >> 11;
|
| + this.hash_ += this.hash_ << 15;
|
| + this.hash_ = this.hash_ & ((1 << 29) - 1);
|
| + }
|
| + return this.hash_;
|
| +}
|
| +StringImplementation.prototype.compareTo = function(other) {
|
| + return this == other ? 0 : this < other ? -1 : 1;
|
| +}
|
| +StringImplementation.prototype.compareTo$1 = StringImplementation.prototype.compareTo;
|
| +StringImplementation.prototype.contains$1 = StringImplementation.prototype.contains;
|
| +StringImplementation.prototype.endsWith$1 = StringImplementation.prototype.endsWith;
|
| +StringImplementation.prototype.hashCode$0 = StringImplementation.prototype.hashCode;
|
| +StringImplementation.prototype.indexOf$1 = StringImplementation.prototype.indexOf;
|
| +StringImplementation.prototype.isEmpty$0 = StringImplementation.prototype.isEmpty;
|
| +StringImplementation.prototype.replaceAll$2 = StringImplementation.prototype.replaceAll;
|
| +StringImplementation.prototype.replaceFirst$2 = StringImplementation.prototype.replaceFirst;
|
| +StringImplementation.prototype.startsWith$1 = StringImplementation.prototype.startsWith;
|
| +StringImplementation.prototype.substring$1 = StringImplementation.prototype.substring;
|
| +StringImplementation.prototype.substring$2 = StringImplementation.prototype.substring;
|
| +// ********** Code for Collections **************
|
| +function Collections() {}
|
| +Collections.forEach = function(iterable, f) {
|
| + for (var $$i = iterable.iterator(); $$i.hasNext$0(); ) {
|
| + var e = $$i.next$0();
|
| + f(e);
|
| + }
|
| +}
|
| +Collections.some = function(iterable, f) {
|
| + for (var $$i = iterable.iterator(); $$i.hasNext$0(); ) {
|
| + var e = $$i.next$0();
|
| + if (f(e)) return true;
|
| + }
|
| + return false;
|
| +}
|
| +Collections.every = function(iterable, f) {
|
| + for (var $$i = iterable.iterator(); $$i.hasNext$0(); ) {
|
| + var e = $$i.next$0();
|
| + if (!f(e)) return false;
|
| + }
|
| + return true;
|
| +}
|
| +Collections.filter = function(source, destination, f) {
|
| + for (var $$i = source.iterator(); $$i.hasNext$0(); ) {
|
| + var e = $$i.next$0();
|
| + if (f(e)) destination.add(e);
|
| + }
|
| + return destination;
|
| +}
|
| +// ********** Code for top level **************
|
| +// ********** Library dom **************
|
| +// ********** Natives frog_dom.js **************
|
| +// 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.
|
| +
|
| +// TODO(jmesserly): we need to find a way to avoid conflicts with other
|
| +// generated "typeName" fields. Ideally we wouldn't be patching 'Object' here.
|
| +Object.prototype.get$typeName = Object.prototype.$typeNameOf;
|
| +// ********** Code for Window **************
|
| +// ********** Code for AbstractWorker **************
|
| +Object.prototype.$typeNameOf = function() {
|
| + if ((typeof(window) != 'undefined' && window.constructor.name == 'DOMWindow')
|
| + || typeof(process) != 'undefined') { // fast-path for Chrome and Node
|
| + return this.constructor.name;
|
| + }
|
| + var str = Object.prototype.toString.call(this);
|
| + str = str.substring(8, str.length - 1);
|
| + if (str == 'Window') str = 'DOMWindow';
|
| + return str;
|
| +}
|
| +function $dynamic(name) {
|
| + var f = Object.prototype[name];
|
| + if (f && f.methods) return f.methods;
|
| +
|
| + var methods = {};
|
| + if (f) methods.Object = f;
|
| + function $dynamicBind() {
|
| + // Find the target method
|
| + var method;
|
| + var proto = Object.getPrototypeOf(this);
|
| + var obj = this;
|
| + do {
|
| + method = methods[obj.$typeNameOf()];
|
| + if (method) break;
|
| + obj = Object.getPrototypeOf(obj);
|
| + } while (obj);
|
| +
|
| + // Patch the prototype, but don't overwrite an existing stub, like
|
| + // the one on Object.prototype.
|
| + if (!proto.hasOwnProperty(name)) proto[name] = method || methods.Object;
|
| +
|
| + return method.apply(this, Array.prototype.slice.call(arguments));
|
| + };
|
| + $dynamicBind.methods = methods;
|
| + Object.prototype[name] = $dynamicBind;
|
| + return methods;
|
| +}
|
| +$dynamic("addEventListener$3").AbstractWorker = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for ArrayBuffer **************
|
| +// ********** Code for ArrayBufferView **************
|
| +// ********** Code for Attr **************
|
| +// ********** Code for AudioBuffer **************
|
| +// ********** Code for AudioBufferSourceNode **************
|
| +// ********** Code for AudioChannelMerger **************
|
| +// ********** Code for AudioChannelSplitter **************
|
| +// ********** Code for AudioContext **************
|
| +// ********** Code for AudioDestinationNode **************
|
| +// ********** Code for AudioGain **************
|
| +// ********** Code for AudioGainNode **************
|
| +// ********** Code for AudioListener **************
|
| +// ********** Code for AudioNode **************
|
| +// ********** Code for AudioPannerNode **************
|
| +// ********** Code for AudioParam **************
|
| +// ********** Code for AudioProcessingEvent **************
|
| +// ********** Code for AudioSourceNode **************
|
| +// ********** Code for BarInfo **************
|
| +// ********** Code for BeforeLoadEvent **************
|
| +// ********** Code for BiquadFilterNode **************
|
| +// ********** Code for Blob **************
|
| +// ********** Code for CDATASection **************
|
| +// ********** Code for CSSCharsetRule **************
|
| +// ********** Code for CSSFontFaceRule **************
|
| +// ********** Code for CSSImportRule **************
|
| +// ********** Code for CSSMediaRule **************
|
| +// ********** Code for CSSPageRule **************
|
| +// ********** Code for CSSPrimitiveValue **************
|
| +// ********** Code for CSSRule **************
|
| +// ********** Code for CSSRuleList **************
|
| +// ********** Code for CSSStyleDeclaration **************
|
| +$dynamic("setProperty$2").CSSStyleDeclaration = function($0, $1) {
|
| + return this.setProperty($0, $1);
|
| +};
|
| +// ********** Code for CSSStyleRule **************
|
| +// ********** Code for CSSStyleSheet **************
|
| +// ********** Code for CSSUnknownRule **************
|
| +// ********** Code for CSSValue **************
|
| +// ********** Code for CSSValueList **************
|
| +// ********** Code for CanvasGradient **************
|
| +// ********** Code for CanvasPattern **************
|
| +// ********** Code for CanvasPixelArray **************
|
| +// ********** Code for CanvasRenderingContext **************
|
| +// ********** Code for CanvasRenderingContext2D **************
|
| +// ********** Code for CharacterData **************
|
| +// ********** Code for ClientRect **************
|
| +// ********** Code for ClientRectList **************
|
| +// ********** Code for Clipboard **************
|
| +// ********** Code for CloseEvent **************
|
| +// ********** Code for Comment **************
|
| +// ********** Code for CompositionEvent **************
|
| +// ********** Code for Console **************
|
| +Console = (typeof console == 'undefined' ? {} : console);
|
| +// ********** Code for ConvolverNode **************
|
| +// ********** Code for Coordinates **************
|
| +// ********** Code for Counter **************
|
| +// ********** Code for Crypto **************
|
| +// ********** Code for CustomEvent **************
|
| +// ********** Code for DOMApplicationCache **************
|
| +$dynamic("addEventListener$3").DOMApplicationCache = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for DOMException **************
|
| +$dynamic("toString$0").DOMException = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for DOMFileSystem **************
|
| +// ********** Code for DOMFileSystemSync **************
|
| +// ********** Code for DOMFormData **************
|
| +// ********** Code for DOMImplementation **************
|
| +// ********** Code for DOMMimeType **************
|
| +// ********** Code for DOMMimeTypeArray **************
|
| +// ********** Code for DOMParser **************
|
| +// ********** Code for DOMPlugin **************
|
| +// ********** Code for DOMPluginArray **************
|
| +// ********** Code for DOMSelection **************
|
| +$dynamic("toString$0").DOMSelection = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for DOMSettableTokenList **************
|
| +// ********** Code for DOMTokenList **************
|
| +$dynamic("add$1").DOMTokenList = function($0) {
|
| + return this.add($0);
|
| +};
|
| +$dynamic("contains$1").DOMTokenList = function($0) {
|
| + return this.contains($0);
|
| +};
|
| +$dynamic("toString$0").DOMTokenList = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for DOMURL **************
|
| +// ********** Code for DOMWindow **************
|
| +$dynamic("addEventListener$3").DOMWindow = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +$dynamic("focus$0").DOMWindow = function() {
|
| + return this.focus();
|
| +};
|
| +// ********** Code for DataTransferItem **************
|
| +// ********** Code for DataTransferItemList **************
|
| +$dynamic("clear$0").DataTransferItemList = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for DataView **************
|
| +// ********** Code for Database **************
|
| +// ********** Code for DatabaseSync **************
|
| +// ********** Code for DedicatedWorkerContext **************
|
| +// ********** Code for DelayNode **************
|
| +// ********** Code for DeviceMotionEvent **************
|
| +// ********** Code for DeviceOrientationEvent **************
|
| +// ********** Code for DirectoryEntry **************
|
| +// ********** Code for DirectoryEntrySync **************
|
| +// ********** Code for DirectoryReader **************
|
| +// ********** Code for DirectoryReaderSync **************
|
| +// ********** Code for Document **************
|
| +// ********** Code for DocumentFragment **************
|
| +// ********** Code for DocumentType **************
|
| +// ********** Code for DynamicsCompressorNode **************
|
| +// ********** Code for Element **************
|
| +Element.prototype.focus$0 = function() {
|
| + return this.focus();
|
| +};
|
| +Element.prototype.getBoundingClientRect$0 = function() {
|
| + return this.getBoundingClientRect();
|
| +};
|
| +// ********** Code for ElementTimeControl **************
|
| +// ********** Code for ElementTraversal **************
|
| +// ********** Code for Entity **************
|
| +// ********** Code for EntityReference **************
|
| +// ********** Code for Entry **************
|
| +// ********** Code for EntryArray **************
|
| +// ********** Code for EntryArraySync **************
|
| +// ********** Code for EntrySync **************
|
| +// ********** Code for ErrorEvent **************
|
| +// ********** Code for Event **************
|
| +// ********** Code for EventException **************
|
| +$dynamic("toString$0").EventException = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for EventSource **************
|
| +$dynamic("addEventListener$3").EventSource = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for EventTarget **************
|
| +$dynamic("addEventListener$3").EventTarget = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for File **************
|
| +// ********** Code for FileEntry **************
|
| +// ********** Code for FileEntrySync **************
|
| +// ********** Code for FileError **************
|
| +// ********** Code for FileException **************
|
| +$dynamic("toString$0").FileException = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for FileList **************
|
| +// ********** Code for FileReader **************
|
| +// ********** Code for FileReaderSync **************
|
| +// ********** Code for FileWriter **************
|
| +// ********** Code for FileWriterSync **************
|
| +// ********** Code for Float32Array **************
|
| +Float32Array.prototype.is$List = function(){return true};
|
| +// ********** Code for Float64Array **************
|
| +Float64Array.prototype.is$List = function(){return true};
|
| +// ********** Code for Geolocation **************
|
| +// ********** Code for Geoposition **************
|
| +// ********** Code for HTMLAllCollection **************
|
| +// ********** Code for HTMLAnchorElement **************
|
| +$dynamic("toString$0").HTMLAnchorElement = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for HTMLAppletElement **************
|
| +// ********** Code for HTMLAreaElement **************
|
| +// ********** Code for HTMLAudioElement **************
|
| +// ********** Code for HTMLBRElement **************
|
| +$dynamic("clear$0").HTMLBRElement = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for HTMLBaseElement **************
|
| +// ********** Code for HTMLBaseFontElement **************
|
| +// ********** Code for HTMLBodyElement **************
|
| +// ********** Code for HTMLButtonElement **************
|
| +// ********** Code for HTMLCanvasElement **************
|
| +// ********** Code for HTMLCollection **************
|
| +HTMLCollection.prototype.$setindex = function(index, value) {
|
| + $throw(new UnsupportedOperationException("Cannot assign element of immutable List."));
|
| +}
|
| +// ********** Code for HTMLDListElement **************
|
| +// ********** Code for HTMLDataListElement **************
|
| +// ********** Code for HTMLDetailsElement **************
|
| +// ********** Code for HTMLDirectoryElement **************
|
| +// ********** Code for HTMLDivElement **************
|
| +// ********** Code for HTMLDocument **************
|
| +$dynamic("clear$0").HTMLDocument = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for HTMLElement **************
|
| +// ********** Code for HTMLEmbedElement **************
|
| +// ********** Code for HTMLFieldSetElement **************
|
| +// ********** Code for HTMLFontElement **************
|
| +// ********** Code for HTMLFormElement **************
|
| +// ********** Code for HTMLFrameElement **************
|
| +// ********** Code for HTMLFrameSetElement **************
|
| +// ********** Code for HTMLHRElement **************
|
| +// ********** Code for HTMLHeadElement **************
|
| +// ********** Code for HTMLHeadingElement **************
|
| +// ********** Code for HTMLHtmlElement **************
|
| +// ********** Code for HTMLIFrameElement **************
|
| +// ********** Code for HTMLImageElement **************
|
| +// ********** Code for HTMLInputElement **************
|
| +HTMLInputElement.prototype.select$0 = function() {
|
| + return this.select();
|
| +};
|
| +// ********** Code for HTMLIsIndexElement **************
|
| +// ********** Code for HTMLKeygenElement **************
|
| +// ********** Code for HTMLLIElement **************
|
| +// ********** Code for HTMLLabelElement **************
|
| +// ********** Code for HTMLLegendElement **************
|
| +// ********** Code for HTMLLinkElement **************
|
| +// ********** Code for HTMLMapElement **************
|
| +// ********** Code for HTMLMarqueeElement **************
|
| +$dynamic("start$0").HTMLMarqueeElement = function() {
|
| + return this.start();
|
| +};
|
| +// ********** Code for HTMLMediaElement **************
|
| +// ********** Code for HTMLMenuElement **************
|
| +// ********** Code for HTMLMetaElement **************
|
| +// ********** Code for HTMLMeterElement **************
|
| +// ********** Code for HTMLModElement **************
|
| +// ********** Code for HTMLOListElement **************
|
| +$dynamic("start$0").HTMLOListElement = function() {
|
| + return this.start();
|
| +};
|
| +// ********** Code for HTMLObjectElement **************
|
| +// ********** Code for HTMLOptGroupElement **************
|
| +// ********** Code for HTMLOptionElement **************
|
| +// ********** Code for HTMLOptionsCollection **************
|
| +// ********** Code for HTMLOutputElement **************
|
| +// ********** Code for HTMLParagraphElement **************
|
| +// ********** Code for HTMLParamElement **************
|
| +// ********** Code for HTMLPreElement **************
|
| +// ********** Code for HTMLProgressElement **************
|
| +// ********** Code for HTMLQuoteElement **************
|
| +// ********** Code for HTMLScriptElement **************
|
| +// ********** Code for HTMLSelectElement **************
|
| +// ********** Code for HTMLSourceElement **************
|
| +// ********** Code for HTMLSpanElement **************
|
| +// ********** Code for HTMLStyleElement **************
|
| +// ********** Code for HTMLTableCaptionElement **************
|
| +// ********** Code for HTMLTableCellElement **************
|
| +// ********** Code for HTMLTableColElement **************
|
| +// ********** Code for HTMLTableElement **************
|
| +// ********** Code for HTMLTableRowElement **************
|
| +// ********** Code for HTMLTableSectionElement **************
|
| +// ********** Code for HTMLTextAreaElement **************
|
| +$dynamic("select$0").HTMLTextAreaElement = function() {
|
| + return this.select();
|
| +};
|
| +// ********** Code for HTMLTitleElement **************
|
| +// ********** Code for HTMLTrackElement **************
|
| +// ********** Code for HTMLUListElement **************
|
| +// ********** Code for HTMLUnknownElement **************
|
| +// ********** Code for HTMLVideoElement **************
|
| +// ********** Code for HashChangeEvent **************
|
| +// ********** Code for HighPass2FilterNode **************
|
| +// ********** Code for History **************
|
| +// ********** Code for IDBAny **************
|
| +// ********** Code for IDBCursor **************
|
| +// ********** Code for IDBCursorWithValue **************
|
| +// ********** Code for IDBDatabase **************
|
| +$dynamic("addEventListener$3").IDBDatabase = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for IDBDatabaseError **************
|
| +// ********** Code for IDBDatabaseException **************
|
| +$dynamic("toString$0").IDBDatabaseException = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for IDBFactory **************
|
| +// ********** Code for IDBIndex **************
|
| +// ********** Code for IDBKey **************
|
| +// ********** Code for IDBKeyRange **************
|
| +// ********** Code for IDBObjectStore **************
|
| +$dynamic("add$1").IDBObjectStore = function($0) {
|
| + return this.add($0);
|
| +};
|
| +$dynamic("clear$0").IDBObjectStore = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for IDBRequest **************
|
| +$dynamic("addEventListener$3").IDBRequest = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for IDBTransaction **************
|
| +$dynamic("addEventListener$3").IDBTransaction = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for IDBVersionChangeEvent **************
|
| +// ********** Code for IDBVersionChangeRequest **************
|
| +// ********** Code for ImageData **************
|
| +// ********** Code for InjectedScriptHost **************
|
| +// ********** Code for InspectorFrontendHost **************
|
| +// ********** Code for Int16Array **************
|
| +Int16Array.prototype.is$List = function(){return true};
|
| +// ********** Code for Int32Array **************
|
| +Int32Array.prototype.is$List = function(){return true};
|
| +// ********** Code for Int8Array **************
|
| +Int8Array.prototype.is$List = function(){return true};
|
| +// ********** Code for JavaScriptAudioNode **************
|
| +// ********** Code for JavaScriptCallFrame **************
|
| +// ********** Code for KeyboardEvent **************
|
| +// ********** Code for Location **************
|
| +$dynamic("toString$0").Location = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for LowPass2FilterNode **************
|
| +// ********** Code for MediaElementAudioSourceNode **************
|
| +// ********** Code for MediaError **************
|
| +// ********** Code for MediaList **************
|
| +// ********** Code for MediaQueryList **************
|
| +// ********** Code for MediaQueryListListener **************
|
| +// ********** Code for MemoryInfo **************
|
| +// ********** Code for MessageChannel **************
|
| +// ********** Code for MessageEvent **************
|
| +// ********** Code for MessagePort **************
|
| +$dynamic("addEventListener$3").MessagePort = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +$dynamic("start$0").MessagePort = function() {
|
| + return this.start();
|
| +};
|
| +// ********** Code for Metadata **************
|
| +// ********** Code for MouseEvent **************
|
| +// ********** Code for MutationCallback **************
|
| +// ********** Code for MutationEvent **************
|
| +// ********** Code for MutationRecord **************
|
| +// ********** Code for NamedNodeMap **************
|
| +// ********** Code for Navigator **************
|
| +// ********** Code for NavigatorUserMediaError **************
|
| +// ********** Code for NavigatorUserMediaSuccessCallback **************
|
| +// ********** Code for Node **************
|
| +Node.prototype.addEventListener$3 = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +Node.prototype.appendChild$1 = function($0) {
|
| + return this.appendChild($0);
|
| +};
|
| +Node.prototype.contains$1 = function($0) {
|
| + return this.contains($0);
|
| +};
|
| +Node.prototype.insertBefore$2 = function($0, $1) {
|
| + return this.insertBefore($0, $1);
|
| +};
|
| +Node.prototype.removeChild$1 = function($0) {
|
| + return this.removeChild($0);
|
| +};
|
| +// ********** Code for NodeFilter **************
|
| +// ********** Code for NodeIterator **************
|
| +$dynamic("filter$1").NodeIterator = function($0) {
|
| + return this.filter($0);
|
| +};
|
| +// ********** Code for NodeList **************
|
| +// ********** Code for NodeSelector **************
|
| +// ********** Code for Notation **************
|
| +// ********** Code for Notification **************
|
| +$dynamic("addEventListener$3").Notification = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for NotificationCenter **************
|
| +// ********** Code for OESStandardDerivatives **************
|
| +// ********** Code for OESTextureFloat **************
|
| +// ********** Code for OESVertexArrayObject **************
|
| +// ********** Code for OfflineAudioCompletionEvent **************
|
| +// ********** Code for OperationNotAllowedException **************
|
| +$dynamic("toString$0").OperationNotAllowedException = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for OverflowEvent **************
|
| +// ********** Code for PageTransitionEvent **************
|
| +// ********** Code for Performance **************
|
| +// ********** Code for PerformanceNavigation **************
|
| +// ********** Code for PerformanceTiming **************
|
| +// ********** Code for PopStateEvent **************
|
| +// ********** Code for PositionError **************
|
| +// ********** Code for ProcessingInstruction **************
|
| +// ********** Code for ProgressEvent **************
|
| +// ********** Code for RGBColor **************
|
| +// ********** Code for Range **************
|
| +$dynamic("getBoundingClientRect$0").Range = function() {
|
| + return this.getBoundingClientRect();
|
| +};
|
| +$dynamic("toString$0").Range = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for RangeException **************
|
| +$dynamic("toString$0").RangeException = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for RealtimeAnalyserNode **************
|
| +// ********** Code for Rect **************
|
| +// ********** Code for SQLError **************
|
| +// ********** Code for SQLException **************
|
| +// ********** Code for SQLResultSet **************
|
| +// ********** Code for SQLResultSetRowList **************
|
| +// ********** Code for SQLTransaction **************
|
| +// ********** Code for SQLTransactionSync **************
|
| +// ********** Code for SVGAElement **************
|
| +// ********** Code for SVGAltGlyphDefElement **************
|
| +// ********** Code for SVGAltGlyphElement **************
|
| +// ********** Code for SVGAltGlyphItemElement **************
|
| +// ********** Code for SVGAngle **************
|
| +// ********** Code for SVGAnimateColorElement **************
|
| +// ********** Code for SVGAnimateElement **************
|
| +// ********** Code for SVGAnimateMotionElement **************
|
| +// ********** Code for SVGAnimateTransformElement **************
|
| +// ********** Code for SVGAnimatedAngle **************
|
| +// ********** Code for SVGAnimatedBoolean **************
|
| +// ********** Code for SVGAnimatedEnumeration **************
|
| +// ********** Code for SVGAnimatedInteger **************
|
| +// ********** Code for SVGAnimatedLength **************
|
| +// ********** Code for SVGAnimatedLengthList **************
|
| +// ********** Code for SVGAnimatedNumber **************
|
| +// ********** Code for SVGAnimatedNumberList **************
|
| +// ********** Code for SVGAnimatedPreserveAspectRatio **************
|
| +// ********** Code for SVGAnimatedRect **************
|
| +// ********** Code for SVGAnimatedString **************
|
| +// ********** Code for SVGAnimatedTransformList **************
|
| +// ********** Code for SVGAnimationElement **************
|
| +// ********** Code for SVGCircleElement **************
|
| +// ********** Code for SVGClipPathElement **************
|
| +// ********** Code for SVGColor **************
|
| +// ********** Code for SVGComponentTransferFunctionElement **************
|
| +// ********** Code for SVGCursorElement **************
|
| +// ********** Code for SVGDefsElement **************
|
| +// ********** Code for SVGDescElement **************
|
| +// ********** Code for SVGDocument **************
|
| +// ********** Code for SVGElement **************
|
| +// ********** Code for SVGElementInstance **************
|
| +$dynamic("addEventListener$3").SVGElementInstance = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for SVGElementInstanceList **************
|
| +// ********** Code for SVGEllipseElement **************
|
| +// ********** Code for SVGException **************
|
| +$dynamic("toString$0").SVGException = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for SVGExternalResourcesRequired **************
|
| +// ********** Code for SVGFEBlendElement **************
|
| +// ********** Code for SVGFEColorMatrixElement **************
|
| +// ********** Code for SVGFEComponentTransferElement **************
|
| +// ********** Code for SVGFECompositeElement **************
|
| +// ********** Code for SVGFEConvolveMatrixElement **************
|
| +// ********** Code for SVGFEDiffuseLightingElement **************
|
| +// ********** Code for SVGFEDisplacementMapElement **************
|
| +// ********** Code for SVGFEDistantLightElement **************
|
| +// ********** Code for SVGFEDropShadowElement **************
|
| +// ********** Code for SVGFEFloodElement **************
|
| +// ********** Code for SVGFEFuncAElement **************
|
| +// ********** Code for SVGFEFuncBElement **************
|
| +// ********** Code for SVGFEFuncGElement **************
|
| +// ********** Code for SVGFEFuncRElement **************
|
| +// ********** Code for SVGFEGaussianBlurElement **************
|
| +// ********** Code for SVGFEImageElement **************
|
| +// ********** Code for SVGFEMergeElement **************
|
| +// ********** Code for SVGFEMergeNodeElement **************
|
| +// ********** Code for SVGFEMorphologyElement **************
|
| +// ********** Code for SVGFEOffsetElement **************
|
| +// ********** Code for SVGFEPointLightElement **************
|
| +// ********** Code for SVGFESpecularLightingElement **************
|
| +// ********** Code for SVGFESpotLightElement **************
|
| +// ********** Code for SVGFETileElement **************
|
| +// ********** Code for SVGFETurbulenceElement **************
|
| +// ********** Code for SVGFilterElement **************
|
| +// ********** Code for SVGFilterPrimitiveStandardAttributes **************
|
| +// ********** Code for SVGFitToViewBox **************
|
| +// ********** Code for SVGFontElement **************
|
| +// ********** Code for SVGFontFaceElement **************
|
| +// ********** Code for SVGFontFaceFormatElement **************
|
| +// ********** Code for SVGFontFaceNameElement **************
|
| +// ********** Code for SVGFontFaceSrcElement **************
|
| +// ********** Code for SVGFontFaceUriElement **************
|
| +// ********** Code for SVGForeignObjectElement **************
|
| +// ********** Code for SVGGElement **************
|
| +// ********** Code for SVGGlyphElement **************
|
| +// ********** Code for SVGGlyphRefElement **************
|
| +// ********** Code for SVGGradientElement **************
|
| +// ********** Code for SVGHKernElement **************
|
| +// ********** Code for SVGImageElement **************
|
| +// ********** Code for SVGLangSpace **************
|
| +// ********** Code for SVGLength **************
|
| +// ********** Code for SVGLengthList **************
|
| +$dynamic("clear$0").SVGLengthList = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for SVGLineElement **************
|
| +// ********** Code for SVGLinearGradientElement **************
|
| +// ********** Code for SVGLocatable **************
|
| +// ********** Code for SVGMPathElement **************
|
| +// ********** Code for SVGMarkerElement **************
|
| +// ********** Code for SVGMaskElement **************
|
| +// ********** Code for SVGMatrix **************
|
| +// ********** Code for SVGMetadataElement **************
|
| +// ********** Code for SVGMissingGlyphElement **************
|
| +// ********** Code for SVGNumber **************
|
| +// ********** Code for SVGNumberList **************
|
| +$dynamic("clear$0").SVGNumberList = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for SVGPaint **************
|
| +// ********** Code for SVGPathElement **************
|
| +// ********** Code for SVGPathSeg **************
|
| +// ********** Code for SVGPathSegArcAbs **************
|
| +// ********** Code for SVGPathSegArcRel **************
|
| +// ********** Code for SVGPathSegClosePath **************
|
| +// ********** Code for SVGPathSegCurvetoCubicAbs **************
|
| +// ********** Code for SVGPathSegCurvetoCubicRel **************
|
| +// ********** Code for SVGPathSegCurvetoCubicSmoothAbs **************
|
| +// ********** Code for SVGPathSegCurvetoCubicSmoothRel **************
|
| +// ********** Code for SVGPathSegCurvetoQuadraticAbs **************
|
| +// ********** Code for SVGPathSegCurvetoQuadraticRel **************
|
| +// ********** Code for SVGPathSegCurvetoQuadraticSmoothAbs **************
|
| +// ********** Code for SVGPathSegCurvetoQuadraticSmoothRel **************
|
| +// ********** Code for SVGPathSegLinetoAbs **************
|
| +// ********** Code for SVGPathSegLinetoHorizontalAbs **************
|
| +// ********** Code for SVGPathSegLinetoHorizontalRel **************
|
| +// ********** Code for SVGPathSegLinetoRel **************
|
| +// ********** Code for SVGPathSegLinetoVerticalAbs **************
|
| +// ********** Code for SVGPathSegLinetoVerticalRel **************
|
| +// ********** Code for SVGPathSegList **************
|
| +$dynamic("clear$0").SVGPathSegList = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for SVGPathSegMovetoAbs **************
|
| +// ********** Code for SVGPathSegMovetoRel **************
|
| +// ********** Code for SVGPatternElement **************
|
| +// ********** Code for SVGPoint **************
|
| +// ********** Code for SVGPointList **************
|
| +$dynamic("clear$0").SVGPointList = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for SVGPolygonElement **************
|
| +// ********** Code for SVGPolylineElement **************
|
| +// ********** Code for SVGPreserveAspectRatio **************
|
| +// ********** Code for SVGRadialGradientElement **************
|
| +// ********** Code for SVGRect **************
|
| +// ********** Code for SVGRectElement **************
|
| +// ********** Code for SVGRenderingIntent **************
|
| +// ********** Code for SVGSVGElement **************
|
| +// ********** Code for SVGScriptElement **************
|
| +// ********** Code for SVGSetElement **************
|
| +// ********** Code for SVGStopElement **************
|
| +// ********** Code for SVGStringList **************
|
| +$dynamic("clear$0").SVGStringList = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for SVGStylable **************
|
| +// ********** Code for SVGStyleElement **************
|
| +// ********** Code for SVGSwitchElement **************
|
| +// ********** Code for SVGSymbolElement **************
|
| +// ********** Code for SVGTRefElement **************
|
| +// ********** Code for SVGTSpanElement **************
|
| +// ********** Code for SVGTests **************
|
| +// ********** Code for SVGTextContentElement **************
|
| +// ********** Code for SVGTextElement **************
|
| +// ********** Code for SVGTextPathElement **************
|
| +// ********** Code for SVGTextPositioningElement **************
|
| +// ********** Code for SVGTitleElement **************
|
| +// ********** Code for SVGTransform **************
|
| +// ********** Code for SVGTransformList **************
|
| +$dynamic("clear$0").SVGTransformList = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for SVGTransformable **************
|
| +// ********** Code for SVGURIReference **************
|
| +// ********** Code for SVGUnitTypes **************
|
| +// ********** Code for SVGUseElement **************
|
| +// ********** Code for SVGVKernElement **************
|
| +// ********** Code for SVGViewElement **************
|
| +// ********** Code for SVGViewSpec **************
|
| +// ********** Code for SVGZoomAndPan **************
|
| +// ********** Code for SVGZoomEvent **************
|
| +// ********** Code for Screen **************
|
| +// ********** Code for ScriptProfile **************
|
| +// ********** Code for ScriptProfileNode **************
|
| +// ********** Code for SharedWorker **************
|
| +// ********** Code for SharedWorkercontext **************
|
| +// ********** Code for SpeechInputEvent **************
|
| +// ********** Code for SpeechInputResult **************
|
| +// ********** Code for SpeechInputResultList **************
|
| +// ********** Code for Storage **************
|
| +$dynamic("clear$0").Storage = function() {
|
| + return this.clear();
|
| +};
|
| +// ********** Code for StorageEvent **************
|
| +// ********** Code for StorageInfo **************
|
| +// ********** Code for StyleMedia **************
|
| +// ********** Code for StyleSheet **************
|
| +// ********** Code for StyleSheetList **************
|
| +// ********** Code for Text **************
|
| +// ********** Code for TextEvent **************
|
| +// ********** Code for TextMetrics **************
|
| +// ********** Code for TextTrack **************
|
| +// ********** Code for TextTrackCue **************
|
| +// ********** Code for TextTrackCueList **************
|
| +// ********** Code for TimeRanges **************
|
| +// ********** Code for Touch **************
|
| +// ********** Code for TouchEvent **************
|
| +// ********** Code for TouchList **************
|
| +// ********** Code for TreeWalker **************
|
| +$dynamic("filter$1").TreeWalker = function($0) {
|
| + return this.filter($0);
|
| +};
|
| +// ********** Code for UIEvent **************
|
| +// ********** Code for Uint16Array **************
|
| +Uint16Array.prototype.is$List = function(){return true};
|
| +// ********** Code for Uint32Array **************
|
| +Uint32Array.prototype.is$List = function(){return true};
|
| +// ********** Code for Uint8Array **************
|
| +Uint8Array.prototype.is$List = function(){return true};
|
| +// ********** Code for ValidityState **************
|
| +// ********** Code for VoidCallback **************
|
| +// ********** Code for WaveShaperNode **************
|
| +// ********** Code for WebGLActiveInfo **************
|
| +// ********** Code for WebGLBuffer **************
|
| +// ********** Code for WebGLContextAttributes **************
|
| +// ********** Code for WebGLContextEvent **************
|
| +// ********** Code for WebGLDebugRendererInfo **************
|
| +// ********** Code for WebGLDebugShaders **************
|
| +// ********** Code for WebGLFramebuffer **************
|
| +// ********** Code for WebGLProgram **************
|
| +// ********** Code for WebGLRenderbuffer **************
|
| +// ********** Code for WebGLRenderingContext **************
|
| +// ********** Code for WebGLShader **************
|
| +// ********** Code for WebGLTexture **************
|
| +// ********** Code for WebGLUniformLocation **************
|
| +// ********** Code for WebGLVertexArrayObjectOES **************
|
| +// ********** Code for WebKitAnimation **************
|
| +// ********** Code for WebKitAnimationEvent **************
|
| +// ********** Code for WebKitAnimationList **************
|
| +// ********** Code for WebKitBlobBuilder **************
|
| +// ********** Code for WebKitCSSFilterValue **************
|
| +// ********** Code for WebKitCSSKeyframeRule **************
|
| +// ********** Code for WebKitCSSKeyframesRule **************
|
| +// ********** Code for WebKitCSSMatrix **************
|
| +$dynamic("toString$0").WebKitCSSMatrix = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for WebKitCSSTransformValue **************
|
| +// ********** Code for WebKitFlags **************
|
| +// ********** Code for WebKitLoseContext **************
|
| +// ********** Code for WebKitMutationObserver **************
|
| +// ********** Code for WebKitPoint **************
|
| +// ********** Code for WebKitTransitionEvent **************
|
| +// ********** Code for WebSocket **************
|
| +$dynamic("addEventListener$3").WebSocket = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for WheelEvent **************
|
| +// ********** Code for Worker **************
|
| +// ********** Code for WorkerContext **************
|
| +$dynamic("addEventListener$3").WorkerContext = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for WorkerLocation **************
|
| +$dynamic("toString$0").WorkerLocation = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for WorkerNavigator **************
|
| +// ********** Code for XMLHttpRequest **************
|
| +$dynamic("addEventListener$3").XMLHttpRequest = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for XMLHttpRequestException **************
|
| +$dynamic("toString$0").XMLHttpRequestException = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for XMLHttpRequestProgressEvent **************
|
| +// ********** Code for XMLHttpRequestUpload **************
|
| +$dynamic("addEventListener$3").XMLHttpRequestUpload = function($0, $1, $2) {
|
| + return this.addEventListener($0, $wrap_call$1(to$call$1($1)), $2);
|
| +};
|
| +// ********** Code for XMLSerializer **************
|
| +// ********** Code for XPathEvaluator **************
|
| +// ********** Code for XPathException **************
|
| +$dynamic("toString$0").XPathException = function() {
|
| + return this.toString();
|
| +};
|
| +// ********** Code for XPathExpression **************
|
| +// ********** Code for XPathNSResolver **************
|
| +// ********** Code for XPathResult **************
|
| +// ********** Code for XSLTProcessor **************
|
| +// ********** Code for _Collections **************
|
| +function _Collections() {}
|
| +// ********** Code for _VariableSizeListIterator_T **************
|
| +$inherits(_VariableSizeListIterator_T, _VariableSizeListIterator);
|
| +function _VariableSizeListIterator_T() {}
|
| +// ********** Code for _FixedSizeListIterator **************
|
| +$inherits(_FixedSizeListIterator, _VariableSizeListIterator_T);
|
| +function _FixedSizeListIterator() {}
|
| +_FixedSizeListIterator.prototype.hasNext$0 = _FixedSizeListIterator.prototype.hasNext;
|
| +// ********** Code for _VariableSizeListIterator **************
|
| +function _VariableSizeListIterator() {}
|
| +_VariableSizeListIterator.prototype.hasNext$0 = _VariableSizeListIterator.prototype.hasNext;
|
| +_VariableSizeListIterator.prototype.next$0 = _VariableSizeListIterator.prototype.next;
|
| +// ********** Code for _Lists **************
|
| +function _Lists() {}
|
| +// ********** Code for top level **************
|
| +function get$window() {
|
| + return window;
|
| +}
|
| +function get$document() {
|
| + return window.document;
|
| +}
|
| +// ********** Library file_system **************
|
| +// ********** Code for top level **************
|
| +function joinPaths(path1, path2) {
|
| + var pieces = path1.split('/');
|
| + var $$list = path2.split('/');
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var piece = $$list.$index($$i);
|
| + if ($eq(piece, '..') && pieces.length > 0 && $ne(pieces.last$0(), '.') && $ne(pieces.last$0(), '..')) {
|
| + pieces.removeLast$0();
|
| + }
|
| + else if ($ne(piece, '')) {
|
| + if (pieces.length > 0 && $eq(pieces.last$0(), '.')) {
|
| + pieces.removeLast$0();
|
| + }
|
| + pieces.add$1(piece);
|
| + }
|
| + }
|
| + return Strings.join(pieces, '/');
|
| +}
|
| +function dirname(path) {
|
| + var lastSlash = path.lastIndexOf('/', path.length);
|
| + if (lastSlash == -1) {
|
| + return '.';
|
| + }
|
| + else {
|
| + return path.substring(0, lastSlash);
|
| + }
|
| +}
|
| +function basename(path) {
|
| + var lastSlash = path.lastIndexOf('/', path.length);
|
| + if (lastSlash == -1) {
|
| + return path;
|
| + }
|
| + else {
|
| + return path.substring(lastSlash + 1);
|
| + }
|
| +}
|
| +// ********** Library lang **************
|
| +// ********** Code for CodeWriter **************
|
| +function CodeWriter() {
|
| + this._indentation = 0
|
| + this._pendingIndent = false
|
| + this.writeComments = true
|
| + this._buf = new StringBufferImpl("");
|
| + // Initializers done
|
| +}
|
| +CodeWriter.prototype.get$text = function() {
|
| + return this._buf.toString();
|
| +}
|
| +Object.defineProperty(CodeWriter.prototype, "text", {
|
| + get: CodeWriter.prototype.get$text
|
| +});
|
| +CodeWriter.prototype._indent = function() {
|
| + this._pendingIndent = false;
|
| + for (var i = 0;
|
| + i < this._indentation; i++) {
|
| + this._buf.add(' '/*CodeWriter.INDENTATION*/);
|
| + }
|
| +}
|
| +CodeWriter.prototype.comment = function(text) {
|
| + if (this.writeComments) {
|
| + this.writeln(text);
|
| + }
|
| +}
|
| +CodeWriter.prototype.write = function(text) {
|
| + if (text.length == 0) return;
|
| + if (this._pendingIndent) this._indent();
|
| + if (text.indexOf('\n') != -1) {
|
| + var lines = text.split('\n');
|
| + for (var i = 0;
|
| + i < lines.length - 1; i++) {
|
| + this.writeln(lines.$index(i));
|
| + }
|
| + this.write(lines.$index(lines.length - 1));
|
| + }
|
| + else {
|
| + this._buf.add(text);
|
| + }
|
| +}
|
| +CodeWriter.prototype.writeln = function(text) {
|
| + if (text != null) {
|
| + this.write(text);
|
| + }
|
| + if (!text.endsWith('\n')) this._buf.add('\n'/*CodeWriter.NEWLINE*/);
|
| + this._pendingIndent = true;
|
| +}
|
| +CodeWriter.prototype.enterBlock = function(text) {
|
| + this.writeln(text);
|
| + this._indentation++;
|
| +}
|
| +CodeWriter.prototype.exitBlock = function(text) {
|
| + this._indentation--;
|
| + this.writeln(text);
|
| +}
|
| +CodeWriter.prototype.nextBlock = function(text) {
|
| + this._indentation--;
|
| + this.writeln(text);
|
| + this._indentation++;
|
| +}
|
| +// ********** Code for CoreJs **************
|
| +function CoreJs() {
|
| + this.useStackTraceOf = false
|
| + this.useThrow = false
|
| + this.useGenStub = false
|
| + this.useAssert = false
|
| + this.useNotNullBool = false
|
| + this.useIndex = false
|
| + this.useSetIndex = false
|
| + this.useWrap0 = false
|
| + this.useWrap1 = false
|
| + this.useIsolates = false
|
| + this.useToString = false
|
| + this._generatedTypeNameOf = false
|
| + this._generatedDynamicProto = false
|
| + this._generatedInherits = false
|
| + this._usedOperators = new HashMapImplementation();
|
| + this.writer = new CodeWriter();
|
| + // Initializers done
|
| +}
|
| +CoreJs.prototype.useOperator = function(name) {
|
| + if (this._usedOperators.$index(name) != null) return;
|
| + var code;
|
| + switch (name) {
|
| + case ':ne':
|
| +
|
| + code = "function $ne(x, y) {\n if (x == null) return y != null;\n return (typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'boolean' && typeof(y) == 'boolean') ||\n (typeof(x) == 'string' && typeof(y) == 'string')\n ? x != y : !x.$eq(y);\n}";
|
| + break;
|
| +
|
| + case ':eq':
|
| +
|
| + code = "function $eq(x, y) {\n if (x == null) return y == null;\n return (typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'boolean' && typeof(y) == 'boolean') ||\n (typeof(x) == 'string' && typeof(y) == 'string')\n ? x == y : x.$eq(y);\n}\n// TODO(jimhug): Should this or should it not match equals?\nObject.prototype.$eq = function(other) { return this === other; }";
|
| + break;
|
| +
|
| + case ':bit_not':
|
| +
|
| + code = "function $bit_not(x) {\n return (typeof(x) == 'number') ? ~x : x.$bit_not();\n}";
|
| + break;
|
| +
|
| + case ':negate':
|
| +
|
| + code = "function $negate(x) {\n return (typeof(x) == 'number') ? -x : x.$negate();\n}";
|
| + break;
|
| +
|
| + case ':add':
|
| +
|
| + code = "function $add(x, y) {\n return ((typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'string'))\n ? x + y : x.$add(y);\n}";
|
| + break;
|
| +
|
| + case ':truncdiv':
|
| +
|
| + this.useThrow = true;
|
| + code = "function $truncdiv(x, y) {\n if (typeof(x) == 'number' && typeof(y) == 'number') {\n if (y == 0) $throw(new IntegerDivisionByZeroException());\n var tmp = x / y;\n return (tmp < 0) ? Math.ceil(tmp) : Math.floor(tmp);\n } else {\n return x.$truncdiv(y);\n }\n}";
|
| + break;
|
| +
|
| + case ':mod':
|
| +
|
| + code = "function $mod(x, y) {\n if (typeof(x) == 'number' && typeof(y) == 'number') {\n var result = x % y;\n if (result == 0) {\n return 0; // Make sure we don't return -0.0.\n } else if (result < 0) {\n if (y < 0) {\n return result - y;\n } else {\n return result + y;\n }\n }\n return result;\n } else {\n return x.$mod(y);\n }\n}";
|
| + break;
|
| +
|
| + default:
|
| +
|
| + var op = TokenKind.rawOperatorFromMethod(name);
|
| + var jsname = $globals.world.toJsIdentifier(name);
|
| + code = ("function " + jsname + "(x, y) {\n return (typeof(x) == 'number' && typeof(y) == 'number')\n ? x " + op + " y : x." + jsname + "(y);\n}");
|
| + break;
|
| +
|
| + }
|
| + this._usedOperators.$setindex(name, code);
|
| +}
|
| +CoreJs.prototype.ensureDynamicProto = function() {
|
| + if (this._generatedDynamicProto) return;
|
| + this._generatedDynamicProto = true;
|
| + this.ensureTypeNameOf();
|
| + this.writer.writeln("function $dynamic(name) {\n var f = Object.prototype[name];\n if (f && f.methods) return f.methods;\n\n var methods = {};\n if (f) methods.Object = f;\n function $dynamicBind() {\n // Find the target method\n var method;\n var proto = Object.getPrototypeOf(this);\n var obj = this;\n do {\n method = methods[obj.$typeNameOf()];\n if (method) break;\n obj = Object.getPrototypeOf(obj);\n } while (obj);\n\n // Patch the prototype, but don't overwrite an existing stub, like\n // the one on Object.prototype.\n if (!proto.hasOwnProperty(name)) proto[name] = method || methods.Object;\n\n return method.apply(this, Array.prototype.slice.call(arguments));\n };\n $dynamicBind.methods = methods;\n Object.prototype[name] = $dynamicBind;\n return methods;\n}");
|
| +}
|
| +CoreJs.prototype.ensureTypeNameOf = function() {
|
| + if (this._generatedTypeNameOf) return;
|
| + this._generatedTypeNameOf = true;
|
| + this.writer.writeln("Object.prototype.$typeNameOf = function() {\n if ((typeof(window) != 'undefined' && window.constructor.name == 'DOMWindow')\n || typeof(process) != 'undefined') { // fast-path for Chrome and Node\n return this.constructor.name;\n }\n var str = Object.prototype.toString.call(this);\n str = str.substring(8, str.length - 1);\n if (str == 'Window') str = 'DOMWindow';\n return str;\n}");
|
| +}
|
| +CoreJs.prototype.ensureInheritsHelper = function() {
|
| + if (this._generatedInherits) return;
|
| + this._generatedInherits = true;
|
| + this.writer.writeln("/** Implements extends for Dart classes on JavaScript prototypes. */\nfunction $inherits(child, parent) {\n if (child.prototype.__proto__) {\n child.prototype.__proto__ = parent.prototype;\n } else {\n function tmp() {};\n tmp.prototype = parent.prototype;\n child.prototype = new tmp();\n child.prototype.constructor = child;\n }\n}");
|
| +}
|
| +CoreJs.prototype.generate = function(w) {
|
| + w.write(this.writer.get$text());
|
| + this.writer = w;
|
| + if (this.useGenStub) {
|
| + this.useThrow = true;
|
| + w.writeln("/**\n * Generates a dynamic call stub for a function.\n * Our goal is to create a stub method like this on-the-fly:\n * function($0, $1, capture) { return this($0, $1, true, capture); }\n *\n * This stub then replaces the dynamic one on Function, with one that is\n * specialized for that particular function, taking into account its default\n * arguments.\n */\nFunction.prototype.$genStub = function(argsLength, names) {\n // Fast path: if no named arguments and arg count matches\n if (this.length == argsLength && !names) {\n return this;\n }\n\n function $throwArgMismatch() {\n // TODO(jmesserly): better error message\n $throw(new ClosureArgumentMismatchException());\n }\n\n var paramsNamed = this.$optional ? (this.$optional.length / 2) : 0;\n var paramsBare = this.length - paramsNamed;\n var argsNamed = names ? names.length : 0;\n var argsBare = argsLength - argsNamed;\n\n // Check we got the right number of arguments\n if (argsBare < paramsBare || argsLength > this.length ||\n argsNamed > paramsNamed) {\n return $throwArgMismatch;\n }\n\n // First, fill in all of the default values\n var p = new Array(paramsBare);\n if (paramsNamed) {\n p = p.concat(this.$optional.slice(paramsNamed));\n }\n // Fill in positional args\n var a = new Array(argsLength);\n for (var i = 0; i < argsBare; i++) {\n p[i] = a[i] = '$' + i;\n }\n // Then overwrite with supplied values for optional args\n var lastParameterIndex;\n var namesInOrder = true;\n for (var i = 0; i < argsNamed; i++) {\n var name = names[i];\n a[i + argsBare] = name;\n var j = this.$optional.indexOf(name);\n if (j < 0 || j >= paramsNamed) {\n return $throwArgMismatch;\n } else if (lastParameterIndex && lastParameterIndex > j) {\n namesInOrder = false;\n }\n p[j + paramsBare] = name;\n lastParameterIndex = j;\n }\n\n if (this.length == argsLength && namesInOrder) {\n // Fast path #2: named arguments, but they're in order.\n return this;\n }\n\n // Note: using Function instead of 'eval' to get a clean scope.\n // TODO(jmesserly): evaluate the performance of these stubs.\n var f = 'function(' + a.join(',') + '){return $f(' + p.join(',') + ');}';\n return new Function('$f', 'return ' + f + '').call(null, this);\n}");
|
| + }
|
| + if (this.useStackTraceOf) {
|
| + w.writeln("function $stackTraceOf(e) {\n // TODO(jmesserly): we shouldn't be relying on the e.stack property.\n // Need to mangle it.\n return (e && e.stack) ? e.stack : null;\n}");
|
| + }
|
| + if (this.useNotNullBool) {
|
| + this.useThrow = true;
|
| + w.writeln("function $notnull_bool(test) {\n if (test === true || test === false) return test;\n $throw(new TypeError(test, 'bool'));\n}");
|
| + }
|
| + if (this.useThrow) {
|
| + w.writeln("function $throw(e) {\n // If e is not a value, we can use V8's captureStackTrace utility method.\n // TODO(jmesserly): capture the stack trace on other JS engines.\n if (e && (typeof e == 'object') && Error.captureStackTrace) {\n // TODO(jmesserly): this will clobber the e.stack property\n Error.captureStackTrace(e, $throw);\n }\n throw e;\n}");
|
| + }
|
| + if (this.useToString) {
|
| + w.writeln("function $toString(o) {\n if (o == null) return 'null';\n var t = typeof(o);\n if (t == 'object') { return o.toString(); }\n else if (t == 'string') { return o; }\n else if (t == 'bool') { return ''+o; }\n else if (t == 'number') { return ''+o; }\n else return o.toString();\n}");
|
| + }
|
| + if (this.useIndex) {
|
| + w.writeln("Object.prototype.$index = function(i) {\n var proto = Object.getPrototypeOf(this);\n if (proto !== Object) {\n proto.$index = function(i) { return this[i]; }\n }\n return this[i];\n}\nArray.prototype.$index = function(i) { return this[i]; }\nString.prototype.$index = function(i) { return this[i]; }");
|
| + }
|
| + if (this.useSetIndex) {
|
| + w.writeln("Object.prototype.$setindex = function(i, value) {\n var proto = Object.getPrototypeOf(this);\n if (proto !== Object) {\n proto.$setindex = function(i, value) { return this[i] = value; }\n }\n return this[i] = value;\n}\nArray.prototype.$setindex = function(i, value) { return this[i] = value; }");
|
| + }
|
| + if (this.useIsolates) {
|
| + if (this.useWrap0) {
|
| + w.writeln("// Wrap a 0-arg dom-callback to bind it with the current isolate:\nfunction $wrap_call$0(fn) { return fn && fn.wrap$call$0(); }\nFunction.prototype.wrap$call$0 = function() {\n var isolateContext = $globalState.currentContext;\n var self = this;\n this.wrap$0 = function() {\n isolateContext.eval(self);\n $globalState.topEventLoop.run();\n };\n this.wrap$call$0 = function() { return this.wrap$0; };\n return this.wrap$0;\n}");
|
| + }
|
| + if (this.useWrap1) {
|
| + w.writeln("// Wrap a 1-arg dom-callback to bind it with the current isolate:\nfunction $wrap_call$1(fn) { return fn && fn.wrap$call$1(); }\nFunction.prototype.wrap$call$1 = function() {\n var isolateContext = $globalState.currentContext;\n var self = this;\n this.wrap$1 = function(arg) {\n isolateContext.eval(function() { self(arg); });\n $globalState.topEventLoop.run();\n };\n this.wrap$call$1 = function() { return this.wrap$1; };\n return this.wrap$1;\n}");
|
| + }
|
| + w.writeln("var $globalThis = this;\nvar $globals = null;\nvar $globalState = null;");
|
| + }
|
| + else {
|
| + if (this.useWrap0) {
|
| + w.writeln("function $wrap_call$0(fn) { return fn; }");
|
| + }
|
| + if (this.useWrap1) {
|
| + w.writeln("function $wrap_call$1(fn) { return fn; }");
|
| + }
|
| + }
|
| + var $$list = orderValuesByKeys(this._usedOperators);
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var opImpl = $$list.$index($$i);
|
| + w.writeln(opImpl);
|
| + }
|
| +}
|
| +CoreJs.prototype.generate$1 = CoreJs.prototype.generate;
|
| +// ********** Code for lang_Element **************
|
| +function lang_Element(name, _enclosingElement) {
|
| + this.name = name;
|
| + this._enclosingElement = _enclosingElement;
|
| + // Initializers done
|
| + this._jsname = $globals.world.toJsIdentifier(this.name);
|
| +}
|
| +lang_Element.prototype.get$_jsname = function() { return this._jsname; };
|
| +lang_Element.prototype.set$_jsname = function(value) { return this._jsname = value; };
|
| +lang_Element.prototype.get$library = function() {
|
| + return null;
|
| +}
|
| +lang_Element.prototype.get$span = function() {
|
| + return null;
|
| +}
|
| +Object.defineProperty(lang_Element.prototype, "span", {
|
| + get: lang_Element.prototype.get$span
|
| +});
|
| +lang_Element.prototype.get$isNative = function() {
|
| + return false;
|
| +}
|
| +lang_Element.prototype.hashCode = function() {
|
| + return this.name.hashCode();
|
| +}
|
| +lang_Element.prototype.get$jsname = function() {
|
| + return this._jsname;
|
| +}
|
| +lang_Element.prototype.resolve = function() {
|
| +
|
| +}
|
| +lang_Element.prototype.get$typeParameters = function() {
|
| + return null;
|
| +}
|
| +lang_Element.prototype.get$enclosingElement = function() {
|
| + return this._enclosingElement == null ? this.get$library() : this._enclosingElement;
|
| +}
|
| +lang_Element.prototype.set$enclosingElement = function(e) {
|
| + return this._enclosingElement = e;
|
| +}
|
| +lang_Element.prototype.resolveType = function(node, typeErrors) {
|
| + if (node == null) return $globals.world.varType;
|
| + if (node.type != null) return node.type;
|
| + if ((node instanceof NameTypeReference)) {
|
| + var typeRef = node;
|
| + var name;
|
| + if (typeRef.names != null) {
|
| + name = typeRef.names.last().name;
|
| + }
|
| + else {
|
| + name = typeRef.name.name;
|
| + }
|
| + if (this.get$typeParameters() != null) {
|
| + var $$list = this.get$typeParameters();
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var tp = $$list.$index($$i);
|
| + if ($eq(tp.name, name)) {
|
| + typeRef.type = tp;
|
| + }
|
| + }
|
| + }
|
| + if (typeRef.type != null) {
|
| + return typeRef.type;
|
| + }
|
| + return this.get$enclosingElement().resolveType(node, typeErrors);
|
| + }
|
| + else if ((node instanceof GenericTypeReference)) {
|
| + var typeRef = node;
|
| + var baseType = this.resolveType(typeRef.baseType, typeErrors);
|
| + if (!baseType.get$isGeneric()) {
|
| + $globals.world.error(('' + baseType.name + ' is not generic'), typeRef.span);
|
| + return null;
|
| + }
|
| + if (typeRef.typeArguments.length != baseType.get$typeParameters().length) {
|
| + $globals.world.error('wrong number of type arguments', typeRef.span);
|
| + return null;
|
| + }
|
| + var typeArgs = [];
|
| + for (var i = 0;
|
| + i < typeRef.typeArguments.length; i++) {
|
| + typeArgs.add$1(this.resolveType(typeRef.typeArguments.$index(i), typeErrors));
|
| + }
|
| + typeRef.type = baseType.getOrMakeConcreteType$1(typeArgs);
|
| + }
|
| + else if ((node instanceof FunctionTypeReference)) {
|
| + var typeRef = node;
|
| + var name = '';
|
| + if (typeRef.func.name != null) {
|
| + name = typeRef.func.name.name;
|
| + }
|
| + typeRef.type = this.get$library().getOrAddFunctionType(this, name, typeRef.func);
|
| + }
|
| + else {
|
| + $globals.world.internalError('unknown type reference', node.span);
|
| + }
|
| + return node.type;
|
| +}
|
| +lang_Element.prototype.hashCode$0 = lang_Element.prototype.hashCode;
|
| +lang_Element.prototype.resolve$0 = lang_Element.prototype.resolve;
|
| +// ********** Code for WorldGenerator **************
|
| +function WorldGenerator(main, writer) {
|
| + this.hasStatics = false
|
| + this.main = main;
|
| + this.writer = writer;
|
| + this.globals = new HashMapImplementation();
|
| + this.corejs = new CoreJs();
|
| + // Initializers done
|
| +}
|
| +WorldGenerator.prototype.run = function() {
|
| + var metaGen = new MethodGenerator(this.main, null);
|
| + var mainTarget = new Value.type$ctor(this.main.declaringType, this.main.get$span());
|
| + var mainCall = this.main.invoke(metaGen, null, mainTarget, Arguments.get$EMPTY(), false);
|
| + this.main.declaringType.markUsed();
|
| + if ($globals.options.compileAll) {
|
| + this.markLibraryUsed($globals.world.corelib);
|
| + this.markLibraryUsed(this.main.declaringType.get$library());
|
| + }
|
| + else {
|
| + $globals.world.corelib.types.$index('BadNumberFormatException').markUsed$0();
|
| + $globals.world.get$coreimpl().types.$index('NumImplementation').markUsed$0();
|
| + $globals.world.get$coreimpl().types.$index('StringImplementation').markUsed$0();
|
| + this.genMethod($globals.world.get$coreimpl().types.$index('StringImplementation').getMember$1('contains'));
|
| + }
|
| + if ($globals.world.corelib.types.$index('Isolate').get$isUsed() || $globals.world.get$coreimpl().types.$index('ReceivePortImpl').get$isUsed()) {
|
| + if (this.corejs.useWrap0 || this.corejs.useWrap1) {
|
| + this.genMethod($globals.world.get$coreimpl().types.$index('IsolateContext').getMember$1('eval'));
|
| + this.genMethod($globals.world.get$coreimpl().types.$index('EventLoop').getMember$1('run'));
|
| + }
|
| + this.corejs.useIsolates = true;
|
| + var isolateMain = $globals.world.get$coreimpl().topType.resolveMember('startRootIsolate').members.$index(0);
|
| + var isolateMainTarget = new Value.type$ctor($globals.world.get$coreimpl().topType, this.main.get$span());
|
| + mainCall = isolateMain.invoke(metaGen, null, isolateMainTarget, new Arguments(null, [this.main._get(metaGen, this.main.definition, null, false)]), false);
|
| + }
|
| + this.writeTypes($globals.world.get$coreimpl());
|
| + this.writeTypes($globals.world.corelib);
|
| + this.writeTypes(this.main.declaringType.get$library());
|
| + if (this._mixins != null) this.writer.write(this._mixins.get$text());
|
| + this.writeGlobals();
|
| + this.writer.writeln(('' + mainCall.code + ';'));
|
| +}
|
| +WorldGenerator.prototype.markLibraryUsed = function(l) {
|
| + var $this = this; // closure support
|
| + if (l.isMarked) return;
|
| + l.isMarked = true;
|
| + l.imports.forEach((function (i) {
|
| + return $this.markLibraryUsed(i.get$library());
|
| + })
|
| + );
|
| + var $$list = l.types.getValues();
|
| + for (var $$i = l.types.getValues().iterator$0(); $$i.hasNext$0(); ) {
|
| + var type = $$i.next$0();
|
| + if (!type.get$isClass()) continue;
|
| + type.markUsed$0();
|
| + type.set$isTested(!type.get$isTop() && !(type.get$isNative() && type.get$members().getValues$0().every$1((function (m) {
|
| + return m.get$isStatic() && !m.get$isFactory();
|
| + })
|
| + )));
|
| + var $list0 = type.get$members().getValues$0();
|
| + for (var $i0 = type.get$members().getValues$0().iterator$0(); $i0.hasNext$0(); ) {
|
| + var member = $i0.next$0();
|
| + if ((member instanceof PropertyMember)) {
|
| + if (member.get$getter() != null) this.genMethod(member.get$getter());
|
| + if (member.get$setter() != null) this.genMethod(member.get$setter());
|
| + }
|
| + if (member.get$isMethod()) this.genMethod(member);
|
| + }
|
| + }
|
| +}
|
| +WorldGenerator.prototype.globalForStaticField = function(field, fieldValue, dependencies) {
|
| + this.hasStatics = true;
|
| + var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname());
|
| + if (!this.globals.containsKey(fullname)) {
|
| + this.globals.$setindex(fullname, GlobalValue.GlobalValue$fromStatic$factory(field, fieldValue, dependencies));
|
| + }
|
| + return this.globals.$index(fullname);
|
| +}
|
| +WorldGenerator.prototype.globalForConst = function(exp, dependencies) {
|
| + var key = exp.get$type().get$jsname() + ':' + exp.canonicalCode;
|
| + if (!this.globals.containsKey(key)) {
|
| + this.globals.$setindex(key, GlobalValue.GlobalValue$fromConst$factory(this.globals.get$length(), exp, dependencies));
|
| + }
|
| + return this.globals.$index(key);
|
| +}
|
| +WorldGenerator.prototype.writeTypes = function(lib) {
|
| + if (lib.isWritten) return;
|
| + lib.isWritten = true;
|
| + var $$list = lib.imports;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var import_ = $$list.$index($$i);
|
| + this.writeTypes(import_.get$library());
|
| + }
|
| + for (var i = 0;
|
| + i < lib.sources.length; i++) {
|
| + lib.sources.$index(i).set$orderInLibrary(i);
|
| + }
|
| + this.writer.comment(('// ********** Library ' + lib.name + ' **************'));
|
| + if (lib.get$isCore()) {
|
| + this.writer.comment('// ********** Natives dart:core **************');
|
| + this.corejs.generate(this.writer);
|
| + }
|
| + var $$list = lib.natives;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var file = $$list.$index($$i);
|
| + var filename = basename(file.filename);
|
| + this.writer.comment(('// ********** Natives ' + filename + ' **************'));
|
| + this.writer.writeln(file.text);
|
| + }
|
| + lib.topType.markUsed();
|
| + var $$list = this._orderValues(lib.types);
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var type = $$list.$index($$i);
|
| + if ((type.get$isUsed() || $eq(type.get$library(), $globals.world.get$dom()) || type.get$isHiddenNativeType()) && type.get$isClass()) {
|
| + this.writeType(type);
|
| + if (type.get$isGeneric()) {
|
| + var $list0 = this._orderValues(type.get$_concreteTypes());
|
| + for (var $i0 = 0;$i0 < $list0.length; $i0++) {
|
| + var ct = $list0.$index($i0);
|
| + this.writeType(ct);
|
| + }
|
| + }
|
| + }
|
| + else if (type.get$isFunction() && type.get$varStubs().length > 0) {
|
| + this.writer.comment(('// ********** Code for ' + type.get$jsname() + ' **************'));
|
| + this._writeDynamicStubs(type);
|
| + }
|
| + if (type.get$typeCheckCode() != null) {
|
| + this.writer.writeln(type.get$typeCheckCode());
|
| + }
|
| + }
|
| +}
|
| +WorldGenerator.prototype.genMethod = function(meth, enclosingMethod) {
|
| + if (!meth.isGenerated && !meth.get$isAbstract() && meth.get$definition() != null) {
|
| + new MethodGenerator(meth, enclosingMethod).run();
|
| + }
|
| +}
|
| +WorldGenerator.prototype._prototypeOf = function(type, name) {
|
| + if (type.get$isSingletonNative()) {
|
| + return ('' + type.get$jsname() + '.' + name);
|
| + }
|
| + else if (type.get$isHiddenNativeType()) {
|
| + this.corejs.ensureDynamicProto();
|
| + return ('\$dynamic("' + name + '").' + type.get$jsname());
|
| + }
|
| + else {
|
| + return ('' + type.get$jsname() + '.prototype.' + name);
|
| + }
|
| +}
|
| +WorldGenerator.prototype._maybeIsTest = function(onType, checkType) {
|
| + var isSubtype = onType.isSubtypeOf(checkType);
|
| + if (checkType.isTested) {
|
| + this.writer.writeln(this._prototypeOf(onType, ('is\$' + checkType.get$jsname())) + (' = function(){return ' + isSubtype + '};'));
|
| + }
|
| + if (checkType.isChecked) {
|
| + var body = 'return this';
|
| + var checkName = ('assert\$' + checkType.get$jsname());
|
| + if (!isSubtype) {
|
| + body = $globals.world.objectType.varStubs.$index(checkName).body;
|
| + }
|
| + else if (onType.name == 'StringImplementation' || onType.name == 'NumImplementation') {
|
| + body = ('return ' + onType.get$nativeType().name + '(this)');
|
| + }
|
| + this.writer.writeln(this._prototypeOf(onType, checkName) + (' = function(){' + body + '};'));
|
| + }
|
| +}
|
| +WorldGenerator.prototype.writeType = function(type) {
|
| + if (type.isWritten) return;
|
| + type.isWritten = true;
|
| + if (type.get$parent() != null && !type.get$isNative()) {
|
| + this.writeType(type.get$parent());
|
| + }
|
| + if (type.name != null && (type instanceof ConcreteType) && $eq(type.get$library(), $globals.world.get$coreimpl()) && type.name.startsWith('ListFactory')) {
|
| + this.writer.writeln(('' + type.get$jsname() + ' = ' + type.get$genericType().get$jsname() + ';'));
|
| + return;
|
| + }
|
| + var typeName = type.get$jsname() != null ? type.get$jsname() : 'top level';
|
| + this.writer.comment(('// ********** Code for ' + typeName + ' **************'));
|
| + if (type.get$isNative() && !type.get$isTop()) {
|
| + var nativeName = type.get$definition().get$nativeType().name;
|
| + if ($eq(nativeName, '')) {
|
| + this.writer.writeln(('function ' + type.get$jsname() + '() {}'));
|
| + }
|
| + else if (type.get$jsname() != nativeName) {
|
| + this.writer.writeln(('' + type.get$jsname() + ' = ' + nativeName + ';'));
|
| + }
|
| + }
|
| + if (!type.get$isTop()) {
|
| + if ((type instanceof ConcreteType)) {
|
| + var c = type;
|
| + this.corejs.ensureInheritsHelper();
|
| + this.writer.writeln(('\$inherits(' + c.get$jsname() + ', ' + c.genericType.get$jsname() + ');'));
|
| + for (var p = c._lang_parent;
|
| + (p instanceof ConcreteType); p = p.get$_lang_parent()) {
|
| + this._ensureInheritMembersHelper();
|
| + this._mixins.writeln(('\$inheritsMembers(' + c.get$jsname() + ', ' + p.get$jsname() + ');'));
|
| + }
|
| + }
|
| + else if (!type.get$isNative()) {
|
| + if (type.get$parent() != null && !type.get$parent().get$isObject()) {
|
| + this.corejs.ensureInheritsHelper();
|
| + this.writer.writeln(('\$inherits(' + type.get$jsname() + ', ' + type.get$parent().get$jsname() + ');'));
|
| + }
|
| + }
|
| + }
|
| + if (type.get$isTop()) {
|
| + }
|
| + else if (type.get$constructors().get$length() == 0) {
|
| + if (!type.get$isNative()) {
|
| + this.writer.writeln(('function ' + type.get$jsname() + '() {}'));
|
| + }
|
| + }
|
| + else {
|
| + var standardConstructor = type.get$constructors().$index('');
|
| + if (standardConstructor == null || standardConstructor.generator == null) {
|
| + if (!type.get$isNative()) {
|
| + this.writer.writeln(('function ' + type.get$jsname() + '() {}'));
|
| + }
|
| + }
|
| + else {
|
| + standardConstructor.generator.writeDefinition(this.writer, null);
|
| + }
|
| + var $$list = type.get$constructors().getValues();
|
| + for (var $$i = type.get$constructors().getValues().iterator$0(); $$i.hasNext$0(); ) {
|
| + var c = $$i.next$0();
|
| + if (c.get$generator() != null && $ne(c, standardConstructor)) {
|
| + c.get$generator().writeDefinition$2(this.writer);
|
| + }
|
| + }
|
| + }
|
| + if (!(type instanceof ConcreteType)) {
|
| + this._maybeIsTest(type, type);
|
| + }
|
| + if (type.get$genericType()._concreteTypes != null) {
|
| + var $$list = this._orderValues(type.get$genericType()._concreteTypes);
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var ct = $$list.$index($$i);
|
| + this._maybeIsTest(type, ct);
|
| + }
|
| + }
|
| + if (type.get$interfaces() != null) {
|
| + var seen = new HashSetImplementation();
|
| + var worklist = [];
|
| + worklist.addAll(type.get$interfaces());
|
| + seen.addAll(type.get$interfaces());
|
| + while (!worklist.isEmpty()) {
|
| + var interface_ = worklist.removeLast();
|
| + this._maybeIsTest(type, interface_.get$genericType());
|
| + if (interface_.get$genericType().get$_concreteTypes() != null) {
|
| + var $$list = this._orderValues(interface_.get$genericType().get$_concreteTypes());
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var ct = $$list.$index($$i);
|
| + this._maybeIsTest(type, ct);
|
| + }
|
| + }
|
| + var $$list = interface_.get$interfaces();
|
| + for (var $$i = interface_.get$interfaces().iterator$0(); $$i.hasNext$0(); ) {
|
| + var other = $$i.next$0();
|
| + if (!seen.contains(other)) {
|
| + worklist.addLast(other);
|
| + seen.add(other);
|
| + }
|
| + }
|
| + }
|
| + }
|
| + type.get$factories().forEach(this.get$_writeMethod());
|
| + var $$list = this._orderValues(type.get$members());
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var member = $$list.$index($$i);
|
| + if ((member instanceof FieldMember)) {
|
| + this._writeField(member);
|
| + }
|
| + if ((member instanceof PropertyMember)) {
|
| + this._writeProperty(member);
|
| + }
|
| + if (member.get$isMethod()) {
|
| + this._writeMethod(member);
|
| + }
|
| + }
|
| + this._writeDynamicStubs(type);
|
| +}
|
| +WorldGenerator.prototype._ensureInheritMembersHelper = function() {
|
| + if (this._mixins != null) return;
|
| + this._mixins = new CodeWriter();
|
| + this._mixins.comment('// ********** Generic Type Inheritance **************');
|
| + this._mixins.writeln("/** Implements extends for generic types. */\nfunction $inheritsMembers(child, parent) {\n child = child.prototype;\n parent = parent.prototype;\n Object.getOwnPropertyNames(parent).forEach(function(name) {\n if (typeof(child[name]) == 'undefined') child[name] = parent[name];\n });\n}");
|
| +}
|
| +WorldGenerator.prototype._writeDynamicStubs = function(type) {
|
| + var $$list = orderValuesByKeys(type.varStubs);
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var stub = $$list.$index($$i);
|
| + stub.generate$1(this.writer);
|
| + }
|
| +}
|
| +WorldGenerator.prototype._writeStaticField = function(field) {
|
| + if (field.isFinal) return;
|
| + var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname());
|
| + if (this.globals.containsKey(fullname)) {
|
| + var value = this.globals.$index(fullname);
|
| + if (field.declaringType.get$isTop() && !field.isNative) {
|
| + this.writer.writeln(('\$globals.' + field.get$jsname() + ' = ' + value.get$exp().code + ';'));
|
| + }
|
| + else {
|
| + this.writer.writeln(('\$globals.' + field.declaringType.get$jsname() + '_' + field.get$jsname()) + (' = ' + value.get$exp().code + ';'));
|
| + }
|
| + }
|
| +}
|
| +WorldGenerator.prototype._writeField = function(field) {
|
| + if (field.declaringType.get$isTop() && !field.isNative && field.value == null) {
|
| + this.writer.writeln(('var ' + field.get$jsname() + ';'));
|
| + }
|
| + if (field._providePropertySyntax) {
|
| + this.writer.writeln(this._prototypeOf(field.declaringType, ('get\$' + field.get$jsname())) + (' = function() { return this.' + field.get$jsname() + '; };'));
|
| + if (!field.isFinal) {
|
| + this.writer.writeln(this._prototypeOf(field.declaringType, ('set\$' + field.get$jsname())) + (' = function(value) { return this.' + field.get$jsname() + ' = value; };'));
|
| + }
|
| + }
|
| +}
|
| +WorldGenerator.prototype._writeProperty = function(property) {
|
| + if (property.getter != null) this._writeMethod(property.getter);
|
| + if (property.setter != null) this._writeMethod(property.setter);
|
| + if (property._provideFieldSyntax) {
|
| + this.writer.enterBlock('Object.defineProperty(' + ('' + property.declaringType.get$jsname() + '.prototype, "' + property.get$jsname() + '", {'));
|
| + if (property.getter != null) {
|
| + this.writer.write(('get: ' + property.declaringType.get$jsname() + '.prototype.' + property.getter.get$jsname()));
|
| + this.writer.writeln(property.setter == null ? '' : ',');
|
| + }
|
| + if (property.setter != null) {
|
| + this.writer.writeln(('set: ' + property.declaringType.get$jsname() + '.prototype.' + property.setter.get$jsname()));
|
| + }
|
| + this.writer.exitBlock('});');
|
| + }
|
| +}
|
| +WorldGenerator.prototype._writeMethod = function(method) {
|
| + if (method.generator != null) {
|
| + method.generator.writeDefinition(this.writer, null);
|
| + }
|
| +}
|
| +WorldGenerator.prototype.get$_writeMethod = function() {
|
| + return WorldGenerator.prototype._writeMethod.bind(this);
|
| +}
|
| +WorldGenerator.prototype.writeGlobals = function() {
|
| + if (this.globals.get$length() > 0) {
|
| + this.writer.comment('// ********** Globals **************');
|
| + var list = this.globals.getValues();
|
| + list.sort$1((function (a, b) {
|
| + return a.compareTo$1(b);
|
| + })
|
| + );
|
| + this.writer.enterBlock('function \$static_init(){');
|
| + for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) {
|
| + var global = $$i.next$0();
|
| + if (global.get$field() != null) {
|
| + this._writeStaticField(global.get$field());
|
| + }
|
| + }
|
| + this.writer.exitBlock('}');
|
| + for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) {
|
| + var global0 = $$i.next$0();
|
| + if (global0.get$field() == null) {
|
| + this.writer.writeln(('var ' + global0.name + ' = ' + global0.get$exp().code + ';'));
|
| + }
|
| + }
|
| + }
|
| + if (!this.corejs.useIsolates) {
|
| + if (this.hasStatics) {
|
| + this.writer.writeln('var \$globals = {};');
|
| + }
|
| + if (this.globals.get$length() > 0) {
|
| + this.writer.writeln('\$static_init();');
|
| + }
|
| + }
|
| +}
|
| +WorldGenerator.prototype._orderValues = function(map) {
|
| + var values = map.getValues();
|
| + values.sort(this.get$_compareMembers());
|
| + return values;
|
| +}
|
| +WorldGenerator.prototype._compareMembers = function(x, y) {
|
| + if (x.span != null && y.span != null) {
|
| + var spans = x.span.compareTo$1(y.span);
|
| + if (spans != 0) return spans;
|
| + }
|
| + if (x.span == null) return 1;
|
| + if (y.span == null) return -1;
|
| + return x.name.compareTo$1(y.name);
|
| +}
|
| +WorldGenerator.prototype.get$_compareMembers = function() {
|
| + return WorldGenerator.prototype._compareMembers.bind(this);
|
| +}
|
| +// ********** Code for BlockScope **************
|
| +function BlockScope(enclosingMethod, parent, reentrant) {
|
| + this.enclosingMethod = enclosingMethod;
|
| + this.parent = parent;
|
| + this.reentrant = reentrant;
|
| + this._vars = new HashMapImplementation();
|
| + this._jsNames = new HashSetImplementation();
|
| + // Initializers done
|
| + if (this.get$isMethodScope()) {
|
| + this._closedOver = new HashSetImplementation();
|
| + }
|
| + else {
|
| + this.reentrant = reentrant || this.parent.reentrant;
|
| + }
|
| +}
|
| +BlockScope.prototype.get$enclosingMethod = function() { return this.enclosingMethod; };
|
| +BlockScope.prototype.set$enclosingMethod = function(value) { return this.enclosingMethod = value; };
|
| +BlockScope.prototype.get$_vars = function() { return this._vars; };
|
| +BlockScope.prototype.set$_vars = function(value) { return this._vars = value; };
|
| +BlockScope.prototype.get$_jsNames = function() { return this._jsNames; };
|
| +BlockScope.prototype.set$_jsNames = function(value) { return this._jsNames = value; };
|
| +BlockScope.prototype.get$_closedOver = function() { return this._closedOver; };
|
| +BlockScope.prototype.set$_closedOver = function(value) { return this._closedOver = value; };
|
| +BlockScope.prototype.get$rethrow = function() { return this.rethrow; };
|
| +BlockScope.prototype.set$rethrow = function(value) { return this.rethrow = value; };
|
| +BlockScope.prototype.get$reentrant = function() { return this.reentrant; };
|
| +BlockScope.prototype.set$reentrant = function(value) { return this.reentrant = value; };
|
| +BlockScope.prototype.get$isMethodScope = function() {
|
| + return this.parent == null || $ne(this.parent.enclosingMethod, this.enclosingMethod);
|
| +}
|
| +BlockScope.prototype.get$methodScope = function() {
|
| + var s = this;
|
| + while (!s.get$isMethodScope()) s = s.parent;
|
| + return s;
|
| +}
|
| +BlockScope.prototype.lookup = function(name) {
|
| + var ret = this._vars.$index(name);
|
| + if (ret != null) return ret;
|
| + for (var s = this.parent;
|
| + s != null; s = s.parent) {
|
| + ret = s.get$_vars().$index(name);
|
| + if (ret != null) {
|
| + if ($ne(s.get$enclosingMethod(), this.enclosingMethod)) {
|
| + s.get$methodScope().get$_closedOver().add$1(ret.code);
|
| + if (this.enclosingMethod.captures != null && s.get$reentrant()) {
|
| + this.enclosingMethod.captures.add(ret.code);
|
| + }
|
| + }
|
| + return ret;
|
| + }
|
| + }
|
| +}
|
| +BlockScope.prototype._isDefinedInParent = function(name) {
|
| + if (this.get$isMethodScope() && this._closedOver.contains(name)) return true;
|
| + for (var s = this.parent;
|
| + s != null; s = s.parent) {
|
| + if (s.get$_vars().containsKey$1(name)) return true;
|
| + if (s.get$_jsNames().contains$1(name)) return true;
|
| + if (s.get$isMethodScope() && s.get$_closedOver().contains$1(name)) return true;
|
| + }
|
| + var type = this.enclosingMethod.method.declaringType;
|
| + if (type.get$library().lookup(name, null) != null) return true;
|
| + return false;
|
| +}
|
| +BlockScope.prototype.create = function(name, type, span, isFinal, isParameter) {
|
| + var jsName = $globals.world.toJsIdentifier(name);
|
| + if (this._vars.containsKey(name)) {
|
| + $globals.world.error(('duplicate name "' + name + '"'), span);
|
| + }
|
| + if (!isParameter) {
|
| + var index = 0;
|
| + while (this._isDefinedInParent(jsName)) {
|
| + jsName = ('' + name + (index++));
|
| + }
|
| + }
|
| + var ret = new Value(type, jsName, span, false);
|
| + ret.set$isFinal(isFinal);
|
| + this._vars.$setindex(name, ret);
|
| + if (name != jsName) this._jsNames.add(jsName);
|
| + return ret;
|
| +}
|
| +BlockScope.prototype.declareParameter = function(p) {
|
| + return this.create(p.name, p.type, p.definition.span, false, true);
|
| +}
|
| +BlockScope.prototype.declare = function(id) {
|
| + var type = this.enclosingMethod.method.resolveType(id.type, false);
|
| + return this.create(id.name.name, type, id.span, false, false);
|
| +}
|
| +BlockScope.prototype.getRethrow = function() {
|
| + var scope = this;
|
| + while (scope.get$rethrow() == null && scope.parent != null) {
|
| + scope = scope.parent;
|
| + }
|
| + return scope.get$rethrow();
|
| +}
|
| +// ********** Code for MethodGenerator **************
|
| +function MethodGenerator(method, enclosingMethod) {
|
| + this.method = method;
|
| + this.enclosingMethod = enclosingMethod;
|
| + this.writer = new CodeWriter();
|
| + this.needsThis = false;
|
| + // Initializers done
|
| + if (this.enclosingMethod != null) {
|
| + this._scope = new BlockScope(this, this.enclosingMethod._scope, false);
|
| + this.captures = new HashSetImplementation();
|
| + }
|
| + else {
|
| + this._scope = new BlockScope(this, null, false);
|
| + }
|
| + this._usedTemps = new HashSetImplementation();
|
| + this._freeTemps = [];
|
| +}
|
| +MethodGenerator.prototype.get$enclosingMethod = function() { return this.enclosingMethod; };
|
| +MethodGenerator.prototype.set$enclosingMethod = function(value) { return this.enclosingMethod = value; };
|
| +MethodGenerator.prototype.get$needsThis = function() { return this.needsThis; };
|
| +MethodGenerator.prototype.set$needsThis = function(value) { return this.needsThis = value; };
|
| +MethodGenerator.prototype.get$library = function() {
|
| + return this.method.get$library();
|
| +}
|
| +MethodGenerator.prototype.findMembers = function(name) {
|
| + return this.get$library()._findMembers(name);
|
| +}
|
| +MethodGenerator.prototype.get$isClosure = function() {
|
| + return (this.enclosingMethod != null);
|
| +}
|
| +MethodGenerator.prototype.get$isStatic = function() {
|
| + return this.method.get$isStatic();
|
| +}
|
| +MethodGenerator.prototype.getTemp = function(value) {
|
| + return value.needsTemp ? this.forceTemp(value) : value;
|
| +}
|
| +MethodGenerator.prototype.forceTemp = function(value) {
|
| + var name;
|
| + if (this._freeTemps.length > 0) {
|
| + name = this._freeTemps.removeLast();
|
| + }
|
| + else {
|
| + name = '\$' + this._usedTemps.get$length();
|
| + }
|
| + this._usedTemps.add(name);
|
| + return new Value(value.get$type(), name, value.span, false);
|
| +}
|
| +MethodGenerator.prototype.assignTemp = function(tmp, v) {
|
| + if ($eq(tmp, v)) {
|
| + return v;
|
| + }
|
| + else {
|
| + return new Value(v.get$type(), ('(' + tmp.code + ' = ' + v.code + ')'), v.span, true);
|
| + }
|
| +}
|
| +MethodGenerator.prototype.freeTemp = function(value) {
|
| + if (this._usedTemps.remove(value.code)) {
|
| + this._freeTemps.add(value.code);
|
| + }
|
| + else {
|
| + $globals.world.internalError(('tried to free unused value or non-temp "' + value.code + '"'));
|
| + }
|
| +}
|
| +MethodGenerator.prototype.run = function() {
|
| + if (this.method.isGenerated) return;
|
| + this.method.isGenerated = true;
|
| + this.method.generator = this;
|
| + this.writeBody();
|
| + if (this.method.get$definition().get$nativeBody() != null) {
|
| + this.writer = new CodeWriter();
|
| + if ($eq(this.method.get$definition().get$nativeBody(), '')) {
|
| + this.method.generator = null;
|
| + }
|
| + else {
|
| + this._paramCode = map(this.method.get$parameters(), (function (p) {
|
| + return p.name;
|
| + })
|
| + );
|
| + this.writer.write(this.method.get$definition().get$nativeBody());
|
| + }
|
| + }
|
| +}
|
| +MethodGenerator.prototype.writeDefinition = function(defWriter, lambda) {
|
| + var paramCode = this._paramCode;
|
| + var names = null;
|
| + if (this.captures != null && this.captures.get$length() > 0) {
|
| + names = ListFactory.ListFactory$from$factory(this.captures);
|
| + names.sort$1((function (x, y) {
|
| + return x.compareTo$1(y);
|
| + })
|
| + );
|
| + paramCode = ListFactory.ListFactory$from$factory(names);
|
| + paramCode.addAll$1(this._paramCode);
|
| + }
|
| + var _params = ('(' + Strings.join(this._paramCode, ", ") + ')');
|
| + var params = ('(' + Strings.join(paramCode, ", ") + ')');
|
| + if (this.method.declaringType.get$isTop() && !this.get$isClosure()) {
|
| + defWriter.enterBlock(('function ' + this.method.get$jsname() + params + ' {'));
|
| + }
|
| + else if (this.get$isClosure()) {
|
| + if (this.method.name == '') {
|
| + defWriter.enterBlock(('(function ' + params + ' {'));
|
| + }
|
| + else if (names != null) {
|
| + if (lambda == null) {
|
| + defWriter.enterBlock(('var ' + this.method.get$jsname() + ' = (function' + params + ' {'));
|
| + }
|
| + else {
|
| + defWriter.enterBlock(('(function ' + this.method.get$jsname() + params + ' {'));
|
| + }
|
| + }
|
| + else {
|
| + defWriter.enterBlock(('function ' + this.method.get$jsname() + params + ' {'));
|
| + }
|
| + }
|
| + else if (this.method.get$isConstructor()) {
|
| + if (this.method.get$constructorName() == '') {
|
| + defWriter.enterBlock(('function ' + this.method.declaringType.get$jsname() + params + ' {'));
|
| + }
|
| + else {
|
| + defWriter.enterBlock(('' + this.method.declaringType.get$jsname() + '.' + this.method.get$constructorName() + '\$ctor = function' + params + ' {'));
|
| + }
|
| + }
|
| + else if (this.method.get$isFactory()) {
|
| + defWriter.enterBlock(('' + this.method.get$generatedFactoryName() + ' = function' + _params + ' {'));
|
| + }
|
| + else if (this.method.get$isStatic()) {
|
| + defWriter.enterBlock(('' + this.method.declaringType.get$jsname() + '.' + this.method.get$jsname() + ' = function' + _params + ' {'));
|
| + }
|
| + else {
|
| + defWriter.enterBlock($globals.world.gen._prototypeOf(this.method.declaringType, this.method.get$jsname()) + (' = function' + _params + ' {'));
|
| + }
|
| + if (this.needsThis) {
|
| + defWriter.writeln('var \$this = this; // closure support');
|
| + }
|
| + if (this._usedTemps.get$length() > 0 || this._freeTemps.length > 0) {
|
| + this._freeTemps.addAll(this._usedTemps);
|
| + this._freeTemps.sort((function (x, y) {
|
| + return x.compareTo$1(y);
|
| + })
|
| + );
|
| + defWriter.writeln(('var ' + Strings.join(this._freeTemps, ", ") + ';'));
|
| + }
|
| + defWriter.writeln(this.writer.get$text());
|
| + if (names != null) {
|
| + defWriter.exitBlock(('}).bind(null, ' + Strings.join(names, ", ") + ')'));
|
| + }
|
| + else if (this.get$isClosure() && this.method.name == '') {
|
| + defWriter.exitBlock('})');
|
| + }
|
| + else {
|
| + defWriter.exitBlock('}');
|
| + }
|
| + if (this.method.get$isConstructor() && this.method.get$constructorName() != '') {
|
| + defWriter.writeln(('' + this.method.declaringType.get$jsname() + '.' + this.method.get$constructorName() + '\$ctor.prototype = ') + ('' + this.method.declaringType.get$jsname() + '.prototype;'));
|
| + }
|
| + this._provideOptionalParamInfo(defWriter);
|
| + if ((this.method instanceof MethodMember)) {
|
| + var m = this.method;
|
| + if (m._providePropertySyntax) {
|
| + defWriter.enterBlock(('' + m.declaringType.get$jsname() + '.prototype') + ('.get\$' + m.get$jsname() + ' = function() {'));
|
| + defWriter.writeln(('return ' + m.declaringType.get$jsname() + '.prototype.') + ('' + m.get$jsname() + '.bind(this);'));
|
| + defWriter.exitBlock('}');
|
| + if (m._provideFieldSyntax) {
|
| + $globals.world.internalError('bound m accessed with field syntax');
|
| + }
|
| + }
|
| + }
|
| +}
|
| +MethodGenerator.prototype._provideOptionalParamInfo = function(defWriter) {
|
| + if ((this.method instanceof MethodMember)) {
|
| + var meth = this.method;
|
| + if (meth._provideOptionalParamInfo) {
|
| + var optNames = [];
|
| + var optValues = [];
|
| + meth.genParameterValues();
|
| + var $$list = meth.parameters;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var param = $$list.$index($$i);
|
| + if (param.get$isOptional()) {
|
| + optNames.add$1(param.name);
|
| + optValues.add$1(MethodGenerator._escapeString(param.value.code));
|
| + }
|
| + }
|
| + if (optNames.length > 0) {
|
| + var start = '';
|
| + if (meth.isStatic) {
|
| + if (!meth.declaringType.get$isTop()) {
|
| + start = meth.declaringType.get$jsname() + '.';
|
| + }
|
| + }
|
| + else {
|
| + start = meth.declaringType.get$jsname() + '.prototype.';
|
| + }
|
| + optNames.addAll$1(optValues);
|
| + var optional = "['" + Strings.join(optNames, "', '") + "']";
|
| + defWriter.writeln(('' + start + meth.get$jsname() + '.\$optional = ' + optional));
|
| + }
|
| + }
|
| + }
|
| +}
|
| +MethodGenerator.prototype.writeBody = function() {
|
| + var initializers = null;
|
| + var initializedFields = null;
|
| + var allMembers = null;
|
| + if (this.method.get$isConstructor()) {
|
| + initializers = [];
|
| + initializedFields = new HashSetImplementation();
|
| + allMembers = $globals.world.gen._orderValues(this.method.declaringType.getAllMembers());
|
| + for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) {
|
| + var f = $$i.next$0();
|
| + if (f.get$isField() && !f.get$isStatic()) {
|
| + var cv = f.computeValue$0();
|
| + if (cv != null) {
|
| + initializers.add$1(('this.' + f.get$jsname() + ' = ' + cv.code));
|
| + initializedFields.add$1(f.name);
|
| + }
|
| + }
|
| + }
|
| + }
|
| + this._paramCode = [];
|
| + var $$list = this.method.get$parameters();
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var p = $$list.$index($$i);
|
| + if (initializers != null && p.get$isInitializer()) {
|
| + var field = this.method.declaringType.getMember(p.name);
|
| + if (field == null) {
|
| + $globals.world.error('bad this parameter - no matching field', p.get$definition().span);
|
| + }
|
| + if (!field.get$isField()) {
|
| + $globals.world.error(('"this.' + p.name + '" does not refer to a field'), p.get$definition().span);
|
| + }
|
| + var paramValue = new Value(field.get$returnType(), p.name, p.get$definition().span, false);
|
| + this._paramCode.add(paramValue.code);
|
| + initializers.add$1(('this.' + field.get$jsname() + ' = ' + paramValue.code + ';'));
|
| + initializedFields.add$1(p.name);
|
| + }
|
| + else {
|
| + var paramValue = this._scope.declareParameter(p);
|
| + this._paramCode.add(paramValue.code);
|
| + }
|
| + }
|
| + var body = this.method.get$definition().body;
|
| + if (body == null && !this.method.get$isConstructor() && !this.method.get$isNative()) {
|
| + $globals.world.error(('unexpected empty body for ' + this.method.name), this.method.get$definition().span);
|
| + }
|
| + var initializerCall = null;
|
| + var declaredInitializers = this.method.get$definition().get$initializers();
|
| + if (initializers != null) {
|
| + for (var $$i = initializers.iterator$0(); $$i.hasNext$0(); ) {
|
| + var i = $$i.next$0();
|
| + this.writer.writeln(i);
|
| + }
|
| + if (declaredInitializers != null) {
|
| + for (var $$i = declaredInitializers.iterator$0(); $$i.hasNext$0(); ) {
|
| + var init = $$i.next$0();
|
| + if ((init instanceof CallExpression)) {
|
| + if (initializerCall != null) {
|
| + $globals.world.error('only one initializer redirecting call is allowed', init.span);
|
| + }
|
| + initializerCall = init;
|
| + }
|
| + else if ((init instanceof BinaryExpression) && TokenKind.kindFromAssign(init.get$op().kind) == 0) {
|
| + var left = init.x;
|
| + if (!((left instanceof DotExpression) && (left.self instanceof ThisExpression) || (left instanceof VarExpression))) {
|
| + $globals.world.error('invalid left side of initializer', left.span);
|
| + continue;
|
| + }
|
| + var f = this.method.declaringType.getMember(left.name.name);
|
| + if (f == null) {
|
| + $globals.world.error('bad initializer - no matching field', left.span);
|
| + continue;
|
| + }
|
| + else if (!f.get$isField()) {
|
| + $globals.world.error(('"' + left.name.name + '" does not refer to a field'), left.span);
|
| + continue;
|
| + }
|
| + initializedFields.add$1(f.name);
|
| + this.writer.writeln(('this.' + f.get$jsname() + ' = ' + this.visitValue(init.y).code + ';'));
|
| + }
|
| + else {
|
| + $globals.world.error('invalid initializer', init.span);
|
| + }
|
| + }
|
| + }
|
| + this.writer.comment('// Initializers done');
|
| + }
|
| + if (this.method.get$isConstructor() && initializerCall == null && !this.method.get$isNative()) {
|
| + var parentType = this.method.declaringType.get$parent();
|
| + if (parentType != null && !parentType.get$isObject()) {
|
| + initializerCall = new CallExpression(new SuperExpression(this.method.get$span()), [], this.method.get$span());
|
| + }
|
| + }
|
| + if (initializerCall != null) {
|
| + var target = this._writeInitializerCall(initializerCall);
|
| + if (!target.get$isSuper()) {
|
| + if (initializers.length > 0) {
|
| + var $$list = this.method.get$parameters();
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var p = $$list.$index($$i);
|
| + if (p.get$isInitializer()) {
|
| + $globals.world.error('no initialization allowed on redirecting constructors', p.get$definition().span);
|
| + break;
|
| + }
|
| + }
|
| + }
|
| + if (declaredInitializers != null && declaredInitializers.length > 1) {
|
| + var init = $eq(declaredInitializers.$index(0), initializerCall) ? declaredInitializers.$index(1) : declaredInitializers.$index(0);
|
| + $globals.world.error('no initialization allowed on redirecting constructors', init.span);
|
| + }
|
| + initializedFields = null;
|
| + }
|
| + }
|
| + if (initializedFields != null) {
|
| + for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) {
|
| + var member = $$i.next$0();
|
| + if (member.get$isField() && member.get$isFinal() && !member.get$isStatic() && !this.method.get$isNative() && !initializedFields.contains$1(member.name)) {
|
| + $globals.world.error(('Field "' + member.name + '" is final and was not initialized'), this.method.get$definition().span);
|
| + }
|
| + }
|
| + }
|
| + this.visitStatementsInBlock(body);
|
| +}
|
| +MethodGenerator.prototype._writeInitializerCall = function(node) {
|
| + var contructorName = '';
|
| + var targetExp = node.target;
|
| + if ((targetExp instanceof DotExpression)) {
|
| + var dot = targetExp;
|
| + targetExp = dot.self;
|
| + contructorName = dot.name.name;
|
| + }
|
| + var target = null;
|
| + if ((targetExp instanceof SuperExpression)) {
|
| + target = this._makeSuperValue(targetExp);
|
| + }
|
| + else if ((targetExp instanceof ThisExpression)) {
|
| + target = this._makeThisValue(targetExp);
|
| + }
|
| + else {
|
| + $globals.world.error('bad call in initializers', node.span);
|
| + }
|
| + target.set$allowDynamic(false);
|
| + var m = target.type.getConstructor$1(contructorName);
|
| + this.method.set$initDelegate(m);
|
| + var other = m;
|
| + while (other != null) {
|
| + if ($eq(other, this.method)) {
|
| + $globals.world.error('initialization cycle', node.span);
|
| + break;
|
| + }
|
| + other = other.get$initDelegate();
|
| + }
|
| + $globals.world.gen.genMethod(m);
|
| + var value = m.invoke$4(this, node, target, this._makeArgs(node.arguments));
|
| + if ($ne(target.type, $globals.world.objectType)) {
|
| + this.writer.writeln(('' + value.code + ';'));
|
| + }
|
| + return target;
|
| +}
|
| +MethodGenerator.prototype._makeArgs = function(arguments) {
|
| + var args = [];
|
| + var seenLabel = false;
|
| + for (var $$i = 0;$$i < arguments.length; $$i++) {
|
| + var arg = arguments.$index($$i);
|
| + if (arg.label != null) {
|
| + seenLabel = true;
|
| + }
|
| + else if (seenLabel) {
|
| + $globals.world.error('bare argument can not follow named arguments', arg.span);
|
| + }
|
| + args.add$1(this.visitValue(arg.value));
|
| + }
|
| + return new Arguments(arguments, args);
|
| +}
|
| +MethodGenerator.prototype._invokeNative = function(name, arguments) {
|
| + var args = Arguments.get$EMPTY();
|
| + if (arguments.length > 0) {
|
| + args = new Arguments(null, arguments);
|
| + }
|
| + var method = $globals.world.corelib.topType.members.$index(name);
|
| + return method.invoke$4(this, method.get$definition(), new Value($globals.world.corelib.topType, null, null, true), args);
|
| +}
|
| +MethodGenerator._escapeString = function(text) {
|
| + return text.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', '\\n').replaceAll('\r', '\\r');
|
| +}
|
| +MethodGenerator.prototype.visitStatementsInBlock = function(body) {
|
| + if ((body instanceof BlockStatement)) {
|
| + var block = body;
|
| + var $$list = block.body;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var stmt = $$list.$index($$i);
|
| + stmt.visit$1(this);
|
| + }
|
| + }
|
| + else {
|
| + if (body != null) body.visit(this);
|
| + }
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype._pushBlock = function(reentrant) {
|
| + this._scope = new BlockScope(this, this._scope, reentrant);
|
| +}
|
| +MethodGenerator.prototype._popBlock = function() {
|
| + this._scope = this._scope.parent;
|
| +}
|
| +MethodGenerator.prototype._makeLambdaMethod = function(name, func) {
|
| + var meth = new MethodMember(name, this.method.declaringType, func);
|
| + meth.set$isLambda(true);
|
| + meth.set$enclosingElement(this.method);
|
| + meth.resolve$0();
|
| + return meth;
|
| +}
|
| +MethodGenerator.prototype.visitBool = function(node) {
|
| + return this.visitValue(node).convertTo$3(this, $globals.world.nonNullBool, node);
|
| +}
|
| +MethodGenerator.prototype.visitValue = function(node) {
|
| + if (node == null) return null;
|
| + var value = node.visit(this);
|
| + value.checkFirstClass$1(node.span);
|
| + return value;
|
| +}
|
| +MethodGenerator.prototype.visitTypedValue = function(node, expectedType) {
|
| + var val = this.visitValue(node);
|
| + return expectedType == null ? val : val.convertTo$3(this, expectedType, node);
|
| +}
|
| +MethodGenerator.prototype.visitVoid = function(node) {
|
| + if ((node instanceof PostfixExpression)) {
|
| + var value = this.visitPostfixExpression(node, true);
|
| + value.checkFirstClass$1(node.span);
|
| + return value;
|
| + }
|
| + else if ((node instanceof BinaryExpression)) {
|
| + var value = this.visitBinaryExpression(node, true);
|
| + value.checkFirstClass$1(node.span);
|
| + return value;
|
| + }
|
| + return this.visitValue(node);
|
| +}
|
| +MethodGenerator.prototype.visitDietStatement = function(node) {
|
| + var parser = new Parser(node.span.file, false, false, false, node.span.start);
|
| + this.visitStatementsInBlock(parser.block$0());
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype.visitVariableDefinition = function(node) {
|
| + var isFinal = false;
|
| + if (node.modifiers != null && $eq(node.modifiers.$index(0).kind, 98/*TokenKind.FINAL*/)) {
|
| + isFinal = true;
|
| + }
|
| + this.writer.write('var ');
|
| + var type = this.method.resolveType(node.type, false);
|
| + for (var i = 0;
|
| + i < node.names.length; i++) {
|
| + var thisType = type;
|
| + if (i > 0) {
|
| + this.writer.write(', ');
|
| + }
|
| + var name = node.names.$index(i).name;
|
| + var value = this.visitValue(node.values.$index(i));
|
| + if (isFinal) {
|
| + if (value == null) {
|
| + $globals.world.error('no value specified for final variable', node.span);
|
| + }
|
| + else {
|
| + if (thisType.get$isVar()) thisType = value.type;
|
| + }
|
| + }
|
| + var val = this._scope.create(name, thisType, node.names.$index(i).span, isFinal, false);
|
| + if (value == null) {
|
| + if (this._scope.reentrant) {
|
| + this.writer.write(('' + val.code + ' = null'));
|
| + }
|
| + else {
|
| + this.writer.write(('' + val.code));
|
| + }
|
| + }
|
| + else {
|
| + value = value.convertTo$3(this, type, node.values.$index(i));
|
| + this.writer.write(('' + val.code + ' = ' + value.code));
|
| + }
|
| + }
|
| + this.writer.writeln(';');
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype.visitFunctionDefinition = function(node) {
|
| + var meth = this._makeLambdaMethod(node.name.name, node);
|
| + var funcValue = this._scope.create(meth.name, meth.get$functionType(), this.method.get$definition().span, true, false);
|
| + $globals.world.gen.genMethod(meth, this);
|
| + meth.get$generator().writeDefinition$2(this.writer);
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype.visitReturnStatement = function(node) {
|
| + if (node.value == null) {
|
| + this.writer.writeln('return;');
|
| + }
|
| + else {
|
| + if (this.method.get$isConstructor()) {
|
| + $globals.world.error('return of value not allowed from constructor', node.span);
|
| + }
|
| + var value = this.visitTypedValue(node.value, this.method.get$returnType());
|
| + this.writer.writeln(('return ' + value.code + ';'));
|
| + }
|
| + return true;
|
| +}
|
| +MethodGenerator.prototype.visitThrowStatement = function(node) {
|
| + if (node.value != null) {
|
| + var value = this.visitValue(node.value);
|
| + value.invoke$4(this, 'toString', node, Arguments.get$EMPTY());
|
| + this.writer.writeln(('\$throw(' + value.code + ');'));
|
| + $globals.world.gen.corejs.useThrow = true;
|
| + }
|
| + else {
|
| + var rethrow = this._scope.getRethrow();
|
| + if (rethrow == null) {
|
| + $globals.world.error('rethrow outside of catch', node.span);
|
| + }
|
| + else {
|
| + this.writer.writeln(('throw ' + rethrow.code + ';'));
|
| + }
|
| + }
|
| + return true;
|
| +}
|
| +MethodGenerator.prototype.visitAssertStatement = function(node) {
|
| + var test = this.visitValue(node.test);
|
| + if ($globals.options.enableAsserts) {
|
| + var span = node.test.span;
|
| + var line = span.get$file().getLine$1(span.start) + 1;
|
| + var column = span.get$file().getColumn$2(line - 1, span.start) + 1;
|
| + var args = [test, EvaluatedValue.EvaluatedValue$factory($globals.world.stringType, MethodGenerator._escapeString(span.text), ('"' + MethodGenerator._escapeString(span.text) + '"'), null), EvaluatedValue.EvaluatedValue$factory($globals.world.stringType, MethodGenerator._escapeString(span.get$file().filename), ('"' + MethodGenerator._escapeString(span.get$file().filename) + '"'), null), EvaluatedValue.EvaluatedValue$factory($globals.world.intType, line, line.toString$0(), null), EvaluatedValue.EvaluatedValue$factory($globals.world.intType, column, column.toString$0(), null)];
|
| + var tp = $globals.world.corelib.topType;
|
| + var f = tp.getMember$1('_assert');
|
| + var value = f.invoke(this, node, new Value.type$ctor(tp, null), new Arguments(null, args), false);
|
| + this.writer.writeln(('' + value.code + ';'));
|
| + }
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype.visitBreakStatement = function(node) {
|
| + if (node.label == null) {
|
| + this.writer.writeln('break;');
|
| + }
|
| + else {
|
| + this.writer.writeln(('break ' + node.label.name + ';'));
|
| + }
|
| + return true;
|
| +}
|
| +MethodGenerator.prototype.visitContinueStatement = function(node) {
|
| + if (node.label == null) {
|
| + this.writer.writeln('continue;');
|
| + }
|
| + else {
|
| + this.writer.writeln(('continue ' + node.label.name + ';'));
|
| + }
|
| + return true;
|
| +}
|
| +MethodGenerator.prototype.visitIfStatement = function(node) {
|
| + var test = this.visitBool(node.test);
|
| + this.writer.write(('if (' + test.code + ') '));
|
| + var exit1 = node.trueBranch.visit(this);
|
| + if (node.falseBranch != null) {
|
| + this.writer.write('else ');
|
| + if (node.falseBranch.visit(this) && exit1) {
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype.visitWhileStatement = function(node) {
|
| + var test = this.visitBool(node.test);
|
| + this.writer.write(('while (' + test.code + ') '));
|
| + this._pushBlock(true);
|
| + node.body.visit(this);
|
| + this._popBlock();
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype.visitDoStatement = function(node) {
|
| + this.writer.write('do ');
|
| + this._pushBlock(true);
|
| + node.body.visit(this);
|
| + this._popBlock();
|
| + var test = this.visitBool(node.test);
|
| + this.writer.writeln(('while (' + test.code + ')'));
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype.visitForStatement = function(node) {
|
| + this._pushBlock(false);
|
| + this.writer.write('for (');
|
| + if (node.init != null) node.init.visit(this);
|
| + else this.writer.write(';');
|
| + if (node.test != null) {
|
| + var test = this.visitBool(node.test);
|
| + this.writer.write((' ' + test.code + '; '));
|
| + }
|
| + else {
|
| + this.writer.write('; ');
|
| + }
|
| + var needsComma = false;
|
| + var $$list = node.step;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var s = $$list.$index($$i);
|
| + if (needsComma) this.writer.write(', ');
|
| + var sv = this.visitVoid(s);
|
| + this.writer.write(sv.code);
|
| + needsComma = true;
|
| + }
|
| + this.writer.write(') ');
|
| + this._pushBlock(true);
|
| + node.body.visit(this);
|
| + this._popBlock();
|
| + this._popBlock();
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype._isFinal = function(typeRef) {
|
| + if ((typeRef instanceof GenericTypeReference)) {
|
| + typeRef = typeRef.get$baseType();
|
| + }
|
| + return typeRef != null && typeRef.get$isFinal();
|
| +}
|
| +MethodGenerator.prototype.visitForInStatement = function(node) {
|
| + var itemType = this.method.resolveType(node.item.type, false);
|
| + var itemName = node.item.name.name;
|
| + var list = node.list.visit(this);
|
| + this._pushBlock(true);
|
| + var isFinal = this._isFinal(node.item.type);
|
| + var item = this._scope.create(itemName, itemType, node.item.name.span, isFinal, false);
|
| + var listVar = list;
|
| + if (list.get$needsTemp()) {
|
| + listVar = this._scope.create('\$list', list.type, null, false, false);
|
| + this.writer.writeln(('var ' + listVar.code + ' = ' + list.code + ';'));
|
| + }
|
| + if (list.type.get$isList()) {
|
| + var tmpi = this._scope.create('\$i', $globals.world.numType, null, false, false);
|
| + this.writer.enterBlock(('for (var ' + tmpi.code + ' = 0;') + ('' + tmpi.code + ' < ' + listVar.code + '.length; ' + tmpi.code + '++) {'));
|
| + var value = listVar.invoke(this, ':index', node.list, new Arguments(null, [tmpi]), false);
|
| + this.writer.writeln(('var ' + item.code + ' = ' + value.code + ';'));
|
| + }
|
| + else {
|
| + this._pushBlock(false);
|
| + var iterator = list.invoke$4(this, 'iterator', node.list, Arguments.get$EMPTY());
|
| + var tmpi = this._scope.create('\$i', iterator.type, null, false, false);
|
| + var hasNext = tmpi.invoke$4(this, 'hasNext', node.list, Arguments.get$EMPTY());
|
| + var next = tmpi.invoke$4(this, 'next', node.list, Arguments.get$EMPTY());
|
| + this.writer.enterBlock(('for (var ' + tmpi.code + ' = ' + iterator.code + '; ' + hasNext.code + '; ) {'));
|
| + this.writer.writeln(('var ' + item.code + ' = ' + next.code + ';'));
|
| + }
|
| + this.visitStatementsInBlock(node.body);
|
| + this.writer.exitBlock('}');
|
| + this._popBlock();
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype._genToDartException = function(ex, node) {
|
| + var result = this._invokeNative("_toDartException", [ex]);
|
| + this.writer.writeln(('' + ex.code + ' = ' + result.code + ';'));
|
| +}
|
| +MethodGenerator.prototype.visitTryStatement = function(node) {
|
| + this.writer.enterBlock('try {');
|
| + this._pushBlock(false);
|
| + this.visitStatementsInBlock(node.body);
|
| + this._popBlock();
|
| + if (node.catches.length == 1) {
|
| + var catch_ = node.catches.$index(0);
|
| + this._pushBlock(false);
|
| + var exType = this.method.resolveType(catch_.get$exception().type, false);
|
| + var ex = this._scope.declare(catch_.get$exception());
|
| + this._scope.rethrow = ex;
|
| + this.writer.nextBlock(('} catch (' + ex.code + ') {'));
|
| + if (catch_.get$trace() != null) {
|
| + var trace = this._scope.declare(catch_.get$trace());
|
| + this.writer.writeln(('var ' + trace.code + ' = \$stackTraceOf(' + ex.code + ');'));
|
| + $globals.world.gen.corejs.useStackTraceOf = true;
|
| + }
|
| + this._genToDartException(ex, node);
|
| + if (!exType.get$isVarOrObject()) {
|
| + var test = ex.instanceOf$3$isTrue$forceCheck(this, exType, catch_.get$exception().span, false, true);
|
| + this.writer.writeln(('if (' + test.code + ') throw ' + ex.code + ';'));
|
| + }
|
| + this.visitStatementsInBlock(node.catches.$index(0).body);
|
| + this._popBlock();
|
| + }
|
| + else if (node.catches.length > 0) {
|
| + this._pushBlock(false);
|
| + var ex = this._scope.create('\$ex', $globals.world.varType, null, false, false);
|
| + this._scope.rethrow = ex;
|
| + this.writer.nextBlock(('} catch (' + ex.code + ') {'));
|
| + var trace = null;
|
| + if (node.catches.some((function (c) {
|
| + return c.get$trace() != null;
|
| + })
|
| + )) {
|
| + trace = this._scope.create('\$trace', $globals.world.varType, null, false, false);
|
| + this.writer.writeln(('var ' + trace.code + ' = \$stackTraceOf(' + ex.code + ');'));
|
| + $globals.world.gen.corejs.useStackTraceOf = true;
|
| + }
|
| + this._genToDartException(ex, node);
|
| + var needsRethrow = true;
|
| + for (var i = 0;
|
| + i < node.catches.length; i++) {
|
| + var catch_ = node.catches.$index(i);
|
| + this._pushBlock(false);
|
| + var tmpType = this.method.resolveType(catch_.get$exception().type, false);
|
| + var tmp = this._scope.declare(catch_.get$exception());
|
| + if (!tmpType.get$isVarOrObject()) {
|
| + var test = ex.instanceOf$3$isTrue$forceCheck(this, tmpType, catch_.get$exception().span, true, true);
|
| + if (i == 0) {
|
| + this.writer.enterBlock(('if (' + test.code + ') {'));
|
| + }
|
| + else {
|
| + this.writer.nextBlock(('} else if (' + test.code + ') {'));
|
| + }
|
| + }
|
| + else if (i > 0) {
|
| + this.writer.nextBlock('} else {');
|
| + }
|
| + this.writer.writeln(('var ' + tmp.code + ' = ' + ex.code + ';'));
|
| + if (catch_.get$trace() != null) {
|
| + var tmptrace = this._scope.declare(catch_.get$trace());
|
| + this.writer.writeln(('var ' + tmptrace.code + ' = ' + trace.code + ';'));
|
| + }
|
| + this.visitStatementsInBlock(catch_.body);
|
| + this._popBlock();
|
| + if (tmpType.get$isVarOrObject()) {
|
| + if (i + 1 < node.catches.length) {
|
| + $globals.world.error('Unreachable catch clause', node.catches.$index(i + 1).span);
|
| + }
|
| + if (i > 0) {
|
| + this.writer.exitBlock('}');
|
| + }
|
| + needsRethrow = false;
|
| + break;
|
| + }
|
| + }
|
| + if (needsRethrow) {
|
| + this.writer.nextBlock('} else {');
|
| + this.writer.writeln(('throw ' + ex.code + ';'));
|
| + this.writer.exitBlock('}');
|
| + }
|
| + this._popBlock();
|
| + }
|
| + if (node.finallyBlock != null) {
|
| + this.writer.nextBlock('} finally {');
|
| + this._pushBlock(false);
|
| + this.visitStatementsInBlock(node.finallyBlock);
|
| + this._popBlock();
|
| + }
|
| + this.writer.exitBlock('}');
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype.visitSwitchStatement = function(node) {
|
| + var test = this.visitValue(node.test);
|
| + this.writer.enterBlock(('switch (' + test.code + ') {'));
|
| + var $$list = node.cases;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var case_ = $$list.$index($$i);
|
| + if (case_.label != null) {
|
| + $globals.world.error('unimplemented: labeled case statement', case_.span);
|
| + }
|
| + this._pushBlock(false);
|
| + for (var i = 0;
|
| + i < case_.get$cases().length; i++) {
|
| + var expr = case_.get$cases().$index(i);
|
| + if (expr == null) {
|
| + if (i < case_.get$cases().length - 1) {
|
| + $globals.world.error('default clause must be the last case', case_.span);
|
| + }
|
| + this.writer.writeln('default:');
|
| + }
|
| + else {
|
| + var value = this.visitValue(expr);
|
| + this.writer.writeln(('case ' + value.code + ':'));
|
| + }
|
| + }
|
| + this.writer.enterBlock('');
|
| + var caseExits = this._visitAllStatements(case_.get$statements(), false);
|
| + if ($ne(case_, node.cases.$index(node.cases.length - 1)) && !caseExits) {
|
| + var span = case_.get$statements().$index(case_.get$statements().length - 1).span;
|
| + this.writer.writeln('\$throw(new FallThroughError());');
|
| + $globals.world.gen.corejs.useThrow = true;
|
| + }
|
| + this.writer.exitBlock('');
|
| + this._popBlock();
|
| + }
|
| + this.writer.exitBlock('}');
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype._visitAllStatements = function(statementList, exits) {
|
| + for (var i = 0;
|
| + i < statementList.length; i++) {
|
| + var stmt = statementList.$index(i);
|
| + exits = stmt.visit$1(this);
|
| + if ($ne(stmt, statementList.$index(statementList.length - 1)) && exits) {
|
| + $globals.world.warning('unreachable code', statementList.$index(i + 1).span);
|
| + }
|
| + }
|
| + return exits;
|
| +}
|
| +MethodGenerator.prototype.visitBlockStatement = function(node) {
|
| + this._pushBlock(false);
|
| + this.writer.enterBlock('{');
|
| + var exits = this._visitAllStatements(node.body, false);
|
| + this.writer.exitBlock('}');
|
| + this._popBlock();
|
| + return exits;
|
| +}
|
| +MethodGenerator.prototype.visitLabeledStatement = function(node) {
|
| + this.writer.writeln(('' + node.name.name + ':'));
|
| + node.body.visit(this);
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype.visitExpressionStatement = function(node) {
|
| + if ((node.body instanceof VarExpression) || (node.body instanceof ThisExpression)) {
|
| + $globals.world.warning('variable used as statement', node.span);
|
| + }
|
| + var value = this.visitVoid(node.body);
|
| + this.writer.writeln(('' + value.code + ';'));
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype.visitEmptyStatement = function(node) {
|
| + this.writer.writeln(';');
|
| + return false;
|
| +}
|
| +MethodGenerator.prototype._checkNonStatic = function(node) {
|
| + if (this.get$isStatic()) {
|
| + $globals.world.warning('not allowed in static method', node.span);
|
| + }
|
| +}
|
| +MethodGenerator.prototype._makeSuperValue = function(node) {
|
| + var parentType = this.method.declaringType.get$parent();
|
| + this._checkNonStatic(node);
|
| + if (parentType == null) {
|
| + $globals.world.error('no super class', node.span);
|
| + }
|
| + var ret = new Value(parentType, 'this', node.span, false);
|
| + ret.set$isSuper(true);
|
| + return ret;
|
| +}
|
| +MethodGenerator.prototype._getOutermostMethod = function() {
|
| + var result = this;
|
| + while (result.get$enclosingMethod() != null) {
|
| + result = result.get$enclosingMethod();
|
| + }
|
| + return result;
|
| +}
|
| +MethodGenerator.prototype._makeThisCode = function() {
|
| + if (this.enclosingMethod != null) {
|
| + this._getOutermostMethod().set$needsThis(true);
|
| + return '\$this';
|
| + }
|
| + else {
|
| + return 'this';
|
| + }
|
| +}
|
| +MethodGenerator.prototype._makeThisValue = function(node) {
|
| + if (this.enclosingMethod != null) {
|
| + var outermostMethod = this._getOutermostMethod();
|
| + outermostMethod._checkNonStatic$1(node);
|
| + outermostMethod.set$needsThis(true);
|
| + return new Value(outermostMethod.method.get$declaringType(), '\$this', node != null ? node.span : null, false);
|
| + }
|
| + else {
|
| + this._checkNonStatic(node);
|
| + return new Value(this.method.declaringType, 'this', node != null ? node.span : null, false);
|
| + }
|
| +}
|
| +MethodGenerator.prototype.visitLambdaExpression = function(node) {
|
| + var name = (node.func.name != null) ? node.func.name.name : '';
|
| + var meth = this._makeLambdaMethod(name, node.func);
|
| + var lambdaGen = new MethodGenerator(meth, this);
|
| + if ($ne(name, '')) {
|
| + lambdaGen._scope.create(name, meth.get$functionType(), meth.definition.span, true, false);
|
| + lambdaGen._pushBlock(false);
|
| + }
|
| + lambdaGen.run();
|
| + var w = new CodeWriter();
|
| + meth.generator.writeDefinition(w, node);
|
| + return new Value(meth.get$functionType(), w.text, node.span, true);
|
| +}
|
| +MethodGenerator.prototype.visitCallExpression = function(node) {
|
| + var target;
|
| + var position = node.target;
|
| + var name = ':call';
|
| + if ((node.target instanceof DotExpression)) {
|
| + var dot = node.target;
|
| + target = dot.self.visit(this);
|
| + name = dot.name.name;
|
| + position = dot.name;
|
| + }
|
| + else if ((node.target instanceof VarExpression)) {
|
| + var varExpr = node.target;
|
| + name = varExpr.name.name;
|
| + target = this._scope.lookup(name);
|
| + if (target != null) {
|
| + return target.invoke$4(this, ':call', node, this._makeArgs(node.arguments));
|
| + }
|
| + target = this._makeThisOrType(varExpr.span);
|
| + return target.invoke$4(this, name, node, this._makeArgs(node.arguments));
|
| + }
|
| + else {
|
| + target = node.target.visit(this);
|
| + }
|
| + return target.invoke$4(this, name, position, this._makeArgs(node.arguments));
|
| +}
|
| +MethodGenerator.prototype.visitIndexExpression = function(node) {
|
| + var target = this.visitValue(node.target);
|
| + var index = this.visitValue(node.index);
|
| + return target.invoke$4(this, ':index', node, new Arguments(null, [index]));
|
| +}
|
| +MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) {
|
| + var kind = node.op.kind;
|
| + if (kind == 35/*TokenKind.AND*/ || kind == 34/*TokenKind.OR*/) {
|
| + var x = this.visitTypedValue(node.x, $globals.world.nonNullBool);
|
| + var y = this.visitTypedValue(node.y, $globals.world.nonNullBool);
|
| + var code = ('' + x.code + ' ' + node.op + ' ' + y.code);
|
| + if (x.get$isConst() && y.get$isConst()) {
|
| + var value = (kind == 35/*TokenKind.AND*/) ? x.get$actualValue() && y.get$actualValue() : x.get$actualValue() || y.get$actualValue();
|
| + return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, value, ('' + value), node.span);
|
| + }
|
| + return new Value($globals.world.nonNullBool, code, node.span, true);
|
| + }
|
| + else if (kind == 50/*TokenKind.EQ_STRICT*/ || kind == 51/*TokenKind.NE_STRICT*/) {
|
| + var x = this.visitValue(node.x);
|
| + var y = this.visitValue(node.y);
|
| + if (x.get$isConst() && y.get$isConst()) {
|
| + var xVal = x.get$actualValue();
|
| + var yVal = y.get$actualValue();
|
| + if (x.type.get$isString() && y.type.get$isString() && $ne(xVal.$index(0), yVal.$index(0))) {
|
| + if ($eq(xVal.$index(0), '"')) {
|
| + xVal = xVal.substring$2(1, xVal.length - 1);
|
| + yVal = toDoubleQuote(yVal.substring$2(1, yVal.length - 1));
|
| + }
|
| + else {
|
| + xVal = toDoubleQuote(xVal.substring$2(1, xVal.length - 1));
|
| + yVal = yVal.substring$2(1, yVal.length - 1);
|
| + }
|
| + }
|
| + var value = kind == 50/*TokenKind.EQ_STRICT*/ ? $eq(xVal, yVal) : $ne(xVal, yVal);
|
| + return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, value, ("" + value), node.span);
|
| + }
|
| + if ($eq(x.code, 'null') || $eq(y.code, 'null')) {
|
| + var op = node.op.toString().substring(0, 2);
|
| + return new Value($globals.world.nonNullBool, ('' + x.code + ' ' + op + ' ' + y.code), node.span, true);
|
| + }
|
| + else {
|
| + return new Value($globals.world.nonNullBool, ('' + x.code + ' ' + node.op + ' ' + y.code), node.span, true);
|
| + }
|
| + }
|
| + var assignKind = TokenKind.kindFromAssign(node.op.kind);
|
| + if (assignKind == -1) {
|
| + var x = this.visitValue(node.x);
|
| + var y = this.visitValue(node.y);
|
| + var name = TokenKind.binaryMethodName(node.op.kind);
|
| + if (node.op.kind == 49/*TokenKind.NE*/) {
|
| + name = ':ne';
|
| + }
|
| + if (name == null) {
|
| + $globals.world.internalError(('unimplemented binary op ' + node.op), node.span);
|
| + return;
|
| + }
|
| + return x.invoke$4(this, name, node, new Arguments(null, [y]));
|
| + }
|
| + else {
|
| + return this._visitAssign(assignKind, node.x, node.y, node, to$call$1(null), isVoid);
|
| + }
|
| +}
|
| +MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, captureOriginal, isVoid) {
|
| + if (captureOriginal == null) {
|
| + captureOriginal = (function (x) {
|
| + return x;
|
| + })
|
| + ;
|
| + }
|
| + if ((xn instanceof VarExpression)) {
|
| + return this._visitVarAssign(kind, xn, yn, position, captureOriginal);
|
| + }
|
| + else if ((xn instanceof IndexExpression)) {
|
| + return this._visitIndexAssign(kind, xn, yn, position, captureOriginal, isVoid);
|
| + }
|
| + else if ((xn instanceof DotExpression)) {
|
| + return this._visitDotAssign(kind, xn, yn, position, captureOriginal);
|
| + }
|
| + else {
|
| + $globals.world.error('illegal lhs', xn.span);
|
| + }
|
| +}
|
| +MethodGenerator.prototype._visitVarAssign = function(kind, xn, yn, position, captureOriginal) {
|
| + var name = xn.name.name;
|
| + var x = this._scope.lookup(name);
|
| + var y = this.visitValue(yn);
|
| + if (x == null) {
|
| + var members = this.method.declaringType.resolveMember(name);
|
| + x = this._makeThisOrType(position.span);
|
| + if (members != null) {
|
| + if ($globals.options.forceDynamic && !members.get$isStatic()) {
|
| + members = this.findMembers(xn.name.name);
|
| + }
|
| + if (kind == 0) {
|
| + return x.set_$4(this, name, position, y);
|
| + }
|
| + else if (!members.get$treatAsField() || members.get$containsMethods()) {
|
| + var right = x.get_$3(this, name, position);
|
| + right = captureOriginal(right);
|
| + y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arguments(null, [y]));
|
| + return x.set_$4(this, name, position, y);
|
| + }
|
| + else {
|
| + x = x.get_$3(this, name, position);
|
| + }
|
| + }
|
| + else {
|
| + var member = this.get$library().lookup(name, xn.name.span);
|
| + if (member == null) {
|
| + $globals.world.warning(('can not resolve ' + name), xn.span);
|
| + return this._makeMissingValue(name);
|
| + }
|
| + members = new MemberSet(member, false);
|
| + if (!members.get$treatAsField() || members.get$containsMethods()) {
|
| + if (kind != 0) {
|
| + var right = members._get$3(this, position, x);
|
| + right = captureOriginal(right);
|
| + y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arguments(null, [y]));
|
| + }
|
| + return members._set$4(this, position, x, y);
|
| + }
|
| + else {
|
| + x = members._get$3(this, position, x);
|
| + }
|
| + }
|
| + }
|
| + if (x.get$isFinal()) {
|
| + $globals.world.error(('final variable "' + x.code + '" is not assignable'), position.span);
|
| + }
|
| + y = y.convertTo$3(this, x.type, yn);
|
| + if (kind == 0) {
|
| + x = captureOriginal(x);
|
| + return new Value(y.type, ('' + x.code + ' = ' + y.code), position.span, true);
|
| + }
|
| + else if (x.type.get$isNum() && y.type.get$isNum() && (kind != 46/*TokenKind.TRUNCDIV*/)) {
|
| + x = captureOriginal(x);
|
| + var op = TokenKind.kindToString(kind);
|
| + return new Value(y.type, ('' + x.code + ' ' + op + '= ' + y.code), position.span, true);
|
| + }
|
| + else {
|
| + var right = x;
|
| + right = captureOriginal(right);
|
| + y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arguments(null, [y]));
|
| + return new Value(y.type, ('' + x.code + ' = ' + y.code), position.span, true);
|
| + }
|
| +}
|
| +MethodGenerator.prototype._visitIndexAssign = function(kind, xn, yn, position, captureOriginal, isVoid) {
|
| + var target = this.visitValue(xn.target);
|
| + var index = this.visitValue(xn.index);
|
| + var y = this.visitValue(yn);
|
| + var tmptarget = target;
|
| + var tmpindex = index;
|
| + if (kind != 0) {
|
| + tmptarget = this.getTemp(target);
|
| + tmpindex = this.getTemp(index);
|
| + index = this.assignTemp(tmpindex, index);
|
| + var right = tmptarget.invoke$4(this, ':index', position, new Arguments(null, [tmpindex]));
|
| + right = captureOriginal(right);
|
| + y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arguments(null, [y]));
|
| + }
|
| + var tmpy = null;
|
| + if (!isVoid) {
|
| + tmpy = this.getTemp(y);
|
| + y = this.assignTemp(tmpy, y);
|
| + }
|
| + var ret = this.assignTemp(tmptarget, target).invoke(this, ':setindex', position, new Arguments(null, [index, y]), false);
|
| + if (tmpy != null) {
|
| + ret = new Value(ret.type, ('(' + ret.code + ', ' + tmpy.code + ')'), ret.span, true);
|
| + if ($ne(tmpy, y)) this.freeTemp(tmpy);
|
| + }
|
| + if ($ne(tmptarget, target)) this.freeTemp(tmptarget);
|
| + if ($ne(tmpindex, index)) this.freeTemp(tmpindex);
|
| + return ret;
|
| +}
|
| +MethodGenerator.prototype._visitDotAssign = function(kind, xn, yn, position, captureOriginal) {
|
| + var target = xn.self.visit(this);
|
| + var y = this.visitValue(yn);
|
| + var tmptarget = target;
|
| + if (kind != 0) {
|
| + tmptarget = this.getTemp(target);
|
| + var right = tmptarget.get_$3(this, xn.name.name, xn.name);
|
| + right = captureOriginal(right);
|
| + y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arguments(null, [y]));
|
| + }
|
| + var ret = this.assignTemp(tmptarget, target).set_(this, xn.name.name, xn.name, y, false);
|
| + if ($ne(tmptarget, target)) this.freeTemp(tmptarget);
|
| + return ret;
|
| +}
|
| +MethodGenerator.prototype.visitUnaryExpression = function(node) {
|
| + var value = this.visitValue(node.self);
|
| + switch (node.op.kind) {
|
| + case 16/*TokenKind.INCR*/:
|
| + case 17/*TokenKind.DECR*/:
|
| +
|
| + if (value.type.get$isNum()) {
|
| + return new Value(value.type, ('' + node.op + value.code), node.span, true);
|
| + }
|
| + else {
|
| + var kind = (16/*TokenKind.INCR*/ == node.op.kind ? 42/*TokenKind.ADD*/ : 43/*TokenKind.SUB*/);
|
| + var operand = new LiteralExpression(1, new TypeReference(node.span, $globals.world.numType), '1', node.span);
|
| + var assignValue = this._visitAssign(kind, node.self, operand, node, to$call$1(null), false);
|
| + return new Value(assignValue.type, ('(' + assignValue.code + ')'), node.span, true);
|
| + }
|
| +
|
| + case 19/*TokenKind.NOT*/:
|
| +
|
| + if (value.type.get$isBool() && value.get$isConst()) {
|
| + var newVal = !value.get$actualValue();
|
| + return EvaluatedValue.EvaluatedValue$factory(value.type, newVal, ('' + newVal), node.span);
|
| + }
|
| + else {
|
| + var newVal = value.convertTo$3(this, $globals.world.nonNullBool, node);
|
| + return new Value(newVal.type, ('!' + newVal.code), node.span, true);
|
| + }
|
| +
|
| + case 42/*TokenKind.ADD*/:
|
| +
|
| + return value.convertTo$3(this, $globals.world.numType, node);
|
| +
|
| + case 43/*TokenKind.SUB*/:
|
| + case 18/*TokenKind.BIT_NOT*/:
|
| +
|
| + if (node.op.kind == 18/*TokenKind.BIT_NOT*/) {
|
| + return value.invoke$4(this, ':bit_not', node, Arguments.get$EMPTY());
|
| + }
|
| + else if (node.op.kind == 43/*TokenKind.SUB*/) {
|
| + return value.invoke$4(this, ':negate', node, Arguments.get$EMPTY());
|
| + }
|
| + else {
|
| + $globals.world.internalError(('unimplemented: unary ' + node.op), node.span);
|
| + }
|
| + $throw(new FallThroughError());
|
| +
|
| + default:
|
| +
|
| + $globals.world.internalError(('unimplemented: ' + node.op), node.span);
|
| +
|
| + }
|
| +}
|
| +MethodGenerator.prototype.visitAwaitExpression = function(node) {
|
| + $globals.world.internalError('Await expressions should have been eliminated before code generation', node.span);
|
| +}
|
| +MethodGenerator.prototype.visitPostfixExpression = function(node, isVoid) {
|
| + var $this = this; // closure support
|
| + var value = this.visitValue(node.body);
|
| + if (value.type.get$isNum() && !value.get$isFinal()) {
|
| + return new Value(value.type, ('' + value.code + node.op), node.span, true);
|
| + }
|
| + var kind = (16/*TokenKind.INCR*/ == node.op.kind) ? 42/*TokenKind.ADD*/ : 43/*TokenKind.SUB*/;
|
| + var operand = new LiteralExpression(1, new TypeReference(node.span, $globals.world.numType), '1', node.span);
|
| + var tmpleft = null, left = null;
|
| + var ret = this._visitAssign(kind, node.body, operand, node, (function (l) {
|
| + if (isVoid) {
|
| + return l;
|
| + }
|
| + else {
|
| + left = l;
|
| + tmpleft = $this.forceTemp(l);
|
| + return $this.assignTemp(tmpleft, left);
|
| + }
|
| + })
|
| + , false);
|
| + if (tmpleft != null) {
|
| + ret = new Value(ret.type, ("(" + ret.code + ", " + tmpleft.code + ")"), node.span, true);
|
| + }
|
| + if ($ne(tmpleft, left)) {
|
| + this.freeTemp(tmpleft);
|
| + }
|
| + return ret;
|
| +}
|
| +MethodGenerator.prototype.visitNewExpression = function(node) {
|
| + var typeRef = node.type;
|
| + var constructorName = '';
|
| + if (node.name != null) {
|
| + constructorName = node.name.name;
|
| + }
|
| + if ($eq(constructorName, '') && !(typeRef instanceof GenericTypeReference) && typeRef.get$names() != null) {
|
| + var names = ListFactory.ListFactory$from$factory(typeRef.get$names());
|
| + constructorName = names.removeLast$0().name;
|
| + if ($eq(names.length, 0)) names = null;
|
| + typeRef = new NameTypeReference(typeRef.get$isFinal(), typeRef.name, names, typeRef.span);
|
| + }
|
| + var type = this.method.resolveType(typeRef, true);
|
| + if (type.get$isTop()) {
|
| + type = type.get$library().findTypeByName$1(constructorName);
|
| + constructorName = '';
|
| + }
|
| + if ((type instanceof ParameterType)) {
|
| + $globals.world.error('cannot instantiate a type parameter', node.span);
|
| + return this._makeMissingValue(constructorName);
|
| + }
|
| + var m = type.getConstructor$1(constructorName);
|
| + if (m == null) {
|
| + var name = type.get$jsname();
|
| + if (type.get$isVar()) {
|
| + name = typeRef.name.name;
|
| + }
|
| + $globals.world.error(('no matching constructor for ' + name), node.span);
|
| + return this._makeMissingValue(name);
|
| + }
|
| + if (node.isConst) {
|
| + if (!m.get$isConst()) {
|
| + $globals.world.error('can\'t use const on a non-const constructor', node.span);
|
| + }
|
| + var $$list = node.arguments;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var arg = $$list.$index($$i);
|
| + if (!this.visitValue(arg.value).get$isConst()) {
|
| + $globals.world.error('const constructor expects const arguments', arg.span);
|
| + }
|
| + }
|
| + }
|
| + var target = new Value.type$ctor(type, typeRef.span);
|
| + return m.invoke$4(this, node, target, this._makeArgs(node.arguments));
|
| +}
|
| +MethodGenerator.prototype.visitListExpression = function(node) {
|
| + var argsCode = [];
|
| + var argValues = [];
|
| + var type = null;
|
| + if (node.type != null) {
|
| + type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index(0);
|
| + if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypeParams())) {
|
| + $globals.world.error('type parameter cannot be used in const list literals');
|
| + }
|
| + }
|
| + var $$list = node.values;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var item = $$list.$index($$i);
|
| + var arg = this.visitTypedValue(item, type);
|
| + argValues.add$1(arg);
|
| + if (node.isConst) {
|
| + if (!arg.get$isConst()) {
|
| + $globals.world.error('const list can only contain const values', item.span);
|
| + argsCode.add$1(arg.code);
|
| + }
|
| + else {
|
| + argsCode.add$1(arg.get$canonicalCode());
|
| + }
|
| + }
|
| + else {
|
| + argsCode.add$1(arg.code);
|
| + }
|
| + }
|
| + $globals.world.get$coreimpl().types.$index('ListFactory').markUsed$0();
|
| + var code = ('[' + Strings.join(argsCode, ", ") + ']');
|
| + var value = new Value($globals.world.listType, code, node.span, true);
|
| + if (node.isConst) {
|
| + var immutableList = $globals.world.get$coreimpl().types.$index('ImmutableList');
|
| + var immutableListCtor = immutableList.getConstructor$1('from');
|
| + var result = immutableListCtor.invoke$4(this, node, new Value.type$ctor(value.type, node.span), new Arguments(null, [value]));
|
| + value = $globals.world.gen.globalForConst(ConstListValue.ConstListValue$factory(immutableList, argValues, ('const ' + code), result.code, node.span), argValues);
|
| + }
|
| + return value;
|
| +}
|
| +MethodGenerator.prototype.visitMapExpression = function(node) {
|
| + if (node.items.length == 0 && !node.isConst) {
|
| + return $globals.world.mapType.getConstructor('').invoke$4(this, node, new Value.type$ctor($globals.world.mapType, node.span), Arguments.get$EMPTY());
|
| + }
|
| + var argValues = [];
|
| + var argsCode = [];
|
| + var type = null;
|
| + if (node.type != null) {
|
| + type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index(1);
|
| + if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypeParams())) {
|
| + $globals.world.error('type parameter cannot be used in const map literals');
|
| + }
|
| + }
|
| + for (var i = 0;
|
| + i < node.items.length; i += 2) {
|
| + var key = this.visitTypedValue(node.items.$index(i), $globals.world.stringType);
|
| + var valueItem = node.items.$index(i + 1);
|
| + var value = this.visitTypedValue(valueItem, type);
|
| + argValues.add$1(key);
|
| + argValues.add$1(value);
|
| + if (node.isConst) {
|
| + if (!key.get$isConst() || !value.get$isConst()) {
|
| + $globals.world.error('const map can only contain const values', valueItem.span);
|
| + argsCode.add$1(key.code);
|
| + argsCode.add$1(value.code);
|
| + }
|
| + else {
|
| + argsCode.add$1(key.get$canonicalCode());
|
| + argsCode.add$1(value.get$canonicalCode());
|
| + }
|
| + }
|
| + else {
|
| + argsCode.add$1(key.code);
|
| + argsCode.add$1(value.code);
|
| + }
|
| + }
|
| + var argList = ('[' + Strings.join(argsCode, ", ") + ']');
|
| + var items = new Value($globals.world.listType, argList, node.span, true);
|
| + var tp = $globals.world.corelib.topType;
|
| + var f = node.isConst ? tp.getMember$1('_constMap') : tp.getMember$1('_map');
|
| + var value = f.invoke(this, node, new Value.type$ctor(tp, null), new Arguments(null, [items]), false);
|
| + if (node.isConst) {
|
| + value = ConstMapValue.ConstMapValue$factory(value.type, argValues, value.code, value.code, value.span);
|
| + return $globals.world.gen.globalForConst(value, argValues);
|
| + }
|
| + else {
|
| + return value;
|
| + }
|
| +}
|
| +MethodGenerator.prototype.visitConditionalExpression = function(node) {
|
| + var test = this.visitBool(node.test);
|
| + var trueBranch = this.visitValue(node.trueBranch);
|
| + var falseBranch = this.visitValue(node.falseBranch);
|
| + var code = ('' + test.code + ' ? ' + trueBranch.code + ' : ' + falseBranch.code);
|
| + return new Value(Type.union(trueBranch.type, falseBranch.type), code, node.span, true);
|
| +}
|
| +MethodGenerator.prototype.visitIsExpression = function(node) {
|
| + var value = this.visitValue(node.x);
|
| + var type = this.method.resolveType(node.type, false);
|
| + return value.instanceOf$4(this, type, node.span, node.isTrue);
|
| +}
|
| +MethodGenerator.prototype.visitParenExpression = function(node) {
|
| + var body = this.visitValue(node.body);
|
| + if (body.get$isConst()) {
|
| + return EvaluatedValue.EvaluatedValue$factory(body.type, body.get$actualValue(), ('(' + body.get$canonicalCode() + ')'), node.span);
|
| + }
|
| + return new Value(body.type, ('(' + body.code + ')'), node.span, true);
|
| +}
|
| +MethodGenerator.prototype.visitDotExpression = function(node) {
|
| + var target = node.self.visit(this);
|
| + return target.get_$3(this, node.name.name, node.name);
|
| +}
|
| +MethodGenerator.prototype.visitVarExpression = function(node) {
|
| + var name = node.name.name;
|
| + var ret = this._scope.lookup(name);
|
| + if (ret != null) return ret;
|
| + return this._makeThisOrType(node.span).get_$3(this, name, node);
|
| +}
|
| +MethodGenerator.prototype._makeMissingValue = function(name) {
|
| + return new Value($globals.world.varType, ('' + name + '()/*NotFound*/'), null, true);
|
| +}
|
| +MethodGenerator.prototype._makeThisOrType = function(span) {
|
| + return new BareValue(this, this._getOutermostMethod(), span);
|
| +}
|
| +MethodGenerator.prototype.visitThisExpression = function(node) {
|
| + return this._makeThisValue(node);
|
| +}
|
| +MethodGenerator.prototype.visitSuperExpression = function(node) {
|
| + return this._makeSuperValue(node);
|
| +}
|
| +MethodGenerator.prototype.visitNullExpression = function(node) {
|
| + return EvaluatedValue.EvaluatedValue$factory($globals.world.varType, null, 'null', null);
|
| +}
|
| +MethodGenerator.prototype._isUnaryIncrement = function(item) {
|
| + if ((item instanceof UnaryExpression)) {
|
| + var u = item;
|
| + return u.op.kind == 16/*TokenKind.INCR*/ || u.op.kind == 17/*TokenKind.DECR*/;
|
| + }
|
| + else {
|
| + return false;
|
| + }
|
| +}
|
| +MethodGenerator.prototype.visitLiteralExpression = function(node) {
|
| + var $0;
|
| + var type = node.type.type;
|
| + if (!!(($0 = node.value) && $0.is$List())) {
|
| + var items = [];
|
| + var $$list = node.value;
|
| + for (var $$i = node.value.iterator$0(); $$i.hasNext$0(); ) {
|
| + var item = $$i.next$0();
|
| + var val = this.visitValue(item);
|
| + val.invoke$4(this, 'toString', item, Arguments.get$EMPTY());
|
| + var code = val.code;
|
| + if ((item instanceof BinaryExpression) || (item instanceof ConditionalExpression) || (item instanceof PostfixExpression) || this._isUnaryIncrement(item)) {
|
| + code = ('(' + code + ')');
|
| + }
|
| + if ($eq(items.length, 0) || ($ne(code, "''") && $ne(code, '""'))) {
|
| + items.add$1(code);
|
| + }
|
| + }
|
| + return new Value(type, ('(' + Strings.join(items, " + ") + ')'), node.span, true);
|
| + }
|
| + var text = node.text;
|
| + if (type.get$isString()) {
|
| + if (text.startsWith$1('@')) {
|
| + text = MethodGenerator._escapeString(parseStringLiteral(text));
|
| + text = ('"' + text + '"');
|
| + }
|
| + else if (isMultilineString(text)) {
|
| + text = parseStringLiteral(text);
|
| + text = text.replaceAll$2('\n', '\\n');
|
| + text = toDoubleQuote(text);
|
| + text = ('"' + text + '"');
|
| + }
|
| + if (text !== node.text) {
|
| + node.value = text;
|
| + node.text = text;
|
| + }
|
| + }
|
| + return EvaluatedValue.EvaluatedValue$factory(type, node.value, node.text, null);
|
| +}
|
| +MethodGenerator.prototype._checkNonStatic$1 = MethodGenerator.prototype._checkNonStatic;
|
| +MethodGenerator.prototype.visitBinaryExpression$1 = function($0) {
|
| + return this.visitBinaryExpression($0, false);
|
| +};
|
| +MethodGenerator.prototype.visitPostfixExpression$1 = function($0) {
|
| + return this.visitPostfixExpression($0, false);
|
| +};
|
| +MethodGenerator.prototype.writeDefinition$2 = MethodGenerator.prototype.writeDefinition;
|
| +// ********** Code for Arguments **************
|
| +function Arguments(nodes, values) {
|
| + this.nodes = nodes;
|
| + this.values = values;
|
| + // Initializers done
|
| +}
|
| +Arguments.Arguments$bare$factory = function(arity) {
|
| + var values = [];
|
| + for (var i = 0;
|
| + i < arity; i++) {
|
| + values.add$1(new Value($globals.world.varType, ('\$' + i), null, false));
|
| + }
|
| + return new Arguments(null, values);
|
| +}
|
| +Arguments.get$EMPTY = function() {
|
| + if ($globals.Arguments__empty == null) {
|
| + $globals.Arguments__empty = new Arguments(null, []);
|
| + }
|
| + return $globals.Arguments__empty;
|
| +}
|
| +Arguments.prototype.get$nameCount = function() {
|
| + return this.get$length() - this.get$bareCount();
|
| +}
|
| +Arguments.prototype.get$hasNames = function() {
|
| + return this.get$bareCount() < this.get$length();
|
| +}
|
| +Arguments.prototype.get$length = function() {
|
| + return this.values.length;
|
| +}
|
| +Object.defineProperty(Arguments.prototype, "length", {
|
| + get: Arguments.prototype.get$length
|
| +});
|
| +Arguments.prototype.getName = function(i) {
|
| + return this.nodes.$index(i).label.name;
|
| +}
|
| +Arguments.prototype.getIndexOfName = function(name) {
|
| + for (var i = this.get$bareCount();
|
| + i < this.get$length(); i++) {
|
| + if (this.getName(i) == name) {
|
| + return i;
|
| + }
|
| + }
|
| + return -1;
|
| +}
|
| +Arguments.prototype.getValue = function(name) {
|
| + var i = this.getIndexOfName(name);
|
| + return i >= 0 ? this.values.$index(i) : null;
|
| +}
|
| +Arguments.prototype.get$bareCount = function() {
|
| + if (this._bareCount == null) {
|
| + this._bareCount = this.get$length();
|
| + if (this.nodes != null) {
|
| + for (var i = 0;
|
| + i < this.nodes.length; i++) {
|
| + if (this.nodes.$index(i).label != null) {
|
| + this._bareCount = i;
|
| + break;
|
| + }
|
| + }
|
| + }
|
| + }
|
| + return this._bareCount;
|
| +}
|
| +Arguments.prototype.getCode = function() {
|
| + var argsCode = [];
|
| + for (var i = 0;
|
| + i < this.get$length(); i++) {
|
| + argsCode.add$1(this.values.$index(i).code);
|
| + }
|
| + Arguments.removeTrailingNulls(argsCode);
|
| + return Strings.join(argsCode, ", ");
|
| +}
|
| +Arguments.removeTrailingNulls = function(argsCode) {
|
| + while (argsCode.length > 0 && $eq(argsCode.last(), 'null')) {
|
| + argsCode.removeLast();
|
| + }
|
| +}
|
| +Arguments.prototype.getNames = function() {
|
| + var names = [];
|
| + for (var i = this.get$bareCount();
|
| + i < this.get$length(); i++) {
|
| + names.add$1(this.getName(i));
|
| + }
|
| + return names;
|
| +}
|
| +Arguments.prototype.toCallStubArgs = function() {
|
| + var result = [];
|
| + for (var i = 0;
|
| + i < this.get$bareCount(); i++) {
|
| + result.add$1(new Value($globals.world.varType, ('\$' + i), null, false));
|
| + }
|
| + for (var i = this.get$bareCount();
|
| + i < this.get$length(); i++) {
|
| + var name = this.getName(i);
|
| + if (name == null) name = ('\$' + i);
|
| + result.add$1(new Value($globals.world.varType, name, null, false));
|
| + }
|
| + return new Arguments(this.nodes, result);
|
| +}
|
| +// ********** Code for LibraryImport **************
|
| +function LibraryImport(library, prefix) {
|
| + this.library = library;
|
| + this.prefix = prefix;
|
| + // Initializers done
|
| +}
|
| +LibraryImport.prototype.get$library = function() { return this.library; };
|
| +LibraryImport.prototype.set$library = function(value) { return this.library = value; };
|
| +// ********** Code for Library **************
|
| +$inherits(Library, lang_Element);
|
| +function Library(baseSource) {
|
| + this.isWritten = false
|
| + this.isMarked = false
|
| + this.baseSource = baseSource;
|
| + // Initializers done
|
| + lang_Element.call(this, null, null);
|
| + this.sourceDir = dirname(this.baseSource.filename);
|
| + this.topType = new DefinedType(null, this, null, true);
|
| + this.types = _map(['', this.topType]);
|
| + this.imports = [];
|
| + this.natives = [];
|
| + this.sources = [];
|
| + this._privateMembers = new HashMapImplementation();
|
| +}
|
| +Library.prototype.get$baseSource = function() { return this.baseSource; };
|
| +Library.prototype.get$_privateMembers = function() { return this._privateMembers; };
|
| +Library.prototype.set$_privateMembers = function(value) { return this._privateMembers = value; };
|
| +Library.prototype.get$topType = function() { return this.topType; };
|
| +Library.prototype.set$topType = function(value) { return this.topType = value; };
|
| +Library.prototype.get$enclosingElement = function() {
|
| + return null;
|
| +}
|
| +Library.prototype.get$library = function() {
|
| + return this;
|
| +}
|
| +Library.prototype.get$isNative = function() {
|
| + return this.topType.isNative;
|
| +}
|
| +Library.prototype.get$isCore = function() {
|
| + return $eq(this, $globals.world.corelib);
|
| +}
|
| +Library.prototype.get$isCoreImpl = function() {
|
| + return $eq(this, $globals.world.get$coreimpl());
|
| +}
|
| +Library.prototype.get$span = function() {
|
| + return new SourceSpan(this.baseSource, 0, 0);
|
| +}
|
| +Object.defineProperty(Library.prototype, "span", {
|
| + get: Library.prototype.get$span
|
| +});
|
| +Library.prototype.makeFullPath = function(filename) {
|
| + if (filename.startsWith('dart:')) return filename;
|
| + if (filename.startsWith('/')) return filename;
|
| + if (filename.startsWith('file:///')) return filename;
|
| + if (filename.startsWith('http://')) return filename;
|
| + return joinPaths(this.sourceDir, filename);
|
| +}
|
| +Library.prototype.addImport = function(fullname, prefix) {
|
| + var newLib = $globals.world.getOrAddLibrary(fullname);
|
| + this.imports.add(new LibraryImport(newLib, prefix));
|
| + return newLib;
|
| +}
|
| +Library.prototype.addNative = function(fullname) {
|
| + this.natives.add($globals.world.reader.readFile(fullname));
|
| +}
|
| +Library.prototype._findMembers = function(name) {
|
| + if (name.startsWith('_')) {
|
| + return this._privateMembers.$index(name);
|
| + }
|
| + else {
|
| + return $globals.world._members.$index(name);
|
| + }
|
| +}
|
| +Library.prototype._addMember = function(member) {
|
| + if (member.get$isPrivate()) {
|
| + if (member.get$isStatic()) {
|
| + if (member.declaringType.get$isTop()) {
|
| + $globals.world._addTopName(member);
|
| + }
|
| + return;
|
| + }
|
| + var mset = this._privateMembers.$index(member.name);
|
| + if (mset == null) {
|
| + var $$list = $globals.world.libraries.getValues();
|
| + for (var $$i = $globals.world.libraries.getValues().iterator$0(); $$i.hasNext$0(); ) {
|
| + var lib = $$i.next$0();
|
| + if (lib.get$_privateMembers().containsKey$1(member.get$jsname())) {
|
| + member._jsname = ('_' + this.get$jsname() + member.get$jsname());
|
| + break;
|
| + }
|
| + }
|
| + mset = new MemberSet(member, true);
|
| + this._privateMembers.$setindex(member.name, mset);
|
| + }
|
| + else {
|
| + mset.get$members().add$1(member);
|
| + }
|
| + }
|
| + else {
|
| + $globals.world._addMember(member);
|
| + }
|
| +}
|
| +Library.prototype.getOrAddFunctionType = function(enclosingElement, name, func) {
|
| + var def = new FunctionTypeDefinition(func, null, func.span);
|
| + var type = new DefinedType(name, this, def, false);
|
| + type.addMethod(':call', func);
|
| + var m = type.members.$index(':call');
|
| + m.set$enclosingElement(enclosingElement);
|
| + m.resolve$0();
|
| + type.interfaces = [$globals.world.functionType];
|
| + return type;
|
| +}
|
| +Library.prototype.addType = function(name, definition, isClass) {
|
| + if (this.types.containsKey(name)) {
|
| + var existingType = this.types.$index(name);
|
| + if (this.get$isCore() && existingType.get$definition() == null) {
|
| + existingType.setDefinition$1(definition);
|
| + }
|
| + else {
|
| + $globals.world.warning(('duplicate definition of ' + name), definition.span, existingType.span);
|
| + }
|
| + }
|
| + else {
|
| + this.types.$setindex(name, new DefinedType(name, this, definition, isClass));
|
| + }
|
| + return this.types.$index(name);
|
| +}
|
| +Library.prototype.findType = function(type) {
|
| + var result = this.findTypeByName(type.name.name);
|
| + if (result == null) return null;
|
| + if (type.names != null) {
|
| + if (type.names.length > 1) {
|
| + return null;
|
| + }
|
| + if (!result.get$isTop()) {
|
| + return null;
|
| + }
|
| + return result.get$library().findTypeByName(type.names.$index(0).name);
|
| + }
|
| + return result;
|
| +}
|
| +Library.prototype.findTypeByName = function(name) {
|
| + var ret = this.types.$index(name);
|
| + var $$list = this.imports;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var imported = $$list.$index($$i);
|
| + var newRet = null;
|
| + if (imported.prefix == null) {
|
| + newRet = imported.get$library().types.$index(name);
|
| + }
|
| + else if ($eq(imported.prefix, name)) {
|
| + newRet = imported.get$library().get$topType();
|
| + }
|
| + if (newRet != null) {
|
| + if (ret != null && $ne(ret, newRet)) {
|
| + $globals.world.error(('conflicting types for "' + name + '"'), ret.span, newRet.span);
|
| + }
|
| + else {
|
| + ret = newRet;
|
| + }
|
| + }
|
| + }
|
| + return ret;
|
| +}
|
| +Library.prototype.resolveType = function(node, typeErrors) {
|
| + if (node == null) return $globals.world.varType;
|
| + if (node.type != null) return node.type;
|
| + node.type = this.findType(node);
|
| + if (node.type == null) {
|
| + var message = ('cannot find type ' + Library._getDottedName(node));
|
| + if (typeErrors) {
|
| + $globals.world.error(message, node.span);
|
| + node.type = $globals.world.objectType;
|
| + }
|
| + else {
|
| + $globals.world.warning(message, node.span);
|
| + node.type = $globals.world.varType;
|
| + }
|
| + }
|
| + return node.type;
|
| +}
|
| +Library._getDottedName = function(type) {
|
| + if (type.names != null) {
|
| + var names = map(type.names, (function (n) {
|
| + return n.name;
|
| + })
|
| + );
|
| + return type.name.name + '.' + Strings.join(names, '.');
|
| + }
|
| + else {
|
| + return type.name.name;
|
| + }
|
| +}
|
| +Library.prototype.lookup = function(name, span) {
|
| + var retType = this.findTypeByName(name);
|
| + var ret = null;
|
| + if (retType != null) {
|
| + ret = retType.get$typeMember();
|
| + }
|
| + var newRet = this.topType.getMember(name);
|
| + if (newRet != null) {
|
| + if (ret != null && $ne(ret, newRet)) {
|
| + $globals.world.error(('conflicting members for "' + name + '"'), span, ret.span, newRet.span);
|
| + }
|
| + else {
|
| + ret = newRet;
|
| + }
|
| + }
|
| + var $$list = this.imports;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var imported = $$list.$index($$i);
|
| + if (imported.prefix == null) {
|
| + newRet = imported.get$library().get$topType().getMember$1(name);
|
| + if (newRet != null) {
|
| + if (ret != null && $ne(ret, newRet)) {
|
| + $globals.world.error(('conflicting members for "' + name + '"'), span, ret.span, newRet.span);
|
| + }
|
| + else {
|
| + ret = newRet;
|
| + }
|
| + }
|
| + }
|
| + }
|
| + return ret;
|
| +}
|
| +Library.prototype.resolve = function() {
|
| + if (this.name == null) {
|
| + this.name = this.baseSource.filename;
|
| + var index = this.name.lastIndexOf('/', this.name.length);
|
| + if (index >= 0) {
|
| + this.name = this.name.substring(index + 1);
|
| + }
|
| + index = this.name.indexOf('.');
|
| + if (index > 0) {
|
| + this.name = this.name.substring(0, index);
|
| + }
|
| + }
|
| + this._jsname = this.name.replaceAll('.', '_').replaceAll(':', '_').replaceAll(' ', '_');
|
| + var $$list = this.types.getValues();
|
| + for (var $$i = this.types.getValues().iterator$0(); $$i.hasNext$0(); ) {
|
| + var type = $$i.next$0();
|
| + type.resolve$0();
|
| + }
|
| +}
|
| +Library.prototype.visitSources = function() {
|
| + var visitor = new _LibraryVisitor(this);
|
| + visitor.addSource$1(this.baseSource);
|
| +}
|
| +Library.prototype.toString = function() {
|
| + return this.baseSource.filename;
|
| +}
|
| +Library.prototype.hashCode = function() {
|
| + return this.baseSource.filename.hashCode();
|
| +}
|
| +Library.prototype.$eq = function(other) {
|
| + return (other instanceof Library) && $eq(other.get$baseSource().filename, this.baseSource.filename);
|
| +}
|
| +Library.prototype.findTypeByName$1 = Library.prototype.findTypeByName;
|
| +Library.prototype.hashCode$0 = Library.prototype.hashCode;
|
| +Library.prototype.resolve$0 = Library.prototype.resolve;
|
| +Library.prototype.toString$0 = Library.prototype.toString;
|
| +Library.prototype.visitSources$0 = Library.prototype.visitSources;
|
| +// ********** Code for _LibraryVisitor **************
|
| +function _LibraryVisitor(library) {
|
| + this.seenImport = false
|
| + this.seenSource = false
|
| + this.seenResource = false
|
| + this.isTop = true
|
| + this.library = library;
|
| + // Initializers done
|
| + this.currentType = this.library.topType;
|
| + this.sources = [];
|
| +}
|
| +_LibraryVisitor.prototype.get$library = function() { return this.library; };
|
| +_LibraryVisitor.prototype.get$isTop = function() { return this.isTop; };
|
| +_LibraryVisitor.prototype.set$isTop = function(value) { return this.isTop = value; };
|
| +_LibraryVisitor.prototype.addSourceFromName = function(name, span) {
|
| + var filename = this.library.makeFullPath(name);
|
| + if ($eq(filename, this.library.baseSource.filename)) {
|
| + $globals.world.error('library can not source itself', span);
|
| + return;
|
| + }
|
| + else if (this.sources.some((function (s) {
|
| + return $eq(s.filename, filename);
|
| + })
|
| + )) {
|
| + $globals.world.error(('file "' + filename + '" has already been sourced'), span);
|
| + return;
|
| + }
|
| + var source = $globals.world.readFile(this.library.makeFullPath(name));
|
| + this.sources.add(source);
|
| +}
|
| +_LibraryVisitor.prototype.addSource = function(source) {
|
| + var $this = this; // closure support
|
| + if (this.library.sources.some((function (s) {
|
| + return $eq(s.filename, source.filename);
|
| + })
|
| + )) {
|
| + $globals.world.error(('duplicate source file "' + source.filename + '"'));
|
| + return;
|
| + }
|
| + this.library.sources.add(source);
|
| + var parser = new Parser(source, $globals.options.dietParse, false, false, 0);
|
| + var unit = parser.compilationUnit();
|
| + unit.forEach((function (def) {
|
| + return def.visit$1($this);
|
| + })
|
| + );
|
| + this.isTop = false;
|
| + var newSources = this.sources;
|
| + this.sources = [];
|
| + for (var $$i = newSources.iterator$0(); $$i.hasNext$0(); ) {
|
| + var source0 = $$i.next$0();
|
| + this.addSource(source0);
|
| + }
|
| +}
|
| +_LibraryVisitor.prototype.visitDirectiveDefinition = function(node) {
|
| + if (!this.isTop) {
|
| + $globals.world.error('directives not allowed in sourced file', node.span);
|
| + return;
|
| + }
|
| + var name;
|
| + switch (node.name.name) {
|
| + case "library":
|
| +
|
| + name = this.getSingleStringArg(node);
|
| + if (this.library.name == null) {
|
| + this.library.name = name;
|
| + if ($eq(name, 'node') || $eq(name, 'dom')) {
|
| + this.library.topType.isNative = true;
|
| + }
|
| + if (this.seenImport || this.seenSource || this.seenResource) {
|
| + $globals.world.error('#library must be first directive in file', node.span);
|
| + }
|
| + }
|
| + else {
|
| + $globals.world.error('already specified library name', node.span);
|
| + }
|
| + break;
|
| +
|
| + case "import":
|
| +
|
| + this.seenImport = true;
|
| + name = this.getFirstStringArg(node);
|
| + var prefix = this.tryGetNamedStringArg(node, 'prefix');
|
| + if (node.arguments.length > 2 || node.arguments.length == 2 && prefix == null) {
|
| + $globals.world.error('expected at most one "name" argument and one optional "prefix"' + (' but found ' + node.arguments.length), node.span);
|
| + }
|
| + else if (prefix != null && prefix.indexOf$1('.') >= 0) {
|
| + $globals.world.error('library prefix canot contain "."', node.span);
|
| + }
|
| + else if (this.seenSource || this.seenResource) {
|
| + $globals.world.error('#imports must come before any #source or #resource', node.span);
|
| + }
|
| + if ($eq(prefix, '')) prefix = null;
|
| + var filename = this.library.makeFullPath(name);
|
| + if (this.library.imports.some((function (li) {
|
| + return $eq(li.get$library().get$baseSource(), filename);
|
| + })
|
| + )) {
|
| + $globals.world.error(('duplicate import of "' + name + '"'), node.span);
|
| + return;
|
| + }
|
| + var newLib = this.library.addImport(filename, prefix);
|
| + break;
|
| +
|
| + case "source":
|
| +
|
| + this.seenSource = true;
|
| + name = this.getSingleStringArg(node);
|
| + this.addSourceFromName(name, node.span);
|
| + if (this.seenResource) {
|
| + $globals.world.error('#sources must come before any #resource', node.span);
|
| + }
|
| + break;
|
| +
|
| + case "native":
|
| +
|
| + name = this.getSingleStringArg(node);
|
| + this.library.addNative(this.library.makeFullPath(name));
|
| + break;
|
| +
|
| + case "resource":
|
| +
|
| + this.seenResource = true;
|
| + this.getFirstStringArg(node);
|
| + break;
|
| +
|
| + default:
|
| +
|
| + $globals.world.error(('unknown directive: ' + node.name.name), node.span);
|
| +
|
| + }
|
| +}
|
| +_LibraryVisitor.prototype.getSingleStringArg = function(node) {
|
| + if (node.arguments.length != 1) {
|
| + $globals.world.error(('expected exactly one argument but found ' + node.arguments.length), node.span);
|
| + }
|
| + return this.getFirstStringArg(node);
|
| +}
|
| +_LibraryVisitor.prototype.getFirstStringArg = function(node) {
|
| + if (node.arguments.length < 1) {
|
| + $globals.world.error(('expected at least one argument but found ' + node.arguments.length), node.span);
|
| + }
|
| + var arg = node.arguments.$index(0);
|
| + if (arg.label != null) {
|
| + $globals.world.error('label not allowed for directive', node.span);
|
| + }
|
| + return this._parseStringArgument(arg);
|
| +}
|
| +_LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) {
|
| + var args = node.arguments.filter((function (a) {
|
| + return a.label != null && $eq(a.label.name, argName);
|
| + })
|
| + );
|
| + if ($eq(args.length, 0)) {
|
| + return null;
|
| + }
|
| + if (args.length > 1) {
|
| + $globals.world.error(('expected at most one "' + argName + '" argument but found ') + node.arguments.length, node.span);
|
| + }
|
| + for (var $$i = args.iterator$0(); $$i.hasNext$0(); ) {
|
| + var arg = $$i.next$0();
|
| + return this._parseStringArgument(arg);
|
| + }
|
| +}
|
| +_LibraryVisitor.prototype._parseStringArgument = function(arg) {
|
| + var expr = arg.value;
|
| + if (!(expr instanceof LiteralExpression) || !expr.type.type.get$isString()) {
|
| + $globals.world.error('expected string', expr.span);
|
| + }
|
| + return parseStringLiteral(expr.value);
|
| +}
|
| +_LibraryVisitor.prototype.visitTypeDefinition = function(node) {
|
| + var oldType = this.currentType;
|
| + this.currentType = this.library.addType(node.name.name, node, node.isClass);
|
| + var $$list = node.body;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var member = $$list.$index($$i);
|
| + member.visit$1(this);
|
| + }
|
| + this.currentType = oldType;
|
| +}
|
| +_LibraryVisitor.prototype.visitVariableDefinition = function(node) {
|
| + this.currentType.addField(node);
|
| +}
|
| +_LibraryVisitor.prototype.visitFunctionDefinition = function(node) {
|
| + this.currentType.addMethod(node.name.name, node);
|
| +}
|
| +_LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) {
|
| + var type = this.library.addType(node.func.name.name, node, false);
|
| + type.addMethod$2(':call', node.func);
|
| +}
|
| +_LibraryVisitor.prototype.addSource$1 = _LibraryVisitor.prototype.addSource;
|
| +// ********** Code for Parameter **************
|
| +function Parameter(definition, method) {
|
| + this.isInitializer = false
|
| + this.definition = definition;
|
| + this.method = method;
|
| + // Initializers done
|
| +}
|
| +Parameter.prototype.get$definition = function() { return this.definition; };
|
| +Parameter.prototype.set$definition = function(value) { return this.definition = value; };
|
| +Parameter.prototype.get$isInitializer = function() { return this.isInitializer; };
|
| +Parameter.prototype.set$isInitializer = function(value) { return this.isInitializer = value; };
|
| +Parameter.prototype.resolve = function() {
|
| + this.name = this.definition.name.name;
|
| + if (this.name.startsWith('this.')) {
|
| + this.name = this.name.substring(5);
|
| + this.isInitializer = true;
|
| + }
|
| + this.type = this.method.resolveType(this.definition.type, false);
|
| + if (this.definition.value != null) {
|
| + if (!this.get$hasDefaultValue()) return;
|
| + if (this.method.name == ':call') {
|
| + if (this.method.get$definition().body == null) {
|
| + $globals.world.error('default value not allowed on function type', this.definition.span);
|
| + }
|
| + }
|
| + else if (this.method.get$isAbstract()) {
|
| + $globals.world.error('default value not allowed on abstract methods', this.definition.span);
|
| + }
|
| + }
|
| + else if (this.isInitializer && !this.method.get$isConstructor()) {
|
| + $globals.world.error('initializer parameters only allowed on constructors', this.definition.span);
|
| + }
|
| +}
|
| +Parameter.prototype.genValue = function(method, context) {
|
| + if (this.definition.value == null || this.value != null) return;
|
| + if (context == null) {
|
| + context = new MethodGenerator(method, null);
|
| + }
|
| + this.value = this.definition.value.visit(context);
|
| + if (!this.value.get$isConst()) {
|
| + $globals.world.error('default parameter values must be constant', this.value.span);
|
| + }
|
| + this.value = this.value.convertTo(context, this.type, this.definition.value, false);
|
| +}
|
| +Parameter.prototype.copyWithNewType = function(newMethod, newType) {
|
| + var ret = new Parameter(this.definition, newMethod);
|
| + ret.type = newType;
|
| + ret.name = this.name;
|
| + ret.set$isInitializer(this.isInitializer);
|
| + return ret;
|
| +}
|
| +Parameter.prototype.get$isOptional = function() {
|
| + return this.definition != null && this.definition.value != null;
|
| +}
|
| +Parameter.prototype.get$hasDefaultValue = function() {
|
| + return !(this.definition.value instanceof NullExpression) || (this.definition.value.span.start != this.definition.span.start);
|
| +}
|
| +Parameter.prototype.copyWithNewType$2 = Parameter.prototype.copyWithNewType;
|
| +Parameter.prototype.genValue$2 = Parameter.prototype.genValue;
|
| +Parameter.prototype.resolve$0 = Parameter.prototype.resolve;
|
| +// ********** Code for Member **************
|
| +$inherits(Member, lang_Element);
|
| +function Member(name, declaringType) {
|
| + this.isGenerated = false;
|
| + this.declaringType = declaringType;
|
| + // Initializers done
|
| + lang_Element.call(this, name, declaringType);
|
| +}
|
| +Member.prototype.get$declaringType = function() { return this.declaringType; };
|
| +Member.prototype.get$generator = function() { return this.generator; };
|
| +Member.prototype.set$generator = function(value) { return this.generator = value; };
|
| +Member.prototype.get$library = function() {
|
| + return this.declaringType.get$library();
|
| +}
|
| +Member.prototype.get$isPrivate = function() {
|
| + return this.name.startsWith('_');
|
| +}
|
| +Member.prototype.get$isConstructor = function() {
|
| + return false;
|
| +}
|
| +Member.prototype.get$isField = function() {
|
| + return false;
|
| +}
|
| +Member.prototype.get$isMethod = function() {
|
| + return false;
|
| +}
|
| +Member.prototype.get$isProperty = function() {
|
| + return false;
|
| +}
|
| +Member.prototype.get$isAbstract = function() {
|
| + return false;
|
| +}
|
| +Member.prototype.get$isFinal = function() {
|
| + return false;
|
| +}
|
| +Member.prototype.get$isConst = function() {
|
| + return false;
|
| +}
|
| +Member.prototype.get$isFactory = function() {
|
| + return false;
|
| +}
|
| +Member.prototype.get$isOperator = function() {
|
| + return this.name.startsWith(':');
|
| +}
|
| +Member.prototype.get$isCallMethod = function() {
|
| + return this.name == ':call';
|
| +}
|
| +Member.prototype.get$prefersPropertySyntax = function() {
|
| + return true;
|
| +}
|
| +Member.prototype.get$requiresFieldSyntax = function() {
|
| + return false;
|
| +}
|
| +Member.prototype.get$isNative = function() {
|
| + return false;
|
| +}
|
| +Member.prototype.get$constructorName = function() {
|
| + $globals.world.internalError('can not be a constructor', this.get$span());
|
| +}
|
| +Member.prototype.provideFieldSyntax = function() {
|
| +
|
| +}
|
| +Member.prototype.providePropertySyntax = function() {
|
| +
|
| +}
|
| +Member.prototype.get$initDelegate = function() {
|
| + $globals.world.internalError('cannot have initializers', this.get$span());
|
| +}
|
| +Member.prototype.set$initDelegate = function(ctor) {
|
| + $globals.world.internalError('cannot have initializers', this.get$span());
|
| +}
|
| +Member.prototype.computeValue = function() {
|
| + $globals.world.internalError('cannot have value', this.get$span());
|
| +}
|
| +Member.prototype.get$inferredResult = function() {
|
| + var t = this.get$returnType();
|
| + if (t.get$isBool() && (this.get$library().get$isCore() || this.get$library().get$isCoreImpl())) {
|
| + return $globals.world.nonNullBool;
|
| + }
|
| + return t;
|
| +}
|
| +Member.prototype.get$definition = function() {
|
| + return null;
|
| +}
|
| +Member.prototype.get$parameters = function() {
|
| + return [];
|
| +}
|
| +Member.prototype.canInvoke = function(context, args) {
|
| + return this.get$canGet() && new Value(this.get$returnType(), null, null, true).canInvoke(context, ':call', args);
|
| +}
|
| +Member.prototype.invoke = function(context, node, target, args, isDynamic) {
|
| + var newTarget = this._get(context, node, target, isDynamic);
|
| + return newTarget.invoke$5(context, ':call', node, args, isDynamic);
|
| +}
|
| +Member.prototype.override = function(other) {
|
| + if (this.get$isStatic()) {
|
| + $globals.world.error('static members can not hide parent members', this.get$span(), other.get$span());
|
| + return false;
|
| + }
|
| + else if (other.get$isStatic()) {
|
| + $globals.world.error('can not override static member', this.get$span(), other.get$span());
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +Member.prototype.get$generatedFactoryName = function() {
|
| + var prefix = ('' + this.declaringType.get$jsname() + '.' + this.get$constructorName() + '\$');
|
| + if (this.name == '') {
|
| + return ('' + prefix + 'factory');
|
| + }
|
| + else {
|
| + return ('' + prefix + this.name + '\$factory');
|
| + }
|
| +}
|
| +Member.prototype.hashCode = function() {
|
| + var typeCode = this.declaringType == null ? 1 : this.declaringType.hashCode();
|
| + var nameCode = this.get$isConstructor() ? this.get$constructorName().hashCode() : this.name.hashCode();
|
| + return (typeCode << 4) ^ nameCode;
|
| +}
|
| +Member.prototype.$eq = function(other) {
|
| + return (other instanceof Member) && $eq(this.get$isConstructor(), other.get$isConstructor()) && $eq(this.declaringType, other.get$declaringType()) && (this.get$isConstructor() ? this.get$constructorName() == other.get$constructorName() : this.name == other.name);
|
| +}
|
| +Member.prototype._get$3 = Member.prototype._get;
|
| +Member.prototype._get$3$isDynamic = Member.prototype._get;
|
| +Member.prototype._get$4 = Member.prototype._get;
|
| +Member.prototype._set$4 = Member.prototype._set;
|
| +Member.prototype._set$4$isDynamic = Member.prototype._set;
|
| +Member.prototype._set$5 = Member.prototype._set;
|
| +Member.prototype.canInvoke$2 = Member.prototype.canInvoke;
|
| +Member.prototype.computeValue$0 = Member.prototype.computeValue;
|
| +Member.prototype.hashCode$0 = Member.prototype.hashCode;
|
| +Member.prototype.invoke$4 = function($0, $1, $2, $3) {
|
| + return this.invoke($0, $1, $2, $3, false);
|
| +};
|
| +Member.prototype.invoke$4$isDynamic = Member.prototype.invoke;
|
| +Member.prototype.invoke$5 = Member.prototype.invoke;
|
| +Member.prototype.provideFieldSyntax$0 = Member.prototype.provideFieldSyntax;
|
| +Member.prototype.providePropertySyntax$0 = Member.prototype.providePropertySyntax;
|
| +// ********** Code for TypeMember **************
|
| +$inherits(TypeMember, Member);
|
| +function TypeMember(type) {
|
| + this.type = type;
|
| + // Initializers done
|
| + Member.call(this, type.name, type.library.topType);
|
| +}
|
| +TypeMember.prototype.get$span = function() {
|
| + return this.type.definition.span;
|
| +}
|
| +Object.defineProperty(TypeMember.prototype, "span", {
|
| + get: TypeMember.prototype.get$span
|
| +});
|
| +TypeMember.prototype.get$isStatic = function() {
|
| + return true;
|
| +}
|
| +TypeMember.prototype.get$returnType = function() {
|
| + return $globals.world.varType;
|
| +}
|
| +TypeMember.prototype.canInvoke = function(context, args) {
|
| + return false;
|
| +}
|
| +TypeMember.prototype.get$canGet = function() {
|
| + return true;
|
| +}
|
| +TypeMember.prototype.get$canSet = function() {
|
| + return false;
|
| +}
|
| +TypeMember.prototype.get$requiresFieldSyntax = function() {
|
| + return true;
|
| +}
|
| +TypeMember.prototype._get = function(context, node, target, isDynamic) {
|
| + return new Value.type$ctor(this.type, node.span);
|
| +}
|
| +TypeMember.prototype._set = function(context, node, target, value, isDynamic) {
|
| + $globals.world.error('cannot set type', node.span);
|
| +}
|
| +TypeMember.prototype.invoke = function(context, node, target, args, isDynamic) {
|
| + $globals.world.error('cannot invoke type', node.span);
|
| +}
|
| +TypeMember.prototype._get$3 = function($0, $1, $2) {
|
| + return this._get($0, $1, $2, false);
|
| +};
|
| +TypeMember.prototype._get$3$isDynamic = TypeMember.prototype._get;
|
| +TypeMember.prototype._get$4 = TypeMember.prototype._get;
|
| +TypeMember.prototype._set$4 = function($0, $1, $2, $3) {
|
| + return this._set($0, $1, $2, $3, false);
|
| +};
|
| +TypeMember.prototype._set$4$isDynamic = TypeMember.prototype._set;
|
| +TypeMember.prototype._set$5 = TypeMember.prototype._set;
|
| +TypeMember.prototype.canInvoke$2 = TypeMember.prototype.canInvoke;
|
| +TypeMember.prototype.invoke$4 = function($0, $1, $2, $3) {
|
| + return this.invoke($0, $1, $2, $3, false);
|
| +};
|
| +TypeMember.prototype.invoke$4$isDynamic = TypeMember.prototype.invoke;
|
| +TypeMember.prototype.invoke$5 = TypeMember.prototype.invoke;
|
| +// ********** Code for FieldMember **************
|
| +$inherits(FieldMember, Member);
|
| +function FieldMember(name, declaringType, definition, value) {
|
| + this._providePropertySyntax = false
|
| + this._computing = false
|
| + this.definition = definition;
|
| + this.value = value;
|
| + this.isNative = false;
|
| + // Initializers done
|
| + Member.call(this, name, declaringType);
|
| +}
|
| +FieldMember.prototype.get$definition = function() { return this.definition; };
|
| +FieldMember.prototype.get$isStatic = function() { return this.isStatic; };
|
| +FieldMember.prototype.set$isStatic = function(value) { return this.isStatic = value; };
|
| +FieldMember.prototype.get$isFinal = function() { return this.isFinal; };
|
| +FieldMember.prototype.set$isFinal = function(value) { return this.isFinal = value; };
|
| +FieldMember.prototype.get$isNative = function() { return this.isNative; };
|
| +FieldMember.prototype.set$isNative = function(value) { return this.isNative = value; };
|
| +FieldMember.prototype.override = function(other) {
|
| + if (!Member.prototype.override.call(this, other)) return false;
|
| + if (other.get$isProperty()) {
|
| + return true;
|
| + }
|
| + else {
|
| + $globals.world.error('field can not override anything but property', this.get$span(), other.get$span());
|
| + return false;
|
| + }
|
| +}
|
| +FieldMember.prototype.get$prefersPropertySyntax = function() {
|
| + return false;
|
| +}
|
| +FieldMember.prototype.get$requiresFieldSyntax = function() {
|
| + return this.isNative;
|
| +}
|
| +FieldMember.prototype.provideFieldSyntax = function() {
|
| +
|
| +}
|
| +FieldMember.prototype.providePropertySyntax = function() {
|
| + this._providePropertySyntax = true;
|
| +}
|
| +FieldMember.prototype.get$span = function() {
|
| + return this.definition == null ? null : this.definition.span;
|
| +}
|
| +Object.defineProperty(FieldMember.prototype, "span", {
|
| + get: FieldMember.prototype.get$span
|
| +});
|
| +FieldMember.prototype.get$returnType = function() {
|
| + return this.type;
|
| +}
|
| +FieldMember.prototype.get$canGet = function() {
|
| + return true;
|
| +}
|
| +FieldMember.prototype.get$canSet = function() {
|
| + return !this.isFinal;
|
| +}
|
| +FieldMember.prototype.get$isField = function() {
|
| + return true;
|
| +}
|
| +FieldMember.prototype.resolve = function() {
|
| + this.isStatic = this.declaringType.get$isTop();
|
| + this.isFinal = false;
|
| + if (this.definition.modifiers != null) {
|
| + var $$list = this.definition.modifiers;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var mod = $$list.$index($$i);
|
| + if ($eq(mod.kind, 86/*TokenKind.STATIC*/)) {
|
| + if (this.isStatic) {
|
| + $globals.world.error('duplicate static modifier', mod.span);
|
| + }
|
| + this.isStatic = true;
|
| + }
|
| + else if ($eq(mod.kind, 98/*TokenKind.FINAL*/)) {
|
| + if (this.isFinal) {
|
| + $globals.world.error('duplicate final modifier', mod.span);
|
| + }
|
| + this.isFinal = true;
|
| + }
|
| + else {
|
| + $globals.world.error(('' + mod + ' modifier not allowed on field'), mod.span);
|
| + }
|
| + }
|
| + }
|
| + this.type = this.resolveType(this.definition.type, false);
|
| + if (this.isStatic && this.type.get$hasTypeParams()) {
|
| + $globals.world.error('using type parameter in static context', this.definition.type.span);
|
| + }
|
| + if (this.isStatic && this.isFinal && this.value == null) {
|
| + $globals.world.error('static final field is missing initializer', this.get$span());
|
| + }
|
| + this.get$library()._addMember(this);
|
| +}
|
| +FieldMember.prototype.computeValue = function() {
|
| + if (this.value == null) return null;
|
| + if (this._computedValue == null) {
|
| + if (this._computing) {
|
| + $globals.world.error('circular reference', this.value.span);
|
| + return null;
|
| + }
|
| + this._computing = true;
|
| + var finalMethod = new MethodMember('final_context', this.declaringType, null);
|
| + finalMethod.set$isStatic(true);
|
| + var finalGen = new MethodGenerator(finalMethod, null);
|
| + this._computedValue = this.value.visit(finalGen);
|
| + if (!this._computedValue.get$isConst()) {
|
| + if (this.isStatic) {
|
| + $globals.world.error('non constant static field must be initialized in functions', this.value.span);
|
| + }
|
| + else {
|
| + $globals.world.error('non constant field must be initialized in constructor', this.value.span);
|
| + }
|
| + }
|
| + if (this.isStatic) {
|
| + this._computedValue = $globals.world.gen.globalForStaticField(this, this._computedValue, [this._computedValue]);
|
| + }
|
| + this._computing = false;
|
| + }
|
| + return this._computedValue;
|
| +}
|
| +FieldMember.prototype._get = function(context, node, target, isDynamic) {
|
| + if (this.isNative && this.get$returnType() != null) {
|
| + this.get$returnType().markUsed();
|
| + if ((this.get$returnType() instanceof DefinedType)) {
|
| + var factory_ = this.get$returnType().get$genericType().factory_;
|
| + if (factory_ != null && factory_.get$isNative()) {
|
| + factory_.markUsed$0();
|
| + }
|
| + }
|
| + }
|
| + if (this.isStatic) {
|
| + this.declaringType.markUsed();
|
| + var cv = this.computeValue();
|
| + if (this.isFinal) {
|
| + return cv;
|
| + }
|
| + $globals.world.gen.hasStatics = true;
|
| + if (this.declaringType.get$isTop()) {
|
| + if ($eq(this.declaringType.get$library(), $globals.world.get$dom())) {
|
| + return new Value(this.type, ('' + this.get$jsname()), node.span, true);
|
| + }
|
| + else {
|
| + return new Value(this.type, ('\$globals.' + this.get$jsname()), node.span, true);
|
| + }
|
| + }
|
| + else if (this.declaringType.get$isNative()) {
|
| + if (this.declaringType.get$isHiddenNativeType()) {
|
| + $globals.world.error('static field of hidden native type is inaccessible', node.span);
|
| + }
|
| + return new Value(this.type, ('' + this.declaringType.get$jsname() + '.' + this.get$jsname()), node.span, true);
|
| + }
|
| + else {
|
| + return new Value(this.type, ('\$globals.' + this.declaringType.get$jsname() + '_' + this.get$jsname()), node.span, true);
|
| + }
|
| + }
|
| + else if (target.get$isConst() && this.isFinal) {
|
| + var constTarget = (target instanceof GlobalValue) ? target.get$dynamic().get$exp() : target;
|
| + if ((constTarget instanceof ConstObjectValue)) {
|
| + return constTarget.get$fields().$index(this.name);
|
| + }
|
| + else if ($eq(constTarget.type, $globals.world.stringType) && this.name == 'length') {
|
| + return new Value(this.type, ('' + constTarget.get$actualValue().length), node.span, true);
|
| + }
|
| + }
|
| + return new Value(this.type, ('' + target.code + '.' + this.get$jsname()), node.span, true);
|
| +}
|
| +FieldMember.prototype._set = function(context, node, target, value, isDynamic) {
|
| + var lhs = this._get(context, node, target, isDynamic);
|
| + value = value.convertTo(context, this.type, node, isDynamic);
|
| + return new Value(this.type, ('' + lhs.code + ' = ' + value.code), node.span, true);
|
| +}
|
| +FieldMember.prototype._get$3 = function($0, $1, $2) {
|
| + return this._get($0, $1, $2, false);
|
| +};
|
| +FieldMember.prototype._get$3$isDynamic = FieldMember.prototype._get;
|
| +FieldMember.prototype._get$4 = FieldMember.prototype._get;
|
| +FieldMember.prototype._set$4 = function($0, $1, $2, $3) {
|
| + return this._set($0, $1, $2, $3, false);
|
| +};
|
| +FieldMember.prototype._set$4$isDynamic = FieldMember.prototype._set;
|
| +FieldMember.prototype._set$5 = FieldMember.prototype._set;
|
| +FieldMember.prototype.computeValue$0 = FieldMember.prototype.computeValue;
|
| +FieldMember.prototype.provideFieldSyntax$0 = FieldMember.prototype.provideFieldSyntax;
|
| +FieldMember.prototype.providePropertySyntax$0 = FieldMember.prototype.providePropertySyntax;
|
| +FieldMember.prototype.resolve$0 = FieldMember.prototype.resolve;
|
| +// ********** Code for PropertyMember **************
|
| +$inherits(PropertyMember, Member);
|
| +function PropertyMember(name, declaringType) {
|
| + this._provideFieldSyntax = false
|
| + // Initializers done
|
| + Member.call(this, name, declaringType);
|
| +}
|
| +PropertyMember.prototype.get$getter = function() { return this.getter; };
|
| +PropertyMember.prototype.set$getter = function(value) { return this.getter = value; };
|
| +PropertyMember.prototype.get$setter = function() { return this.setter; };
|
| +PropertyMember.prototype.set$setter = function(value) { return this.setter = value; };
|
| +PropertyMember.prototype.get$span = function() {
|
| + return this.getter != null ? this.getter.get$span() : null;
|
| +}
|
| +Object.defineProperty(PropertyMember.prototype, "span", {
|
| + get: PropertyMember.prototype.get$span
|
| +});
|
| +PropertyMember.prototype.get$canGet = function() {
|
| + return this.getter != null;
|
| +}
|
| +PropertyMember.prototype.get$canSet = function() {
|
| + return this.setter != null;
|
| +}
|
| +PropertyMember.prototype.get$prefersPropertySyntax = function() {
|
| + return true;
|
| +}
|
| +PropertyMember.prototype.get$requiresFieldSyntax = function() {
|
| + return false;
|
| +}
|
| +PropertyMember.prototype.provideFieldSyntax = function() {
|
| + this._provideFieldSyntax = true;
|
| +}
|
| +PropertyMember.prototype.providePropertySyntax = function() {
|
| +
|
| +}
|
| +PropertyMember.prototype.get$isStatic = function() {
|
| + return this.getter == null ? this.setter.isStatic : this.getter.isStatic;
|
| +}
|
| +PropertyMember.prototype.get$isProperty = function() {
|
| + return true;
|
| +}
|
| +PropertyMember.prototype.get$returnType = function() {
|
| + return this.getter == null ? this.setter.returnType : this.getter.returnType;
|
| +}
|
| +PropertyMember.prototype.override = function(other) {
|
| + if (!Member.prototype.override.call(this, other)) return false;
|
| + if (other.get$isProperty() || other.get$isField()) {
|
| + if (other.get$isProperty()) this.addFromParent(other);
|
| + else this._overriddenField = other;
|
| + return true;
|
| + }
|
| + else {
|
| + $globals.world.error('property can only override field or property', this.get$span(), other.get$span());
|
| + return false;
|
| + }
|
| +}
|
| +PropertyMember.prototype._get = function(context, node, target, isDynamic) {
|
| + if (this.getter == null) {
|
| + if (this._overriddenField != null) {
|
| + return this._overriddenField._get(context, node, target, isDynamic);
|
| + }
|
| + return target.invokeNoSuchMethod(context, ('get:' + this.name), node);
|
| + }
|
| + return this.getter.invoke(context, node, target, Arguments.get$EMPTY(), false);
|
| +}
|
| +PropertyMember.prototype._set = function(context, node, target, value, isDynamic) {
|
| + if (this.setter == null) {
|
| + if (this._overriddenField != null) {
|
| + return this._overriddenField._set(context, node, target, value, isDynamic);
|
| + }
|
| + return target.invokeNoSuchMethod(context, ('set:' + this.name), node, new Arguments(null, [value]));
|
| + }
|
| + return this.setter.invoke(context, node, target, new Arguments(null, [value]), isDynamic);
|
| +}
|
| +PropertyMember.prototype.addFromParent = function(parentMember) {
|
| + var parent;
|
| + if ((parentMember instanceof ConcreteMember)) {
|
| + var c = parentMember;
|
| + parent = c.baseMember;
|
| + }
|
| + else {
|
| + parent = parentMember;
|
| + }
|
| + if (this.getter == null) this.getter = parent.getter;
|
| + if (this.setter == null) this.setter = parent.setter;
|
| +}
|
| +PropertyMember.prototype.resolve = function() {
|
| + if (this.getter != null) {
|
| + this.getter.resolve();
|
| + if (this.getter.parameters.length != 0) {
|
| + $globals.world.error('getter methods should take no arguments', this.getter.definition.span);
|
| + }
|
| + if (this.getter.returnType.get$isVoid()) {
|
| + $globals.world.warning('getter methods should not be void', this.getter.definition.returnType.span);
|
| + }
|
| + }
|
| + if (this.setter != null) {
|
| + this.setter.resolve();
|
| + if (this.setter.parameters.length != 1) {
|
| + $globals.world.error('setter methods should take a single argument', this.setter.definition.span);
|
| + }
|
| + if (!this.setter.returnType.get$isVoid() && this.setter.definition.returnType != null) {
|
| + $globals.world.warning('setter methods should be void', this.setter.definition.returnType.span);
|
| + }
|
| + }
|
| + this.get$library()._addMember(this);
|
| +}
|
| +PropertyMember.prototype._get$3 = function($0, $1, $2) {
|
| + return this._get($0, $1, $2, false);
|
| +};
|
| +PropertyMember.prototype._get$3$isDynamic = PropertyMember.prototype._get;
|
| +PropertyMember.prototype._get$4 = PropertyMember.prototype._get;
|
| +PropertyMember.prototype._set$4 = function($0, $1, $2, $3) {
|
| + return this._set($0, $1, $2, $3, false);
|
| +};
|
| +PropertyMember.prototype._set$4$isDynamic = PropertyMember.prototype._set;
|
| +PropertyMember.prototype._set$5 = PropertyMember.prototype._set;
|
| +PropertyMember.prototype.provideFieldSyntax$0 = PropertyMember.prototype.provideFieldSyntax;
|
| +PropertyMember.prototype.providePropertySyntax$0 = PropertyMember.prototype.providePropertySyntax;
|
| +PropertyMember.prototype.resolve$0 = PropertyMember.prototype.resolve;
|
| +// ********** Code for ConcreteMember **************
|
| +$inherits(ConcreteMember, Member);
|
| +function ConcreteMember(name, declaringType, baseMember) {
|
| + this.baseMember = baseMember;
|
| + // Initializers done
|
| + Member.call(this, name, declaringType);
|
| + this.parameters = [];
|
| + this.returnType = this.baseMember.get$returnType().resolveTypeParams(declaringType);
|
| + var $$list = this.baseMember.get$parameters();
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var p = $$list.$index($$i);
|
| + var newType = p.type.resolveTypeParams$1(declaringType);
|
| + if ($ne(newType, p.type)) {
|
| + this.parameters.add(p.copyWithNewType$2(this, newType));
|
| + }
|
| + else {
|
| + this.parameters.add(p);
|
| + }
|
| + }
|
| +}
|
| +ConcreteMember.prototype.get$returnType = function() { return this.returnType; };
|
| +ConcreteMember.prototype.set$returnType = function(value) { return this.returnType = value; };
|
| +ConcreteMember.prototype.get$parameters = function() { return this.parameters; };
|
| +ConcreteMember.prototype.set$parameters = function(value) { return this.parameters = value; };
|
| +ConcreteMember.prototype.get$span = function() {
|
| + return this.baseMember.get$span();
|
| +}
|
| +Object.defineProperty(ConcreteMember.prototype, "span", {
|
| + get: ConcreteMember.prototype.get$span
|
| +});
|
| +ConcreteMember.prototype.get$isStatic = function() {
|
| + return this.baseMember.get$isStatic();
|
| +}
|
| +ConcreteMember.prototype.get$isAbstract = function() {
|
| + return this.baseMember.get$isAbstract();
|
| +}
|
| +ConcreteMember.prototype.get$isConst = function() {
|
| + return this.baseMember.get$isConst();
|
| +}
|
| +ConcreteMember.prototype.get$isFactory = function() {
|
| + return this.baseMember.get$isFactory();
|
| +}
|
| +ConcreteMember.prototype.get$isFinal = function() {
|
| + return this.baseMember.get$isFinal();
|
| +}
|
| +ConcreteMember.prototype.get$isNative = function() {
|
| + return this.baseMember.get$isNative();
|
| +}
|
| +ConcreteMember.prototype.get$jsname = function() {
|
| + return this.baseMember.get$jsname();
|
| +}
|
| +ConcreteMember.prototype.get$canGet = function() {
|
| + return this.baseMember.get$canGet();
|
| +}
|
| +ConcreteMember.prototype.get$canSet = function() {
|
| + return this.baseMember.get$canSet();
|
| +}
|
| +ConcreteMember.prototype.canInvoke = function(context, args) {
|
| + return this.baseMember.canInvoke(context, args);
|
| +}
|
| +ConcreteMember.prototype.get$isField = function() {
|
| + return this.baseMember.get$isField();
|
| +}
|
| +ConcreteMember.prototype.get$isMethod = function() {
|
| + return this.baseMember.get$isMethod();
|
| +}
|
| +ConcreteMember.prototype.get$isProperty = function() {
|
| + return this.baseMember.get$isProperty();
|
| +}
|
| +ConcreteMember.prototype.get$prefersPropertySyntax = function() {
|
| + return this.baseMember.get$prefersPropertySyntax();
|
| +}
|
| +ConcreteMember.prototype.get$requiresFieldSyntax = function() {
|
| + return this.baseMember.get$requiresFieldSyntax();
|
| +}
|
| +ConcreteMember.prototype.provideFieldSyntax = function() {
|
| + return this.baseMember.provideFieldSyntax();
|
| +}
|
| +ConcreteMember.prototype.providePropertySyntax = function() {
|
| + return this.baseMember.providePropertySyntax();
|
| +}
|
| +ConcreteMember.prototype.get$isConstructor = function() {
|
| + return this.name == this.declaringType.name;
|
| +}
|
| +ConcreteMember.prototype.get$constructorName = function() {
|
| + return this.baseMember.get$constructorName();
|
| +}
|
| +ConcreteMember.prototype.get$definition = function() {
|
| + return this.baseMember.get$definition();
|
| +}
|
| +ConcreteMember.prototype.get$initDelegate = function() {
|
| + return this.baseMember.get$initDelegate();
|
| +}
|
| +ConcreteMember.prototype.set$initDelegate = function(ctor) {
|
| + this.baseMember.set$initDelegate(ctor);
|
| +}
|
| +ConcreteMember.prototype.resolveType = function(node, isRequired) {
|
| + var type = this.baseMember.resolveType(node, isRequired);
|
| + return type.resolveTypeParams$1(this.declaringType);
|
| +}
|
| +ConcreteMember.prototype.computeValue = function() {
|
| + return this.baseMember.computeValue();
|
| +}
|
| +ConcreteMember.prototype.override = function(other) {
|
| + return this.baseMember.override(other);
|
| +}
|
| +ConcreteMember.prototype._get = function(context, node, target, isDynamic) {
|
| + var ret = this.baseMember._get(context, node, target, isDynamic);
|
| + return new Value(this.get$inferredResult(), ret.code, node.span, true);
|
| +}
|
| +ConcreteMember.prototype._set = function(context, node, target, value, isDynamic) {
|
| + var ret = this.baseMember._set(context, node, target, value, isDynamic);
|
| + return new Value(this.returnType, ret.code, node.span, true);
|
| +}
|
| +ConcreteMember.prototype.invoke = function(context, node, target, args, isDynamic) {
|
| + var ret = this.baseMember.invoke(context, node, target, args, isDynamic);
|
| + var code = ret.code;
|
| + if (this.get$isConstructor()) {
|
| + code = code.replaceFirst$2(this.declaringType.get$genericType().get$jsname(), this.declaringType.get$jsname());
|
| + }
|
| + if ((this.baseMember instanceof MethodMember)) {
|
| + this.declaringType.genMethod(this);
|
| + }
|
| + return new Value(this.get$inferredResult(), code, node.span, true);
|
| +}
|
| +ConcreteMember.prototype._get$3 = function($0, $1, $2) {
|
| + return this._get($0, $1, $2, false);
|
| +};
|
| +ConcreteMember.prototype._get$3$isDynamic = ConcreteMember.prototype._get;
|
| +ConcreteMember.prototype._get$4 = ConcreteMember.prototype._get;
|
| +ConcreteMember.prototype._set$4 = function($0, $1, $2, $3) {
|
| + return this._set($0, $1, $2, $3, false);
|
| +};
|
| +ConcreteMember.prototype._set$4$isDynamic = ConcreteMember.prototype._set;
|
| +ConcreteMember.prototype._set$5 = ConcreteMember.prototype._set;
|
| +ConcreteMember.prototype.canInvoke$2 = ConcreteMember.prototype.canInvoke;
|
| +ConcreteMember.prototype.computeValue$0 = ConcreteMember.prototype.computeValue;
|
| +ConcreteMember.prototype.invoke$4 = function($0, $1, $2, $3) {
|
| + return this.invoke($0, $1, $2, $3, false);
|
| +};
|
| +ConcreteMember.prototype.invoke$4$isDynamic = ConcreteMember.prototype.invoke;
|
| +ConcreteMember.prototype.invoke$5 = ConcreteMember.prototype.invoke;
|
| +ConcreteMember.prototype.provideFieldSyntax$0 = ConcreteMember.prototype.provideFieldSyntax;
|
| +ConcreteMember.prototype.providePropertySyntax$0 = ConcreteMember.prototype.providePropertySyntax;
|
| +// ********** Code for MethodMember **************
|
| +$inherits(MethodMember, Member);
|
| +function MethodMember(name, declaringType, definition) {
|
| + this.isStatic = false
|
| + this.isAbstract = false
|
| + this.isConst = false
|
| + this.isFactory = false
|
| + this.isLambda = false
|
| + this._providePropertySyntax = false
|
| + this._provideFieldSyntax = false
|
| + this._provideOptionalParamInfo = false
|
| + this.definition = definition;
|
| + // Initializers done
|
| + Member.call(this, name, declaringType);
|
| +}
|
| +MethodMember.prototype.get$definition = function() { return this.definition; };
|
| +MethodMember.prototype.set$definition = function(value) { return this.definition = value; };
|
| +MethodMember.prototype.get$returnType = function() { return this.returnType; };
|
| +MethodMember.prototype.set$returnType = function(value) { return this.returnType = value; };
|
| +MethodMember.prototype.get$parameters = function() { return this.parameters; };
|
| +MethodMember.prototype.set$parameters = function(value) { return this.parameters = value; };
|
| +MethodMember.prototype.get$typeParameters = function() { return this.typeParameters; };
|
| +MethodMember.prototype.set$typeParameters = function(value) { return this.typeParameters = value; };
|
| +MethodMember.prototype.get$isStatic = function() { return this.isStatic; };
|
| +MethodMember.prototype.set$isStatic = function(value) { return this.isStatic = value; };
|
| +MethodMember.prototype.get$isAbstract = function() { return this.isAbstract; };
|
| +MethodMember.prototype.set$isAbstract = function(value) { return this.isAbstract = value; };
|
| +MethodMember.prototype.get$isConst = function() { return this.isConst; };
|
| +MethodMember.prototype.set$isConst = function(value) { return this.isConst = value; };
|
| +MethodMember.prototype.get$isFactory = function() { return this.isFactory; };
|
| +MethodMember.prototype.set$isFactory = function(value) { return this.isFactory = value; };
|
| +MethodMember.prototype.get$isLambda = function() { return this.isLambda; };
|
| +MethodMember.prototype.set$isLambda = function(value) { return this.isLambda = value; };
|
| +MethodMember.prototype.get$initDelegate = function() { return this.initDelegate; };
|
| +MethodMember.prototype.set$initDelegate = function(value) { return this.initDelegate = value; };
|
| +MethodMember.prototype.get$isConstructor = function() {
|
| + return this.name == this.declaringType.name;
|
| +}
|
| +MethodMember.prototype.get$isMethod = function() {
|
| + return !this.get$isConstructor();
|
| +}
|
| +MethodMember.prototype.get$isNative = function() {
|
| + return this.definition.nativeBody != null;
|
| +}
|
| +MethodMember.prototype.get$canGet = function() {
|
| + return false;
|
| +}
|
| +MethodMember.prototype.get$canSet = function() {
|
| + return false;
|
| +}
|
| +MethodMember.prototype.get$span = function() {
|
| + return this.definition == null ? null : this.definition.span;
|
| +}
|
| +Object.defineProperty(MethodMember.prototype, "span", {
|
| + get: MethodMember.prototype.get$span
|
| +});
|
| +MethodMember.prototype.get$constructorName = function() {
|
| + var returnType = this.definition.returnType;
|
| + if (returnType == null) return '';
|
| + if ((returnType instanceof GenericTypeReference)) {
|
| + return '';
|
| + }
|
| + if (returnType.get$names() != null) {
|
| + return returnType.get$names().$index(0).name;
|
| + }
|
| + else if (returnType.name != null) {
|
| + return returnType.name.name;
|
| + }
|
| + $globals.world.internalError('no valid constructor name', this.definition.span);
|
| +}
|
| +MethodMember.prototype.get$functionType = function() {
|
| + if (this._functionType == null) {
|
| + this._functionType = this.get$library().getOrAddFunctionType(this.declaringType, this.name, this.definition);
|
| + if (this.parameters == null) {
|
| + this.resolve();
|
| + }
|
| + }
|
| + return this._functionType;
|
| +}
|
| +MethodMember.prototype.override = function(other) {
|
| + if (!Member.prototype.override.call(this, other)) return false;
|
| + if (other.get$isMethod()) {
|
| + return true;
|
| + }
|
| + else {
|
| + $globals.world.error('method can only override methods', this.get$span(), other.get$span());
|
| + return false;
|
| + }
|
| +}
|
| +MethodMember.prototype.canInvoke = function(context, args) {
|
| + var bareCount = args.get$bareCount();
|
| + if (bareCount > this.parameters.length) return false;
|
| + if (bareCount == this.parameters.length) {
|
| + if (bareCount != args.get$length()) return false;
|
| + }
|
| + else {
|
| + if (!this.parameters.$index(bareCount).get$isOptional()) return false;
|
| + for (var i = bareCount;
|
| + i < args.get$length(); i++) {
|
| + if (this.indexOfParameter(args.getName(i)) < 0) {
|
| + return false;
|
| + }
|
| + }
|
| + }
|
| + return true;
|
| +}
|
| +MethodMember.prototype.indexOfParameter = function(name) {
|
| + for (var i = 0;
|
| + i < this.parameters.length; i++) {
|
| + var p = this.parameters.$index(i);
|
| + if (p.get$isOptional() && $eq(p.name, name)) {
|
| + return i;
|
| + }
|
| + }
|
| + return -1;
|
| +}
|
| +MethodMember.prototype.get$prefersPropertySyntax = function() {
|
| + return true;
|
| +}
|
| +MethodMember.prototype.get$requiresFieldSyntax = function() {
|
| + return false;
|
| +}
|
| +MethodMember.prototype.provideFieldSyntax = function() {
|
| + this._provideFieldSyntax = true;
|
| +}
|
| +MethodMember.prototype.providePropertySyntax = function() {
|
| + this._providePropertySyntax = true;
|
| +}
|
| +MethodMember.prototype._set = function(context, node, target, value, isDynamic) {
|
| + $globals.world.error('cannot set method', node.span);
|
| +}
|
| +MethodMember.prototype._get = function(context, node, target, isDynamic) {
|
| + this.declaringType.genMethod(this);
|
| + this._provideOptionalParamInfo = true;
|
| + if (this.isStatic) {
|
| + this.declaringType.markUsed();
|
| + var type = this.declaringType.get$isTop() ? '' : ('' + this.declaringType.get$jsname() + '.');
|
| + return new Value(this.get$functionType(), ('' + type + this.get$jsname()), node.span, true);
|
| + }
|
| + this._providePropertySyntax = true;
|
| + return new Value(this.get$functionType(), ('' + target.code + '.get\$' + this.get$jsname() + '()'), node.span, true);
|
| +}
|
| +MethodMember.prototype.namesInOrder = function(args) {
|
| + if (!args.get$hasNames()) return true;
|
| + var lastParameter = null;
|
| + for (var i = args.get$bareCount();
|
| + i < this.parameters.length; i++) {
|
| + var p = args.getIndexOfName(this.parameters.$index(i).name);
|
| + if (p >= 0 && args.values.$index(p).get$needsTemp()) {
|
| + if (lastParameter != null && lastParameter > p) {
|
| + return false;
|
| + }
|
| + lastParameter = p;
|
| + }
|
| + }
|
| + return true;
|
| +}
|
| +MethodMember.prototype.needsArgumentConversion = function(args) {
|
| + var bareCount = args.get$bareCount();
|
| + for (var i = 0;
|
| + i < bareCount; i++) {
|
| + var arg = args.values.$index(i);
|
| + if (arg.needsConversion$1(this.parameters.$index(i).type)) {
|
| + return true;
|
| + }
|
| + }
|
| + if (bareCount < this.parameters.length) {
|
| + this.genParameterValues();
|
| + for (var i = bareCount;
|
| + i < this.parameters.length; i++) {
|
| + var arg = args.getValue(this.parameters.$index(i).name);
|
| + if (arg != null && arg.needsConversion$1(this.parameters.$index(i).type)) {
|
| + return true;
|
| + }
|
| + }
|
| + }
|
| + return false;
|
| +}
|
| +MethodMember._argCountMsg = function(actual, expected, atLeast) {
|
| + return 'wrong number of positional arguments, expected ' + ('' + (atLeast ? "at least " : "") + expected + ' but found ' + actual);
|
| +}
|
| +MethodMember.prototype._argError = function(context, node, target, args, msg, span) {
|
| + if (this.isStatic || this.get$isConstructor()) {
|
| + $globals.world.error(msg, span);
|
| + }
|
| + else {
|
| + $globals.world.warning(msg, span);
|
| + }
|
| + return target.invokeNoSuchMethod(context, this.name, node, args);
|
| +}
|
| +MethodMember.prototype.genParameterValues = function() {
|
| + var $$list = this.parameters;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var p = $$list.$index($$i);
|
| + p.genValue$2(this, this.generator);
|
| + }
|
| +}
|
| +MethodMember.prototype.invoke = function(context, node, target, args, isDynamic) {
|
| + if (this.parameters == null) {
|
| + $globals.world.info(('surprised to need to resolve: ' + this.declaringType.name + '.' + this.name));
|
| + this.resolve();
|
| + }
|
| + this.declaringType.genMethod(this);
|
| + if (this.isStatic || this.isFactory) {
|
| + this.declaringType.markUsed();
|
| + }
|
| + if (this.get$isNative() && this.returnType != null) this.returnType.markUsed();
|
| + if (!this.namesInOrder(args)) {
|
| + return context.findMembers(this.name).invokeOnVar(context, node, target, args);
|
| + }
|
| + var argsCode = [];
|
| + if (!target.isType && (this.get$isConstructor() || target.isSuper)) {
|
| + argsCode.add$1('this');
|
| + }
|
| + var bareCount = args.get$bareCount();
|
| + for (var i = 0;
|
| + i < bareCount; i++) {
|
| + var arg = args.values.$index(i);
|
| + if (i >= this.parameters.length) {
|
| + var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.length, false);
|
| + return this._argError(context, node, target, args, msg, args.nodes.$index(i).span);
|
| + }
|
| + arg = arg.convertTo$4(context, this.parameters.$index(i).type, node, isDynamic);
|
| + if (this.isConst && arg.get$isConst()) {
|
| + argsCode.add$1(arg.get$canonicalCode());
|
| + }
|
| + else {
|
| + argsCode.add$1(arg.code);
|
| + }
|
| + }
|
| + var namedArgsUsed = 0;
|
| + if (bareCount < this.parameters.length) {
|
| + this.genParameterValues();
|
| + for (var i = bareCount;
|
| + i < this.parameters.length; i++) {
|
| + var arg = args.getValue(this.parameters.$index(i).name);
|
| + if (arg == null) {
|
| + arg = this.parameters.$index(i).value;
|
| + }
|
| + else {
|
| + arg = arg.convertTo$4(context, this.parameters.$index(i).type, node, isDynamic);
|
| + namedArgsUsed++;
|
| + }
|
| + if (arg == null || !this.parameters.$index(i).get$isOptional()) {
|
| + var msg = MethodMember._argCountMsg(Math.min(i, args.get$length()), i + 1, true);
|
| + return this._argError(context, node, target, args, msg, args.nodes.$index(i).span);
|
| + }
|
| + else {
|
| + argsCode.add$1(this.isConst && arg.get$isConst() ? arg.get$canonicalCode() : arg.code);
|
| + }
|
| + }
|
| + Arguments.removeTrailingNulls(argsCode);
|
| + }
|
| + if (namedArgsUsed < args.get$nameCount()) {
|
| + var seen = new HashSetImplementation();
|
| + for (var i = bareCount;
|
| + i < args.get$length(); i++) {
|
| + var name = args.getName(i);
|
| + if (seen.contains$1(name)) {
|
| + return this._argError(context, node, target, args, ('duplicate argument "' + name + '"'), args.nodes.$index(i).span);
|
| + }
|
| + seen.add$1(name);
|
| + var p = this.indexOfParameter(name);
|
| + if (p < 0) {
|
| + return this._argError(context, node, target, args, ('method does not have optional parameter "' + name + '"'), args.nodes.$index(i).span);
|
| + }
|
| + else if (p < bareCount) {
|
| + return this._argError(context, node, target, args, ('argument "' + name + '" passed as positional and named'), args.nodes.$index(p).span);
|
| + }
|
| + }
|
| + $globals.world.internalError(('wrong named arguments calling ' + this.name), node.span);
|
| + }
|
| + var argsString = Strings.join(argsCode, ', ');
|
| + if (this.get$isConstructor()) {
|
| + return this._invokeConstructor(context, node, target, args, argsString);
|
| + }
|
| + if (target.isSuper) {
|
| + return new Value(this.get$inferredResult(), ('' + this.declaringType.get$jsname() + '.prototype.' + this.get$jsname() + '.call(' + argsString + ')'), node.span, true);
|
| + }
|
| + if (this.get$isOperator()) {
|
| + return this._invokeBuiltin(context, node, target, args, argsCode, isDynamic);
|
| + }
|
| + if (this.isFactory) {
|
| + return new Value(target.get$type(), ('' + this.get$generatedFactoryName() + '(' + argsString + ')'), node.span, true);
|
| + }
|
| + if (this.isStatic) {
|
| + if (this.declaringType.get$isTop()) {
|
| + return new Value(this.get$inferredResult(), ('' + this.get$jsname() + '(' + argsString + ')'), node != null ? node.span : node, true);
|
| + }
|
| + return new Value(this.get$inferredResult(), ('' + this.declaringType.get$jsname() + '.' + this.get$jsname() + '(' + argsString + ')'), node.span, true);
|
| + }
|
| + var code = ('' + target.code + '.' + this.get$jsname() + '(' + argsString + ')');
|
| + if (target.get$isConst()) {
|
| + if ((target instanceof GlobalValue)) {
|
| + target = target.get$dynamic().get$exp();
|
| + }
|
| + if (this.name == 'get:length') {
|
| + if ((target instanceof ConstListValue) || (target instanceof ConstMapValue)) {
|
| + code = ('' + target.get$dynamic().values.length);
|
| + }
|
| + }
|
| + else if (this.name == 'isEmpty') {
|
| + if ((target instanceof ConstListValue) || (target instanceof ConstMapValue)) {
|
| + code = ('' + target.get$dynamic().values.isEmpty$0());
|
| + }
|
| + }
|
| + }
|
| + if (this.name == 'get:typeName' && $eq(this.declaringType.get$library(), $globals.world.get$dom())) {
|
| + $globals.world.gen.corejs.ensureTypeNameOf();
|
| + }
|
| + return new Value(this.get$inferredResult(), code, node.span, true);
|
| +}
|
| +MethodMember.prototype._invokeConstructor = function(context, node, target, args, argsString) {
|
| + this.declaringType.markUsed();
|
| + if (!target.isType) {
|
| + var code = (this.get$constructorName() != '') ? ('' + this.declaringType.get$jsname() + '.' + this.get$constructorName() + '\$ctor.call(' + argsString + ')') : ('' + this.declaringType.get$jsname() + '.call(' + argsString + ')');
|
| + return new Value(target.get$type(), code, node.span, true);
|
| + }
|
| + else {
|
| + var code = (this.get$constructorName() != '') ? ('new ' + this.declaringType.get$jsname() + '.' + this.get$constructorName() + '\$ctor(' + argsString + ')') : ('new ' + this.declaringType.get$jsname() + '(' + argsString + ')');
|
| + if (this.isConst && (node instanceof NewExpression) && node.get$dynamic().get$isConst()) {
|
| + return this._invokeConstConstructor(node, code, target, args);
|
| + }
|
| + else {
|
| + return new Value(target.get$type(), code, node.span, true);
|
| + }
|
| + }
|
| +}
|
| +MethodMember.prototype._invokeConstConstructor = function(node, code, target, args) {
|
| + var fields = new HashMapImplementation();
|
| + for (var i = 0;
|
| + i < this.parameters.length; i++) {
|
| + var param = this.parameters.$index(i);
|
| + if (param.get$isInitializer()) {
|
| + var value = null;
|
| + if (i < args.get$length()) {
|
| + value = args.values.$index(i);
|
| + }
|
| + else {
|
| + value = args.getValue(param.name);
|
| + if (value == null) {
|
| + value = param.value;
|
| + }
|
| + }
|
| + fields.$setindex(param.name, value);
|
| + }
|
| + }
|
| + if (this.definition.initializers != null) {
|
| + this.generator._pushBlock(false);
|
| + for (var j = 0;
|
| + j < this.definition.formals.length; j++) {
|
| + var name = this.definition.formals.$index(j).name.name;
|
| + var value = null;
|
| + if (j < args.get$length()) {
|
| + value = args.values.$index(j);
|
| + }
|
| + else {
|
| + value = args.getValue(this.parameters.$index(j).name);
|
| + if (value == null) {
|
| + value = this.parameters.$index(j).value;
|
| + }
|
| + }
|
| + this.generator._scope._vars.$setindex(name, value);
|
| + }
|
| + var $$list = this.definition.initializers;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var init = $$list.$index($$i);
|
| + if ((init instanceof CallExpression)) {
|
| + var delegateArgs = this.generator._makeArgs(init.get$arguments());
|
| + var value = this.initDelegate.invoke(this.generator, node, target, delegateArgs, false);
|
| + if ((init.target instanceof ThisExpression)) {
|
| + return value;
|
| + }
|
| + else {
|
| + if ((value instanceof GlobalValue)) {
|
| + value = value.get$exp();
|
| + }
|
| + var $list0 = value.get$fields().getKeys$0();
|
| + for (var $i0 = value.get$fields().getKeys$0().iterator$0(); $i0.hasNext$0(); ) {
|
| + var fname = $i0.next$0();
|
| + fields.$setindex(fname, value.get$fields().$index(fname));
|
| + }
|
| + }
|
| + }
|
| + else {
|
| + var assign = init;
|
| + var x = assign.x;
|
| + var fname = x.name.name;
|
| + var val = this.generator.visitValue(assign.y);
|
| + if (!val.get$isConst()) {
|
| + $globals.world.error('invalid non-const initializer in const constructor', assign.y.span);
|
| + }
|
| + fields.$setindex(fname, val);
|
| + }
|
| + }
|
| + this.generator._popBlock();
|
| + }
|
| + var $$list = this.declaringType.get$members().getValues();
|
| + for (var $$i = this.declaringType.get$members().getValues().iterator$0(); $$i.hasNext$0(); ) {
|
| + var f = $$i.next$0();
|
| + if ((f instanceof FieldMember) && !f.get$isStatic() && !fields.containsKey(f.name)) {
|
| + if (!f.get$isFinal()) {
|
| + $globals.world.error(('const class "' + this.declaringType.name + '" has non-final ') + ('field "' + f.name + '"'), f.span);
|
| + }
|
| + if (f.value != null) {
|
| + fields.$setindex(f.name, f.computeValue$0());
|
| + }
|
| + }
|
| + }
|
| + return $globals.world.gen.globalForConst(ConstObjectValue.ConstObjectValue$factory(target.get$type(), fields, code, node.span), args.values);
|
| +}
|
| +MethodMember.prototype._invokeBuiltin = function(context, node, target, args, argsCode, isDynamic) {
|
| + var allConst = target.get$isConst() && args.values.every((function (arg) {
|
| + return arg.get$isConst();
|
| + })
|
| + );
|
| + if (this.declaringType.get$isNum()) {
|
| + if (!allConst) {
|
| + var code;
|
| + if (this.name == ':negate') {
|
| + code = ('-' + target.code);
|
| + }
|
| + else if (this.name == ':bit_not') {
|
| + code = ('~' + target.code);
|
| + }
|
| + else if (this.name == ':truncdiv' || this.name == ':mod') {
|
| + $globals.world.gen.corejs.useOperator(this.name);
|
| + code = ('' + this.get$jsname() + '(' + target.code + ', ' + argsCode.$index(0) + ')');
|
| + }
|
| + else {
|
| + var op = TokenKind.rawOperatorFromMethod(this.name);
|
| + code = ('' + target.code + ' ' + op + ' ' + argsCode.$index(0));
|
| + }
|
| + return new Value(this.get$inferredResult(), code, node.span, true);
|
| + }
|
| + else {
|
| + var value;
|
| + var val0, val1, ival0, ival1;
|
| + val0 = target.get$dynamic().get$actualValue();
|
| + ival0 = val0.toInt();
|
| + if (args.values.length > 0) {
|
| + val1 = args.values.$index(0).get$dynamic().get$actualValue();
|
| + ival1 = val1.toInt();
|
| + }
|
| + switch (this.name) {
|
| + case ':negate':
|
| +
|
| + value = -val0;
|
| + break;
|
| +
|
| + case ':add':
|
| +
|
| + value = val0 + val1;
|
| + break;
|
| +
|
| + case ':sub':
|
| +
|
| + value = val0 - val1;
|
| + break;
|
| +
|
| + case ':mul':
|
| +
|
| + value = val0 * val1;
|
| + break;
|
| +
|
| + case ':div':
|
| +
|
| + value = val0 / val1;
|
| + break;
|
| +
|
| + case ':truncdiv':
|
| +
|
| + value = $truncdiv(val0, val1);
|
| + break;
|
| +
|
| + case ':mod':
|
| +
|
| + value = $mod(val0, val1);
|
| + break;
|
| +
|
| + case ':eq':
|
| +
|
| + value = val0 == val1;
|
| + break;
|
| +
|
| + case ':lt':
|
| +
|
| + value = val0 < val1;
|
| + break;
|
| +
|
| + case ':gt':
|
| +
|
| + value = val0 > val1;
|
| + break;
|
| +
|
| + case ':lte':
|
| +
|
| + value = val0 <= val1;
|
| + break;
|
| +
|
| + case ':gte':
|
| +
|
| + value = val0 >= val1;
|
| + break;
|
| +
|
| + case ':ne':
|
| +
|
| + value = val0 != val1;
|
| + break;
|
| +
|
| + case ':bit_not':
|
| +
|
| + value = (~ival0).toDouble();
|
| + break;
|
| +
|
| + case ':bit_or':
|
| +
|
| + value = (ival0 | ival1).toDouble();
|
| + break;
|
| +
|
| + case ':bit_xor':
|
| +
|
| + value = (ival0 ^ ival1).toDouble();
|
| + break;
|
| +
|
| + case ':bit_and':
|
| +
|
| + value = (ival0 & ival1).toDouble();
|
| + break;
|
| +
|
| + case ':shl':
|
| +
|
| + value = (ival0 << ival1).toDouble();
|
| + break;
|
| +
|
| + case ':sar':
|
| +
|
| + value = (ival0 >> ival1).toDouble();
|
| + break;
|
| +
|
| + case ':shr':
|
| +
|
| + value = (ival0 >>> ival1).toDouble();
|
| + break;
|
| +
|
| + }
|
| + return EvaluatedValue.EvaluatedValue$factory(this.get$inferredResult(), value, ("" + value), node.span);
|
| + }
|
| + }
|
| + else if (this.declaringType.get$isString()) {
|
| + if (this.name == ':index') {
|
| + return new Value(this.declaringType, ('' + target.code + '[' + argsCode.$index(0) + ']'), node.span, true);
|
| + }
|
| + else if (this.name == ':add') {
|
| + if (allConst) {
|
| + var value = this._normConcat(target, args.values.$index(0));
|
| + return EvaluatedValue.EvaluatedValue$factory($globals.world.stringType, value, value, node.span);
|
| + }
|
| + return new Value(this.declaringType, ('' + target.code + ' + ' + argsCode.$index(0)), node.span, true);
|
| + }
|
| + }
|
| + else if (this.declaringType.get$isNative()) {
|
| + if (this.name == ':index') {
|
| + return new Value(this.returnType, ('' + target.code + '[' + argsCode.$index(0) + ']'), node.span, true);
|
| + }
|
| + else if (this.name == ':setindex') {
|
| + return new Value(this.returnType, ('' + target.code + '[' + argsCode.$index(0) + '] = ' + argsCode.$index(1)), node.span, true);
|
| + }
|
| + }
|
| + if (this.name == ':eq' || this.name == ':ne') {
|
| + var op = this.name == ':eq' ? '==' : '!=';
|
| + if (this.name == ':ne') {
|
| + target.invoke(context, ':eq', node, args, isDynamic);
|
| + }
|
| + if (allConst) {
|
| + var val0 = target.get$dynamic().get$actualValue();
|
| + var val1 = args.values.$index(0).get$dynamic().get$actualValue();
|
| + var newVal = this.name == ':eq' ? $eq(val0, val1) : $ne(val0, val1);
|
| + return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, newVal, ("" + newVal), node.span);
|
| + }
|
| + if ($eq(argsCode.$index(0), 'null')) {
|
| + return new Value(this.get$inferredResult(), ('' + target.code + ' ' + op + ' null'), node.span, true);
|
| + }
|
| + else if (target.get$type().get$isNum() || target.get$type().get$isString()) {
|
| + return new Value(this.get$inferredResult(), ('' + target.code + ' ' + op + ' ' + argsCode.$index(0)), node.span, true);
|
| + }
|
| + $globals.world.gen.corejs.useOperator(this.name);
|
| + return new Value(this.get$inferredResult(), ('' + this.get$jsname() + '(' + target.code + ', ' + argsCode.$index(0) + ')'), node.span, true);
|
| + }
|
| + if (this.get$isCallMethod()) {
|
| + this.declaringType.markUsed();
|
| + return new Value(this.get$inferredResult(), ('' + target.code + '(' + Strings.join(argsCode, ", ") + ')'), node.span, true);
|
| + }
|
| + if (this.name == ':index') {
|
| + $globals.world.gen.corejs.useIndex = true;
|
| + }
|
| + else if (this.name == ':setindex') {
|
| + $globals.world.gen.corejs.useSetIndex = true;
|
| + }
|
| + var argsString = Strings.join(argsCode, ', ');
|
| + return new Value(this.get$inferredResult(), ('' + target.code + '.' + this.get$jsname() + '(' + argsString + ')'), node.span, true);
|
| +}
|
| +MethodMember.prototype._normConcat = function(a, b) {
|
| + var val0 = a.get$dynamic().get$actualValue();
|
| + var quote0 = val0.$index(0);
|
| + val0 = val0.substring$2(1, val0.length - 1);
|
| + var val1 = b.get$dynamic().get$actualValue();
|
| + var quote1 = null;
|
| + if (b.get$type().get$isString()) {
|
| + quote1 = val1.$index(0);
|
| + val1 = val1.substring$2(1, val1.length - 1);
|
| + }
|
| + var value;
|
| + if ($eq(quote0, quote1) || quote1 == null) {
|
| + value = ('' + quote0 + val0 + val1 + quote0);
|
| + }
|
| + else if ($eq(quote0, '"')) {
|
| + value = ('' + quote0 + val0 + toDoubleQuote(val1) + quote0);
|
| + }
|
| + else {
|
| + value = ('' + quote1 + toDoubleQuote(val0) + val1 + quote1);
|
| + }
|
| + return value;
|
| +}
|
| +MethodMember.prototype.resolve = function() {
|
| + this.isStatic = this.declaringType.get$isTop();
|
| + this.isConst = false;
|
| + this.isFactory = false;
|
| + this.isAbstract = !this.declaringType.get$isClass();
|
| + if (this.definition.modifiers != null) {
|
| + var $$list = this.definition.modifiers;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var mod = $$list.$index($$i);
|
| + if ($eq(mod.kind, 86/*TokenKind.STATIC*/)) {
|
| + if (this.isStatic) {
|
| + $globals.world.error('duplicate static modifier', mod.span);
|
| + }
|
| + this.isStatic = true;
|
| + }
|
| + else if (this.get$isConstructor() && $eq(mod.kind, 92/*TokenKind.CONST*/)) {
|
| + if (this.isConst) {
|
| + $globals.world.error('duplicate const modifier', mod.span);
|
| + }
|
| + this.isConst = true;
|
| + }
|
| + else if ($eq(mod.kind, 75/*TokenKind.FACTORY*/)) {
|
| + if (this.isFactory) {
|
| + $globals.world.error('duplicate factory modifier', mod.span);
|
| + }
|
| + this.isFactory = true;
|
| + }
|
| + else if ($eq(mod.kind, 71/*TokenKind.ABSTRACT*/)) {
|
| + if (this.isAbstract) {
|
| + if (this.declaringType.get$isClass()) {
|
| + $globals.world.error('duplicate abstract modifier', mod.span);
|
| + }
|
| + else {
|
| + $globals.world.error('abstract modifier not allowed on interface members', mod.span);
|
| + }
|
| + }
|
| + this.isAbstract = true;
|
| + }
|
| + else {
|
| + $globals.world.error(('' + mod + ' modifier not allowed on method'), mod.span);
|
| + }
|
| + }
|
| + }
|
| + if (this.isFactory) {
|
| + this.isStatic = true;
|
| + }
|
| + if (this.definition.typeParameters != null) {
|
| + if (!this.isFactory) {
|
| + $globals.world.error('Only factories are allowed to have explicit type parameters', this.definition.typeParameters.$index(0).span);
|
| + }
|
| + else {
|
| + this.typeParameters = this.definition.typeParameters;
|
| + var $$list = this.definition.typeParameters;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var tp = $$list.$index($$i);
|
| + tp.set$enclosingElement(this);
|
| + tp.resolve$0();
|
| + }
|
| + }
|
| + }
|
| + if (this.get$isOperator() && this.isStatic && !this.get$isCallMethod()) {
|
| + $globals.world.error(('operator method may not be static "' + this.name + '"'), this.get$span());
|
| + }
|
| + if (this.isAbstract) {
|
| + if (this.definition.body != null && !(this.declaringType.get$definition() instanceof FunctionTypeDefinition)) {
|
| + $globals.world.error('abstract method can not have a body', this.get$span());
|
| + }
|
| + if (this.isStatic && !(this.declaringType.get$definition() instanceof FunctionTypeDefinition)) {
|
| + $globals.world.error('static method can not be abstract', this.get$span());
|
| + }
|
| + }
|
| + else {
|
| + if (this.definition.body == null && !this.get$isConstructor() && !this.get$isNative()) {
|
| + $globals.world.error('method needs a body', this.get$span());
|
| + }
|
| + }
|
| + if (this.get$isConstructor() && !this.isFactory) {
|
| + this.returnType = this.declaringType;
|
| + }
|
| + else {
|
| + this.returnType = this.resolveType(this.definition.returnType, false);
|
| + }
|
| + this.parameters = [];
|
| + var $$list = this.definition.formals;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var formal = $$list.$index($$i);
|
| + var param = new Parameter(formal, this);
|
| + param.resolve$0();
|
| + this.parameters.add(param);
|
| + }
|
| + if (!this.isLambda) {
|
| + this.get$library()._addMember(this);
|
| + }
|
| +}
|
| +MethodMember.prototype.resolveType = function(node, typeErrors) {
|
| + var t = lang_Element.prototype.resolveType.call(this, node, typeErrors);
|
| + if (this.isStatic && (t instanceof ParameterType) && (this.typeParameters == null || !this.typeParameters.some((function (p) {
|
| + return p === t;
|
| + })
|
| + ))) {
|
| + $globals.world.error('using type parameter in static context.', node.span);
|
| + }
|
| + return t;
|
| +}
|
| +MethodMember.prototype._get$3 = function($0, $1, $2) {
|
| + return this._get($0, $1, $2, false);
|
| +};
|
| +MethodMember.prototype._get$3$isDynamic = MethodMember.prototype._get;
|
| +MethodMember.prototype._get$4 = MethodMember.prototype._get;
|
| +MethodMember.prototype._set$4 = function($0, $1, $2, $3) {
|
| + return this._set($0, $1, $2, $3, false);
|
| +};
|
| +MethodMember.prototype._set$4$isDynamic = MethodMember.prototype._set;
|
| +MethodMember.prototype._set$5 = MethodMember.prototype._set;
|
| +MethodMember.prototype.canInvoke$2 = MethodMember.prototype.canInvoke;
|
| +MethodMember.prototype.invoke$4 = function($0, $1, $2, $3) {
|
| + return this.invoke($0, $1, $2, $3, false);
|
| +};
|
| +MethodMember.prototype.invoke$4$isDynamic = MethodMember.prototype.invoke;
|
| +MethodMember.prototype.invoke$5 = MethodMember.prototype.invoke;
|
| +MethodMember.prototype.namesInOrder$1 = MethodMember.prototype.namesInOrder;
|
| +MethodMember.prototype.provideFieldSyntax$0 = MethodMember.prototype.provideFieldSyntax;
|
| +MethodMember.prototype.providePropertySyntax$0 = MethodMember.prototype.providePropertySyntax;
|
| +MethodMember.prototype.resolve$0 = MethodMember.prototype.resolve;
|
| +// ********** Code for MemberSet **************
|
| +function MemberSet(member, isVar) {
|
| + this.name = member.name;
|
| + this.members = [member];
|
| + this.jsname = member.get$jsname();
|
| + this.isVar = isVar;
|
| + // Initializers done
|
| +}
|
| +MemberSet.prototype.get$members = function() { return this.members; };
|
| +MemberSet.prototype.get$jsname = function() { return this.jsname; };
|
| +MemberSet.prototype.get$isVar = function() { return this.isVar; };
|
| +MemberSet.prototype.toString = function() {
|
| + return ('' + this.name + ':' + this.members.length);
|
| +}
|
| +MemberSet.prototype.get$containsMethods = function() {
|
| + return this.members.some((function (m) {
|
| + return (m instanceof MethodMember);
|
| + })
|
| + );
|
| +}
|
| +MemberSet.prototype.add = function(member) {
|
| + return this.members.add(member);
|
| +}
|
| +MemberSet.prototype.get$isStatic = function() {
|
| + return this.members.length == 1 && this.members.$index(0).get$isStatic();
|
| +}
|
| +MemberSet.prototype.get$isOperator = function() {
|
| + return this.members.$index(0).get$isOperator();
|
| +}
|
| +MemberSet.prototype.canInvoke = function(context, args) {
|
| + return this.members.some((function (m) {
|
| + return m.canInvoke$2(context, args);
|
| + })
|
| + );
|
| +}
|
| +MemberSet.prototype._makeError = function(node, target, action) {
|
| + if (!target.get$type().get$isVar()) {
|
| + $globals.world.warning(('could not find applicable ' + action + ' for "' + this.name + '"'), node.span);
|
| + }
|
| + return new Value($globals.world.varType, ('' + target.code + '.' + this.jsname + '() /*no applicable ' + action + '*/'), node.span, true);
|
| +}
|
| +MemberSet.prototype.get$treatAsField = function() {
|
| + if (this._treatAsField == null) {
|
| + this._treatAsField = !this.isVar;
|
| + var $$list = this.members;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var member = $$list.$index($$i);
|
| + if (member.get$requiresFieldSyntax()) {
|
| + this._treatAsField = true;
|
| + break;
|
| + }
|
| + if (member.get$prefersPropertySyntax()) {
|
| + this._treatAsField = false;
|
| + }
|
| + }
|
| + var $$list = this.members;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var member = $$list.$index($$i);
|
| + if (this._treatAsField) {
|
| + member.provideFieldSyntax$0();
|
| + }
|
| + else {
|
| + member.providePropertySyntax$0();
|
| + }
|
| + }
|
| + }
|
| + return this._treatAsField;
|
| +}
|
| +MemberSet.prototype._get = function(context, node, target, isDynamic) {
|
| + var returnValue;
|
| + var targets = this.members.filter((function (m) {
|
| + return m.get$canGet();
|
| + })
|
| + );
|
| + if (this.isVar) {
|
| + targets.forEach$1((function (m) {
|
| + return m._get$3$isDynamic(context, node, target, true);
|
| + })
|
| + );
|
| + returnValue = new Value(this._foldTypes(targets), null, node.span, true);
|
| + }
|
| + else {
|
| + if (this.members.length == 1) {
|
| + return this.members.$index(0)._get$4(context, node, target, isDynamic);
|
| + }
|
| + else if ($eq(targets.length, 1)) {
|
| + return targets.$index(0)._get$4(context, node, target, isDynamic);
|
| + }
|
| + for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
|
| + var member = $$i.next$0();
|
| + var value = member._get$3$isDynamic(context, node, target, true);
|
| + returnValue = this._tryUnion(returnValue, value, node);
|
| + }
|
| + if (returnValue == null) {
|
| + return this._makeError(node, target, 'getter');
|
| + }
|
| + }
|
| + if (returnValue.code == null) {
|
| + if (this.get$treatAsField()) {
|
| + return new Value(returnValue.get$type(), ('' + target.code + '.' + this.jsname), node.span, true);
|
| + }
|
| + else {
|
| + return new Value(returnValue.get$type(), ('' + target.code + '.get\$' + this.jsname + '()'), node.span, true);
|
| + }
|
| + }
|
| + return returnValue;
|
| +}
|
| +MemberSet.prototype._set = function(context, node, target, value, isDynamic) {
|
| + var returnValue;
|
| + var targets = this.members.filter((function (m) {
|
| + return m.get$canSet();
|
| + })
|
| + );
|
| + if (this.isVar) {
|
| + targets.forEach$1((function (m) {
|
| + return m._set$4$isDynamic(context, node, target, value, true);
|
| + })
|
| + );
|
| + returnValue = new Value(this._foldTypes(targets), null, node.span, true);
|
| + }
|
| + else {
|
| + if (this.members.length == 1) {
|
| + return this.members.$index(0)._set$5(context, node, target, value, isDynamic);
|
| + }
|
| + else if ($eq(targets.length, 1)) {
|
| + return targets.$index(0)._set$5(context, node, target, value, isDynamic);
|
| + }
|
| + for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
|
| + var member = $$i.next$0();
|
| + var res = member._set$4$isDynamic(context, node, target, value, true);
|
| + returnValue = this._tryUnion(returnValue, res, node);
|
| + }
|
| + if (returnValue == null) {
|
| + return this._makeError(node, target, 'setter');
|
| + }
|
| + }
|
| + if (returnValue.code == null) {
|
| + if (this.get$treatAsField()) {
|
| + return new Value(returnValue.get$type(), ('' + target.code + '.' + this.jsname + ' = ' + value.code), node.span, true);
|
| + }
|
| + else {
|
| + return new Value(returnValue.get$type(), ('' + target.code + '.set\$' + this.jsname + '(' + value.code + ')'), node.span, true);
|
| + }
|
| + }
|
| + return returnValue;
|
| +}
|
| +MemberSet.prototype.invoke = function(context, node, target, args, isDynamic) {
|
| + if (this.isVar && !this.get$isOperator()) {
|
| + return this.invokeOnVar(context, node, target, args);
|
| + }
|
| + if (this.members.length == 1) {
|
| + return this.members.$index(0).invoke$5(context, node, target, args, isDynamic);
|
| + }
|
| + var targets = this.members.filter((function (m) {
|
| + return m.canInvoke$2(context, args);
|
| + })
|
| + );
|
| + if ($eq(targets.length, 1)) {
|
| + return targets.$index(0).invoke$5(context, node, target, args, isDynamic);
|
| + }
|
| + var returnValue = null;
|
| + for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
|
| + var member = $$i.next$0();
|
| + var res = member.invoke$4$isDynamic(context, node, target, args, true);
|
| + returnValue = this._tryUnion(returnValue, res, node);
|
| + }
|
| + if (returnValue == null) {
|
| + return this._makeError(node, target, 'method');
|
| + }
|
| + if (returnValue.code == null) {
|
| + if (this.name == ':call') {
|
| + return target._varCall(context, args);
|
| + }
|
| + else if (this.get$isOperator()) {
|
| + return this.invokeSpecial(target, args, returnValue.get$type());
|
| + }
|
| + else {
|
| + return this.invokeOnVar(context, node, target, args);
|
| + }
|
| + }
|
| + return returnValue;
|
| +}
|
| +MemberSet.prototype.invokeSpecial = function(target, args, returnType) {
|
| + var argsString = args.getCode();
|
| + if (this.name == ':index' || this.name == ':setindex') {
|
| + return new Value(returnType, ('' + target.code + '.' + this.jsname + '(' + argsString + ')'), target.span, true);
|
| + }
|
| + else {
|
| + if (argsString.length > 0) argsString = (', ' + argsString);
|
| + $globals.world.gen.corejs.useOperator(this.name);
|
| + return new Value(returnType, ('' + this.jsname + '(' + target.code + argsString + ')'), target.span, true);
|
| + }
|
| +}
|
| +MemberSet.prototype.invokeOnVar = function(context, node, target, args) {
|
| + var member = this.getVarMember(context, node, args);
|
| + return member.invoke$4(context, node, target, args);
|
| +}
|
| +MemberSet.prototype._tryUnion = function(x, y, node) {
|
| + if (x == null) return y;
|
| + var type = Type.union(x.get$type(), y.get$type());
|
| + if (x.code == y.code) {
|
| + if ($eq(type, x.get$type())) {
|
| + return x;
|
| + }
|
| + else if (x.get$isConst() || y.get$isConst()) {
|
| + $globals.world.internalError("unexpected: union of const values ");
|
| + }
|
| + else {
|
| + var ret = new Value(type, x.code, node.span, true);
|
| + ret.set$isSuper(x.isSuper && y.isSuper);
|
| + ret.set$needsTemp(x.needsTemp || y.needsTemp);
|
| + ret.set$isType(x.isType && y.isType);
|
| + return ret;
|
| + }
|
| + }
|
| + else {
|
| + return new Value(type, null, node.span, true);
|
| + }
|
| +}
|
| +MemberSet.prototype.getVarMember = function(context, node, args) {
|
| + if ($globals.world.objectType.varStubs == null) {
|
| + $globals.world.objectType.varStubs = new HashMapImplementation();
|
| + }
|
| + var stubName = _getCallStubName(this.name, args);
|
| + var stub = $globals.world.objectType.varStubs.$index(stubName);
|
| + if (stub == null) {
|
| + var mset = context.findMembers(this.name).members;
|
| + var targets = mset.filter((function (m) {
|
| + return m.canInvoke$2(context, args);
|
| + })
|
| + );
|
| + stub = new VarMethodSet(this.name, stubName, targets, args, this._foldTypes(targets));
|
| + $globals.world.objectType.varStubs.$setindex(stubName, stub);
|
| + }
|
| + return stub;
|
| +}
|
| +MemberSet.prototype._foldTypes = function(targets) {
|
| + return reduce(map(targets, (function (t) {
|
| + return t.get$returnType();
|
| + })
|
| + ), Type.union, $globals.world.varType);
|
| +}
|
| +MemberSet.prototype._get$3 = function($0, $1, $2) {
|
| + return this._get($0, $1, $2, false);
|
| +};
|
| +MemberSet.prototype._get$3$isDynamic = MemberSet.prototype._get;
|
| +MemberSet.prototype._get$4 = MemberSet.prototype._get;
|
| +MemberSet.prototype._set$4 = function($0, $1, $2, $3) {
|
| + return this._set($0, $1, $2, $3, false);
|
| +};
|
| +MemberSet.prototype._set$4$isDynamic = MemberSet.prototype._set;
|
| +MemberSet.prototype._set$5 = MemberSet.prototype._set;
|
| +MemberSet.prototype.add$1 = MemberSet.prototype.add;
|
| +MemberSet.prototype.canInvoke$2 = MemberSet.prototype.canInvoke;
|
| +MemberSet.prototype.invoke$4 = function($0, $1, $2, $3) {
|
| + return this.invoke($0, $1, $2, $3, false);
|
| +};
|
| +MemberSet.prototype.invoke$4$isDynamic = MemberSet.prototype.invoke;
|
| +MemberSet.prototype.invoke$5 = MemberSet.prototype.invoke;
|
| +MemberSet.prototype.toString$0 = MemberSet.prototype.toString;
|
| +// ********** Code for FactoryMap **************
|
| +function FactoryMap() {
|
| + this.factories = new HashMapImplementation();
|
| + // Initializers done
|
| +}
|
| +FactoryMap.prototype.getFactoriesFor = function(typeName) {
|
| + var ret = this.factories.$index(typeName);
|
| + if (ret == null) {
|
| + ret = new HashMapImplementation();
|
| + this.factories.$setindex(typeName, ret);
|
| + }
|
| + return ret;
|
| +}
|
| +FactoryMap.prototype.addFactory = function(typeName, name, member) {
|
| + this.getFactoriesFor(typeName).$setindex(name, member);
|
| +}
|
| +FactoryMap.prototype.getFactory = function(typeName, name) {
|
| + return this.getFactoriesFor(typeName).$index(name);
|
| +}
|
| +FactoryMap.prototype.forEach = function(f) {
|
| + this.factories.forEach((function (_, constructors) {
|
| + constructors.forEach((function (_, member) {
|
| + f(member);
|
| + })
|
| + );
|
| + })
|
| + );
|
| +}
|
| +FactoryMap.prototype.forEach$1 = function($0) {
|
| + return this.forEach(to$call$1($0));
|
| +};
|
| +FactoryMap.prototype.getFactory$2 = FactoryMap.prototype.getFactory;
|
| +// ********** Code for Token **************
|
| +function Token(kind, source, start, end) {
|
| + this.kind = kind;
|
| + this.source = source;
|
| + this.start = start;
|
| + this.end = end;
|
| + // Initializers done
|
| +}
|
| +Token.prototype.get$end = function() { return this.end; };
|
| +Token.prototype.get$text = function() {
|
| + return this.source.get$text().substring(this.start, this.end);
|
| +}
|
| +Object.defineProperty(Token.prototype, "text", {
|
| + get: Token.prototype.get$text
|
| +});
|
| +Token.prototype.toString = function() {
|
| + var kindText = TokenKind.kindToString(this.kind);
|
| + var actualText = this.get$text();
|
| + if ($ne(kindText, actualText)) {
|
| + if (actualText.length > 10) {
|
| + actualText = actualText.substring$2(0, 8) + '...';
|
| + }
|
| + return ('' + kindText + '(' + actualText + ')');
|
| + }
|
| + else {
|
| + return kindText;
|
| + }
|
| +}
|
| +Token.prototype.get$span = function() {
|
| + return new SourceSpan(this.source, this.start, this.end);
|
| +}
|
| +Object.defineProperty(Token.prototype, "span", {
|
| + get: Token.prototype.get$span
|
| +});
|
| +Token.prototype.end$0 = function() {
|
| + return this.end();
|
| +};
|
| +Token.prototype.start$0 = function() {
|
| + return this.start();
|
| +};
|
| +Token.prototype.toString$0 = Token.prototype.toString;
|
| +// ********** Code for ErrorToken **************
|
| +$inherits(ErrorToken, Token);
|
| +function ErrorToken(kind, source, start, end, message) {
|
| + this.message = message;
|
| + // Initializers done
|
| + Token.call(this, kind, source, start, end);
|
| +}
|
| +// ********** Code for SourceFile **************
|
| +function SourceFile(filename, _text) {
|
| + this.filename = filename;
|
| + this._lang_text = _text;
|
| + // Initializers done
|
| +}
|
| +SourceFile.prototype.get$orderInLibrary = function() { return this.orderInLibrary; };
|
| +SourceFile.prototype.set$orderInLibrary = function(value) { return this.orderInLibrary = value; };
|
| +SourceFile.prototype.get$text = function() {
|
| + return this._lang_text;
|
| +}
|
| +Object.defineProperty(SourceFile.prototype, "text", {
|
| + get: SourceFile.prototype.get$text,
|
| + set: SourceFile.prototype.set$text
|
| +});
|
| +SourceFile.prototype.get$lineStarts = function() {
|
| + if (this._lang_lineStarts == null) {
|
| + var starts = [0];
|
| + var index = 0;
|
| + while (index < this.get$text().length) {
|
| + index = this.get$text().indexOf('\n', index) + 1;
|
| + if (index <= 0) break;
|
| + starts.add$1(index);
|
| + }
|
| + starts.add$1(this.get$text().length + 1);
|
| + this._lang_lineStarts = starts;
|
| + }
|
| + return this._lang_lineStarts;
|
| +}
|
| +SourceFile.prototype.getLine = function(position) {
|
| + var starts = this.get$lineStarts();
|
| + for (var i = 0;
|
| + i < starts.length; i++) {
|
| + if (starts.$index(i) > position) return i - 1;
|
| + }
|
| + $globals.world.internalError('bad position');
|
| +}
|
| +SourceFile.prototype.getColumn = function(line, position) {
|
| + return position - this.get$lineStarts().$index(line);
|
| +}
|
| +SourceFile.prototype.getLocationMessage = function(message, start, end, includeText) {
|
| + var line = this.getLine(start);
|
| + var column = this.getColumn(line, start);
|
| + var buf = new StringBufferImpl(('' + this.filename + ':' + (line + 1) + ':' + (column + 1) + ': ' + message));
|
| + if (includeText) {
|
| + buf.add$1('\n');
|
| + var textLine;
|
| + if ((line + 2) < this._lang_lineStarts.length) {
|
| + textLine = this.get$text().substring(this._lang_lineStarts.$index(line), this._lang_lineStarts.$index(line + 1));
|
| + }
|
| + else {
|
| + textLine = this.get$text().substring(this._lang_lineStarts.$index(line)) + '\n';
|
| + }
|
| + var toColumn = Math.min(column + (end - start), textLine.length);
|
| + if ($globals.options.useColors) {
|
| + buf.add$1(textLine.substring$2(0, column));
|
| + buf.add$1($globals._RED_COLOR);
|
| + buf.add$1(textLine.substring$2(column, toColumn));
|
| + buf.add$1($globals._NO_COLOR);
|
| + buf.add$1(textLine.substring$1(toColumn));
|
| + }
|
| + else {
|
| + buf.add$1(textLine);
|
| + }
|
| + var i = 0;
|
| + for (; i < column; i++) {
|
| + buf.add$1(' ');
|
| + }
|
| + if ($globals.options.useColors) buf.add$1($globals._RED_COLOR);
|
| + for (; i < toColumn; i++) {
|
| + buf.add$1('^');
|
| + }
|
| + if ($globals.options.useColors) buf.add$1($globals._NO_COLOR);
|
| + }
|
| + return buf.toString$0();
|
| +}
|
| +SourceFile.prototype.compareTo = function(other) {
|
| + if (this.orderInLibrary != null && other.orderInLibrary != null) {
|
| + return this.orderInLibrary - other.orderInLibrary;
|
| + }
|
| + else {
|
| + return this.filename.compareTo(other.filename);
|
| + }
|
| +}
|
| +SourceFile.prototype.compareTo$1 = SourceFile.prototype.compareTo;
|
| +SourceFile.prototype.getColumn$2 = SourceFile.prototype.getColumn;
|
| +SourceFile.prototype.getLine$1 = SourceFile.prototype.getLine;
|
| +// ********** Code for SourceSpan **************
|
| +function SourceSpan(file, start, end) {
|
| + this.file = file;
|
| + this.start = start;
|
| + this.end = end;
|
| + // Initializers done
|
| +}
|
| +SourceSpan.prototype.get$file = function() { return this.file; };
|
| +SourceSpan.prototype.get$end = function() { return this.end; };
|
| +SourceSpan.prototype.get$text = function() {
|
| + return this.file.get$text().substring(this.start, this.end);
|
| +}
|
| +Object.defineProperty(SourceSpan.prototype, "text", {
|
| + get: SourceSpan.prototype.get$text
|
| +});
|
| +SourceSpan.prototype.toMessageString = function(message) {
|
| + return this.file.getLocationMessage(message, this.start, this.end, true);
|
| +}
|
| +SourceSpan.prototype.get$locationText = function() {
|
| + var line = this.file.getLine(this.start);
|
| + var column = this.file.getColumn(line, this.start);
|
| + return ('' + this.file.filename + ':' + (line + 1) + ':' + (column + 1));
|
| +}
|
| +SourceSpan.prototype.compareTo = function(other) {
|
| + if ($eq(this.file, other.file)) {
|
| + var d = this.start - other.start;
|
| + return d == 0 ? (this.end - other.end) : d;
|
| + }
|
| + return this.file.compareTo(other.file);
|
| +}
|
| +SourceSpan.prototype.compareTo$1 = SourceSpan.prototype.compareTo;
|
| +SourceSpan.prototype.end$0 = function() {
|
| + return this.end();
|
| +};
|
| +SourceSpan.prototype.start$0 = function() {
|
| + return this.start();
|
| +};
|
| +// ********** Code for InterpStack **************
|
| +function InterpStack(previous, quote, isMultiline) {
|
| + this.previous = previous;
|
| + this.quote = quote;
|
| + this.isMultiline = isMultiline;
|
| + this.depth = -1;
|
| + // Initializers done
|
| +}
|
| +InterpStack.prototype.get$previous = function() { return this.previous; };
|
| +InterpStack.prototype.set$previous = function(value) { return this.previous = value; };
|
| +InterpStack.prototype.get$quote = function() { return this.quote; };
|
| +InterpStack.prototype.get$isMultiline = function() { return this.isMultiline; };
|
| +InterpStack.prototype.pop = function() {
|
| + return this.previous;
|
| +}
|
| +InterpStack.push = function(stack, quote, isMultiline) {
|
| + var newStack = new InterpStack(stack, quote, isMultiline);
|
| + if (stack != null) newStack.set$previous(stack);
|
| + return newStack;
|
| +}
|
| +InterpStack.prototype.next$0 = function() {
|
| + return this.next();
|
| +};
|
| +// ********** Code for TokenizerHelpers **************
|
| +function TokenizerHelpers() {
|
| + // Initializers done
|
| +}
|
| +TokenizerHelpers.isIdentifierStart = function(c) {
|
| + return ((c >= 97 && c <= 122) || (c >= 65 && c <= 90) || c == 95);
|
| +}
|
| +TokenizerHelpers.isDigit = function(c) {
|
| + return (c >= 48 && c <= 57);
|
| +}
|
| +TokenizerHelpers.isHexDigit = function(c) {
|
| + return (TokenizerHelpers.isDigit(c) || (c >= 97 && c <= 102) || (c >= 65 && c <= 70));
|
| +}
|
| +TokenizerHelpers.isIdentifierPart = function(c) {
|
| + return (TokenizerHelpers.isIdentifierStart(c) || TokenizerHelpers.isDigit(c) || c == 36);
|
| +}
|
| +TokenizerHelpers.isInterpIdentifierPart = function(c) {
|
| + return (TokenizerHelpers.isIdentifierStart(c) || TokenizerHelpers.isDigit(c));
|
| +}
|
| +// ********** Code for TokenizerBase **************
|
| +$inherits(TokenizerBase, TokenizerHelpers);
|
| +function TokenizerBase(_source, _skipWhitespace, index) {
|
| + this._source = _source;
|
| + this._skipWhitespace = _skipWhitespace;
|
| + this._index = index;
|
| + // Initializers done
|
| + TokenizerHelpers.call(this);
|
| + this._text = this._source.get$text();
|
| +}
|
| +TokenizerBase.prototype._nextChar = function() {
|
| + if (this._index < this._text.length) {
|
| + return this._text.charCodeAt(this._index++);
|
| + }
|
| + else {
|
| + return 0;
|
| + }
|
| +}
|
| +TokenizerBase.prototype._peekChar = function() {
|
| + if (this._index < this._text.length) {
|
| + return this._text.charCodeAt(this._index);
|
| + }
|
| + else {
|
| + return 0;
|
| + }
|
| +}
|
| +TokenizerBase.prototype._maybeEatChar = function(ch) {
|
| + if (this._index < this._text.length) {
|
| + if (this._text.charCodeAt(this._index) == ch) {
|
| + this._index++;
|
| + return true;
|
| + }
|
| + else {
|
| + return false;
|
| + }
|
| + }
|
| + else {
|
| + return false;
|
| + }
|
| +}
|
| +TokenizerBase.prototype._finishToken = function(kind) {
|
| + return new Token(kind, this._source, this._startIndex, this._index);
|
| +}
|
| +TokenizerBase.prototype._errorToken = function(message) {
|
| + return new ErrorToken(65/*TokenKind.ERROR*/, this._source, this._startIndex, this._index, message);
|
| +}
|
| +TokenizerBase.prototype.finishWhitespace = function() {
|
| + this._index--;
|
| + while (this._index < this._text.length) {
|
| + var ch = this._text.charCodeAt(this._index++);
|
| + if (ch == 32 || ch == 9 || ch == 13) {
|
| + }
|
| + else if (ch == 10) {
|
| + if (!this._skipWhitespace) {
|
| + return this._finishToken(63/*TokenKind.WHITESPACE*/);
|
| + }
|
| + }
|
| + else {
|
| + this._index--;
|
| + if (this._skipWhitespace) {
|
| + return this.next();
|
| + }
|
| + else {
|
| + return this._finishToken(63/*TokenKind.WHITESPACE*/);
|
| + }
|
| + }
|
| + }
|
| + return this._finishToken(1/*TokenKind.END_OF_FILE*/);
|
| +}
|
| +TokenizerBase.prototype.finishHashBang = function() {
|
| + while (true) {
|
| + var ch = this._nextChar();
|
| + if (ch == 0 || ch == 10 || ch == 13) {
|
| + return this._finishToken(13/*TokenKind.HASHBANG*/);
|
| + }
|
| + }
|
| +}
|
| +TokenizerBase.prototype.finishSingleLineComment = function() {
|
| + while (true) {
|
| + var ch = this._nextChar();
|
| + if (ch == 0 || ch == 10 || ch == 13) {
|
| + if (this._skipWhitespace) {
|
| + return this.next();
|
| + }
|
| + else {
|
| + return this._finishToken(64/*TokenKind.COMMENT*/);
|
| + }
|
| + }
|
| + }
|
| +}
|
| +TokenizerBase.prototype.finishMultiLineComment = function() {
|
| + while (true) {
|
| + var ch = this._nextChar();
|
| + if (ch == 0) {
|
| + return this._finishToken(67/*TokenKind.INCOMPLETE_COMMENT*/);
|
| + }
|
| + else if (ch == 42) {
|
| + if (this._maybeEatChar(47)) {
|
| + if (this._skipWhitespace) {
|
| + return this.next();
|
| + }
|
| + else {
|
| + return this._finishToken(64/*TokenKind.COMMENT*/);
|
| + }
|
| + }
|
| + }
|
| + }
|
| + return this._errorToken();
|
| +}
|
| +TokenizerBase.prototype.eatDigits = function() {
|
| + while (this._index < this._text.length) {
|
| + if (TokenizerHelpers.isDigit(this._text.charCodeAt(this._index))) {
|
| + this._index++;
|
| + }
|
| + else {
|
| + return;
|
| + }
|
| + }
|
| +}
|
| +TokenizerBase.prototype.eatHexDigits = function() {
|
| + while (this._index < this._text.length) {
|
| + if (TokenizerHelpers.isHexDigit(this._text.charCodeAt(this._index))) {
|
| + this._index++;
|
| + }
|
| + else {
|
| + return;
|
| + }
|
| + }
|
| +}
|
| +TokenizerBase.prototype.maybeEatHexDigit = function() {
|
| + if (this._index < this._text.length && TokenizerHelpers.isHexDigit(this._text.charCodeAt(this._index))) {
|
| + this._index++;
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +TokenizerBase.prototype.finishHex = function() {
|
| + this.eatHexDigits();
|
| + return this._finishToken(61/*TokenKind.HEX_INTEGER*/);
|
| +}
|
| +TokenizerBase.prototype.finishNumber = function() {
|
| + this.eatDigits();
|
| + if (this._peekChar() == 46) {
|
| + this._nextChar();
|
| + if (TokenizerHelpers.isDigit(this._peekChar())) {
|
| + this.eatDigits();
|
| + return this.finishNumberExtra(62/*TokenKind.DOUBLE*/);
|
| + }
|
| + else {
|
| + this._index--;
|
| + }
|
| + }
|
| + return this.finishNumberExtra(60/*TokenKind.INTEGER*/);
|
| +}
|
| +TokenizerBase.prototype.finishNumberExtra = function(kind) {
|
| + if (this._maybeEatChar(101) || this._maybeEatChar(69)) {
|
| + kind = 62/*TokenKind.DOUBLE*/;
|
| + this._maybeEatChar(45);
|
| + this._maybeEatChar(43);
|
| + this.eatDigits();
|
| + }
|
| + if (this._peekChar() != 0 && TokenizerHelpers.isIdentifierStart(this._peekChar())) {
|
| + this._nextChar();
|
| + return this._errorToken("illegal character in number");
|
| + }
|
| + return this._finishToken(kind);
|
| +}
|
| +TokenizerBase.prototype.finishMultilineString = function(quote) {
|
| + while (true) {
|
| + var ch = this._nextChar();
|
| + if (ch == 0) {
|
| + var kind = quote == 34 ? 68/*TokenKind.INCOMPLETE_MULTILINE_STRING_DQ*/ : 69/*TokenKind.INCOMPLETE_MULTILINE_STRING_SQ*/;
|
| + return this._finishToken(kind);
|
| + }
|
| + else if (ch == quote) {
|
| + if (this._maybeEatChar(quote)) {
|
| + if (this._maybeEatChar(quote)) {
|
| + return this._finishToken(58/*TokenKind.STRING*/);
|
| + }
|
| + }
|
| + }
|
| + else if (ch == 36) {
|
| + this._interpStack = InterpStack.push(this._interpStack, quote, true);
|
| + return this._finishToken(66/*TokenKind.INCOMPLETE_STRING*/);
|
| + }
|
| + else if (ch == 92) {
|
| + if (!this.eatEscapeSequence()) {
|
| + return this._errorToken("invalid hex escape sequence");
|
| + }
|
| + }
|
| + }
|
| +}
|
| +TokenizerBase.prototype._finishOpenBrace = function() {
|
| + var $0;
|
| + if (this._interpStack != null) {
|
| + if (this._interpStack.depth == -1) {
|
| + this._interpStack.depth = 1;
|
| + }
|
| + else {
|
| + ($0 = this._interpStack).depth = $0.depth + 1;
|
| + }
|
| + }
|
| + return this._finishToken(6/*TokenKind.LBRACE*/);
|
| +}
|
| +TokenizerBase.prototype._finishCloseBrace = function() {
|
| + var $0;
|
| + if (this._interpStack != null) {
|
| + ($0 = this._interpStack).depth = $0.depth - 1;
|
| + }
|
| + return this._finishToken(7/*TokenKind.RBRACE*/);
|
| +}
|
| +TokenizerBase.prototype.finishString = function(quote) {
|
| + if (this._maybeEatChar(quote)) {
|
| + if (this._maybeEatChar(quote)) {
|
| + return this.finishMultilineString(quote);
|
| + }
|
| + else {
|
| + return this._finishToken(58/*TokenKind.STRING*/);
|
| + }
|
| + }
|
| + return this.finishStringBody(quote);
|
| +}
|
| +TokenizerBase.prototype.finishRawString = function(quote) {
|
| + if (this._maybeEatChar(quote)) {
|
| + if (this._maybeEatChar(quote)) {
|
| + return this.finishMultilineRawString(quote);
|
| + }
|
| + else {
|
| + return this._finishToken(58/*TokenKind.STRING*/);
|
| + }
|
| + }
|
| + while (true) {
|
| + var ch = this._nextChar();
|
| + if (ch == quote) {
|
| + return this._finishToken(58/*TokenKind.STRING*/);
|
| + }
|
| + else if (ch == 0) {
|
| + return this._finishToken(66/*TokenKind.INCOMPLETE_STRING*/);
|
| + }
|
| + }
|
| +}
|
| +TokenizerBase.prototype.finishMultilineRawString = function(quote) {
|
| + while (true) {
|
| + var ch = this._nextChar();
|
| + if (ch == 0) {
|
| + var kind = quote == 34 ? 68/*TokenKind.INCOMPLETE_MULTILINE_STRING_DQ*/ : 69/*TokenKind.INCOMPLETE_MULTILINE_STRING_SQ*/;
|
| + return this._finishToken(kind);
|
| + }
|
| + else if (ch == quote && this._maybeEatChar(quote) && this._maybeEatChar(quote)) {
|
| + return this._finishToken(58/*TokenKind.STRING*/);
|
| + }
|
| + }
|
| +}
|
| +TokenizerBase.prototype.finishStringBody = function(quote) {
|
| + while (true) {
|
| + var ch = this._nextChar();
|
| + if (ch == quote) {
|
| + return this._finishToken(58/*TokenKind.STRING*/);
|
| + }
|
| + else if (ch == 36) {
|
| + this._interpStack = InterpStack.push(this._interpStack, quote, false);
|
| + return this._finishToken(66/*TokenKind.INCOMPLETE_STRING*/);
|
| + }
|
| + else if (ch == 0) {
|
| + return this._finishToken(66/*TokenKind.INCOMPLETE_STRING*/);
|
| + }
|
| + else if (ch == 92) {
|
| + if (!this.eatEscapeSequence()) {
|
| + return this._errorToken("invalid hex escape sequence");
|
| + }
|
| + }
|
| + }
|
| +}
|
| +TokenizerBase.prototype.eatEscapeSequence = function() {
|
| + var hex;
|
| + switch (this._nextChar()) {
|
| + case 120:
|
| +
|
| + return this.maybeEatHexDigit() && this.maybeEatHexDigit();
|
| +
|
| + case 117:
|
| +
|
| + if (this._maybeEatChar(123)) {
|
| + var start = this._index;
|
| + this.eatHexDigits();
|
| + var chars = this._index - start;
|
| + if (chars > 0 && chars <= 6 && this._maybeEatChar(125)) {
|
| + hex = this._text.substring(start, start + chars);
|
| + break;
|
| + }
|
| + else {
|
| + return false;
|
| + }
|
| + }
|
| + else {
|
| + if (this.maybeEatHexDigit() && this.maybeEatHexDigit() && this.maybeEatHexDigit() && this.maybeEatHexDigit()) {
|
| + hex = this._text.substring(this._index - 4, this._index);
|
| + break;
|
| + }
|
| + else {
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + default:
|
| +
|
| + return true;
|
| +
|
| + }
|
| + var n = Parser.parseHex(hex);
|
| + return n < 0xD800 || n > 0xDFFF && n <= 0x10FFFF;
|
| +}
|
| +TokenizerBase.prototype.finishDot = function() {
|
| + if (TokenizerHelpers.isDigit(this._peekChar())) {
|
| + this.eatDigits();
|
| + return this.finishNumberExtra(62/*TokenKind.DOUBLE*/);
|
| + }
|
| + else {
|
| + return this._finishToken(14/*TokenKind.DOT*/);
|
| + }
|
| +}
|
| +TokenizerBase.prototype.finishIdentifier = function(ch) {
|
| + if (this._interpStack != null && this._interpStack.depth == -1) {
|
| + this._interpStack.depth = 0;
|
| + if (ch == 36) {
|
| + return this._errorToken("illegal character after $ in string interpolation");
|
| + }
|
| + while (this._index < this._text.length) {
|
| + if (!TokenizerHelpers.isInterpIdentifierPart(this._text.charCodeAt(this._index++))) {
|
| + this._index--;
|
| + break;
|
| + }
|
| + }
|
| + }
|
| + else {
|
| + while (this._index < this._text.length) {
|
| + if (!TokenizerHelpers.isIdentifierPart(this._text.charCodeAt(this._index++))) {
|
| + this._index--;
|
| + break;
|
| + }
|
| + }
|
| + }
|
| + var kind = this.getIdentifierKind();
|
| + if (kind == 70/*TokenKind.IDENTIFIER*/) {
|
| + return this._finishToken(70/*TokenKind.IDENTIFIER*/);
|
| + }
|
| + else {
|
| + return this._finishToken(kind);
|
| + }
|
| +}
|
| +TokenizerBase.prototype.next$0 = TokenizerBase.prototype.next;
|
| +// ********** Code for Tokenizer **************
|
| +$inherits(Tokenizer, TokenizerBase);
|
| +function Tokenizer(source, skipWhitespace, index) {
|
| + // Initializers done
|
| + TokenizerBase.call(this, source, skipWhitespace, index);
|
| +}
|
| +Tokenizer.prototype.next = function() {
|
| + this._startIndex = this._index;
|
| + if (this._interpStack != null && this._interpStack.depth == 0) {
|
| + var istack = this._interpStack;
|
| + this._interpStack = this._interpStack.pop();
|
| + if (istack.get$isMultiline()) {
|
| + return this.finishMultilineString(istack.get$quote());
|
| + }
|
| + else {
|
| + return this.finishStringBody(istack.get$quote());
|
| + }
|
| + }
|
| + var ch;
|
| + ch = this._nextChar();
|
| + switch (ch) {
|
| + case 0:
|
| +
|
| + return this._finishToken(1/*TokenKind.END_OF_FILE*/);
|
| +
|
| + case 32:
|
| + case 9:
|
| + case 10:
|
| + case 13:
|
| +
|
| + return this.finishWhitespace();
|
| +
|
| + case 33:
|
| +
|
| + if (this._maybeEatChar(61)) {
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(51/*TokenKind.NE_STRICT*/);
|
| + }
|
| + else {
|
| + return this._finishToken(49/*TokenKind.NE*/);
|
| + }
|
| + }
|
| + else {
|
| + return this._finishToken(19/*TokenKind.NOT*/);
|
| + }
|
| +
|
| + case 34:
|
| +
|
| + return this.finishString(34);
|
| +
|
| + case 35:
|
| +
|
| + if (this._maybeEatChar(33)) {
|
| + return this.finishHashBang();
|
| + }
|
| + else {
|
| + return this._finishToken(12/*TokenKind.HASH*/);
|
| + }
|
| +
|
| + case 36:
|
| +
|
| + if (this._maybeEatChar(34)) {
|
| + return this.finishString(34);
|
| + }
|
| + else if (this._maybeEatChar(39)) {
|
| + return this.finishString(39);
|
| + }
|
| + else {
|
| + return this.finishIdentifier(36);
|
| + }
|
| +
|
| + case 37:
|
| +
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(32/*TokenKind.ASSIGN_MOD*/);
|
| + }
|
| + else {
|
| + return this._finishToken(47/*TokenKind.MOD*/);
|
| + }
|
| +
|
| + case 38:
|
| +
|
| + if (this._maybeEatChar(38)) {
|
| + return this._finishToken(35/*TokenKind.AND*/);
|
| + }
|
| + else if (this._maybeEatChar(61)) {
|
| + return this._finishToken(23/*TokenKind.ASSIGN_AND*/);
|
| + }
|
| + else {
|
| + return this._finishToken(38/*TokenKind.BIT_AND*/);
|
| + }
|
| +
|
| + case 39:
|
| +
|
| + return this.finishString(39);
|
| +
|
| + case 40:
|
| +
|
| + return this._finishToken(2/*TokenKind.LPAREN*/);
|
| +
|
| + case 41:
|
| +
|
| + return this._finishToken(3/*TokenKind.RPAREN*/);
|
| +
|
| + case 42:
|
| +
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(29/*TokenKind.ASSIGN_MUL*/);
|
| + }
|
| + else {
|
| + return this._finishToken(44/*TokenKind.MUL*/);
|
| + }
|
| +
|
| + case 43:
|
| +
|
| + if (this._maybeEatChar(43)) {
|
| + return this._finishToken(16/*TokenKind.INCR*/);
|
| + }
|
| + else if (this._maybeEatChar(61)) {
|
| + return this._finishToken(27/*TokenKind.ASSIGN_ADD*/);
|
| + }
|
| + else {
|
| + return this._finishToken(42/*TokenKind.ADD*/);
|
| + }
|
| +
|
| + case 44:
|
| +
|
| + return this._finishToken(11/*TokenKind.COMMA*/);
|
| +
|
| + case 45:
|
| +
|
| + if (this._maybeEatChar(45)) {
|
| + return this._finishToken(17/*TokenKind.DECR*/);
|
| + }
|
| + else if (this._maybeEatChar(61)) {
|
| + return this._finishToken(28/*TokenKind.ASSIGN_SUB*/);
|
| + }
|
| + else {
|
| + return this._finishToken(43/*TokenKind.SUB*/);
|
| + }
|
| +
|
| + case 46:
|
| +
|
| + if (this._maybeEatChar(46)) {
|
| + if (this._maybeEatChar(46)) {
|
| + return this._finishToken(15/*TokenKind.ELLIPSIS*/);
|
| + }
|
| + else {
|
| + return this._errorToken();
|
| + }
|
| + }
|
| + else {
|
| + return this.finishDot();
|
| + }
|
| +
|
| + case 47:
|
| +
|
| + if (this._maybeEatChar(42)) {
|
| + return this.finishMultiLineComment();
|
| + }
|
| + else if (this._maybeEatChar(47)) {
|
| + return this.finishSingleLineComment();
|
| + }
|
| + else if (this._maybeEatChar(61)) {
|
| + return this._finishToken(30/*TokenKind.ASSIGN_DIV*/);
|
| + }
|
| + else {
|
| + return this._finishToken(45/*TokenKind.DIV*/);
|
| + }
|
| +
|
| + case 48:
|
| +
|
| + if (this._maybeEatChar(88)) {
|
| + return this.finishHex();
|
| + }
|
| + else if (this._maybeEatChar(120)) {
|
| + return this.finishHex();
|
| + }
|
| + else {
|
| + return this.finishNumber();
|
| + }
|
| +
|
| + case 58:
|
| +
|
| + return this._finishToken(8/*TokenKind.COLON*/);
|
| +
|
| + case 59:
|
| +
|
| + return this._finishToken(10/*TokenKind.SEMICOLON*/);
|
| +
|
| + case 60:
|
| +
|
| + if (this._maybeEatChar(60)) {
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(24/*TokenKind.ASSIGN_SHL*/);
|
| + }
|
| + else {
|
| + return this._finishToken(39/*TokenKind.SHL*/);
|
| + }
|
| + }
|
| + else if (this._maybeEatChar(61)) {
|
| + return this._finishToken(54/*TokenKind.LTE*/);
|
| + }
|
| + else {
|
| + return this._finishToken(52/*TokenKind.LT*/);
|
| + }
|
| +
|
| + case 61:
|
| +
|
| + if (this._maybeEatChar(61)) {
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(50/*TokenKind.EQ_STRICT*/);
|
| + }
|
| + else {
|
| + return this._finishToken(48/*TokenKind.EQ*/);
|
| + }
|
| + }
|
| + else if (this._maybeEatChar(62)) {
|
| + return this._finishToken(9/*TokenKind.ARROW*/);
|
| + }
|
| + else {
|
| + return this._finishToken(20/*TokenKind.ASSIGN*/);
|
| + }
|
| +
|
| + case 62:
|
| +
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(55/*TokenKind.GTE*/);
|
| + }
|
| + else if (this._maybeEatChar(62)) {
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(25/*TokenKind.ASSIGN_SAR*/);
|
| + }
|
| + else if (this._maybeEatChar(62)) {
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(26/*TokenKind.ASSIGN_SHR*/);
|
| + }
|
| + else {
|
| + return this._finishToken(41/*TokenKind.SHR*/);
|
| + }
|
| + }
|
| + else {
|
| + return this._finishToken(40/*TokenKind.SAR*/);
|
| + }
|
| + }
|
| + else {
|
| + return this._finishToken(53/*TokenKind.GT*/);
|
| + }
|
| +
|
| + case 63:
|
| +
|
| + return this._finishToken(33/*TokenKind.CONDITIONAL*/);
|
| +
|
| + case 64:
|
| +
|
| + if (this._maybeEatChar(34)) {
|
| + return this.finishRawString(34);
|
| + }
|
| + else if (this._maybeEatChar(39)) {
|
| + return this.finishRawString(39);
|
| + }
|
| + else {
|
| + return this._errorToken();
|
| + }
|
| +
|
| + case 91:
|
| +
|
| + if (this._maybeEatChar(93)) {
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(57/*TokenKind.SETINDEX*/);
|
| + }
|
| + else {
|
| + return this._finishToken(56/*TokenKind.INDEX*/);
|
| + }
|
| + }
|
| + else {
|
| + return this._finishToken(4/*TokenKind.LBRACK*/);
|
| + }
|
| +
|
| + case 93:
|
| +
|
| + return this._finishToken(5/*TokenKind.RBRACK*/);
|
| +
|
| + case 94:
|
| +
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(22/*TokenKind.ASSIGN_XOR*/);
|
| + }
|
| + else {
|
| + return this._finishToken(37/*TokenKind.BIT_XOR*/);
|
| + }
|
| +
|
| + case 123:
|
| +
|
| + return this._finishOpenBrace();
|
| +
|
| + case 124:
|
| +
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(21/*TokenKind.ASSIGN_OR*/);
|
| + }
|
| + else if (this._maybeEatChar(124)) {
|
| + return this._finishToken(34/*TokenKind.OR*/);
|
| + }
|
| + else {
|
| + return this._finishToken(36/*TokenKind.BIT_OR*/);
|
| + }
|
| +
|
| + case 125:
|
| +
|
| + return this._finishCloseBrace();
|
| +
|
| + case 126:
|
| +
|
| + if (this._maybeEatChar(47)) {
|
| + if (this._maybeEatChar(61)) {
|
| + return this._finishToken(31/*TokenKind.ASSIGN_TRUNCDIV*/);
|
| + }
|
| + else {
|
| + return this._finishToken(46/*TokenKind.TRUNCDIV*/);
|
| + }
|
| + }
|
| + else {
|
| + return this._finishToken(18/*TokenKind.BIT_NOT*/);
|
| + }
|
| +
|
| + default:
|
| +
|
| + if (TokenizerHelpers.isIdentifierStart(ch)) {
|
| + return this.finishIdentifier(ch);
|
| + }
|
| + else if (TokenizerHelpers.isDigit(ch)) {
|
| + return this.finishNumber();
|
| + }
|
| + else {
|
| + return this._errorToken();
|
| + }
|
| +
|
| + }
|
| +}
|
| +Tokenizer.prototype.getIdentifierKind = function() {
|
| + var i0 = this._startIndex;
|
| + switch (this._index - i0) {
|
| + case 2:
|
| +
|
| + if (this._text.charCodeAt(i0) == 100) {
|
| + if (this._text.charCodeAt(i0 + 1) == 111) return 95/*TokenKind.DO*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 105) {
|
| + if (this._text.charCodeAt(i0 + 1) == 102) {
|
| + return 101/*TokenKind.IF*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0 + 1) == 110) {
|
| + return 102/*TokenKind.IN*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0 + 1) == 115) {
|
| + return 103/*TokenKind.IS*/;
|
| + }
|
| + }
|
| + return 70/*TokenKind.IDENTIFIER*/;
|
| +
|
| + case 3:
|
| +
|
| + if (this._text.charCodeAt(i0) == 102) {
|
| + if (this._text.charCodeAt(i0 + 1) == 111 && this._text.charCodeAt(i0 + 2) == 114) return 100/*TokenKind.FOR*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 103) {
|
| + if (this._text.charCodeAt(i0 + 1) == 101 && this._text.charCodeAt(i0 + 2) == 116) return 76/*TokenKind.GET*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 110) {
|
| + if (this._text.charCodeAt(i0 + 1) == 101 && this._text.charCodeAt(i0 + 2) == 119) return 104/*TokenKind.NEW*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 115) {
|
| + if (this._text.charCodeAt(i0 + 1) == 101 && this._text.charCodeAt(i0 + 2) == 116) return 84/*TokenKind.SET*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 116) {
|
| + if (this._text.charCodeAt(i0 + 1) == 114 && this._text.charCodeAt(i0 + 2) == 121) return 112/*TokenKind.TRY*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 118) {
|
| + if (this._text.charCodeAt(i0 + 1) == 97 && this._text.charCodeAt(i0 + 2) == 114) return 113/*TokenKind.VAR*/;
|
| + }
|
| + return 70/*TokenKind.IDENTIFIER*/;
|
| +
|
| + case 4:
|
| +
|
| + if (this._text.charCodeAt(i0) == 99) {
|
| + if (this._text.charCodeAt(i0 + 1) == 97 && this._text.charCodeAt(i0 + 2) == 115 && this._text.charCodeAt(i0 + 3) == 101) return 90/*TokenKind.CASE*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 101) {
|
| + if (this._text.charCodeAt(i0 + 1) == 108 && this._text.charCodeAt(i0 + 2) == 115 && this._text.charCodeAt(i0 + 3) == 101) return 96/*TokenKind.ELSE*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 110) {
|
| + if (this._text.charCodeAt(i0 + 1) == 117 && this._text.charCodeAt(i0 + 2) == 108 && this._text.charCodeAt(i0 + 3) == 108) return 105/*TokenKind.NULL*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 116) {
|
| + if (this._text.charCodeAt(i0 + 1) == 104) {
|
| + if (this._text.charCodeAt(i0 + 2) == 105 && this._text.charCodeAt(i0 + 3) == 115) return 109/*TokenKind.THIS*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0 + 1) == 114) {
|
| + if (this._text.charCodeAt(i0 + 2) == 117 && this._text.charCodeAt(i0 + 3) == 101) return 111/*TokenKind.TRUE*/;
|
| + }
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 118) {
|
| + if (this._text.charCodeAt(i0 + 1) == 111 && this._text.charCodeAt(i0 + 2) == 105 && this._text.charCodeAt(i0 + 3) == 100) return 114/*TokenKind.VOID*/;
|
| + }
|
| + return 70/*TokenKind.IDENTIFIER*/;
|
| +
|
| + case 5:
|
| +
|
| + if (this._text.charCodeAt(i0) == 97) {
|
| + if (this._text.charCodeAt(i0 + 1) == 119 && this._text.charCodeAt(i0 + 2) == 97 && this._text.charCodeAt(i0 + 3) == 105 && this._text.charCodeAt(i0 + 4) == 116) return 88/*TokenKind.AWAIT*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 98) {
|
| + if (this._text.charCodeAt(i0 + 1) == 114 && this._text.charCodeAt(i0 + 2) == 101 && this._text.charCodeAt(i0 + 3) == 97 && this._text.charCodeAt(i0 + 4) == 107) return 89/*TokenKind.BREAK*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 99) {
|
| + if (this._text.charCodeAt(i0 + 1) == 97) {
|
| + if (this._text.charCodeAt(i0 + 2) == 116 && this._text.charCodeAt(i0 + 3) == 99 && this._text.charCodeAt(i0 + 4) == 104) return 91/*TokenKind.CATCH*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0 + 1) == 108) {
|
| + if (this._text.charCodeAt(i0 + 2) == 97 && this._text.charCodeAt(i0 + 3) == 115 && this._text.charCodeAt(i0 + 4) == 115) return 73/*TokenKind.CLASS*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0 + 1) == 111) {
|
| + if (this._text.charCodeAt(i0 + 2) == 110 && this._text.charCodeAt(i0 + 3) == 115 && this._text.charCodeAt(i0 + 4) == 116) return 92/*TokenKind.CONST*/;
|
| + }
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 102) {
|
| + if (this._text.charCodeAt(i0 + 1) == 97) {
|
| + if (this._text.charCodeAt(i0 + 2) == 108 && this._text.charCodeAt(i0 + 3) == 115 && this._text.charCodeAt(i0 + 4) == 101) return 97/*TokenKind.FALSE*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0 + 1) == 105) {
|
| + if (this._text.charCodeAt(i0 + 2) == 110 && this._text.charCodeAt(i0 + 3) == 97 && this._text.charCodeAt(i0 + 4) == 108) return 98/*TokenKind.FINAL*/;
|
| + }
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 115) {
|
| + if (this._text.charCodeAt(i0 + 1) == 117 && this._text.charCodeAt(i0 + 2) == 112 && this._text.charCodeAt(i0 + 3) == 101 && this._text.charCodeAt(i0 + 4) == 114) return 107/*TokenKind.SUPER*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 116) {
|
| + if (this._text.charCodeAt(i0 + 1) == 104 && this._text.charCodeAt(i0 + 2) == 114 && this._text.charCodeAt(i0 + 3) == 111 && this._text.charCodeAt(i0 + 4) == 119) return 110/*TokenKind.THROW*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 119) {
|
| + if (this._text.charCodeAt(i0 + 1) == 104 && this._text.charCodeAt(i0 + 2) == 105 && this._text.charCodeAt(i0 + 3) == 108 && this._text.charCodeAt(i0 + 4) == 101) return 115/*TokenKind.WHILE*/;
|
| + }
|
| + return 70/*TokenKind.IDENTIFIER*/;
|
| +
|
| + case 6:
|
| +
|
| + if (this._text.charCodeAt(i0) == 97) {
|
| + if (this._text.charCodeAt(i0 + 1) == 115 && this._text.charCodeAt(i0 + 2) == 115 && this._text.charCodeAt(i0 + 3) == 101 && this._text.charCodeAt(i0 + 4) == 114 && this._text.charCodeAt(i0 + 5) == 116) return 72/*TokenKind.ASSERT*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 105) {
|
| + if (this._text.charCodeAt(i0 + 1) == 109 && this._text.charCodeAt(i0 + 2) == 112 && this._text.charCodeAt(i0 + 3) == 111 && this._text.charCodeAt(i0 + 4) == 114 && this._text.charCodeAt(i0 + 5) == 116) return 78/*TokenKind.IMPORT*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 110) {
|
| + if (this._text.charCodeAt(i0 + 1) == 97) {
|
| + if (this._text.charCodeAt(i0 + 2) == 116 && this._text.charCodeAt(i0 + 3) == 105 && this._text.charCodeAt(i0 + 4) == 118 && this._text.charCodeAt(i0 + 5) == 101) return 81/*TokenKind.NATIVE*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0 + 1) == 101) {
|
| + if (this._text.charCodeAt(i0 + 2) == 103 && this._text.charCodeAt(i0 + 3) == 97 && this._text.charCodeAt(i0 + 4) == 116 && this._text.charCodeAt(i0 + 5) == 101) return 82/*TokenKind.NEGATE*/;
|
| + }
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 114) {
|
| + if (this._text.charCodeAt(i0 + 1) == 101 && this._text.charCodeAt(i0 + 2) == 116 && this._text.charCodeAt(i0 + 3) == 117 && this._text.charCodeAt(i0 + 4) == 114 && this._text.charCodeAt(i0 + 5) == 110) return 106/*TokenKind.RETURN*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 115) {
|
| + if (this._text.charCodeAt(i0 + 1) == 111) {
|
| + if (this._text.charCodeAt(i0 + 2) == 117 && this._text.charCodeAt(i0 + 3) == 114 && this._text.charCodeAt(i0 + 4) == 99 && this._text.charCodeAt(i0 + 5) == 101) return 85/*TokenKind.SOURCE*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0 + 1) == 116) {
|
| + if (this._text.charCodeAt(i0 + 2) == 97 && this._text.charCodeAt(i0 + 3) == 116 && this._text.charCodeAt(i0 + 4) == 105 && this._text.charCodeAt(i0 + 5) == 99) return 86/*TokenKind.STATIC*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0 + 1) == 119) {
|
| + if (this._text.charCodeAt(i0 + 2) == 105 && this._text.charCodeAt(i0 + 3) == 116 && this._text.charCodeAt(i0 + 4) == 99 && this._text.charCodeAt(i0 + 5) == 104) return 108/*TokenKind.SWITCH*/;
|
| + }
|
| + }
|
| + return 70/*TokenKind.IDENTIFIER*/;
|
| +
|
| + case 7:
|
| +
|
| + if (this._text.charCodeAt(i0) == 100) {
|
| + if (this._text.charCodeAt(i0 + 1) == 101 && this._text.charCodeAt(i0 + 2) == 102 && this._text.charCodeAt(i0 + 3) == 97 && this._text.charCodeAt(i0 + 4) == 117 && this._text.charCodeAt(i0 + 5) == 108 && this._text.charCodeAt(i0 + 6) == 116) return 94/*TokenKind.DEFAULT*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 101) {
|
| + if (this._text.charCodeAt(i0 + 1) == 120 && this._text.charCodeAt(i0 + 2) == 116 && this._text.charCodeAt(i0 + 3) == 101 && this._text.charCodeAt(i0 + 4) == 110 && this._text.charCodeAt(i0 + 5) == 100 && this._text.charCodeAt(i0 + 6) == 115) return 74/*TokenKind.EXTENDS*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 102) {
|
| + if (this._text.charCodeAt(i0 + 1) == 97) {
|
| + if (this._text.charCodeAt(i0 + 2) == 99 && this._text.charCodeAt(i0 + 3) == 116 && this._text.charCodeAt(i0 + 4) == 111 && this._text.charCodeAt(i0 + 5) == 114 && this._text.charCodeAt(i0 + 6) == 121) return 75/*TokenKind.FACTORY*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0 + 1) == 105) {
|
| + if (this._text.charCodeAt(i0 + 2) == 110 && this._text.charCodeAt(i0 + 3) == 97 && this._text.charCodeAt(i0 + 4) == 108 && this._text.charCodeAt(i0 + 5) == 108 && this._text.charCodeAt(i0 + 6) == 121) return 99/*TokenKind.FINALLY*/;
|
| + }
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 108) {
|
| + if (this._text.charCodeAt(i0 + 1) == 105 && this._text.charCodeAt(i0 + 2) == 98 && this._text.charCodeAt(i0 + 3) == 114 && this._text.charCodeAt(i0 + 4) == 97 && this._text.charCodeAt(i0 + 5) == 114 && this._text.charCodeAt(i0 + 6) == 121) return 80/*TokenKind.LIBRARY*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 116) {
|
| + if (this._text.charCodeAt(i0 + 1) == 121 && this._text.charCodeAt(i0 + 2) == 112 && this._text.charCodeAt(i0 + 3) == 101 && this._text.charCodeAt(i0 + 4) == 100 && this._text.charCodeAt(i0 + 5) == 101 && this._text.charCodeAt(i0 + 6) == 102) return 87/*TokenKind.TYPEDEF*/;
|
| + }
|
| + return 70/*TokenKind.IDENTIFIER*/;
|
| +
|
| + case 8:
|
| +
|
| + if (this._text.charCodeAt(i0) == 97) {
|
| + if (this._text.charCodeAt(i0 + 1) == 98 && this._text.charCodeAt(i0 + 2) == 115 && this._text.charCodeAt(i0 + 3) == 116 && this._text.charCodeAt(i0 + 4) == 114 && this._text.charCodeAt(i0 + 5) == 97 && this._text.charCodeAt(i0 + 6) == 99 && this._text.charCodeAt(i0 + 7) == 116) return 71/*TokenKind.ABSTRACT*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 99) {
|
| + if (this._text.charCodeAt(i0 + 1) == 111 && this._text.charCodeAt(i0 + 2) == 110 && this._text.charCodeAt(i0 + 3) == 116 && this._text.charCodeAt(i0 + 4) == 105 && this._text.charCodeAt(i0 + 5) == 110 && this._text.charCodeAt(i0 + 6) == 117 && this._text.charCodeAt(i0 + 7) == 101) return 93/*TokenKind.CONTINUE*/;
|
| + }
|
| + else if (this._text.charCodeAt(i0) == 111) {
|
| + if (this._text.charCodeAt(i0 + 1) == 112 && this._text.charCodeAt(i0 + 2) == 101 && this._text.charCodeAt(i0 + 3) == 114 && this._text.charCodeAt(i0 + 4) == 97 && this._text.charCodeAt(i0 + 5) == 116 && this._text.charCodeAt(i0 + 6) == 111 && this._text.charCodeAt(i0 + 7) == 114) return 83/*TokenKind.OPERATOR*/;
|
| + }
|
| + return 70/*TokenKind.IDENTIFIER*/;
|
| +
|
| + case 9:
|
| +
|
| + if (this._text.charCodeAt(i0) == 105 && this._text.charCodeAt(i0 + 1) == 110 && this._text.charCodeAt(i0 + 2) == 116 && this._text.charCodeAt(i0 + 3) == 101 && this._text.charCodeAt(i0 + 4) == 114 && this._text.charCodeAt(i0 + 5) == 102 && this._text.charCodeAt(i0 + 6) == 97 && this._text.charCodeAt(i0 + 7) == 99 && this._text.charCodeAt(i0 + 8) == 101) return 79/*TokenKind.INTERFACE*/;
|
| + return 70/*TokenKind.IDENTIFIER*/;
|
| +
|
| + case 10:
|
| +
|
| + if (this._text.charCodeAt(i0) == 105 && this._text.charCodeAt(i0 + 1) == 109 && this._text.charCodeAt(i0 + 2) == 112 && this._text.charCodeAt(i0 + 3) == 108 && this._text.charCodeAt(i0 + 4) == 101 && this._text.charCodeAt(i0 + 5) == 109 && this._text.charCodeAt(i0 + 6) == 101 && this._text.charCodeAt(i0 + 7) == 110 && this._text.charCodeAt(i0 + 8) == 116 && this._text.charCodeAt(i0 + 9) == 115) return 77/*TokenKind.IMPLEMENTS*/;
|
| + return 70/*TokenKind.IDENTIFIER*/;
|
| +
|
| + default:
|
| +
|
| + return 70/*TokenKind.IDENTIFIER*/;
|
| +
|
| + }
|
| +}
|
| +Tokenizer.prototype.next$0 = Tokenizer.prototype.next;
|
| +// ********** Code for TokenKind **************
|
| +function TokenKind() {}
|
| +TokenKind.kindToString = function(kind) {
|
| + switch (kind) {
|
| + case 1/*TokenKind.END_OF_FILE*/:
|
| +
|
| + return "end of file";
|
| +
|
| + case 2/*TokenKind.LPAREN*/:
|
| +
|
| + return "(";
|
| +
|
| + case 3/*TokenKind.RPAREN*/:
|
| +
|
| + return ")";
|
| +
|
| + case 4/*TokenKind.LBRACK*/:
|
| +
|
| + return "[";
|
| +
|
| + case 5/*TokenKind.RBRACK*/:
|
| +
|
| + return "]";
|
| +
|
| + case 6/*TokenKind.LBRACE*/:
|
| +
|
| + return "{";
|
| +
|
| + case 7/*TokenKind.RBRACE*/:
|
| +
|
| + return "}";
|
| +
|
| + case 8/*TokenKind.COLON*/:
|
| +
|
| + return ":";
|
| +
|
| + case 9/*TokenKind.ARROW*/:
|
| +
|
| + return "=>";
|
| +
|
| + case 10/*TokenKind.SEMICOLON*/:
|
| +
|
| + return ";";
|
| +
|
| + case 11/*TokenKind.COMMA*/:
|
| +
|
| + return ",";
|
| +
|
| + case 12/*TokenKind.HASH*/:
|
| +
|
| + return "#";
|
| +
|
| + case 13/*TokenKind.HASHBANG*/:
|
| +
|
| + return "#!";
|
| +
|
| + case 14/*TokenKind.DOT*/:
|
| +
|
| + return ".";
|
| +
|
| + case 15/*TokenKind.ELLIPSIS*/:
|
| +
|
| + return "...";
|
| +
|
| + case 16/*TokenKind.INCR*/:
|
| +
|
| + return "++";
|
| +
|
| + case 17/*TokenKind.DECR*/:
|
| +
|
| + return "--";
|
| +
|
| + case 18/*TokenKind.BIT_NOT*/:
|
| +
|
| + return "~";
|
| +
|
| + case 19/*TokenKind.NOT*/:
|
| +
|
| + return "!";
|
| +
|
| + case 20/*TokenKind.ASSIGN*/:
|
| +
|
| + return "=";
|
| +
|
| + case 21/*TokenKind.ASSIGN_OR*/:
|
| +
|
| + return "|=";
|
| +
|
| + case 22/*TokenKind.ASSIGN_XOR*/:
|
| +
|
| + return "^=";
|
| +
|
| + case 23/*TokenKind.ASSIGN_AND*/:
|
| +
|
| + return "&=";
|
| +
|
| + case 24/*TokenKind.ASSIGN_SHL*/:
|
| +
|
| + return "<<=";
|
| +
|
| + case 25/*TokenKind.ASSIGN_SAR*/:
|
| +
|
| + return ">>=";
|
| +
|
| + case 26/*TokenKind.ASSIGN_SHR*/:
|
| +
|
| + return ">>>=";
|
| +
|
| + case 27/*TokenKind.ASSIGN_ADD*/:
|
| +
|
| + return "+=";
|
| +
|
| + case 28/*TokenKind.ASSIGN_SUB*/:
|
| +
|
| + return "-=";
|
| +
|
| + case 29/*TokenKind.ASSIGN_MUL*/:
|
| +
|
| + return "*=";
|
| +
|
| + case 30/*TokenKind.ASSIGN_DIV*/:
|
| +
|
| + return "/=";
|
| +
|
| + case 31/*TokenKind.ASSIGN_TRUNCDIV*/:
|
| +
|
| + return "~/=";
|
| +
|
| + case 32/*TokenKind.ASSIGN_MOD*/:
|
| +
|
| + return "%=";
|
| +
|
| + case 33/*TokenKind.CONDITIONAL*/:
|
| +
|
| + return "?";
|
| +
|
| + case 34/*TokenKind.OR*/:
|
| +
|
| + return "||";
|
| +
|
| + case 35/*TokenKind.AND*/:
|
| +
|
| + return "&&";
|
| +
|
| + case 36/*TokenKind.BIT_OR*/:
|
| +
|
| + return "|";
|
| +
|
| + case 37/*TokenKind.BIT_XOR*/:
|
| +
|
| + return "^";
|
| +
|
| + case 38/*TokenKind.BIT_AND*/:
|
| +
|
| + return "&";
|
| +
|
| + case 39/*TokenKind.SHL*/:
|
| +
|
| + return "<<";
|
| +
|
| + case 40/*TokenKind.SAR*/:
|
| +
|
| + return ">>";
|
| +
|
| + case 41/*TokenKind.SHR*/:
|
| +
|
| + return ">>>";
|
| +
|
| + case 42/*TokenKind.ADD*/:
|
| +
|
| + return "+";
|
| +
|
| + case 43/*TokenKind.SUB*/:
|
| +
|
| + return "-";
|
| +
|
| + case 44/*TokenKind.MUL*/:
|
| +
|
| + return "*";
|
| +
|
| + case 45/*TokenKind.DIV*/:
|
| +
|
| + return "/";
|
| +
|
| + case 46/*TokenKind.TRUNCDIV*/:
|
| +
|
| + return "~/";
|
| +
|
| + case 47/*TokenKind.MOD*/:
|
| +
|
| + return "%";
|
| +
|
| + case 48/*TokenKind.EQ*/:
|
| +
|
| + return "==";
|
| +
|
| + case 49/*TokenKind.NE*/:
|
| +
|
| + return "!=";
|
| +
|
| + case 50/*TokenKind.EQ_STRICT*/:
|
| +
|
| + return "===";
|
| +
|
| + case 51/*TokenKind.NE_STRICT*/:
|
| +
|
| + return "!==";
|
| +
|
| + case 52/*TokenKind.LT*/:
|
| +
|
| + return "<";
|
| +
|
| + case 53/*TokenKind.GT*/:
|
| +
|
| + return ">";
|
| +
|
| + case 54/*TokenKind.LTE*/:
|
| +
|
| + return "<=";
|
| +
|
| + case 55/*TokenKind.GTE*/:
|
| +
|
| + return ">=";
|
| +
|
| + case 56/*TokenKind.INDEX*/:
|
| +
|
| + return "[]";
|
| +
|
| + case 57/*TokenKind.SETINDEX*/:
|
| +
|
| + return "[]=";
|
| +
|
| + case 58/*TokenKind.STRING*/:
|
| +
|
| + return "string";
|
| +
|
| + case 59/*TokenKind.STRING_PART*/:
|
| +
|
| + return "string part";
|
| +
|
| + case 60/*TokenKind.INTEGER*/:
|
| +
|
| + return "integer";
|
| +
|
| + case 61/*TokenKind.HEX_INTEGER*/:
|
| +
|
| + return "hex integer";
|
| +
|
| + case 62/*TokenKind.DOUBLE*/:
|
| +
|
| + return "double";
|
| +
|
| + case 63/*TokenKind.WHITESPACE*/:
|
| +
|
| + return "whitespace";
|
| +
|
| + case 64/*TokenKind.COMMENT*/:
|
| +
|
| + return "comment";
|
| +
|
| + case 65/*TokenKind.ERROR*/:
|
| +
|
| + return "error";
|
| +
|
| + case 66/*TokenKind.INCOMPLETE_STRING*/:
|
| +
|
| + return "incomplete string";
|
| +
|
| + case 67/*TokenKind.INCOMPLETE_COMMENT*/:
|
| +
|
| + return "incomplete comment";
|
| +
|
| + case 68/*TokenKind.INCOMPLETE_MULTILINE_STRING_DQ*/:
|
| +
|
| + return "incomplete multiline string dq";
|
| +
|
| + case 69/*TokenKind.INCOMPLETE_MULTILINE_STRING_SQ*/:
|
| +
|
| + return "incomplete multiline string sq";
|
| +
|
| + case 70/*TokenKind.IDENTIFIER*/:
|
| +
|
| + return "identifier";
|
| +
|
| + case 71/*TokenKind.ABSTRACT*/:
|
| +
|
| + return "pseudo-keyword 'abstract'";
|
| +
|
| + case 72/*TokenKind.ASSERT*/:
|
| +
|
| + return "pseudo-keyword 'assert'";
|
| +
|
| + case 73/*TokenKind.CLASS*/:
|
| +
|
| + return "pseudo-keyword 'class'";
|
| +
|
| + case 74/*TokenKind.EXTENDS*/:
|
| +
|
| + return "pseudo-keyword 'extends'";
|
| +
|
| + case 75/*TokenKind.FACTORY*/:
|
| +
|
| + return "pseudo-keyword 'factory'";
|
| +
|
| + case 76/*TokenKind.GET*/:
|
| +
|
| + return "pseudo-keyword 'get'";
|
| +
|
| + case 77/*TokenKind.IMPLEMENTS*/:
|
| +
|
| + return "pseudo-keyword 'implements'";
|
| +
|
| + case 78/*TokenKind.IMPORT*/:
|
| +
|
| + return "pseudo-keyword 'import'";
|
| +
|
| + case 79/*TokenKind.INTERFACE*/:
|
| +
|
| + return "pseudo-keyword 'interface'";
|
| +
|
| + case 80/*TokenKind.LIBRARY*/:
|
| +
|
| + return "pseudo-keyword 'library'";
|
| +
|
| + case 81/*TokenKind.NATIVE*/:
|
| +
|
| + return "pseudo-keyword 'native'";
|
| +
|
| + case 82/*TokenKind.NEGATE*/:
|
| +
|
| + return "pseudo-keyword 'negate'";
|
| +
|
| + case 83/*TokenKind.OPERATOR*/:
|
| +
|
| + return "pseudo-keyword 'operator'";
|
| +
|
| + case 84/*TokenKind.SET*/:
|
| +
|
| + return "pseudo-keyword 'set'";
|
| +
|
| + case 85/*TokenKind.SOURCE*/:
|
| +
|
| + return "pseudo-keyword 'source'";
|
| +
|
| + case 86/*TokenKind.STATIC*/:
|
| +
|
| + return "pseudo-keyword 'static'";
|
| +
|
| + case 87/*TokenKind.TYPEDEF*/:
|
| +
|
| + return "pseudo-keyword 'typedef'";
|
| +
|
| + case 88/*TokenKind.AWAIT*/:
|
| +
|
| + return "keyword 'await'";
|
| +
|
| + case 89/*TokenKind.BREAK*/:
|
| +
|
| + return "keyword 'break'";
|
| +
|
| + case 90/*TokenKind.CASE*/:
|
| +
|
| + return "keyword 'case'";
|
| +
|
| + case 91/*TokenKind.CATCH*/:
|
| +
|
| + return "keyword 'catch'";
|
| +
|
| + case 92/*TokenKind.CONST*/:
|
| +
|
| + return "keyword 'const'";
|
| +
|
| + case 93/*TokenKind.CONTINUE*/:
|
| +
|
| + return "keyword 'continue'";
|
| +
|
| + case 94/*TokenKind.DEFAULT*/:
|
| +
|
| + return "keyword 'default'";
|
| +
|
| + case 95/*TokenKind.DO*/:
|
| +
|
| + return "keyword 'do'";
|
| +
|
| + case 96/*TokenKind.ELSE*/:
|
| +
|
| + return "keyword 'else'";
|
| +
|
| + case 97/*TokenKind.FALSE*/:
|
| +
|
| + return "keyword 'false'";
|
| +
|
| + case 98/*TokenKind.FINAL*/:
|
| +
|
| + return "keyword 'final'";
|
| +
|
| + case 99/*TokenKind.FINALLY*/:
|
| +
|
| + return "keyword 'finally'";
|
| +
|
| + case 100/*TokenKind.FOR*/:
|
| +
|
| + return "keyword 'for'";
|
| +
|
| + case 101/*TokenKind.IF*/:
|
| +
|
| + return "keyword 'if'";
|
| +
|
| + case 102/*TokenKind.IN*/:
|
| +
|
| + return "keyword 'in'";
|
| +
|
| + case 103/*TokenKind.IS*/:
|
| +
|
| + return "keyword 'is'";
|
| +
|
| + case 104/*TokenKind.NEW*/:
|
| +
|
| + return "keyword 'new'";
|
| +
|
| + case 105/*TokenKind.NULL*/:
|
| +
|
| + return "keyword 'null'";
|
| +
|
| + case 106/*TokenKind.RETURN*/:
|
| +
|
| + return "keyword 'return'";
|
| +
|
| + case 107/*TokenKind.SUPER*/:
|
| +
|
| + return "keyword 'super'";
|
| +
|
| + case 108/*TokenKind.SWITCH*/:
|
| +
|
| + return "keyword 'switch'";
|
| +
|
| + case 109/*TokenKind.THIS*/:
|
| +
|
| + return "keyword 'this'";
|
| +
|
| + case 110/*TokenKind.THROW*/:
|
| +
|
| + return "keyword 'throw'";
|
| +
|
| + case 111/*TokenKind.TRUE*/:
|
| +
|
| + return "keyword 'true'";
|
| +
|
| + case 112/*TokenKind.TRY*/:
|
| +
|
| + return "keyword 'try'";
|
| +
|
| + case 113/*TokenKind.VAR*/:
|
| +
|
| + return "keyword 'var'";
|
| +
|
| + case 114/*TokenKind.VOID*/:
|
| +
|
| + return "keyword 'void'";
|
| +
|
| + case 115/*TokenKind.WHILE*/:
|
| +
|
| + return "keyword 'while'";
|
| +
|
| + default:
|
| +
|
| + return "TokenKind(" + kind.toString() + ")";
|
| +
|
| + }
|
| +}
|
| +TokenKind.isIdentifier = function(kind) {
|
| + return kind >= 70/*TokenKind.IDENTIFIER*/ && kind < 88/*TokenKind.AWAIT*/;
|
| +}
|
| +TokenKind.infixPrecedence = function(kind) {
|
| + switch (kind) {
|
| + case 20/*TokenKind.ASSIGN*/:
|
| +
|
| + return 2;
|
| +
|
| + case 21/*TokenKind.ASSIGN_OR*/:
|
| +
|
| + return 2;
|
| +
|
| + case 22/*TokenKind.ASSIGN_XOR*/:
|
| +
|
| + return 2;
|
| +
|
| + case 23/*TokenKind.ASSIGN_AND*/:
|
| +
|
| + return 2;
|
| +
|
| + case 24/*TokenKind.ASSIGN_SHL*/:
|
| +
|
| + return 2;
|
| +
|
| + case 25/*TokenKind.ASSIGN_SAR*/:
|
| +
|
| + return 2;
|
| +
|
| + case 26/*TokenKind.ASSIGN_SHR*/:
|
| +
|
| + return 2;
|
| +
|
| + case 27/*TokenKind.ASSIGN_ADD*/:
|
| +
|
| + return 2;
|
| +
|
| + case 28/*TokenKind.ASSIGN_SUB*/:
|
| +
|
| + return 2;
|
| +
|
| + case 29/*TokenKind.ASSIGN_MUL*/:
|
| +
|
| + return 2;
|
| +
|
| + case 30/*TokenKind.ASSIGN_DIV*/:
|
| +
|
| + return 2;
|
| +
|
| + case 31/*TokenKind.ASSIGN_TRUNCDIV*/:
|
| +
|
| + return 2;
|
| +
|
| + case 32/*TokenKind.ASSIGN_MOD*/:
|
| +
|
| + return 2;
|
| +
|
| + case 33/*TokenKind.CONDITIONAL*/:
|
| +
|
| + return 3;
|
| +
|
| + case 34/*TokenKind.OR*/:
|
| +
|
| + return 4;
|
| +
|
| + case 35/*TokenKind.AND*/:
|
| +
|
| + return 5;
|
| +
|
| + case 36/*TokenKind.BIT_OR*/:
|
| +
|
| + return 6;
|
| +
|
| + case 37/*TokenKind.BIT_XOR*/:
|
| +
|
| + return 7;
|
| +
|
| + case 38/*TokenKind.BIT_AND*/:
|
| +
|
| + return 8;
|
| +
|
| + case 39/*TokenKind.SHL*/:
|
| +
|
| + return 11;
|
| +
|
| + case 40/*TokenKind.SAR*/:
|
| +
|
| + return 11;
|
| +
|
| + case 41/*TokenKind.SHR*/:
|
| +
|
| + return 11;
|
| +
|
| + case 42/*TokenKind.ADD*/:
|
| +
|
| + return 12;
|
| +
|
| + case 43/*TokenKind.SUB*/:
|
| +
|
| + return 12;
|
| +
|
| + case 44/*TokenKind.MUL*/:
|
| +
|
| + return 13;
|
| +
|
| + case 45/*TokenKind.DIV*/:
|
| +
|
| + return 13;
|
| +
|
| + case 46/*TokenKind.TRUNCDIV*/:
|
| +
|
| + return 13;
|
| +
|
| + case 47/*TokenKind.MOD*/:
|
| +
|
| + return 13;
|
| +
|
| + case 48/*TokenKind.EQ*/:
|
| +
|
| + return 9;
|
| +
|
| + case 49/*TokenKind.NE*/:
|
| +
|
| + return 9;
|
| +
|
| + case 50/*TokenKind.EQ_STRICT*/:
|
| +
|
| + return 9;
|
| +
|
| + case 51/*TokenKind.NE_STRICT*/:
|
| +
|
| + return 9;
|
| +
|
| + case 52/*TokenKind.LT*/:
|
| +
|
| + return 10;
|
| +
|
| + case 53/*TokenKind.GT*/:
|
| +
|
| + return 10;
|
| +
|
| + case 54/*TokenKind.LTE*/:
|
| +
|
| + return 10;
|
| +
|
| + case 55/*TokenKind.GTE*/:
|
| +
|
| + return 10;
|
| +
|
| + case 103/*TokenKind.IS*/:
|
| +
|
| + return 10;
|
| +
|
| + default:
|
| +
|
| + return -1;
|
| +
|
| + }
|
| +}
|
| +TokenKind.rawOperatorFromMethod = function(name) {
|
| + switch (name) {
|
| + case ':bit_not':
|
| +
|
| + return '~';
|
| +
|
| + case ':bit_or':
|
| +
|
| + return '|';
|
| +
|
| + case ':bit_xor':
|
| +
|
| + return '^';
|
| +
|
| + case ':bit_and':
|
| +
|
| + return '&';
|
| +
|
| + case ':shl':
|
| +
|
| + return '<<';
|
| +
|
| + case ':sar':
|
| +
|
| + return '>>';
|
| +
|
| + case ':shr':
|
| +
|
| + return '>>>';
|
| +
|
| + case ':add':
|
| +
|
| + return '+';
|
| +
|
| + case ':sub':
|
| +
|
| + return '-';
|
| +
|
| + case ':mul':
|
| +
|
| + return '*';
|
| +
|
| + case ':div':
|
| +
|
| + return '/';
|
| +
|
| + case ':truncdiv':
|
| +
|
| + return '~/';
|
| +
|
| + case ':mod':
|
| +
|
| + return '%';
|
| +
|
| + case ':eq':
|
| +
|
| + return '==';
|
| +
|
| + case ':lt':
|
| +
|
| + return '<';
|
| +
|
| + case ':gt':
|
| +
|
| + return '>';
|
| +
|
| + case ':lte':
|
| +
|
| + return '<=';
|
| +
|
| + case ':gte':
|
| +
|
| + return '>=';
|
| +
|
| + case ':index':
|
| +
|
| + return '[]';
|
| +
|
| + case ':setindex':
|
| +
|
| + return '[]=';
|
| +
|
| + case ':ne':
|
| +
|
| + return '!=';
|
| +
|
| + }
|
| +}
|
| +TokenKind.binaryMethodName = function(kind) {
|
| + switch (kind) {
|
| + case 18/*TokenKind.BIT_NOT*/:
|
| +
|
| + return ':bit_not';
|
| +
|
| + case 36/*TokenKind.BIT_OR*/:
|
| +
|
| + return ':bit_or';
|
| +
|
| + case 37/*TokenKind.BIT_XOR*/:
|
| +
|
| + return ':bit_xor';
|
| +
|
| + case 38/*TokenKind.BIT_AND*/:
|
| +
|
| + return ':bit_and';
|
| +
|
| + case 39/*TokenKind.SHL*/:
|
| +
|
| + return ':shl';
|
| +
|
| + case 40/*TokenKind.SAR*/:
|
| +
|
| + return ':sar';
|
| +
|
| + case 41/*TokenKind.SHR*/:
|
| +
|
| + return ':shr';
|
| +
|
| + case 42/*TokenKind.ADD*/:
|
| +
|
| + return ':add';
|
| +
|
| + case 43/*TokenKind.SUB*/:
|
| +
|
| + return ':sub';
|
| +
|
| + case 44/*TokenKind.MUL*/:
|
| +
|
| + return ':mul';
|
| +
|
| + case 45/*TokenKind.DIV*/:
|
| +
|
| + return ':div';
|
| +
|
| + case 46/*TokenKind.TRUNCDIV*/:
|
| +
|
| + return ':truncdiv';
|
| +
|
| + case 47/*TokenKind.MOD*/:
|
| +
|
| + return ':mod';
|
| +
|
| + case 48/*TokenKind.EQ*/:
|
| +
|
| + return ':eq';
|
| +
|
| + case 52/*TokenKind.LT*/:
|
| +
|
| + return ':lt';
|
| +
|
| + case 53/*TokenKind.GT*/:
|
| +
|
| + return ':gt';
|
| +
|
| + case 54/*TokenKind.LTE*/:
|
| +
|
| + return ':lte';
|
| +
|
| + case 55/*TokenKind.GTE*/:
|
| +
|
| + return ':gte';
|
| +
|
| + case 56/*TokenKind.INDEX*/:
|
| +
|
| + return ':index';
|
| +
|
| + case 57/*TokenKind.SETINDEX*/:
|
| +
|
| + return ':setindex';
|
| +
|
| + }
|
| +}
|
| +TokenKind.kindFromAssign = function(kind) {
|
| + if (kind == 20/*TokenKind.ASSIGN*/) return 0;
|
| + if (kind > 20/*TokenKind.ASSIGN*/ && kind <= 32/*TokenKind.ASSIGN_MOD*/) {
|
| + return kind + (15)/*(ADD - ASSIGN_ADD)*/;
|
| + }
|
| + return -1;
|
| +}
|
| +// ********** Code for Parser **************
|
| +function Parser(source, diet, throwOnIncomplete, optionalSemicolons, startOffset) {
|
| + this._inhibitLambda = false
|
| + this._afterParensIndex = 0
|
| + this._recover = false
|
| + this.source = source;
|
| + this.diet = diet;
|
| + this.throwOnIncomplete = throwOnIncomplete;
|
| + this.optionalSemicolons = optionalSemicolons;
|
| + // Initializers done
|
| + this.tokenizer = new Tokenizer(this.source, true, startOffset);
|
| + this._peekToken = this.tokenizer.next();
|
| + this._afterParens = [];
|
| +}
|
| +Parser.prototype.get$enableAwait = function() {
|
| + return $globals.experimentalAwaitPhase != null;
|
| +}
|
| +Parser.prototype.isPrematureEndOfFile = function() {
|
| + if (this.throwOnIncomplete && this._maybeEat(1/*TokenKind.END_OF_FILE*/) || this._maybeEat(68/*TokenKind.INCOMPLETE_MULTILINE_STRING_DQ*/) || this._maybeEat(69/*TokenKind.INCOMPLETE_MULTILINE_STRING_SQ*/)) {
|
| + $throw(new IncompleteSourceException(this._previousToken));
|
| + }
|
| + else if (this._maybeEat(1/*TokenKind.END_OF_FILE*/)) {
|
| + this._lang_error('unexpected end of file', this._peekToken.get$span());
|
| + return true;
|
| + }
|
| + else {
|
| + return false;
|
| + }
|
| +}
|
| +Parser.prototype._recoverTo = function(kind1, kind2, kind3) {
|
| + while (!this.isPrematureEndOfFile()) {
|
| + var kind = this._peek();
|
| + if (kind == kind1 || kind == kind2 || kind == kind3) {
|
| + this._recover = false;
|
| + return true;
|
| + }
|
| + this._lang_next();
|
| + }
|
| + return false;
|
| +}
|
| +Parser.prototype._peek = function() {
|
| + return this._peekToken.kind;
|
| +}
|
| +Parser.prototype._lang_next = function() {
|
| + this._previousToken = this._peekToken;
|
| + this._peekToken = this.tokenizer.next();
|
| + return this._previousToken;
|
| +}
|
| +Parser.prototype._peekKind = function(kind) {
|
| + return this._peekToken.kind == kind;
|
| +}
|
| +Parser.prototype._peekIdentifier = function() {
|
| + return this._isIdentifier(this._peekToken.kind);
|
| +}
|
| +Parser.prototype._isIdentifier = function(kind) {
|
| + return TokenKind.isIdentifier(kind) || (!this.get$enableAwait() && $eq(kind, 88/*TokenKind.AWAIT*/));
|
| +}
|
| +Parser.prototype._maybeEat = function(kind) {
|
| + if (this._peekToken.kind == kind) {
|
| + this._previousToken = this._peekToken;
|
| + this._peekToken = this.tokenizer.next();
|
| + return true;
|
| + }
|
| + else {
|
| + return false;
|
| + }
|
| +}
|
| +Parser.prototype._eat = function(kind) {
|
| + if (!this._maybeEat(kind)) {
|
| + this._errorExpected(TokenKind.kindToString(kind));
|
| + }
|
| +}
|
| +Parser.prototype._eatSemicolon = function() {
|
| + if (this.optionalSemicolons && this._peekKind(1/*TokenKind.END_OF_FILE*/)) return;
|
| + this._eat(10/*TokenKind.SEMICOLON*/);
|
| +}
|
| +Parser.prototype._errorExpected = function(expected) {
|
| + if (this.throwOnIncomplete) this.isPrematureEndOfFile();
|
| + var tok = this._lang_next();
|
| + if ((tok instanceof ErrorToken) && tok.message != null) {
|
| + this._lang_error(tok.message, tok.span);
|
| + }
|
| + else {
|
| + this._lang_error(('expected ' + expected + ', but found ' + tok), tok.span);
|
| + }
|
| +}
|
| +Parser.prototype._lang_error = function(message, location) {
|
| + if (this._recover) return;
|
| + if (location == null) {
|
| + location = this._peekToken.get$span();
|
| + }
|
| + $globals.world.fatal(message, location);
|
| + this._recover = true;
|
| +}
|
| +Parser.prototype._skipBlock = function() {
|
| + var depth = 1;
|
| + this._eat(6/*TokenKind.LBRACE*/);
|
| + while (true) {
|
| + var tok = this._lang_next();
|
| + if ($eq(tok.kind, 6/*TokenKind.LBRACE*/)) {
|
| + depth += 1;
|
| + }
|
| + else if ($eq(tok.kind, 7/*TokenKind.RBRACE*/)) {
|
| + depth -= 1;
|
| + if (depth == 0) return;
|
| + }
|
| + else if ($eq(tok.kind, 1/*TokenKind.END_OF_FILE*/)) {
|
| + this._lang_error('unexpected end of file during diet parse', tok.span);
|
| + return;
|
| + }
|
| + }
|
| +}
|
| +Parser.prototype._makeSpan = function(start) {
|
| + return new SourceSpan(this.source, start, this._previousToken.end);
|
| +}
|
| +Parser.prototype.compilationUnit = function() {
|
| + var ret = [];
|
| + this._maybeEat(13/*TokenKind.HASHBANG*/);
|
| + while (this._peekKind(12/*TokenKind.HASH*/)) {
|
| + ret.add$1(this.directive());
|
| + }
|
| + this._recover = false;
|
| + while (!this._maybeEat(1/*TokenKind.END_OF_FILE*/)) {
|
| + ret.add$1(this.topLevelDefinition());
|
| + }
|
| + this._recover = false;
|
| + return ret;
|
| +}
|
| +Parser.prototype.directive = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(12/*TokenKind.HASH*/);
|
| + var name = this.identifier();
|
| + var args = this.arguments();
|
| + this._eatSemicolon();
|
| + return new DirectiveDefinition(name, args, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.topLevelDefinition = function() {
|
| + switch (this._peek()) {
|
| + case 73/*TokenKind.CLASS*/:
|
| +
|
| + return this.classDefinition(73/*TokenKind.CLASS*/);
|
| +
|
| + case 79/*TokenKind.INTERFACE*/:
|
| +
|
| + return this.classDefinition(79/*TokenKind.INTERFACE*/);
|
| +
|
| + case 87/*TokenKind.TYPEDEF*/:
|
| +
|
| + return this.functionTypeAlias();
|
| +
|
| + default:
|
| +
|
| + return this.declaration(true);
|
| +
|
| + }
|
| +}
|
| +Parser.prototype.classDefinition = function(kind) {
|
| + var start = this._peekToken.start;
|
| + this._eat(kind);
|
| + var name = this.identifier();
|
| + var typeParams = null;
|
| + if (this._peekKind(52/*TokenKind.LT*/)) {
|
| + typeParams = this.typeParameters();
|
| + }
|
| + var _extends = null;
|
| + if (this._maybeEat(74/*TokenKind.EXTENDS*/)) {
|
| + _extends = this.typeList();
|
| + }
|
| + var _implements = null;
|
| + if (this._maybeEat(77/*TokenKind.IMPLEMENTS*/)) {
|
| + _implements = this.typeList();
|
| + }
|
| + var _native = null;
|
| + if (this._maybeEat(81/*TokenKind.NATIVE*/)) {
|
| + _native = this.maybeStringLiteral();
|
| + if (_native != null) _native = new NativeType(_native);
|
| + }
|
| + var _factory = null;
|
| + if (this._maybeEat(75/*TokenKind.FACTORY*/)) {
|
| + _factory = this.nameTypeReference();
|
| + if (this._peekKind(52/*TokenKind.LT*/)) {
|
| + this.typeParameters();
|
| + }
|
| + }
|
| + var body = [];
|
| + if (this._maybeEat(6/*TokenKind.LBRACE*/)) {
|
| + while (!this._maybeEat(7/*TokenKind.RBRACE*/)) {
|
| + body.add$1(this.declaration(true));
|
| + if (this._recover) {
|
| + if (!this._recoverTo(7/*TokenKind.RBRACE*/, 10/*TokenKind.SEMICOLON*/)) break;
|
| + this._maybeEat(10/*TokenKind.SEMICOLON*/);
|
| + }
|
| + }
|
| + }
|
| + else {
|
| + this._errorExpected('block starting with "{" or ";"');
|
| + }
|
| + return new TypeDefinition(kind == 73/*TokenKind.CLASS*/, name, typeParams, _extends, _implements, _native, _factory, body, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.functionTypeAlias = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(87/*TokenKind.TYPEDEF*/);
|
| + var di = this.declaredIdentifier(false);
|
| + var typeParams = null;
|
| + if (this._peekKind(52/*TokenKind.LT*/)) {
|
| + typeParams = this.typeParameters();
|
| + }
|
| + var formals = this.formalParameterList();
|
| + this._eatSemicolon();
|
| + var func = new FunctionDefinition(null, di.type, di.name, formals, null, null, null, null, this._makeSpan(start));
|
| + return new FunctionTypeDefinition(func, typeParams, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.initializers = function() {
|
| + this._inhibitLambda = true;
|
| + var ret = [];
|
| + do {
|
| + ret.add$1(this.expression());
|
| + }
|
| + while (this._maybeEat(11/*TokenKind.COMMA*/))
|
| + this._inhibitLambda = false;
|
| + return ret;
|
| +}
|
| +Parser.prototype.get$initializers = function() {
|
| + return Parser.prototype.initializers.bind(this);
|
| +}
|
| +Parser.prototype.functionBody = function(inExpression) {
|
| + var start = this._peekToken.start;
|
| + if (this._maybeEat(9/*TokenKind.ARROW*/)) {
|
| + var expr = this.expression();
|
| + if (!inExpression) {
|
| + this._eatSemicolon();
|
| + }
|
| + return new ReturnStatement(expr, this._makeSpan(start));
|
| + }
|
| + else if (this._peekKind(6/*TokenKind.LBRACE*/)) {
|
| + if (this.diet) {
|
| + this._skipBlock();
|
| + return new DietStatement(this._makeSpan(start));
|
| + }
|
| + else {
|
| + return this.block();
|
| + }
|
| + }
|
| + else if (!inExpression) {
|
| + if (this._maybeEat(10/*TokenKind.SEMICOLON*/)) {
|
| + return null;
|
| + }
|
| + }
|
| + this._lang_error('Expected function body (neither { nor => found)');
|
| +}
|
| +Parser.prototype.finishField = function(start, modifiers, typeParams, type, name, value) {
|
| + if (typeParams != null) {
|
| + $globals.world.internalError('trying to create a generic field', this._makeSpan(start));
|
| + }
|
| + var names = [name];
|
| + var values = [value];
|
| + while (this._maybeEat(11/*TokenKind.COMMA*/)) {
|
| + names.add$1(this.identifier());
|
| + if (this._maybeEat(20/*TokenKind.ASSIGN*/)) {
|
| + values.add$1(this.expression());
|
| + }
|
| + else {
|
| + values.add$1();
|
| + }
|
| + }
|
| + this._eatSemicolon();
|
| + return new VariableDefinition(modifiers, type, names, values, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.finishDefinition = function(start, modifiers, di, typeParams) {
|
| + switch (this._peek()) {
|
| + case 2/*TokenKind.LPAREN*/:
|
| +
|
| + var formals = this.formalParameterList();
|
| + var inits = null, native_ = null;
|
| + if (this._maybeEat(8/*TokenKind.COLON*/)) {
|
| + inits = this.initializers();
|
| + }
|
| + if (this._maybeEat(81/*TokenKind.NATIVE*/)) {
|
| + native_ = this.maybeStringLiteral();
|
| + if (native_ == null) native_ = '';
|
| + }
|
| + var body = this.functionBody(false);
|
| + if (di.name == null) {
|
| + di.name = di.type.name;
|
| + }
|
| + return new FunctionDefinition(modifiers, di.type, di.name, formals, typeParams, inits, native_, body, this._makeSpan(start));
|
| +
|
| + case 20/*TokenKind.ASSIGN*/:
|
| +
|
| + this._eat(20/*TokenKind.ASSIGN*/);
|
| + var value = this.expression();
|
| + return this.finishField(start, modifiers, typeParams, di.type, di.name, value);
|
| +
|
| + case 11/*TokenKind.COMMA*/:
|
| + case 10/*TokenKind.SEMICOLON*/:
|
| +
|
| + return this.finishField(start, modifiers, typeParams, di.type, di.name, null);
|
| +
|
| + default:
|
| +
|
| + this._errorExpected('declaration');
|
| + return null;
|
| +
|
| + }
|
| +}
|
| +Parser.prototype.declaration = function(includeOperators) {
|
| + var start = this._peekToken.start;
|
| + if (this._peekKind(75/*TokenKind.FACTORY*/)) {
|
| + return this.factoryConstructorDeclaration();
|
| + }
|
| + var modifiers = this._readModifiers();
|
| + return this.finishDefinition(start, modifiers, this.declaredIdentifier(includeOperators), null);
|
| +}
|
| +Parser.prototype.factoryConstructorDeclaration = function() {
|
| + var start = this._peekToken.start;
|
| + var factoryToken = this._lang_next();
|
| + var names = [this.identifier()];
|
| + while (this._maybeEat(14/*TokenKind.DOT*/)) {
|
| + names.add$1(this.identifier());
|
| + }
|
| + var typeParams = null;
|
| + if (this._peekKind(52/*TokenKind.LT*/)) {
|
| + typeParams = this.typeParameters();
|
| + }
|
| + var name = null;
|
| + var type = null;
|
| + if (this._maybeEat(14/*TokenKind.DOT*/)) {
|
| + name = this.identifier();
|
| + }
|
| + else if (typeParams == null) {
|
| + if (names.length > 1) {
|
| + name = names.removeLast$0();
|
| + }
|
| + else {
|
| + name = new Identifier('', names.$index(0).span);
|
| + }
|
| + }
|
| + else {
|
| + name = new Identifier('', names.$index(0).span);
|
| + }
|
| + if (names.length > 1) {
|
| + this._lang_error('unsupported qualified name for factory', names.$index(0).span);
|
| + }
|
| + type = new NameTypeReference(false, names.$index(0), null, names.$index(0).span);
|
| + var di = new DeclaredIdentifier(type, name, this._makeSpan(start));
|
| + return this.finishDefinition(start, [factoryToken], di, typeParams);
|
| +}
|
| +Parser.prototype.statement = function() {
|
| + switch (this._peek()) {
|
| + case 89/*TokenKind.BREAK*/:
|
| +
|
| + return this.breakStatement();
|
| +
|
| + case 93/*TokenKind.CONTINUE*/:
|
| +
|
| + return this.continueStatement();
|
| +
|
| + case 106/*TokenKind.RETURN*/:
|
| +
|
| + return this.returnStatement();
|
| +
|
| + case 110/*TokenKind.THROW*/:
|
| +
|
| + return this.throwStatement();
|
| +
|
| + case 72/*TokenKind.ASSERT*/:
|
| +
|
| + return this.assertStatement();
|
| +
|
| + case 115/*TokenKind.WHILE*/:
|
| +
|
| + return this.whileStatement();
|
| +
|
| + case 95/*TokenKind.DO*/:
|
| +
|
| + return this.doStatement();
|
| +
|
| + case 100/*TokenKind.FOR*/:
|
| +
|
| + return this.forStatement();
|
| +
|
| + case 101/*TokenKind.IF*/:
|
| +
|
| + return this.ifStatement();
|
| +
|
| + case 108/*TokenKind.SWITCH*/:
|
| +
|
| + return this.switchStatement();
|
| +
|
| + case 112/*TokenKind.TRY*/:
|
| +
|
| + return this.tryStatement();
|
| +
|
| + case 6/*TokenKind.LBRACE*/:
|
| +
|
| + return this.block();
|
| +
|
| + case 10/*TokenKind.SEMICOLON*/:
|
| +
|
| + return this.emptyStatement();
|
| +
|
| + case 98/*TokenKind.FINAL*/:
|
| +
|
| + return this.declaration(false);
|
| +
|
| + case 113/*TokenKind.VAR*/:
|
| +
|
| + return this.declaration(false);
|
| +
|
| + default:
|
| +
|
| + return this.finishExpressionAsStatement(this.expression());
|
| +
|
| + }
|
| +}
|
| +Parser.prototype.finishExpressionAsStatement = function(expr) {
|
| + var start = expr.span.start;
|
| + if (this._maybeEat(8/*TokenKind.COLON*/)) {
|
| + var label = this._makeLabel(expr);
|
| + return new LabeledStatement(label, this.statement(), this._makeSpan(start));
|
| + }
|
| + if ((expr instanceof LambdaExpression)) {
|
| + if (!(expr.get$func().body instanceof BlockStatement)) {
|
| + this._eatSemicolon();
|
| + expr.get$func().span = this._makeSpan(start);
|
| + }
|
| + return expr.get$func();
|
| + }
|
| + else if ((expr instanceof DeclaredIdentifier)) {
|
| + var value = null;
|
| + if (this._maybeEat(20/*TokenKind.ASSIGN*/)) {
|
| + value = this.expression();
|
| + }
|
| + return this.finishField(start, null, null, expr.type, expr.name, value);
|
| + }
|
| + else if (this._isBin(expr, 20/*TokenKind.ASSIGN*/) && ((expr.x instanceof DeclaredIdentifier))) {
|
| + var di = expr.x;
|
| + return this.finishField(start, null, null, di.type, di.name, expr.y);
|
| + }
|
| + else if (this._isBin(expr, 52/*TokenKind.LT*/) && this._maybeEat(11/*TokenKind.COMMA*/)) {
|
| + var baseType = this._makeType(expr.x);
|
| + var typeArgs = [this._makeType(expr.y)];
|
| + var gt = this._finishTypeArguments(baseType, 0, typeArgs);
|
| + var name = this.identifier();
|
| + var value = null;
|
| + if (this._maybeEat(20/*TokenKind.ASSIGN*/)) {
|
| + value = this.expression();
|
| + }
|
| + return this.finishField(expr.span.start, null, null, gt, name, value);
|
| + }
|
| + else {
|
| + this._eatSemicolon();
|
| + return new ExpressionStatement(expr, this._makeSpan(expr.span.start));
|
| + }
|
| +}
|
| +Parser.prototype.testCondition = function() {
|
| + this._eatLeftParen();
|
| + var ret = this.expression();
|
| + this._eat(3/*TokenKind.RPAREN*/);
|
| + return ret;
|
| +}
|
| +Parser.prototype.block = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(6/*TokenKind.LBRACE*/);
|
| + var stmts = [];
|
| + while (!this._maybeEat(7/*TokenKind.RBRACE*/)) {
|
| + stmts.add$1(this.statement());
|
| + if (this._recover && !this._recoverTo(7/*TokenKind.RBRACE*/, 10/*TokenKind.SEMICOLON*/)) break;
|
| + }
|
| + this._recover = false;
|
| + return new BlockStatement(stmts, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.get$block = function() {
|
| + return Parser.prototype.block.bind(this);
|
| +}
|
| +Parser.prototype.emptyStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(10/*TokenKind.SEMICOLON*/);
|
| + return new EmptyStatement(this._makeSpan(start));
|
| +}
|
| +Parser.prototype.ifStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(101/*TokenKind.IF*/);
|
| + var test = this.testCondition();
|
| + var trueBranch = this.statement();
|
| + var falseBranch = null;
|
| + if (this._maybeEat(96/*TokenKind.ELSE*/)) {
|
| + falseBranch = this.statement();
|
| + }
|
| + return new IfStatement(test, trueBranch, falseBranch, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.whileStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(115/*TokenKind.WHILE*/);
|
| + var test = this.testCondition();
|
| + var body = this.statement();
|
| + return new WhileStatement(test, body, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.doStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(95/*TokenKind.DO*/);
|
| + var body = this.statement();
|
| + this._eat(115/*TokenKind.WHILE*/);
|
| + var test = this.testCondition();
|
| + this._eatSemicolon();
|
| + return new DoStatement(body, test, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.forStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(100/*TokenKind.FOR*/);
|
| + this._eatLeftParen();
|
| + var init = this.forInitializerStatement(start);
|
| + if ((init instanceof ForInStatement)) {
|
| + return init;
|
| + }
|
| + var test = null;
|
| + if (!this._maybeEat(10/*TokenKind.SEMICOLON*/)) {
|
| + test = this.expression();
|
| + this._eatSemicolon();
|
| + }
|
| + var step = [];
|
| + if (!this._maybeEat(3/*TokenKind.RPAREN*/)) {
|
| + step.add$1(this.expression());
|
| + while (this._maybeEat(11/*TokenKind.COMMA*/)) {
|
| + step.add$1(this.expression());
|
| + }
|
| + this._eat(3/*TokenKind.RPAREN*/);
|
| + }
|
| + var body = this.statement();
|
| + return new ForStatement(init, test, step, body, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.forInitializerStatement = function(start) {
|
| + if (this._maybeEat(10/*TokenKind.SEMICOLON*/)) {
|
| + return null;
|
| + }
|
| + else {
|
| + var init = this.expression();
|
| + if (this._peekKind(11/*TokenKind.COMMA*/) && this._isBin(init, 52/*TokenKind.LT*/)) {
|
| + this._eat(11/*TokenKind.COMMA*/);
|
| + var baseType = this._makeType(init.x);
|
| + var typeArgs = [this._makeType(init.y)];
|
| + var gt = this._finishTypeArguments(baseType, 0, typeArgs);
|
| + var name = this.identifier();
|
| + init = new DeclaredIdentifier(gt, name, this._makeSpan(init.span.start));
|
| + }
|
| + if (this._maybeEat(102/*TokenKind.IN*/)) {
|
| + return this._finishForIn(start, this._makeDeclaredIdentifier(init));
|
| + }
|
| + else {
|
| + return this.finishExpressionAsStatement(init);
|
| + }
|
| + }
|
| +}
|
| +Parser.prototype._finishForIn = function(start, di) {
|
| + var expr = this.expression();
|
| + this._eat(3/*TokenKind.RPAREN*/);
|
| + var body = this.statement();
|
| + return new ForInStatement(di, expr, body, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.tryStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(112/*TokenKind.TRY*/);
|
| + var body = this.block();
|
| + var catches = [];
|
| + while (this._peekKind(91/*TokenKind.CATCH*/)) {
|
| + catches.add$1(this.catchNode());
|
| + }
|
| + var finallyBlock = null;
|
| + if (this._maybeEat(99/*TokenKind.FINALLY*/)) {
|
| + finallyBlock = this.block();
|
| + }
|
| + return new TryStatement(body, catches, finallyBlock, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.catchNode = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(91/*TokenKind.CATCH*/);
|
| + this._eatLeftParen();
|
| + var exc = this.declaredIdentifier(false);
|
| + var trace = null;
|
| + if (this._maybeEat(11/*TokenKind.COMMA*/)) {
|
| + trace = this.declaredIdentifier(false);
|
| + }
|
| + this._eat(3/*TokenKind.RPAREN*/);
|
| + var body = this.block();
|
| + return new CatchNode(exc, trace, body, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.switchStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(108/*TokenKind.SWITCH*/);
|
| + var test = this.testCondition();
|
| + var cases = [];
|
| + this._eat(6/*TokenKind.LBRACE*/);
|
| + while (!this._maybeEat(7/*TokenKind.RBRACE*/)) {
|
| + cases.add$1(this.caseNode());
|
| + }
|
| + return new SwitchStatement(test, cases, this._makeSpan(start));
|
| +}
|
| +Parser.prototype._peekCaseEnd = function() {
|
| + var kind = this._peek();
|
| + return $eq(kind, 7/*TokenKind.RBRACE*/) || $eq(kind, 90/*TokenKind.CASE*/) || $eq(kind, 94/*TokenKind.DEFAULT*/);
|
| +}
|
| +Parser.prototype.caseNode = function() {
|
| + var start = this._peekToken.start;
|
| + var label = null;
|
| + if (this._peekIdentifier()) {
|
| + label = this.identifier();
|
| + this._eat(8/*TokenKind.COLON*/);
|
| + }
|
| + var cases = [];
|
| + while (true) {
|
| + if (this._maybeEat(90/*TokenKind.CASE*/)) {
|
| + cases.add$1(this.expression());
|
| + this._eat(8/*TokenKind.COLON*/);
|
| + }
|
| + else if (this._maybeEat(94/*TokenKind.DEFAULT*/)) {
|
| + cases.add$1();
|
| + this._eat(8/*TokenKind.COLON*/);
|
| + }
|
| + else {
|
| + break;
|
| + }
|
| + }
|
| + if ($eq(cases.length, 0)) {
|
| + this._lang_error('case or default');
|
| + }
|
| + var stmts = [];
|
| + while (!this._peekCaseEnd()) {
|
| + stmts.add$1(this.statement());
|
| + if (this._recover && !this._recoverTo(7/*TokenKind.RBRACE*/, 90/*TokenKind.CASE*/, 94/*TokenKind.DEFAULT*/)) {
|
| + break;
|
| + }
|
| + }
|
| + return new CaseNode(label, cases, stmts, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.returnStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(106/*TokenKind.RETURN*/);
|
| + var expr;
|
| + if (this._maybeEat(10/*TokenKind.SEMICOLON*/)) {
|
| + expr = null;
|
| + }
|
| + else {
|
| + expr = this.expression();
|
| + this._eatSemicolon();
|
| + }
|
| + return new ReturnStatement(expr, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.throwStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(110/*TokenKind.THROW*/);
|
| + var expr;
|
| + if (this._maybeEat(10/*TokenKind.SEMICOLON*/)) {
|
| + expr = null;
|
| + }
|
| + else {
|
| + expr = this.expression();
|
| + this._eatSemicolon();
|
| + }
|
| + return new ThrowStatement(expr, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.assertStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(72/*TokenKind.ASSERT*/);
|
| + this._eatLeftParen();
|
| + var expr = this.expression();
|
| + this._eat(3/*TokenKind.RPAREN*/);
|
| + this._eatSemicolon();
|
| + return new AssertStatement(expr, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.breakStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(89/*TokenKind.BREAK*/);
|
| + var name = null;
|
| + if (this._peekIdentifier()) {
|
| + name = this.identifier();
|
| + }
|
| + this._eatSemicolon();
|
| + return new BreakStatement(name, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.continueStatement = function() {
|
| + var start = this._peekToken.start;
|
| + this._eat(93/*TokenKind.CONTINUE*/);
|
| + var name = null;
|
| + if (this._peekIdentifier()) {
|
| + name = this.identifier();
|
| + }
|
| + this._eatSemicolon();
|
| + return new ContinueStatement(name, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.expression = function() {
|
| + return this.infixExpression(0);
|
| +}
|
| +Parser.prototype._makeType = function(expr) {
|
| + if ((expr instanceof VarExpression)) {
|
| + return new NameTypeReference(false, expr.name, null, expr.span);
|
| + }
|
| + else if ((expr instanceof DotExpression)) {
|
| + var type = this._makeType(expr.self);
|
| + if (type.get$names() == null) {
|
| + type.set$names([expr.name]);
|
| + }
|
| + else {
|
| + type.get$names().add$1(expr.name);
|
| + }
|
| + type.span = expr.span;
|
| + return type;
|
| + }
|
| + else {
|
| + this._lang_error('expected type reference');
|
| + return null;
|
| + }
|
| +}
|
| +Parser.prototype.infixExpression = function(precedence) {
|
| + return this.finishInfixExpression(this.unaryExpression(), precedence);
|
| +}
|
| +Parser.prototype._finishDeclaredId = function(type) {
|
| + var name = this.identifier();
|
| + return this.finishPostfixExpression(new DeclaredIdentifier(type, name, this._makeSpan(type.span.start)));
|
| +}
|
| +Parser.prototype._fixAsType = function(x) {
|
| + if (this._maybeEat(53/*TokenKind.GT*/)) {
|
| + var base = this._makeType(x.x);
|
| + var typeParam = this._makeType(x.y);
|
| + var type = new GenericTypeReference(base, [typeParam], 0, this._makeSpan(x.span.start));
|
| + return this._finishDeclaredId(type);
|
| + }
|
| + else {
|
| + var base = this._makeType(x.x);
|
| + var paramBase = this._makeType(x.y);
|
| + var firstParam = this.addTypeArguments(paramBase, 1);
|
| + var type;
|
| + if (firstParam.depth <= 0) {
|
| + type = new GenericTypeReference(base, [firstParam], 0, this._makeSpan(x.span.start));
|
| + }
|
| + else if (this._maybeEat(11/*TokenKind.COMMA*/)) {
|
| + type = this._finishTypeArguments(base, 0, [firstParam]);
|
| + }
|
| + else {
|
| + this._eat(53/*TokenKind.GT*/);
|
| + type = new GenericTypeReference(base, [firstParam], 0, this._makeSpan(x.span.start));
|
| + }
|
| + return this._finishDeclaredId(type);
|
| + }
|
| +}
|
| +Parser.prototype.finishInfixExpression = function(x, precedence) {
|
| + while (true) {
|
| + var kind = this._peek();
|
| + var prec = TokenKind.infixPrecedence(this._peek());
|
| + if (prec >= precedence) {
|
| + if (kind == 52/*TokenKind.LT*/ || kind == 53/*TokenKind.GT*/) {
|
| + if (this._isBin(x, 52/*TokenKind.LT*/)) {
|
| + return this._fixAsType(x);
|
| + }
|
| + }
|
| + var op = this._lang_next();
|
| + if ($eq(op.kind, 103/*TokenKind.IS*/)) {
|
| + var isTrue = !this._maybeEat(19/*TokenKind.NOT*/);
|
| + var typeRef = this.type(0);
|
| + x = new IsExpression(isTrue, x, typeRef, this._makeSpan(x.span.start));
|
| + continue;
|
| + }
|
| + var y = this.infixExpression($eq(prec, 2) ? prec : prec + 1);
|
| + if ($eq(op.kind, 33/*TokenKind.CONDITIONAL*/)) {
|
| + this._eat(8/*TokenKind.COLON*/);
|
| + var z = this.infixExpression(prec);
|
| + x = new ConditionalExpression(x, y, z, this._makeSpan(x.span.start));
|
| + }
|
| + else {
|
| + x = new BinaryExpression(op, x, y, this._makeSpan(x.span.start));
|
| + }
|
| + }
|
| + else {
|
| + break;
|
| + }
|
| + }
|
| + return x;
|
| +}
|
| +Parser.prototype._isPrefixUnaryOperator = function(kind) {
|
| + switch (kind) {
|
| + case 42/*TokenKind.ADD*/:
|
| + case 43/*TokenKind.SUB*/:
|
| + case 19/*TokenKind.NOT*/:
|
| + case 18/*TokenKind.BIT_NOT*/:
|
| + case 16/*TokenKind.INCR*/:
|
| + case 17/*TokenKind.DECR*/:
|
| +
|
| + return true;
|
| +
|
| + default:
|
| +
|
| + return false;
|
| +
|
| + }
|
| +}
|
| +Parser.prototype.unaryExpression = function() {
|
| + var start = this._peekToken.start;
|
| + if (this._isPrefixUnaryOperator(this._peek())) {
|
| + var tok = this._lang_next();
|
| + var expr = this.unaryExpression();
|
| + return new UnaryExpression(tok, expr, this._makeSpan(start));
|
| + }
|
| + else if (this.get$enableAwait() && this._maybeEat(88/*TokenKind.AWAIT*/)) {
|
| + var expr = this.unaryExpression();
|
| + return new AwaitExpression(expr, this._makeSpan(start));
|
| + }
|
| + return this.finishPostfixExpression(this.primary());
|
| +}
|
| +Parser.prototype.argument = function() {
|
| + var start = this._peekToken.start;
|
| + var expr;
|
| + var label = null;
|
| + if (this._maybeEat(15/*TokenKind.ELLIPSIS*/)) {
|
| + label = new Identifier('...', this._makeSpan(start));
|
| + }
|
| + expr = this.expression();
|
| + if (label == null && this._maybeEat(8/*TokenKind.COLON*/)) {
|
| + label = this._makeLabel(expr);
|
| + expr = this.expression();
|
| + }
|
| + return new ArgumentNode(label, expr, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.arguments = function() {
|
| + var args = [];
|
| + this._eatLeftParen();
|
| + var saved = this._inhibitLambda;
|
| + this._inhibitLambda = false;
|
| + if (!this._maybeEat(3/*TokenKind.RPAREN*/)) {
|
| + do {
|
| + args.add$1(this.argument());
|
| + }
|
| + while (this._maybeEat(11/*TokenKind.COMMA*/))
|
| + this._eat(3/*TokenKind.RPAREN*/);
|
| + }
|
| + this._inhibitLambda = saved;
|
| + return args;
|
| +}
|
| +Parser.prototype.get$arguments = function() {
|
| + return Parser.prototype.arguments.bind(this);
|
| +}
|
| +Parser.prototype.finishPostfixExpression = function(expr) {
|
| + switch (this._peek()) {
|
| + case 2/*TokenKind.LPAREN*/:
|
| +
|
| + return this.finishCallOrLambdaExpression(expr);
|
| +
|
| + case 4/*TokenKind.LBRACK*/:
|
| +
|
| + this._eat(4/*TokenKind.LBRACK*/);
|
| + var index = this.expression();
|
| + this._eat(5/*TokenKind.RBRACK*/);
|
| + return this.finishPostfixExpression(new IndexExpression(expr, index, this._makeSpan(expr.span.start)));
|
| +
|
| + case 14/*TokenKind.DOT*/:
|
| +
|
| + this._eat(14/*TokenKind.DOT*/);
|
| + var name = this.identifier();
|
| + var ret = new DotExpression(expr, name, this._makeSpan(expr.span.start));
|
| + return this.finishPostfixExpression(ret);
|
| +
|
| + case 16/*TokenKind.INCR*/:
|
| + case 17/*TokenKind.DECR*/:
|
| +
|
| + var tok = this._lang_next();
|
| + return new PostfixExpression(expr, tok, this._makeSpan(expr.span.start));
|
| +
|
| + case 9/*TokenKind.ARROW*/:
|
| + case 6/*TokenKind.LBRACE*/:
|
| +
|
| + return expr;
|
| +
|
| + default:
|
| +
|
| + if (this._peekIdentifier()) {
|
| + return this.finishPostfixExpression(new DeclaredIdentifier(this._makeType(expr), this.identifier(), this._makeSpan(expr.span.start)));
|
| + }
|
| + else {
|
| + return expr;
|
| + }
|
| +
|
| + }
|
| +}
|
| +Parser.prototype.finishCallOrLambdaExpression = function(expr) {
|
| + if (this._atClosureParameters()) {
|
| + var formals = this.formalParameterList();
|
| + var body = this.functionBody(true);
|
| + return this._makeFunction(expr, formals, body);
|
| + }
|
| + else {
|
| + if ((expr instanceof DeclaredIdentifier)) {
|
| + this._lang_error('illegal target for call, did you mean to declare a function?', expr.span);
|
| + }
|
| + var args = this.arguments();
|
| + return this.finishPostfixExpression(new CallExpression(expr, args, this._makeSpan(expr.span.start)));
|
| + }
|
| +}
|
| +Parser.prototype._isBin = function(expr, kind) {
|
| + return (expr instanceof BinaryExpression) && $eq(expr.get$op().kind, kind);
|
| +}
|
| +Parser.prototype._boolTypeRef = function(span) {
|
| + return new TypeReference(span, $globals.world.nonNullBool);
|
| +}
|
| +Parser.prototype._intTypeRef = function(span) {
|
| + return new TypeReference(span, $globals.world.intType);
|
| +}
|
| +Parser.prototype._doubleTypeRef = function(span) {
|
| + return new TypeReference(span, $globals.world.doubleType);
|
| +}
|
| +Parser.prototype._stringTypeRef = function(span) {
|
| + return new TypeReference(span, $globals.world.stringType);
|
| +}
|
| +Parser.prototype.primary = function() {
|
| + var start = this._peekToken.start;
|
| + switch (this._peek()) {
|
| + case 109/*TokenKind.THIS*/:
|
| +
|
| + this._eat(109/*TokenKind.THIS*/);
|
| + return new ThisExpression(this._makeSpan(start));
|
| +
|
| + case 107/*TokenKind.SUPER*/:
|
| +
|
| + this._eat(107/*TokenKind.SUPER*/);
|
| + return new SuperExpression(this._makeSpan(start));
|
| +
|
| + case 92/*TokenKind.CONST*/:
|
| +
|
| + this._eat(92/*TokenKind.CONST*/);
|
| + if (this._peekKind(4/*TokenKind.LBRACK*/) || this._peekKind(56/*TokenKind.INDEX*/)) {
|
| + return this.finishListLiteral(start, true, null);
|
| + }
|
| + else if (this._peekKind(6/*TokenKind.LBRACE*/)) {
|
| + return this.finishMapLiteral(start, true, null);
|
| + }
|
| + else if (this._peekKind(52/*TokenKind.LT*/)) {
|
| + return this.finishTypedLiteral(start, true);
|
| + }
|
| + else {
|
| + return this.finishNewExpression(start, true);
|
| + }
|
| +
|
| + case 104/*TokenKind.NEW*/:
|
| +
|
| + this._eat(104/*TokenKind.NEW*/);
|
| + return this.finishNewExpression(start, false);
|
| +
|
| + case 2/*TokenKind.LPAREN*/:
|
| +
|
| + return this._parenOrLambda();
|
| +
|
| + case 4/*TokenKind.LBRACK*/:
|
| + case 56/*TokenKind.INDEX*/:
|
| +
|
| + return this.finishListLiteral(start, false, null);
|
| +
|
| + case 6/*TokenKind.LBRACE*/:
|
| +
|
| + return this.finishMapLiteral(start, false, null);
|
| +
|
| + case 105/*TokenKind.NULL*/:
|
| +
|
| + this._eat(105/*TokenKind.NULL*/);
|
| + return new NullExpression(this._makeSpan(start));
|
| +
|
| + case 111/*TokenKind.TRUE*/:
|
| +
|
| + this._eat(111/*TokenKind.TRUE*/);
|
| + return new LiteralExpression(true, this._boolTypeRef(this._makeSpan(start)), 'true', this._makeSpan(start));
|
| +
|
| + case 97/*TokenKind.FALSE*/:
|
| +
|
| + this._eat(97/*TokenKind.FALSE*/);
|
| + return new LiteralExpression(false, this._boolTypeRef(this._makeSpan(start)), 'false', this._makeSpan(start));
|
| +
|
| + case 61/*TokenKind.HEX_INTEGER*/:
|
| +
|
| + var t = this._lang_next();
|
| + return new LiteralExpression(Parser.parseHex(t.text.substring$1(2)), this._intTypeRef(this._makeSpan(start)), t.text, this._makeSpan(start));
|
| +
|
| + case 60/*TokenKind.INTEGER*/:
|
| +
|
| + var t = this._lang_next();
|
| + return new LiteralExpression(Math.parseInt(t.text), this._intTypeRef(this._makeSpan(start)), t.text, this._makeSpan(start));
|
| +
|
| + case 62/*TokenKind.DOUBLE*/:
|
| +
|
| + var t = this._lang_next();
|
| + return new LiteralExpression(Math.parseDouble(t.text), this._doubleTypeRef(this._makeSpan(start)), t.text, this._makeSpan(start));
|
| +
|
| + case 58/*TokenKind.STRING*/:
|
| +
|
| + return this.stringLiteralExpr();
|
| +
|
| + case 66/*TokenKind.INCOMPLETE_STRING*/:
|
| +
|
| + return this.stringInterpolation();
|
| +
|
| + case 52/*TokenKind.LT*/:
|
| +
|
| + return this.finishTypedLiteral(start, false);
|
| +
|
| + case 114/*TokenKind.VOID*/:
|
| + case 113/*TokenKind.VAR*/:
|
| + case 98/*TokenKind.FINAL*/:
|
| +
|
| + return this.declaredIdentifier(false);
|
| +
|
| + default:
|
| +
|
| + if (!this._peekIdentifier()) {
|
| + this._errorExpected('expression');
|
| + }
|
| + return new VarExpression(this.identifier(), this._makeSpan(start));
|
| +
|
| + }
|
| +}
|
| +Parser.prototype.stringInterpolation = function() {
|
| + var start = this._peekToken.start;
|
| + var lits = [];
|
| + var startQuote = null, endQuote = null;
|
| + while (this._peekKind(66/*TokenKind.INCOMPLETE_STRING*/)) {
|
| + var token = this._lang_next();
|
| + var text = token.text;
|
| + if (startQuote == null) {
|
| + if (isMultilineString(text)) {
|
| + endQuote = text.substring$2(0, 3);
|
| + startQuote = endQuote + '\n';
|
| + }
|
| + else {
|
| + startQuote = endQuote = text.$index(0);
|
| + }
|
| + text = text.substring$2(0, text.length - 1) + endQuote;
|
| + }
|
| + else {
|
| + text = startQuote + text.substring$2(0, text.length - 1) + endQuote;
|
| + }
|
| + lits.add$1(this.makeStringLiteral(text, token.span));
|
| + if (this._maybeEat(6/*TokenKind.LBRACE*/)) {
|
| + lits.add$1(this.expression());
|
| + this._eat(7/*TokenKind.RBRACE*/);
|
| + }
|
| + else if (this._maybeEat(109/*TokenKind.THIS*/)) {
|
| + lits.add$1(new ThisExpression(this._previousToken.get$span()));
|
| + }
|
| + else {
|
| + var id = this.identifier();
|
| + lits.add$1(new VarExpression(id, id.span));
|
| + }
|
| + }
|
| + var tok = this._lang_next();
|
| + if ($ne(tok.kind, 58/*TokenKind.STRING*/)) {
|
| + this._errorExpected('interpolated string');
|
| + }
|
| + var text = startQuote + tok.text;
|
| + lits.add$1(this.makeStringLiteral(text, tok.span));
|
| + var span = this._makeSpan(start);
|
| + return new LiteralExpression(lits, this._stringTypeRef(span), '\$\$\$', span);
|
| +}
|
| +Parser.prototype.makeStringLiteral = function(text, span) {
|
| + return new LiteralExpression(text, this._stringTypeRef(span), text, span);
|
| +}
|
| +Parser.prototype.stringLiteralExpr = function() {
|
| + var token = this._lang_next();
|
| + return this.makeStringLiteral(token.text, token.span);
|
| +}
|
| +Parser.prototype.maybeStringLiteral = function() {
|
| + var kind = this._peek();
|
| + if ($eq(kind, 58/*TokenKind.STRING*/)) {
|
| + return parseStringLiteral(this._lang_next().get$text());
|
| + }
|
| + else if ($eq(kind, 59/*TokenKind.STRING_PART*/)) {
|
| + this._lang_next();
|
| + this._errorExpected('string literal, but found interpolated string start');
|
| + }
|
| + else if ($eq(kind, 66/*TokenKind.INCOMPLETE_STRING*/)) {
|
| + this._lang_next();
|
| + this._errorExpected('string literal, but found incomplete string');
|
| + }
|
| + return null;
|
| +}
|
| +Parser.prototype._parenOrLambda = function() {
|
| + var start = this._peekToken.start;
|
| + if (this._atClosureParameters()) {
|
| + var formals = this.formalParameterList();
|
| + var body = this.functionBody(true);
|
| + var func = new FunctionDefinition(null, null, null, formals, null, null, null, body, this._makeSpan(start));
|
| + return new LambdaExpression(func, func.span);
|
| + }
|
| + else {
|
| + this._eatLeftParen();
|
| + var saved = this._inhibitLambda;
|
| + this._inhibitLambda = false;
|
| + var expr = this.expression();
|
| + this._eat(3/*TokenKind.RPAREN*/);
|
| + this._inhibitLambda = saved;
|
| + return new ParenExpression(expr, this._makeSpan(start));
|
| + }
|
| +}
|
| +Parser.prototype._atClosureParameters = function() {
|
| + if (this._inhibitLambda) return false;
|
| + var after = this._peekAfterCloseParen();
|
| + return after.kind == 9/*TokenKind.ARROW*/ || after.kind == 6/*TokenKind.LBRACE*/;
|
| +}
|
| +Parser.prototype._eatLeftParen = function() {
|
| + this._eat(2/*TokenKind.LPAREN*/);
|
| + this._afterParensIndex++;
|
| +}
|
| +Parser.prototype._peekAfterCloseParen = function() {
|
| + if (this._afterParensIndex < this._afterParens.length) {
|
| + return this._afterParens.$index(this._afterParensIndex);
|
| + }
|
| + this._afterParensIndex = 0;
|
| + this._afterParens.clear();
|
| + var tokens = [this._lang_next()];
|
| + this._lookaheadAfterParens(tokens);
|
| + var after = this._peekToken;
|
| + tokens.add$1(after);
|
| + this.tokenizer = new DivertedTokenSource(tokens, this, this.tokenizer);
|
| + this._lang_next();
|
| + return after;
|
| +}
|
| +Parser.prototype._lookaheadAfterParens = function(tokens) {
|
| + var saved = this._afterParens.length;
|
| + this._afterParens.add(null);
|
| + while (true) {
|
| + var token = this._lang_next();
|
| + tokens.add(token);
|
| + var kind = token.kind;
|
| + if (kind == 3/*TokenKind.RPAREN*/ || kind == 1/*TokenKind.END_OF_FILE*/) {
|
| + this._afterParens.$setindex(saved, this._peekToken);
|
| + return;
|
| + }
|
| + else if (kind == 2/*TokenKind.LPAREN*/) {
|
| + this._lookaheadAfterParens(tokens);
|
| + }
|
| + }
|
| +}
|
| +Parser.prototype._typeAsIdentifier = function(type) {
|
| + return type.name;
|
| +}
|
| +Parser.prototype._specialIdentifier = function(includeOperators) {
|
| + var start = this._peekToken.start;
|
| + var name;
|
| + switch (this._peek()) {
|
| + case 15/*TokenKind.ELLIPSIS*/:
|
| +
|
| + this._eat(15/*TokenKind.ELLIPSIS*/);
|
| + this._lang_error('rest no longer supported', this._previousToken.get$span());
|
| + name = this.identifier().name;
|
| + break;
|
| +
|
| + case 109/*TokenKind.THIS*/:
|
| +
|
| + this._eat(109/*TokenKind.THIS*/);
|
| + this._eat(14/*TokenKind.DOT*/);
|
| + name = ('this.' + this.identifier().name);
|
| + break;
|
| +
|
| + case 76/*TokenKind.GET*/:
|
| +
|
| + if (!includeOperators) return null;
|
| + this._eat(76/*TokenKind.GET*/);
|
| + if (this._peekIdentifier()) {
|
| + name = ('get:' + this.identifier().name);
|
| + }
|
| + else {
|
| + name = 'get';
|
| + }
|
| + break;
|
| +
|
| + case 84/*TokenKind.SET*/:
|
| +
|
| + if (!includeOperators) return null;
|
| + this._eat(84/*TokenKind.SET*/);
|
| + if (this._peekIdentifier()) {
|
| + name = ('set:' + this.identifier().name);
|
| + }
|
| + else {
|
| + name = 'set';
|
| + }
|
| + break;
|
| +
|
| + case 83/*TokenKind.OPERATOR*/:
|
| +
|
| + if (!includeOperators) return null;
|
| + this._eat(83/*TokenKind.OPERATOR*/);
|
| + var kind = this._peek();
|
| + if ($eq(kind, 82/*TokenKind.NEGATE*/)) {
|
| + name = ':negate';
|
| + this._lang_next();
|
| + }
|
| + else {
|
| + name = TokenKind.binaryMethodName(kind);
|
| + if (name == null) {
|
| + name = 'operator';
|
| + }
|
| + else {
|
| + this._lang_next();
|
| + }
|
| + }
|
| + break;
|
| +
|
| + default:
|
| +
|
| + return null;
|
| +
|
| + }
|
| + return new Identifier(name, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.declaredIdentifier = function(includeOperators) {
|
| + var start = this._peekToken.start;
|
| + var myType = null;
|
| + var name = this._specialIdentifier(includeOperators);
|
| + if (name == null) {
|
| + myType = this.type(0);
|
| + name = this._specialIdentifier(includeOperators);
|
| + if (name == null) {
|
| + if (this._peekIdentifier()) {
|
| + name = this.identifier();
|
| + }
|
| + else if ((myType instanceof NameTypeReference) && myType.get$names() == null) {
|
| + name = this._typeAsIdentifier(myType);
|
| + myType = null;
|
| + }
|
| + else {
|
| + }
|
| + }
|
| + }
|
| + return new DeclaredIdentifier(myType, name, this._makeSpan(start));
|
| +}
|
| +Parser._hexDigit = function(c) {
|
| + if (c >= 48 && c <= 57) {
|
| + return c - 48;
|
| + }
|
| + else if (c >= 97 && c <= 102) {
|
| + return c - 87;
|
| + }
|
| + else if (c >= 65 && c <= 70) {
|
| + return c - 55;
|
| + }
|
| + else {
|
| + return -1;
|
| + }
|
| +}
|
| +Parser.parseHex = function(hex) {
|
| + var result = 0;
|
| + for (var i = 0;
|
| + i < hex.length; i++) {
|
| + var digit = Parser._hexDigit(hex.charCodeAt(i));
|
| + result = (result * 16) + digit;
|
| + }
|
| + return result;
|
| +}
|
| +Parser.prototype.finishNewExpression = function(start, isConst) {
|
| + var type = this.type(0);
|
| + var name = null;
|
| + if (this._maybeEat(14/*TokenKind.DOT*/)) {
|
| + name = this.identifier();
|
| + }
|
| + var args = this.arguments();
|
| + return new NewExpression(isConst, type, name, args, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.finishListLiteral = function(start, isConst, type) {
|
| + if (this._maybeEat(56/*TokenKind.INDEX*/)) {
|
| + return new ListExpression(isConst, type, [], this._makeSpan(start));
|
| + }
|
| + var values = [];
|
| + this._eat(4/*TokenKind.LBRACK*/);
|
| + while (!this._maybeEat(5/*TokenKind.RBRACK*/)) {
|
| + values.add$1(this.expression());
|
| + if (this._recover && !this._recoverTo(5/*TokenKind.RBRACK*/, 11/*TokenKind.COMMA*/)) break;
|
| + if (!this._maybeEat(11/*TokenKind.COMMA*/)) {
|
| + this._eat(5/*TokenKind.RBRACK*/);
|
| + break;
|
| + }
|
| + }
|
| + return new ListExpression(isConst, type, values, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.finishMapLiteral = function(start, isConst, type) {
|
| + var items = [];
|
| + this._eat(6/*TokenKind.LBRACE*/);
|
| + while (!this._maybeEat(7/*TokenKind.RBRACE*/)) {
|
| + items.add$1(this.expression());
|
| + this._eat(8/*TokenKind.COLON*/);
|
| + items.add$1(this.expression());
|
| + if (this._recover && !this._recoverTo(7/*TokenKind.RBRACE*/, 11/*TokenKind.COMMA*/)) break;
|
| + if (!this._maybeEat(11/*TokenKind.COMMA*/)) {
|
| + this._eat(7/*TokenKind.RBRACE*/);
|
| + break;
|
| + }
|
| + }
|
| + return new MapExpression(isConst, type, items, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.finishTypedLiteral = function(start, isConst) {
|
| + var span = this._makeSpan(start);
|
| + var typeToBeNamedLater = new NameTypeReference(false, null, null, span);
|
| + var genericType = this.addTypeArguments(typeToBeNamedLater, 0);
|
| + if (this._peekKind(4/*TokenKind.LBRACK*/) || this._peekKind(56/*TokenKind.INDEX*/)) {
|
| + genericType.set$baseType(new TypeReference(span, $globals.world.listType));
|
| + return this.finishListLiteral(start, isConst, genericType);
|
| + }
|
| + else if (this._peekKind(6/*TokenKind.LBRACE*/)) {
|
| + genericType.set$baseType(new TypeReference(span, $globals.world.mapType));
|
| + var typeArgs = genericType.get$typeArguments();
|
| + if ($eq(typeArgs.length, 1)) {
|
| + genericType.set$typeArguments([new TypeReference(span, $globals.world.stringType), typeArgs.$index(0)]);
|
| + }
|
| + else if ($eq(typeArgs.length, 2)) {
|
| + var keyType = typeArgs.$index(0);
|
| + if (!(keyType instanceof NameTypeReference) || $ne(keyType.name.name, "String")) {
|
| + $globals.world.error('the key type of a map literal is implicitly "String"', keyType.span);
|
| + }
|
| + else {
|
| + $globals.world.warning('a map literal takes one type argument specifying the value type', keyType.span);
|
| + }
|
| + }
|
| + return this.finishMapLiteral(start, isConst, genericType);
|
| + }
|
| + else {
|
| + this._errorExpected('array or map literal');
|
| + }
|
| +}
|
| +Parser.prototype._readModifiers = function() {
|
| + var modifiers = null;
|
| + while (true) {
|
| + switch (this._peek()) {
|
| + case 86/*TokenKind.STATIC*/:
|
| + case 98/*TokenKind.FINAL*/:
|
| + case 92/*TokenKind.CONST*/:
|
| + case 71/*TokenKind.ABSTRACT*/:
|
| + case 75/*TokenKind.FACTORY*/:
|
| +
|
| + if (modifiers == null) modifiers = [];
|
| + modifiers.add$1(this._lang_next());
|
| + break;
|
| +
|
| + default:
|
| +
|
| + return modifiers;
|
| +
|
| + }
|
| + }
|
| + return null;
|
| +}
|
| +Parser.prototype.typeParameter = function() {
|
| + var start = this._peekToken.start;
|
| + var name = this.identifier();
|
| + var myType = null;
|
| + if (this._maybeEat(74/*TokenKind.EXTENDS*/)) {
|
| + myType = this.type(1);
|
| + }
|
| + var tp = new TypeParameter(name, myType, this._makeSpan(start));
|
| + return new ParameterType(name.name, tp);
|
| +}
|
| +Parser.prototype.get$typeParameter = function() {
|
| + return Parser.prototype.typeParameter.bind(this);
|
| +}
|
| +Parser.prototype.typeParameters = function() {
|
| + this._eat(52/*TokenKind.LT*/);
|
| + var closed = false;
|
| + var ret = [];
|
| + do {
|
| + var tp = this.typeParameter();
|
| + ret.add$1(tp);
|
| + if ((tp.get$typeParameter().get$extendsType() instanceof GenericTypeReference) && $eq(tp.get$typeParameter().get$extendsType().depth, 0)) {
|
| + closed = true;
|
| + break;
|
| + }
|
| + }
|
| + while (this._maybeEat(11/*TokenKind.COMMA*/))
|
| + if (!closed) {
|
| + this._eat(53/*TokenKind.GT*/);
|
| + }
|
| + return ret;
|
| +}
|
| +Parser.prototype.get$typeParameters = function() {
|
| + return Parser.prototype.typeParameters.bind(this);
|
| +}
|
| +Parser.prototype._eatClosingAngle = function(depth) {
|
| + if (this._maybeEat(53/*TokenKind.GT*/)) {
|
| + return depth;
|
| + }
|
| + else if (depth > 0 && this._maybeEat(40/*TokenKind.SAR*/)) {
|
| + return depth - 1;
|
| + }
|
| + else if (depth > 1 && this._maybeEat(41/*TokenKind.SHR*/)) {
|
| + return depth - 2;
|
| + }
|
| + else {
|
| + this._errorExpected('>');
|
| + return depth;
|
| + }
|
| +}
|
| +Parser.prototype.addTypeArguments = function(baseType, depth) {
|
| + this._eat(52/*TokenKind.LT*/);
|
| + return this._finishTypeArguments(baseType, depth, []);
|
| +}
|
| +Parser.prototype._finishTypeArguments = function(baseType, depth, types) {
|
| + var delta = -1;
|
| + do {
|
| + var myType = this.type(depth + 1);
|
| + types.add$1(myType);
|
| + if ((myType instanceof GenericTypeReference) && myType.depth <= depth) {
|
| + delta = depth - myType.depth;
|
| + break;
|
| + }
|
| + }
|
| + while (this._maybeEat(11/*TokenKind.COMMA*/))
|
| + if (delta >= 0) {
|
| + depth = depth - delta;
|
| + }
|
| + else {
|
| + depth = this._eatClosingAngle(depth);
|
| + }
|
| + var span = this._makeSpan(baseType.span.start);
|
| + return new GenericTypeReference(baseType, types, depth, span);
|
| +}
|
| +Parser.prototype.typeList = function() {
|
| + var types = [];
|
| + do {
|
| + types.add$1(this.type(0));
|
| + }
|
| + while (this._maybeEat(11/*TokenKind.COMMA*/))
|
| + return types;
|
| +}
|
| +Parser.prototype.nameTypeReference = function() {
|
| + var start = this._peekToken.start;
|
| + var name;
|
| + var names = null;
|
| + var typeArgs = null;
|
| + var isFinal = false;
|
| + switch (this._peek()) {
|
| + case 114/*TokenKind.VOID*/:
|
| +
|
| + return new TypeReference(this._lang_next().get$span(), $globals.world.voidType);
|
| +
|
| + case 113/*TokenKind.VAR*/:
|
| +
|
| + return new TypeReference(this._lang_next().get$span(), $globals.world.varType);
|
| +
|
| + case 98/*TokenKind.FINAL*/:
|
| +
|
| + this._eat(98/*TokenKind.FINAL*/);
|
| + isFinal = true;
|
| + name = this.identifier();
|
| + break;
|
| +
|
| + default:
|
| +
|
| + name = this.identifier();
|
| + break;
|
| +
|
| + }
|
| + while (this._maybeEat(14/*TokenKind.DOT*/)) {
|
| + if (names == null) names = [];
|
| + names.add$1(this.identifier());
|
| + }
|
| + return new NameTypeReference(isFinal, name, names, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.type = function(depth) {
|
| + var typeRef = this.nameTypeReference();
|
| + if (this._peekKind(52/*TokenKind.LT*/)) {
|
| + return this.addTypeArguments(typeRef, depth);
|
| + }
|
| + else {
|
| + return typeRef;
|
| + }
|
| +}
|
| +Parser.prototype.formalParameter = function(inOptionalBlock) {
|
| + var start = this._peekToken.start;
|
| + var isThis = false;
|
| + var isRest = false;
|
| + var di = this.declaredIdentifier(false);
|
| + var type = di.type;
|
| + var name = di.name;
|
| + var value = null;
|
| + if (this._maybeEat(20/*TokenKind.ASSIGN*/)) {
|
| + if (!inOptionalBlock) {
|
| + this._lang_error('default values only allowed inside [optional] section');
|
| + }
|
| + value = this.expression();
|
| + }
|
| + else if (this._peekKind(2/*TokenKind.LPAREN*/)) {
|
| + var formals = this.formalParameterList();
|
| + var func = new FunctionDefinition(null, type, name, formals, null, null, null, null, this._makeSpan(start));
|
| + type = new FunctionTypeReference(false, func, func.span);
|
| + }
|
| + if (inOptionalBlock && value == null) {
|
| + value = new NullExpression(this._makeSpan(start));
|
| + }
|
| + return new FormalNode(isThis, isRest, type, name, value, this._makeSpan(start));
|
| +}
|
| +Parser.prototype.formalParameterList = function() {
|
| + this._eatLeftParen();
|
| + var formals = [];
|
| + var inOptionalBlock = false;
|
| + if (!this._maybeEat(3/*TokenKind.RPAREN*/)) {
|
| + if (this._maybeEat(4/*TokenKind.LBRACK*/)) {
|
| + inOptionalBlock = true;
|
| + }
|
| + formals.add$1(this.formalParameter(inOptionalBlock));
|
| + while (this._maybeEat(11/*TokenKind.COMMA*/)) {
|
| + if (this._maybeEat(4/*TokenKind.LBRACK*/)) {
|
| + if (inOptionalBlock) {
|
| + this._lang_error('already inside an optional block', this._previousToken.get$span());
|
| + }
|
| + inOptionalBlock = true;
|
| + }
|
| + formals.add$1(this.formalParameter(inOptionalBlock));
|
| + }
|
| + if (inOptionalBlock) {
|
| + this._eat(5/*TokenKind.RBRACK*/);
|
| + }
|
| + this._eat(3/*TokenKind.RPAREN*/);
|
| + }
|
| + return formals;
|
| +}
|
| +Parser.prototype.identifier = function() {
|
| + var tok = this._lang_next();
|
| + if (!this._isIdentifier(tok.kind)) {
|
| + this._lang_error(('expected identifier, but found ' + tok), tok.span);
|
| + }
|
| + return new Identifier(tok.text, this._makeSpan(tok.start));
|
| +}
|
| +Parser.prototype._makeFunction = function(expr, formals, body) {
|
| + var name, type;
|
| + if ((expr instanceof VarExpression)) {
|
| + name = expr.name;
|
| + type = null;
|
| + }
|
| + else if ((expr instanceof DeclaredIdentifier)) {
|
| + name = expr.name;
|
| + type = expr.type;
|
| + }
|
| + else {
|
| + this._lang_error('bad function body', expr.span);
|
| + }
|
| + var span = new SourceSpan(expr.span.get$file(), expr.span.start, body.span.get$end());
|
| + var func = new FunctionDefinition(null, type, name, formals, null, null, null, body, span);
|
| + return new LambdaExpression(func, func.span);
|
| +}
|
| +Parser.prototype._makeDeclaredIdentifier = function(e) {
|
| + if ((e instanceof VarExpression)) {
|
| + return new DeclaredIdentifier(null, e.name, e.span);
|
| + }
|
| + else if ((e instanceof DeclaredIdentifier)) {
|
| + return e;
|
| + }
|
| + else {
|
| + this._lang_error('expected declared identifier');
|
| + return new DeclaredIdentifier(null, null, e.span);
|
| + }
|
| +}
|
| +Parser.prototype._makeLabel = function(expr) {
|
| + if ((expr instanceof VarExpression)) {
|
| + return expr.name;
|
| + }
|
| + else {
|
| + this._errorExpected('label');
|
| + return null;
|
| + }
|
| +}
|
| +Parser.prototype.block$0 = Parser.prototype.block;
|
| +Parser.prototype.compilationUnit$0 = Parser.prototype.compilationUnit;
|
| +// ********** Code for IncompleteSourceException **************
|
| +function IncompleteSourceException(token) {
|
| + this.token = token;
|
| + // Initializers done
|
| +}
|
| +IncompleteSourceException.prototype.toString = function() {
|
| + if (this.token.get$span() == null) return ('Unexpected ' + this.token);
|
| + return this.token.get$span().toMessageString(('Unexpected ' + this.token));
|
| +}
|
| +IncompleteSourceException.prototype.toString$0 = IncompleteSourceException.prototype.toString;
|
| +// ********** Code for DivertedTokenSource **************
|
| +function DivertedTokenSource(tokens, parser, previousTokenizer) {
|
| + this._lang_pos = 0
|
| + this.tokens = tokens;
|
| + this.parser = parser;
|
| + this.previousTokenizer = previousTokenizer;
|
| + // Initializers done
|
| +}
|
| +DivertedTokenSource.prototype.next = function() {
|
| + var token = this.tokens.$index(this._lang_pos);
|
| + ++this._lang_pos;
|
| + if (this._lang_pos == this.tokens.length) {
|
| + this.parser.tokenizer = this.previousTokenizer;
|
| + }
|
| + return token;
|
| +}
|
| +DivertedTokenSource.prototype.next$0 = DivertedTokenSource.prototype.next;
|
| +// ********** Code for lang_Node **************
|
| +function lang_Node(span) {
|
| + this.span = span;
|
| + // Initializers done
|
| +}
|
| +lang_Node.prototype.visit$1 = lang_Node.prototype.visit;
|
| +// ********** Code for Statement **************
|
| +$inherits(Statement, lang_Node);
|
| +function Statement(span) {
|
| + // Initializers done
|
| + lang_Node.call(this, span);
|
| +}
|
| +// ********** Code for Definition **************
|
| +$inherits(Definition, Statement);
|
| +function Definition(span) {
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +Definition.prototype.get$typeParameters = function() {
|
| + return null;
|
| +}
|
| +Definition.prototype.get$nativeType = function() {
|
| + return null;
|
| +}
|
| +// ********** Code for Expression **************
|
| +$inherits(Expression, lang_Node);
|
| +function Expression(span) {
|
| + // Initializers done
|
| + lang_Node.call(this, span);
|
| +}
|
| +// ********** Code for TypeReference **************
|
| +$inherits(TypeReference, lang_Node);
|
| +function TypeReference(span, type) {
|
| + this.type = type;
|
| + // Initializers done
|
| + lang_Node.call(this, span);
|
| +}
|
| +TypeReference.prototype.visit = function(visitor) {
|
| + return visitor.visitTypeReference(this);
|
| +}
|
| +TypeReference.prototype.get$isFinal = function() {
|
| + return false;
|
| +}
|
| +TypeReference.prototype.visit$1 = TypeReference.prototype.visit;
|
| +// ********** Code for DirectiveDefinition **************
|
| +$inherits(DirectiveDefinition, Definition);
|
| +function DirectiveDefinition(name, arguments, span) {
|
| + this.name = name;
|
| + this.arguments = arguments;
|
| + // Initializers done
|
| + Definition.call(this, span);
|
| +}
|
| +DirectiveDefinition.prototype.get$arguments = function() { return this.arguments; };
|
| +DirectiveDefinition.prototype.set$arguments = function(value) { return this.arguments = value; };
|
| +DirectiveDefinition.prototype.visit = function(visitor) {
|
| + return visitor.visitDirectiveDefinition(this);
|
| +}
|
| +DirectiveDefinition.prototype.visit$1 = DirectiveDefinition.prototype.visit;
|
| +// ********** Code for TypeDefinition **************
|
| +$inherits(TypeDefinition, Definition);
|
| +function TypeDefinition(isClass, name, typeParameters, extendsTypes, implementsTypes, nativeType, factoryType, body, span) {
|
| + this.isClass = isClass;
|
| + this.name = name;
|
| + this.typeParameters = typeParameters;
|
| + this.extendsTypes = extendsTypes;
|
| + this.implementsTypes = implementsTypes;
|
| + this.nativeType = nativeType;
|
| + this.factoryType = factoryType;
|
| + this.body = body;
|
| + // Initializers done
|
| + Definition.call(this, span);
|
| +}
|
| +TypeDefinition.prototype.get$isClass = function() { return this.isClass; };
|
| +TypeDefinition.prototype.set$isClass = function(value) { return this.isClass = value; };
|
| +TypeDefinition.prototype.get$typeParameters = function() { return this.typeParameters; };
|
| +TypeDefinition.prototype.set$typeParameters = function(value) { return this.typeParameters = value; };
|
| +TypeDefinition.prototype.get$nativeType = function() { return this.nativeType; };
|
| +TypeDefinition.prototype.set$nativeType = function(value) { return this.nativeType = value; };
|
| +TypeDefinition.prototype.visit = function(visitor) {
|
| + return visitor.visitTypeDefinition(this);
|
| +}
|
| +TypeDefinition.prototype.visit$1 = TypeDefinition.prototype.visit;
|
| +// ********** Code for FunctionTypeDefinition **************
|
| +$inherits(FunctionTypeDefinition, Definition);
|
| +function FunctionTypeDefinition(func, typeParameters, span) {
|
| + this.func = func;
|
| + this.typeParameters = typeParameters;
|
| + // Initializers done
|
| + Definition.call(this, span);
|
| +}
|
| +FunctionTypeDefinition.prototype.get$func = function() { return this.func; };
|
| +FunctionTypeDefinition.prototype.set$func = function(value) { return this.func = value; };
|
| +FunctionTypeDefinition.prototype.get$typeParameters = function() { return this.typeParameters; };
|
| +FunctionTypeDefinition.prototype.set$typeParameters = function(value) { return this.typeParameters = value; };
|
| +FunctionTypeDefinition.prototype.visit = function(visitor) {
|
| + return visitor.visitFunctionTypeDefinition(this);
|
| +}
|
| +FunctionTypeDefinition.prototype.visit$1 = FunctionTypeDefinition.prototype.visit;
|
| +// ********** Code for VariableDefinition **************
|
| +$inherits(VariableDefinition, Definition);
|
| +function VariableDefinition(modifiers, type, names, values, span) {
|
| + this.modifiers = modifiers;
|
| + this.type = type;
|
| + this.names = names;
|
| + this.values = values;
|
| + // Initializers done
|
| + Definition.call(this, span);
|
| +}
|
| +VariableDefinition.prototype.get$names = function() { return this.names; };
|
| +VariableDefinition.prototype.set$names = function(value) { return this.names = value; };
|
| +VariableDefinition.prototype.visit = function(visitor) {
|
| + return visitor.visitVariableDefinition(this);
|
| +}
|
| +VariableDefinition.prototype.visit$1 = VariableDefinition.prototype.visit;
|
| +// ********** Code for FunctionDefinition **************
|
| +$inherits(FunctionDefinition, Definition);
|
| +function FunctionDefinition(modifiers, returnType, name, formals, typeParameters, initializers, nativeBody, body, span) {
|
| + this.modifiers = modifiers;
|
| + this.returnType = returnType;
|
| + this.name = name;
|
| + this.formals = formals;
|
| + this.typeParameters = typeParameters;
|
| + this.initializers = initializers;
|
| + this.nativeBody = nativeBody;
|
| + this.body = body;
|
| + // Initializers done
|
| + Definition.call(this, span);
|
| +}
|
| +FunctionDefinition.prototype.get$returnType = function() { return this.returnType; };
|
| +FunctionDefinition.prototype.set$returnType = function(value) { return this.returnType = value; };
|
| +FunctionDefinition.prototype.get$typeParameters = function() { return this.typeParameters; };
|
| +FunctionDefinition.prototype.set$typeParameters = function(value) { return this.typeParameters = value; };
|
| +FunctionDefinition.prototype.get$initializers = function() { return this.initializers; };
|
| +FunctionDefinition.prototype.set$initializers = function(value) { return this.initializers = value; };
|
| +FunctionDefinition.prototype.get$nativeBody = function() { return this.nativeBody; };
|
| +FunctionDefinition.prototype.set$nativeBody = function(value) { return this.nativeBody = value; };
|
| +FunctionDefinition.prototype.visit = function(visitor) {
|
| + return visitor.visitFunctionDefinition(this);
|
| +}
|
| +FunctionDefinition.prototype.visit$1 = FunctionDefinition.prototype.visit;
|
| +// ********** Code for ReturnStatement **************
|
| +$inherits(ReturnStatement, Statement);
|
| +function ReturnStatement(value, span) {
|
| + this.value = value;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +ReturnStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitReturnStatement(this);
|
| +}
|
| +ReturnStatement.prototype.visit$1 = ReturnStatement.prototype.visit;
|
| +// ********** Code for ThrowStatement **************
|
| +$inherits(ThrowStatement, Statement);
|
| +function ThrowStatement(value, span) {
|
| + this.value = value;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +ThrowStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitThrowStatement(this);
|
| +}
|
| +ThrowStatement.prototype.visit$1 = ThrowStatement.prototype.visit;
|
| +// ********** Code for AssertStatement **************
|
| +$inherits(AssertStatement, Statement);
|
| +function AssertStatement(test, span) {
|
| + this.test = test;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +AssertStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitAssertStatement(this);
|
| +}
|
| +AssertStatement.prototype.visit$1 = AssertStatement.prototype.visit;
|
| +// ********** Code for BreakStatement **************
|
| +$inherits(BreakStatement, Statement);
|
| +function BreakStatement(label, span) {
|
| + this.label = label;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +BreakStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitBreakStatement(this);
|
| +}
|
| +BreakStatement.prototype.visit$1 = BreakStatement.prototype.visit;
|
| +// ********** Code for ContinueStatement **************
|
| +$inherits(ContinueStatement, Statement);
|
| +function ContinueStatement(label, span) {
|
| + this.label = label;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +ContinueStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitContinueStatement(this);
|
| +}
|
| +ContinueStatement.prototype.visit$1 = ContinueStatement.prototype.visit;
|
| +// ********** Code for IfStatement **************
|
| +$inherits(IfStatement, Statement);
|
| +function IfStatement(test, trueBranch, falseBranch, span) {
|
| + this.test = test;
|
| + this.trueBranch = trueBranch;
|
| + this.falseBranch = falseBranch;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +IfStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitIfStatement(this);
|
| +}
|
| +IfStatement.prototype.visit$1 = IfStatement.prototype.visit;
|
| +// ********** Code for WhileStatement **************
|
| +$inherits(WhileStatement, Statement);
|
| +function WhileStatement(test, body, span) {
|
| + this.test = test;
|
| + this.body = body;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +WhileStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitWhileStatement(this);
|
| +}
|
| +WhileStatement.prototype.visit$1 = WhileStatement.prototype.visit;
|
| +// ********** Code for DoStatement **************
|
| +$inherits(DoStatement, Statement);
|
| +function DoStatement(body, test, span) {
|
| + this.body = body;
|
| + this.test = test;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +DoStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitDoStatement(this);
|
| +}
|
| +DoStatement.prototype.visit$1 = DoStatement.prototype.visit;
|
| +// ********** Code for ForStatement **************
|
| +$inherits(ForStatement, Statement);
|
| +function ForStatement(init, test, step, body, span) {
|
| + this.init = init;
|
| + this.test = test;
|
| + this.step = step;
|
| + this.body = body;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +ForStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitForStatement(this);
|
| +}
|
| +ForStatement.prototype.visit$1 = ForStatement.prototype.visit;
|
| +// ********** Code for ForInStatement **************
|
| +$inherits(ForInStatement, Statement);
|
| +function ForInStatement(item, list, body, span) {
|
| + this.item = item;
|
| + this.list = list;
|
| + this.body = body;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +ForInStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitForInStatement(this);
|
| +}
|
| +ForInStatement.prototype.visit$1 = ForInStatement.prototype.visit;
|
| +// ********** Code for TryStatement **************
|
| +$inherits(TryStatement, Statement);
|
| +function TryStatement(body, catches, finallyBlock, span) {
|
| + this.body = body;
|
| + this.catches = catches;
|
| + this.finallyBlock = finallyBlock;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +TryStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitTryStatement(this);
|
| +}
|
| +TryStatement.prototype.visit$1 = TryStatement.prototype.visit;
|
| +// ********** Code for SwitchStatement **************
|
| +$inherits(SwitchStatement, Statement);
|
| +function SwitchStatement(test, cases, span) {
|
| + this.test = test;
|
| + this.cases = cases;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +SwitchStatement.prototype.get$cases = function() { return this.cases; };
|
| +SwitchStatement.prototype.set$cases = function(value) { return this.cases = value; };
|
| +SwitchStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitSwitchStatement(this);
|
| +}
|
| +SwitchStatement.prototype.visit$1 = SwitchStatement.prototype.visit;
|
| +// ********** Code for BlockStatement **************
|
| +$inherits(BlockStatement, Statement);
|
| +function BlockStatement(body, span) {
|
| + this.body = body;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +BlockStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitBlockStatement(this);
|
| +}
|
| +BlockStatement.prototype.visit$1 = BlockStatement.prototype.visit;
|
| +// ********** Code for LabeledStatement **************
|
| +$inherits(LabeledStatement, Statement);
|
| +function LabeledStatement(name, body, span) {
|
| + this.name = name;
|
| + this.body = body;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +LabeledStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitLabeledStatement(this);
|
| +}
|
| +LabeledStatement.prototype.visit$1 = LabeledStatement.prototype.visit;
|
| +// ********** Code for ExpressionStatement **************
|
| +$inherits(ExpressionStatement, Statement);
|
| +function ExpressionStatement(body, span) {
|
| + this.body = body;
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +ExpressionStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitExpressionStatement(this);
|
| +}
|
| +ExpressionStatement.prototype.visit$1 = ExpressionStatement.prototype.visit;
|
| +// ********** Code for EmptyStatement **************
|
| +$inherits(EmptyStatement, Statement);
|
| +function EmptyStatement(span) {
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +EmptyStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitEmptyStatement(this);
|
| +}
|
| +EmptyStatement.prototype.visit$1 = EmptyStatement.prototype.visit;
|
| +// ********** Code for DietStatement **************
|
| +$inherits(DietStatement, Statement);
|
| +function DietStatement(span) {
|
| + // Initializers done
|
| + Statement.call(this, span);
|
| +}
|
| +DietStatement.prototype.visit = function(visitor) {
|
| + return visitor.visitDietStatement(this);
|
| +}
|
| +DietStatement.prototype.visit$1 = DietStatement.prototype.visit;
|
| +// ********** Code for LambdaExpression **************
|
| +$inherits(LambdaExpression, Expression);
|
| +function LambdaExpression(func, span) {
|
| + this.func = func;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +LambdaExpression.prototype.get$func = function() { return this.func; };
|
| +LambdaExpression.prototype.set$func = function(value) { return this.func = value; };
|
| +LambdaExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitLambdaExpression(this);
|
| +}
|
| +LambdaExpression.prototype.visit$1 = LambdaExpression.prototype.visit;
|
| +// ********** Code for CallExpression **************
|
| +$inherits(CallExpression, Expression);
|
| +function CallExpression(target, arguments, span) {
|
| + this.target = target;
|
| + this.arguments = arguments;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +CallExpression.prototype.get$arguments = function() { return this.arguments; };
|
| +CallExpression.prototype.set$arguments = function(value) { return this.arguments = value; };
|
| +CallExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitCallExpression(this);
|
| +}
|
| +CallExpression.prototype.visit$1 = CallExpression.prototype.visit;
|
| +// ********** Code for IndexExpression **************
|
| +$inherits(IndexExpression, Expression);
|
| +function IndexExpression(target, index, span) {
|
| + this.target = target;
|
| + this.index = index;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +IndexExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitIndexExpression(this);
|
| +}
|
| +IndexExpression.prototype.visit$1 = IndexExpression.prototype.visit;
|
| +// ********** Code for BinaryExpression **************
|
| +$inherits(BinaryExpression, Expression);
|
| +function BinaryExpression(op, x, y, span) {
|
| + this.op = op;
|
| + this.x = x;
|
| + this.y = y;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +BinaryExpression.prototype.get$op = function() { return this.op; };
|
| +BinaryExpression.prototype.set$op = function(value) { return this.op = value; };
|
| +BinaryExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitBinaryExpression$1(this);
|
| +}
|
| +BinaryExpression.prototype.visit$1 = BinaryExpression.prototype.visit;
|
| +// ********** Code for UnaryExpression **************
|
| +$inherits(UnaryExpression, Expression);
|
| +function UnaryExpression(op, self, span) {
|
| + this.op = op;
|
| + this.self = self;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +UnaryExpression.prototype.get$op = function() { return this.op; };
|
| +UnaryExpression.prototype.set$op = function(value) { return this.op = value; };
|
| +UnaryExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitUnaryExpression(this);
|
| +}
|
| +UnaryExpression.prototype.visit$1 = UnaryExpression.prototype.visit;
|
| +// ********** Code for PostfixExpression **************
|
| +$inherits(PostfixExpression, Expression);
|
| +function PostfixExpression(body, op, span) {
|
| + this.body = body;
|
| + this.op = op;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +PostfixExpression.prototype.get$op = function() { return this.op; };
|
| +PostfixExpression.prototype.set$op = function(value) { return this.op = value; };
|
| +PostfixExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitPostfixExpression$1(this);
|
| +}
|
| +PostfixExpression.prototype.visit$1 = PostfixExpression.prototype.visit;
|
| +// ********** Code for NewExpression **************
|
| +$inherits(NewExpression, Expression);
|
| +function NewExpression(isConst, type, name, arguments, span) {
|
| + this.isConst = isConst;
|
| + this.type = type;
|
| + this.name = name;
|
| + this.arguments = arguments;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +NewExpression.prototype.get$isConst = function() { return this.isConst; };
|
| +NewExpression.prototype.set$isConst = function(value) { return this.isConst = value; };
|
| +NewExpression.prototype.get$arguments = function() { return this.arguments; };
|
| +NewExpression.prototype.set$arguments = function(value) { return this.arguments = value; };
|
| +NewExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitNewExpression(this);
|
| +}
|
| +NewExpression.prototype.visit$1 = NewExpression.prototype.visit;
|
| +// ********** Code for ListExpression **************
|
| +$inherits(ListExpression, Expression);
|
| +function ListExpression(isConst, type, values, span) {
|
| + this.isConst = isConst;
|
| + this.type = type;
|
| + this.values = values;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +ListExpression.prototype.get$isConst = function() { return this.isConst; };
|
| +ListExpression.prototype.set$isConst = function(value) { return this.isConst = value; };
|
| +ListExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitListExpression(this);
|
| +}
|
| +ListExpression.prototype.visit$1 = ListExpression.prototype.visit;
|
| +// ********** Code for MapExpression **************
|
| +$inherits(MapExpression, Expression);
|
| +function MapExpression(isConst, type, items, span) {
|
| + this.isConst = isConst;
|
| + this.type = type;
|
| + this.items = items;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +MapExpression.prototype.get$isConst = function() { return this.isConst; };
|
| +MapExpression.prototype.set$isConst = function(value) { return this.isConst = value; };
|
| +MapExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitMapExpression(this);
|
| +}
|
| +MapExpression.prototype.visit$1 = MapExpression.prototype.visit;
|
| +// ********** Code for ConditionalExpression **************
|
| +$inherits(ConditionalExpression, Expression);
|
| +function ConditionalExpression(test, trueBranch, falseBranch, span) {
|
| + this.test = test;
|
| + this.trueBranch = trueBranch;
|
| + this.falseBranch = falseBranch;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +ConditionalExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitConditionalExpression(this);
|
| +}
|
| +ConditionalExpression.prototype.visit$1 = ConditionalExpression.prototype.visit;
|
| +// ********** Code for IsExpression **************
|
| +$inherits(IsExpression, Expression);
|
| +function IsExpression(isTrue, x, type, span) {
|
| + this.isTrue = isTrue;
|
| + this.x = x;
|
| + this.type = type;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +IsExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitIsExpression(this);
|
| +}
|
| +IsExpression.prototype.visit$1 = IsExpression.prototype.visit;
|
| +// ********** Code for ParenExpression **************
|
| +$inherits(ParenExpression, Expression);
|
| +function ParenExpression(body, span) {
|
| + this.body = body;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +ParenExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitParenExpression(this);
|
| +}
|
| +ParenExpression.prototype.visit$1 = ParenExpression.prototype.visit;
|
| +// ********** Code for AwaitExpression **************
|
| +$inherits(AwaitExpression, Expression);
|
| +function AwaitExpression(body, span) {
|
| + this.body = body;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +AwaitExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitAwaitExpression(this);
|
| +}
|
| +AwaitExpression.prototype.visit$1 = AwaitExpression.prototype.visit;
|
| +// ********** Code for DotExpression **************
|
| +$inherits(DotExpression, Expression);
|
| +function DotExpression(self, name, span) {
|
| + this.self = self;
|
| + this.name = name;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +DotExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitDotExpression(this);
|
| +}
|
| +DotExpression.prototype.visit$1 = DotExpression.prototype.visit;
|
| +// ********** Code for VarExpression **************
|
| +$inherits(VarExpression, Expression);
|
| +function VarExpression(name, span) {
|
| + this.name = name;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +VarExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitVarExpression(this);
|
| +}
|
| +VarExpression.prototype.visit$1 = VarExpression.prototype.visit;
|
| +// ********** Code for ThisExpression **************
|
| +$inherits(ThisExpression, Expression);
|
| +function ThisExpression(span) {
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +ThisExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitThisExpression(this);
|
| +}
|
| +ThisExpression.prototype.visit$1 = ThisExpression.prototype.visit;
|
| +// ********** Code for SuperExpression **************
|
| +$inherits(SuperExpression, Expression);
|
| +function SuperExpression(span) {
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +SuperExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitSuperExpression(this);
|
| +}
|
| +SuperExpression.prototype.visit$1 = SuperExpression.prototype.visit;
|
| +// ********** Code for NullExpression **************
|
| +$inherits(NullExpression, Expression);
|
| +function NullExpression(span) {
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +NullExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitNullExpression(this);
|
| +}
|
| +NullExpression.prototype.visit$1 = NullExpression.prototype.visit;
|
| +// ********** Code for LiteralExpression **************
|
| +$inherits(LiteralExpression, Expression);
|
| +function LiteralExpression(value, type, text, span) {
|
| + this.value = value;
|
| + this.type = type;
|
| + this.text = text;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +LiteralExpression.prototype.visit = function(visitor) {
|
| + return visitor.visitLiteralExpression(this);
|
| +}
|
| +LiteralExpression.prototype.visit$1 = LiteralExpression.prototype.visit;
|
| +// ********** Code for NameTypeReference **************
|
| +$inherits(NameTypeReference, TypeReference);
|
| +function NameTypeReference(isFinal, name, names, span) {
|
| + this.isFinal = isFinal;
|
| + this.name = name;
|
| + this.names = names;
|
| + // Initializers done
|
| + TypeReference.call(this, span);
|
| +}
|
| +NameTypeReference.prototype.get$isFinal = function() { return this.isFinal; };
|
| +NameTypeReference.prototype.set$isFinal = function(value) { return this.isFinal = value; };
|
| +NameTypeReference.prototype.get$names = function() { return this.names; };
|
| +NameTypeReference.prototype.set$names = function(value) { return this.names = value; };
|
| +NameTypeReference.prototype.visit = function(visitor) {
|
| + return visitor.visitNameTypeReference(this);
|
| +}
|
| +NameTypeReference.prototype.visit$1 = NameTypeReference.prototype.visit;
|
| +// ********** Code for GenericTypeReference **************
|
| +$inherits(GenericTypeReference, TypeReference);
|
| +function GenericTypeReference(baseType, typeArguments, depth, span) {
|
| + this.baseType = baseType;
|
| + this.typeArguments = typeArguments;
|
| + this.depth = depth;
|
| + // Initializers done
|
| + TypeReference.call(this, span);
|
| +}
|
| +GenericTypeReference.prototype.get$baseType = function() { return this.baseType; };
|
| +GenericTypeReference.prototype.set$baseType = function(value) { return this.baseType = value; };
|
| +GenericTypeReference.prototype.get$typeArguments = function() { return this.typeArguments; };
|
| +GenericTypeReference.prototype.set$typeArguments = function(value) { return this.typeArguments = value; };
|
| +GenericTypeReference.prototype.visit = function(visitor) {
|
| + return visitor.visitGenericTypeReference(this);
|
| +}
|
| +GenericTypeReference.prototype.visit$1 = GenericTypeReference.prototype.visit;
|
| +// ********** Code for FunctionTypeReference **************
|
| +$inherits(FunctionTypeReference, TypeReference);
|
| +function FunctionTypeReference(isFinal, func, span) {
|
| + this.isFinal = isFinal;
|
| + this.func = func;
|
| + // Initializers done
|
| + TypeReference.call(this, span);
|
| +}
|
| +FunctionTypeReference.prototype.get$isFinal = function() { return this.isFinal; };
|
| +FunctionTypeReference.prototype.set$isFinal = function(value) { return this.isFinal = value; };
|
| +FunctionTypeReference.prototype.get$func = function() { return this.func; };
|
| +FunctionTypeReference.prototype.set$func = function(value) { return this.func = value; };
|
| +FunctionTypeReference.prototype.visit = function(visitor) {
|
| + return visitor.visitFunctionTypeReference(this);
|
| +}
|
| +FunctionTypeReference.prototype.visit$1 = FunctionTypeReference.prototype.visit;
|
| +// ********** Code for ArgumentNode **************
|
| +$inherits(ArgumentNode, lang_Node);
|
| +function ArgumentNode(label, value, span) {
|
| + this.label = label;
|
| + this.value = value;
|
| + // Initializers done
|
| + lang_Node.call(this, span);
|
| +}
|
| +ArgumentNode.prototype.visit = function(visitor) {
|
| + return visitor.visitArgumentNode(this);
|
| +}
|
| +ArgumentNode.prototype.visit$1 = ArgumentNode.prototype.visit;
|
| +// ********** Code for FormalNode **************
|
| +$inherits(FormalNode, lang_Node);
|
| +function FormalNode(isThis, isRest, type, name, value, span) {
|
| + this.isThis = isThis;
|
| + this.isRest = isRest;
|
| + this.type = type;
|
| + this.name = name;
|
| + this.value = value;
|
| + // Initializers done
|
| + lang_Node.call(this, span);
|
| +}
|
| +FormalNode.prototype.visit = function(visitor) {
|
| + return visitor.visitFormalNode(this);
|
| +}
|
| +FormalNode.prototype.visit$1 = FormalNode.prototype.visit;
|
| +// ********** Code for CatchNode **************
|
| +$inherits(CatchNode, lang_Node);
|
| +function CatchNode(exception, trace, body, span) {
|
| + this.exception = exception;
|
| + this.trace = trace;
|
| + this.body = body;
|
| + // Initializers done
|
| + lang_Node.call(this, span);
|
| +}
|
| +CatchNode.prototype.get$exception = function() { return this.exception; };
|
| +CatchNode.prototype.set$exception = function(value) { return this.exception = value; };
|
| +CatchNode.prototype.get$trace = function() { return this.trace; };
|
| +CatchNode.prototype.set$trace = function(value) { return this.trace = value; };
|
| +CatchNode.prototype.visit = function(visitor) {
|
| + return visitor.visitCatchNode(this);
|
| +}
|
| +CatchNode.prototype.visit$1 = CatchNode.prototype.visit;
|
| +// ********** Code for CaseNode **************
|
| +$inherits(CaseNode, lang_Node);
|
| +function CaseNode(label, cases, statements, span) {
|
| + this.label = label;
|
| + this.cases = cases;
|
| + this.statements = statements;
|
| + // Initializers done
|
| + lang_Node.call(this, span);
|
| +}
|
| +CaseNode.prototype.get$cases = function() { return this.cases; };
|
| +CaseNode.prototype.set$cases = function(value) { return this.cases = value; };
|
| +CaseNode.prototype.get$statements = function() { return this.statements; };
|
| +CaseNode.prototype.set$statements = function(value) { return this.statements = value; };
|
| +CaseNode.prototype.visit = function(visitor) {
|
| + return visitor.visitCaseNode(this);
|
| +}
|
| +CaseNode.prototype.visit$1 = CaseNode.prototype.visit;
|
| +// ********** Code for TypeParameter **************
|
| +$inherits(TypeParameter, lang_Node);
|
| +function TypeParameter(name, extendsType, span) {
|
| + this.name = name;
|
| + this.extendsType = extendsType;
|
| + // Initializers done
|
| + lang_Node.call(this, span);
|
| +}
|
| +TypeParameter.prototype.get$extendsType = function() { return this.extendsType; };
|
| +TypeParameter.prototype.set$extendsType = function(value) { return this.extendsType = value; };
|
| +TypeParameter.prototype.visit = function(visitor) {
|
| + return visitor.visitTypeParameter(this);
|
| +}
|
| +TypeParameter.prototype.visit$1 = TypeParameter.prototype.visit;
|
| +// ********** Code for Identifier **************
|
| +$inherits(Identifier, lang_Node);
|
| +function Identifier(name, span) {
|
| + this.name = name;
|
| + // Initializers done
|
| + lang_Node.call(this, span);
|
| +}
|
| +Identifier.prototype.visit = function(visitor) {
|
| + return visitor.visitIdentifier(this);
|
| +}
|
| +Identifier.prototype.visit$1 = Identifier.prototype.visit;
|
| +// ********** Code for DeclaredIdentifier **************
|
| +$inherits(DeclaredIdentifier, Expression);
|
| +function DeclaredIdentifier(type, name, span) {
|
| + this.type = type;
|
| + this.name = name;
|
| + // Initializers done
|
| + Expression.call(this, span);
|
| +}
|
| +DeclaredIdentifier.prototype.visit = function(visitor) {
|
| + return visitor.visitDeclaredIdentifier(this);
|
| +}
|
| +DeclaredIdentifier.prototype.visit$1 = DeclaredIdentifier.prototype.visit;
|
| +// ********** Code for Type **************
|
| +$inherits(Type, lang_Element);
|
| +function Type(name) {
|
| + this.isTested = false
|
| + this.isChecked = false
|
| + this.isWritten = false
|
| + this._resolvedMembers = new HashMapImplementation();
|
| + this.varStubs = new HashMapImplementation();
|
| + // Initializers done
|
| + lang_Element.call(this, name, null);
|
| +}
|
| +Type.prototype.get$isTested = function() { return this.isTested; };
|
| +Type.prototype.set$isTested = function(value) { return this.isTested = value; };
|
| +Type.prototype.get$typeCheckCode = function() { return this.typeCheckCode; };
|
| +Type.prototype.set$typeCheckCode = function(value) { return this.typeCheckCode = value; };
|
| +Type.prototype.get$varStubs = function() { return this.varStubs; };
|
| +Type.prototype.set$varStubs = function(value) { return this.varStubs = value; };
|
| +Type.prototype.markUsed = function() {
|
| +
|
| +}
|
| +Type.prototype.get$typeMember = function() {
|
| + if (this._typeMember == null) {
|
| + this._typeMember = new TypeMember(this);
|
| + }
|
| + return this._typeMember;
|
| +}
|
| +Type.prototype.getMember = function(name) {
|
| + return null;
|
| +}
|
| +Type.prototype.get$subtypes = function() {
|
| + return null;
|
| +}
|
| +Type.prototype.get$isVar = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$isTop = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$isObject = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$isString = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$isBool = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$isFunction = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$isList = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$isNum = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$isVoid = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$isNullable = function() {
|
| + return true;
|
| +}
|
| +Type.prototype.get$isVarOrFunction = function() {
|
| + return this.get$isVar() || this.get$isFunction();
|
| +}
|
| +Type.prototype.get$isVarOrObject = function() {
|
| + return this.get$isVar() || this.get$isObject();
|
| +}
|
| +Type.prototype.getCallMethod = function() {
|
| + return null;
|
| +}
|
| +Type.prototype.get$isClosed = function() {
|
| + return this.get$isString() || this.get$isBool() || this.get$isNum() || this.get$isFunction() || this.get$isVar();
|
| +}
|
| +Type.prototype.get$isUsed = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$isGeneric = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$nativeType = function() {
|
| + return null;
|
| +}
|
| +Type.prototype.get$isHiddenNativeType = function() {
|
| + return (this.get$nativeType() != null && this.get$nativeType().isConstructorHidden);
|
| +}
|
| +Type.prototype.get$isSingletonNative = function() {
|
| + return (this.get$nativeType() != null && this.get$nativeType().isSingleton);
|
| +}
|
| +Type.prototype.get$isJsGlobalObject = function() {
|
| + return (this.get$nativeType() != null && this.get$nativeType().isJsGlobalObject);
|
| +}
|
| +Type.prototype.get$hasTypeParams = function() {
|
| + return false;
|
| +}
|
| +Type.prototype.get$typeofName = function() {
|
| + return null;
|
| +}
|
| +Type.prototype.get$members = function() {
|
| + return null;
|
| +}
|
| +Type.prototype.get$definition = function() {
|
| + return null;
|
| +}
|
| +Type.prototype.get$factories = function() {
|
| + return null;
|
| +}
|
| +Type.prototype.get$typeArgsInOrder = function() {
|
| + return null;
|
| +}
|
| +Type.prototype.get$genericType = function() {
|
| + return this;
|
| +}
|
| +Type.prototype.get$interfaces = function() {
|
| + return null;
|
| +}
|
| +Type.prototype.get$parent = function() {
|
| + return null;
|
| +}
|
| +Object.defineProperty(Type.prototype, "parent", {
|
| + get: Type.prototype.get$parent
|
| +});
|
| +Type.prototype.getAllMembers = function() {
|
| + return new HashMapImplementation();
|
| +}
|
| +Type.prototype.get$hasNativeSubtypes = function() {
|
| + if (this._hasNativeSubtypes == null) {
|
| + this._hasNativeSubtypes = this.get$subtypes().some((function (t) {
|
| + return t.get$isNative();
|
| + })
|
| + );
|
| + }
|
| + return this._hasNativeSubtypes;
|
| +}
|
| +Type.prototype._checkExtends = function() {
|
| + var typeParams = this.get$genericType().typeParameters;
|
| + if (typeParams != null && this.get$typeArgsInOrder() != null) {
|
| + var args = this.get$typeArgsInOrder().iterator$0();
|
| + var params = typeParams.iterator$0();
|
| + while (args.hasNext$0() && params.hasNext$0()) {
|
| + var typeParam = params.next$0();
|
| + var typeArg = args.next$0();
|
| + if (typeParam.get$extendsType() != null && typeArg != null) {
|
| + typeArg.ensureSubtypeOf$3(typeParam.get$extendsType(), typeParam.span, true);
|
| + }
|
| + }
|
| + }
|
| + if (this.get$interfaces() != null) {
|
| + var $$list = this.get$interfaces();
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var i = $$list.$index($$i);
|
| + i._checkExtends$0();
|
| + }
|
| + }
|
| +}
|
| +Type.prototype._checkOverride = function(member) {
|
| + var parentMember = this._getMemberInParents(member.name);
|
| + if (parentMember != null) {
|
| + if (!member.get$isPrivate() || $eq(member.get$library(), parentMember.get$library())) {
|
| + member.override(parentMember);
|
| + }
|
| + }
|
| +}
|
| +Type.prototype._createNotEqualMember = function() {
|
| + var eq = this.get$members().$index(':eq');
|
| + if (eq == null) {
|
| + return;
|
| + }
|
| + var ne = new MethodMember(':ne', this, eq.definition);
|
| + ne.isGenerated = true;
|
| + ne.returnType = eq.returnType;
|
| + ne.parameters = eq.parameters;
|
| + ne.isStatic = eq.isStatic;
|
| + ne.isAbstract = eq.isAbstract;
|
| + this.get$members().$setindex(':ne', ne);
|
| +}
|
| +Type.prototype._getMemberInParents = function(memberName) {
|
| + if (this.get$isClass()) {
|
| + if (this.get$parent() != null) {
|
| + return this.get$parent().getMember(memberName);
|
| + }
|
| + else {
|
| + return null;
|
| + }
|
| + }
|
| + else {
|
| + if (this.get$interfaces() != null && this.get$interfaces().length > 0) {
|
| + var $$list = this.get$interfaces();
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var i = $$list.$index($$i);
|
| + var ret = i.getMember$1(memberName);
|
| + if (ret != null) {
|
| + return ret;
|
| + }
|
| + }
|
| + }
|
| + return $globals.world.objectType.getMember(memberName);
|
| + }
|
| +}
|
| +Type.prototype.resolveMember = function(memberName) {
|
| + var ret = this._resolvedMembers.$index(memberName);
|
| + if (ret != null) return ret;
|
| + var member = this.getMember(memberName);
|
| + if (member == null) {
|
| + return null;
|
| + }
|
| + ret = new MemberSet(member, false);
|
| + this._resolvedMembers.$setindex(memberName, ret);
|
| + if (member.get$isStatic()) {
|
| + return ret;
|
| + }
|
| + else {
|
| + var $$list = this.get$subtypes();
|
| + for (var $$i = this.get$subtypes().iterator(); $$i.hasNext$0(); ) {
|
| + var t = $$i.next$0();
|
| + if (!this.get$isClass() && t.get$isClass()) {
|
| + var m = t.getMember$1(memberName);
|
| + if (m != null && ret.members.indexOf(m) == -1) {
|
| + ret.add(m);
|
| + }
|
| + }
|
| + else {
|
| + var m = t.get$members().$index(memberName);
|
| + if (m != null) ret.add(m);
|
| + }
|
| + }
|
| + return ret;
|
| + }
|
| +}
|
| +Type.prototype.ensureSubtypeOf = function(other, span, typeErrors) {
|
| + if (!this.isSubtypeOf(other)) {
|
| + var msg = ('type ' + this.name + ' is not a subtype of ' + other.name);
|
| + if (typeErrors) {
|
| + $globals.world.error(msg, span);
|
| + }
|
| + else {
|
| + $globals.world.warning(msg, span);
|
| + }
|
| + }
|
| +}
|
| +Type.prototype.needsVarCall = function(args) {
|
| + if (this.get$isVarOrFunction()) {
|
| + return true;
|
| + }
|
| + var call = this.getCallMethod();
|
| + if (call != null) {
|
| + if (args.get$length() != call.get$parameters().length || !call.namesInOrder$1(args)) {
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| +}
|
| +Type.union = function(x, y) {
|
| + if ($eq(x, y)) return x;
|
| + if (x.get$isNum() && y.get$isNum()) return $globals.world.numType;
|
| + if (x.get$isString() && y.get$isString()) return $globals.world.stringType;
|
| + return $globals.world.varType;
|
| +}
|
| +Type.prototype.isAssignable = function(other) {
|
| + return this.isSubtypeOf(other) || other.isSubtypeOf(this);
|
| +}
|
| +Type.prototype._isDirectSupertypeOf = function(other) {
|
| + var $this = this; // closure support
|
| + if (other.get$isClass()) {
|
| + return $eq(other.get$parent(), this) || this.get$isObject() && other.get$parent() == null;
|
| + }
|
| + else {
|
| + if (other.get$interfaces() == null || other.get$interfaces().isEmpty()) {
|
| + return this.get$isObject();
|
| + }
|
| + else {
|
| + return other.get$interfaces().some((function (i) {
|
| + return $eq(i, $this);
|
| + })
|
| + );
|
| + }
|
| + }
|
| +}
|
| +Type.prototype.isSubtypeOf = function(other) {
|
| + if ((other instanceof ParameterType)) {
|
| + return true;
|
| + }
|
| + if ($eq(this, other)) return true;
|
| + if (this.get$isVar()) return true;
|
| + if (other.get$isVar()) return true;
|
| + if (other._isDirectSupertypeOf(this)) return true;
|
| + var call = this.getCallMethod();
|
| + var otherCall = other.getCallMethod();
|
| + if (call != null && otherCall != null) {
|
| + return Type._isFunctionSubtypeOf(call, otherCall);
|
| + }
|
| + if ($eq(this.get$genericType(), other.get$genericType()) && this.get$typeArgsInOrder() != null && other.get$typeArgsInOrder() != null && $eq(this.get$typeArgsInOrder().length, other.get$typeArgsInOrder().length)) {
|
| + var t = this.get$typeArgsInOrder().iterator$0();
|
| + var s = other.get$typeArgsInOrder().iterator$0();
|
| + while (t.hasNext$0()) {
|
| + if (!t.next$0().isSubtypeOf$1(s.next$0())) return false;
|
| + }
|
| + return true;
|
| + }
|
| + if (this.get$parent() != null && this.get$parent().isSubtypeOf(other)) {
|
| + return true;
|
| + }
|
| + if (this.get$interfaces() != null && this.get$interfaces().some((function (i) {
|
| + return i.isSubtypeOf$1(other);
|
| + })
|
| + )) {
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +Type.prototype.hashCode = function() {
|
| + var libraryCode = this.get$library() == null ? 1 : this.get$library().hashCode();
|
| + var nameCode = this.name == null ? 1 : this.name.hashCode();
|
| + return (libraryCode << 4) ^ nameCode;
|
| +}
|
| +Type.prototype.$eq = function(other) {
|
| + return (other instanceof Type) && $eq(other.name, this.name) && $eq(this.get$library(), other.get$library());
|
| +}
|
| +Type._isFunctionSubtypeOf = function(t, s) {
|
| + if (!s.returnType.get$isVoid() && !s.returnType.isAssignable(t.returnType)) {
|
| + return false;
|
| + }
|
| + var tp = t.parameters;
|
| + var sp = s.parameters;
|
| + if (tp.length < sp.length) return false;
|
| + for (var i = 0;
|
| + i < sp.length; i++) {
|
| + if ($ne(tp.$index(i).get$isOptional(), sp.$index(i).get$isOptional())) return false;
|
| + if (tp.$index(i).get$isOptional() && $ne(tp.$index(i).name, sp.$index(i).name)) return false;
|
| + if (!tp.$index(i).type.isAssignable$1(sp.$index(i).type)) return false;
|
| + }
|
| + if (tp.length > sp.length && !tp.$index(sp.length).get$isOptional()) return false;
|
| + return true;
|
| +}
|
| +Type.prototype._checkExtends$0 = Type.prototype._checkExtends;
|
| +Type.prototype.addDirectSubtype$1 = Type.prototype.addDirectSubtype;
|
| +Type.prototype.ensureSubtypeOf$3 = Type.prototype.ensureSubtypeOf;
|
| +Type.prototype.getConstructor$1 = Type.prototype.getConstructor;
|
| +Type.prototype.getFactory$2 = Type.prototype.getFactory;
|
| +Type.prototype.getMember$1 = Type.prototype.getMember;
|
| +Type.prototype.getOrMakeConcreteType$1 = Type.prototype.getOrMakeConcreteType;
|
| +Type.prototype.hashCode$0 = Type.prototype.hashCode;
|
| +Type.prototype.isAssignable$1 = Type.prototype.isAssignable;
|
| +Type.prototype.isSubtypeOf$1 = Type.prototype.isSubtypeOf;
|
| +Type.prototype.markUsed$0 = Type.prototype.markUsed;
|
| +Type.prototype.resolveTypeParams$1 = Type.prototype.resolveTypeParams;
|
| +// ********** Code for ParameterType **************
|
| +$inherits(ParameterType, Type);
|
| +function ParameterType(name, typeParameter) {
|
| + this.typeParameter = typeParameter;
|
| + // Initializers done
|
| + Type.call(this, name);
|
| +}
|
| +ParameterType.prototype.get$typeParameter = function() { return this.typeParameter; };
|
| +ParameterType.prototype.set$typeParameter = function(value) { return this.typeParameter = value; };
|
| +ParameterType.prototype.get$extendsType = function() { return this.extendsType; };
|
| +ParameterType.prototype.set$extendsType = function(value) { return this.extendsType = value; };
|
| +ParameterType.prototype.get$isClass = function() {
|
| + return false;
|
| +}
|
| +ParameterType.prototype.get$library = function() {
|
| + return null;
|
| +}
|
| +ParameterType.prototype.get$span = function() {
|
| + return this.typeParameter.span;
|
| +}
|
| +Object.defineProperty(ParameterType.prototype, "span", {
|
| + get: ParameterType.prototype.get$span
|
| +});
|
| +ParameterType.prototype.get$constructors = function() {
|
| + $globals.world.internalError('no constructors on type parameters yet');
|
| +}
|
| +ParameterType.prototype.getCallMethod = function() {
|
| + return this.extendsType.getCallMethod();
|
| +}
|
| +ParameterType.prototype.genMethod = function(method) {
|
| + this.extendsType.genMethod(method);
|
| +}
|
| +ParameterType.prototype.isSubtypeOf = function(other) {
|
| + return true;
|
| +}
|
| +ParameterType.prototype.resolveMember = function(memberName) {
|
| + return this.extendsType.resolveMember(memberName);
|
| +}
|
| +ParameterType.prototype.getConstructor = function(constructorName) {
|
| + $globals.world.internalError('no constructors on type parameters yet');
|
| +}
|
| +ParameterType.prototype.getOrMakeConcreteType = function(typeArgs) {
|
| + $globals.world.internalError('no concrete types of type parameters yet', this.get$span());
|
| +}
|
| +ParameterType.prototype.resolveTypeParams = function(inType) {
|
| + return inType.typeArguments.$index(this.name);
|
| +}
|
| +ParameterType.prototype.addDirectSubtype = function(type) {
|
| + $globals.world.internalError('no subtypes of type parameters yet', this.get$span());
|
| +}
|
| +ParameterType.prototype.resolve = function() {
|
| + if (this.typeParameter.extendsType != null) {
|
| + this.extendsType = this.get$enclosingElement().resolveType(this.typeParameter.extendsType, true);
|
| + }
|
| + else {
|
| + this.extendsType = $globals.world.objectType;
|
| + }
|
| +}
|
| +ParameterType.prototype.addDirectSubtype$1 = ParameterType.prototype.addDirectSubtype;
|
| +ParameterType.prototype.getConstructor$1 = ParameterType.prototype.getConstructor;
|
| +ParameterType.prototype.getOrMakeConcreteType$1 = ParameterType.prototype.getOrMakeConcreteType;
|
| +ParameterType.prototype.isSubtypeOf$1 = ParameterType.prototype.isSubtypeOf;
|
| +ParameterType.prototype.resolve$0 = ParameterType.prototype.resolve;
|
| +ParameterType.prototype.resolveTypeParams$1 = ParameterType.prototype.resolveTypeParams;
|
| +// ********** Code for NonNullableType **************
|
| +$inherits(NonNullableType, Type);
|
| +function NonNullableType(type) {
|
| + this.type = type;
|
| + // Initializers done
|
| + Type.call(this, type.name);
|
| +}
|
| +NonNullableType.prototype.get$isNullable = function() {
|
| + return false;
|
| +}
|
| +NonNullableType.prototype.get$isBool = function() {
|
| + return this.type.get$isBool();
|
| +}
|
| +NonNullableType.prototype.get$isUsed = function() {
|
| + return false;
|
| +}
|
| +NonNullableType.prototype.isSubtypeOf = function(other) {
|
| + return $eq(this, other) || $eq(this.type, other) || this.type.isSubtypeOf(other);
|
| +}
|
| +NonNullableType.prototype.resolveType = function(node, isRequired) {
|
| + return this.type.resolveType(node, isRequired);
|
| +}
|
| +NonNullableType.prototype.resolveTypeParams = function(inType) {
|
| + return this.type.resolveTypeParams(inType);
|
| +}
|
| +NonNullableType.prototype.addDirectSubtype = function(subtype) {
|
| + this.type.addDirectSubtype(subtype);
|
| +}
|
| +NonNullableType.prototype.markUsed = function() {
|
| + this.type.markUsed();
|
| +}
|
| +NonNullableType.prototype.genMethod = function(method) {
|
| + this.type.genMethod(method);
|
| +}
|
| +NonNullableType.prototype.get$span = function() {
|
| + return this.type.get$span();
|
| +}
|
| +Object.defineProperty(NonNullableType.prototype, "span", {
|
| + get: NonNullableType.prototype.get$span
|
| +});
|
| +NonNullableType.prototype.resolveMember = function(name) {
|
| + return this.type.resolveMember(name);
|
| +}
|
| +NonNullableType.prototype.getMember = function(name) {
|
| + return this.type.getMember(name);
|
| +}
|
| +NonNullableType.prototype.getConstructor = function(name) {
|
| + return this.type.getConstructor(name);
|
| +}
|
| +NonNullableType.prototype.getFactory = function(t, name) {
|
| + return this.type.getFactory(t, name);
|
| +}
|
| +NonNullableType.prototype.getOrMakeConcreteType = function(typeArgs) {
|
| + return this.type.getOrMakeConcreteType(typeArgs);
|
| +}
|
| +NonNullableType.prototype.get$constructors = function() {
|
| + return this.type.get$constructors();
|
| +}
|
| +NonNullableType.prototype.get$isClass = function() {
|
| + return this.type.get$isClass();
|
| +}
|
| +NonNullableType.prototype.get$library = function() {
|
| + return this.type.get$library();
|
| +}
|
| +NonNullableType.prototype.getCallMethod = function() {
|
| + return this.type.getCallMethod();
|
| +}
|
| +NonNullableType.prototype.get$isGeneric = function() {
|
| + return this.type.get$isGeneric();
|
| +}
|
| +NonNullableType.prototype.get$hasTypeParams = function() {
|
| + return this.type.get$hasTypeParams();
|
| +}
|
| +NonNullableType.prototype.get$typeofName = function() {
|
| + return this.type.get$typeofName();
|
| +}
|
| +NonNullableType.prototype.get$jsname = function() {
|
| + return this.type.get$jsname();
|
| +}
|
| +NonNullableType.prototype.get$members = function() {
|
| + return this.type.get$members();
|
| +}
|
| +NonNullableType.prototype.get$definition = function() {
|
| + return this.type.get$definition();
|
| +}
|
| +NonNullableType.prototype.get$factories = function() {
|
| + return this.type.get$factories();
|
| +}
|
| +NonNullableType.prototype.get$typeArgsInOrder = function() {
|
| + return this.type.get$typeArgsInOrder();
|
| +}
|
| +NonNullableType.prototype.get$genericType = function() {
|
| + return this.type.get$genericType();
|
| +}
|
| +NonNullableType.prototype.get$interfaces = function() {
|
| + return this.type.get$interfaces();
|
| +}
|
| +NonNullableType.prototype.get$parent = function() {
|
| + return this.type.get$parent();
|
| +}
|
| +Object.defineProperty(NonNullableType.prototype, "parent", {
|
| + get: NonNullableType.prototype.get$parent
|
| +});
|
| +NonNullableType.prototype.getAllMembers = function() {
|
| + return this.type.getAllMembers();
|
| +}
|
| +NonNullableType.prototype.get$isNative = function() {
|
| + return this.type.get$isNative();
|
| +}
|
| +NonNullableType.prototype.addDirectSubtype$1 = NonNullableType.prototype.addDirectSubtype;
|
| +NonNullableType.prototype.getConstructor$1 = NonNullableType.prototype.getConstructor;
|
| +NonNullableType.prototype.getFactory$2 = NonNullableType.prototype.getFactory;
|
| +NonNullableType.prototype.getMember$1 = NonNullableType.prototype.getMember;
|
| +NonNullableType.prototype.getOrMakeConcreteType$1 = NonNullableType.prototype.getOrMakeConcreteType;
|
| +NonNullableType.prototype.isSubtypeOf$1 = NonNullableType.prototype.isSubtypeOf;
|
| +NonNullableType.prototype.markUsed$0 = NonNullableType.prototype.markUsed;
|
| +NonNullableType.prototype.resolveTypeParams$1 = NonNullableType.prototype.resolveTypeParams;
|
| +// ********** Code for ConcreteType **************
|
| +$inherits(ConcreteType, Type);
|
| +function ConcreteType(name, genericType, typeArguments, typeArgsInOrder) {
|
| + this.isUsed = false
|
| + this.genericType = genericType;
|
| + this.typeArguments = typeArguments;
|
| + this.typeArgsInOrder = typeArgsInOrder;
|
| + this.constructors = new HashMapImplementation();
|
| + this.members = new HashMapImplementation();
|
| + this.factories = new FactoryMap();
|
| + // Initializers done
|
| + Type.call(this, name);
|
| +}
|
| +ConcreteType.prototype.get$genericType = function() { return this.genericType; };
|
| +ConcreteType.prototype.get$typeArguments = function() { return this.typeArguments; };
|
| +ConcreteType.prototype.set$typeArguments = function(value) { return this.typeArguments = value; };
|
| +ConcreteType.prototype.get$_lang_parent = function() { return this._lang_parent; };
|
| +ConcreteType.prototype.set$_lang_parent = function(value) { return this._lang_parent = value; };
|
| +ConcreteType.prototype.get$typeArgsInOrder = function() { return this.typeArgsInOrder; };
|
| +ConcreteType.prototype.set$typeArgsInOrder = function(value) { return this.typeArgsInOrder = value; };
|
| +ConcreteType.prototype.get$isList = function() {
|
| + return this.genericType.get$isList();
|
| +}
|
| +ConcreteType.prototype.get$isClass = function() {
|
| + return this.genericType.isClass;
|
| +}
|
| +ConcreteType.prototype.get$library = function() {
|
| + return this.genericType.library;
|
| +}
|
| +ConcreteType.prototype.get$span = function() {
|
| + return this.genericType.get$span();
|
| +}
|
| +Object.defineProperty(ConcreteType.prototype, "span", {
|
| + get: ConcreteType.prototype.get$span
|
| +});
|
| +ConcreteType.prototype.get$hasTypeParams = function() {
|
| + return this.typeArguments.getValues().some$1((function (e) {
|
| + return (e instanceof ParameterType);
|
| + })
|
| + );
|
| +}
|
| +ConcreteType.prototype.get$isUsed = function() { return this.isUsed; };
|
| +ConcreteType.prototype.set$isUsed = function(value) { return this.isUsed = value; };
|
| +ConcreteType.prototype.get$members = function() { return this.members; };
|
| +ConcreteType.prototype.set$members = function(value) { return this.members = value; };
|
| +ConcreteType.prototype.get$constructors = function() { return this.constructors; };
|
| +ConcreteType.prototype.set$constructors = function(value) { return this.constructors = value; };
|
| +ConcreteType.prototype.get$factories = function() { return this.factories; };
|
| +ConcreteType.prototype.set$factories = function(value) { return this.factories = value; };
|
| +ConcreteType.prototype.resolveTypeParams = function(inType) {
|
| + var newTypeArgs = [];
|
| + var needsNewType = false;
|
| + var $$list = this.typeArgsInOrder;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var t = $$list.$index($$i);
|
| + var newType = t.resolveTypeParams$1(inType);
|
| + if ($ne(newType, t)) needsNewType = true;
|
| + newTypeArgs.add$1(newType);
|
| + }
|
| + if (!needsNewType) return this;
|
| + return this.genericType.getOrMakeConcreteType(newTypeArgs);
|
| +}
|
| +ConcreteType.prototype.getOrMakeConcreteType = function(typeArgs) {
|
| + return this.genericType.getOrMakeConcreteType(typeArgs);
|
| +}
|
| +ConcreteType.prototype.get$parent = function() {
|
| + if (this._lang_parent == null && this.genericType.get$parent() != null) {
|
| + this._lang_parent = this.genericType.get$parent().resolveTypeParams(this);
|
| + }
|
| + return this._lang_parent;
|
| +}
|
| +Object.defineProperty(ConcreteType.prototype, "parent", {
|
| + get: ConcreteType.prototype.get$parent
|
| +});
|
| +ConcreteType.prototype.get$interfaces = function() {
|
| + if (this._interfaces == null && this.genericType.interfaces != null) {
|
| + this._interfaces = [];
|
| + var $$list = this.genericType.interfaces;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var i = $$list.$index($$i);
|
| + this._interfaces.add(i.resolveTypeParams$1(this));
|
| + }
|
| + }
|
| + return this._interfaces;
|
| +}
|
| +ConcreteType.prototype.get$subtypes = function() {
|
| + if (this._subtypes == null) {
|
| + this._subtypes = new HashSetImplementation();
|
| + var $$list = this.genericType.get$subtypes();
|
| + for (var $$i = this.genericType.get$subtypes().iterator(); $$i.hasNext$0(); ) {
|
| + var s = $$i.next$0();
|
| + this._subtypes.add(s.resolveTypeParams$1(this));
|
| + }
|
| + }
|
| + return this._subtypes;
|
| +}
|
| +ConcreteType.prototype.getCallMethod = function() {
|
| + return this.genericType.getCallMethod();
|
| +}
|
| +ConcreteType.prototype.getAllMembers = function() {
|
| + var result = this.genericType.getAllMembers();
|
| + var $$list = result.getKeys$0();
|
| + for (var $$i = result.getKeys$0().iterator$0(); $$i.hasNext$0(); ) {
|
| + var memberName = $$i.next$0();
|
| + var myMember = this.members.$index(memberName);
|
| + if (myMember != null) {
|
| + result.$setindex(memberName, myMember);
|
| + }
|
| + }
|
| + return result;
|
| +}
|
| +ConcreteType.prototype.markUsed = function() {
|
| + if (this.isUsed) return;
|
| + this.isUsed = true;
|
| + this._checkExtends();
|
| + this.genericType.markUsed();
|
| +}
|
| +ConcreteType.prototype.genMethod = function(method) {
|
| + return this.genericType.genMethod(method);
|
| +}
|
| +ConcreteType.prototype.getFactory = function(type, constructorName) {
|
| + return this.genericType.getFactory(type, constructorName);
|
| +}
|
| +ConcreteType.prototype.getConstructor = function(constructorName) {
|
| + var ret = this.constructors.$index(constructorName);
|
| + if (ret != null) return ret;
|
| + ret = this.factories.getFactory(this.name, constructorName);
|
| + if (ret != null) return ret;
|
| + var genericMember = this.genericType.getConstructor(constructorName);
|
| + if (genericMember == null) return null;
|
| + if ($ne(genericMember.get$declaringType(), this.genericType)) {
|
| + if (!genericMember.get$declaringType().get$isGeneric()) return genericMember;
|
| + var newDeclaringType = genericMember.get$declaringType().getOrMakeConcreteType$1(this.typeArgsInOrder);
|
| + var factory = newDeclaringType.getFactory$2(this.genericType, constructorName);
|
| + if (factory != null) return factory;
|
| + return newDeclaringType.getConstructor$1(constructorName);
|
| + }
|
| + if (genericMember.get$isFactory()) {
|
| + ret = new ConcreteMember(genericMember.name, this, genericMember);
|
| + this.factories.addFactory(this.name, constructorName, ret);
|
| + }
|
| + else {
|
| + ret = new ConcreteMember(this.name, this, genericMember);
|
| + this.constructors.$setindex(constructorName, ret);
|
| + }
|
| + return ret;
|
| +}
|
| +ConcreteType.prototype.getMember = function(memberName) {
|
| + var member = this.members.$index(memberName);
|
| + if (member != null) {
|
| + this._checkOverride(member);
|
| + return member;
|
| + }
|
| + var genericMember = this.genericType.members.$index(memberName);
|
| + if (genericMember != null) {
|
| + member = new ConcreteMember(genericMember.name, this, genericMember);
|
| + this.members.$setindex(memberName, member);
|
| + return member;
|
| + }
|
| + return this._getMemberInParents(memberName);
|
| +}
|
| +ConcreteType.prototype.resolveType = function(node, isRequired) {
|
| + var ret = this.genericType.resolveType(node, isRequired);
|
| + return ret;
|
| +}
|
| +ConcreteType.prototype.addDirectSubtype = function(type) {
|
| + this.genericType.addDirectSubtype(type);
|
| +}
|
| +ConcreteType.prototype.addDirectSubtype$1 = ConcreteType.prototype.addDirectSubtype;
|
| +ConcreteType.prototype.getConstructor$1 = ConcreteType.prototype.getConstructor;
|
| +ConcreteType.prototype.getFactory$2 = ConcreteType.prototype.getFactory;
|
| +ConcreteType.prototype.getMember$1 = ConcreteType.prototype.getMember;
|
| +ConcreteType.prototype.getOrMakeConcreteType$1 = ConcreteType.prototype.getOrMakeConcreteType;
|
| +ConcreteType.prototype.markUsed$0 = ConcreteType.prototype.markUsed;
|
| +ConcreteType.prototype.resolveTypeParams$1 = ConcreteType.prototype.resolveTypeParams;
|
| +// ********** Code for DefinedType **************
|
| +$inherits(DefinedType, Type);
|
| +function DefinedType(name, library, definition, isClass) {
|
| + this.isUsed = false
|
| + this.isNative = false
|
| + this.library = library;
|
| + this.isClass = isClass;
|
| + this.directSubtypes = new HashSetImplementation();
|
| + this.constructors = new HashMapImplementation();
|
| + this.members = new HashMapImplementation();
|
| + this.factories = new FactoryMap();
|
| + // Initializers done
|
| + Type.call(this, name);
|
| + this.setDefinition(definition);
|
| +}
|
| +DefinedType.prototype.get$definition = function() { return this.definition; };
|
| +DefinedType.prototype.set$definition = function(value) { return this.definition = value; };
|
| +DefinedType.prototype.get$library = function() { return this.library; };
|
| +DefinedType.prototype.get$isClass = function() { return this.isClass; };
|
| +DefinedType.prototype.get$_parent = function() { return this._parent; };
|
| +DefinedType.prototype.set$_parent = function(value) { return this._parent = value; };
|
| +DefinedType.prototype.get$parent = function() {
|
| + return this._parent;
|
| +}
|
| +DefinedType.prototype.set$parent = function(p) {
|
| + this._parent = p;
|
| +}
|
| +Object.defineProperty(DefinedType.prototype, "parent", {
|
| + get: DefinedType.prototype.get$parent,
|
| + set: DefinedType.prototype.set$parent
|
| +});
|
| +DefinedType.prototype.get$interfaces = function() { return this.interfaces; };
|
| +DefinedType.prototype.set$interfaces = function(value) { return this.interfaces = value; };
|
| +DefinedType.prototype.get$typeParameters = function() { return this.typeParameters; };
|
| +DefinedType.prototype.set$typeParameters = function(value) { return this.typeParameters = value; };
|
| +DefinedType.prototype.get$constructors = function() { return this.constructors; };
|
| +DefinedType.prototype.set$constructors = function(value) { return this.constructors = value; };
|
| +DefinedType.prototype.get$members = function() { return this.members; };
|
| +DefinedType.prototype.set$members = function(value) { return this.members = value; };
|
| +DefinedType.prototype.get$factories = function() { return this.factories; };
|
| +DefinedType.prototype.set$factories = function(value) { return this.factories = value; };
|
| +DefinedType.prototype.get$_concreteTypes = function() { return this._concreteTypes; };
|
| +DefinedType.prototype.set$_concreteTypes = function(value) { return this._concreteTypes = value; };
|
| +DefinedType.prototype.get$isUsed = function() { return this.isUsed; };
|
| +DefinedType.prototype.set$isUsed = function(value) { return this.isUsed = value; };
|
| +DefinedType.prototype.get$isNative = function() { return this.isNative; };
|
| +DefinedType.prototype.set$isNative = function(value) { return this.isNative = value; };
|
| +DefinedType.prototype.setDefinition = function(def) {
|
| + this.definition = def;
|
| + if ((this.definition instanceof TypeDefinition) && this.definition.get$nativeType() != null) {
|
| + this.isNative = true;
|
| + }
|
| + if (this.definition != null && this.definition.get$typeParameters() != null) {
|
| + this._concreteTypes = new HashMapImplementation();
|
| + this.typeParameters = this.definition.get$typeParameters();
|
| + }
|
| +}
|
| +DefinedType.prototype.get$nativeType = function() {
|
| + return (this.definition != null ? this.definition.get$nativeType() : null);
|
| +}
|
| +DefinedType.prototype.get$typeArgsInOrder = function() {
|
| + if (this.typeParameters == null) return null;
|
| + if (this._typeArgsInOrder == null) {
|
| + this._typeArgsInOrder = new FixedCollection_Type($globals.world.varType, this.typeParameters.length);
|
| + }
|
| + return this._typeArgsInOrder;
|
| +}
|
| +DefinedType.prototype.get$isVar = function() {
|
| + return $eq(this, $globals.world.varType);
|
| +}
|
| +DefinedType.prototype.get$isVoid = function() {
|
| + return $eq(this, $globals.world.voidType);
|
| +}
|
| +DefinedType.prototype.get$isTop = function() {
|
| + return this.name == null;
|
| +}
|
| +DefinedType.prototype.get$isObject = function() {
|
| + return this.library.get$isCore() && this.name == 'Object';
|
| +}
|
| +DefinedType.prototype.get$isString = function() {
|
| + return this.library.get$isCore() && this.name == 'String' || this.library.get$isCoreImpl() && this.name == 'StringImplementation';
|
| +}
|
| +DefinedType.prototype.get$isBool = function() {
|
| + return this.library.get$isCore() && this.name == 'bool';
|
| +}
|
| +DefinedType.prototype.get$isFunction = function() {
|
| + return this.library.get$isCore() && this.name == 'Function';
|
| +}
|
| +DefinedType.prototype.get$isList = function() {
|
| + return this.library.get$isCore() && this.name == 'List';
|
| +}
|
| +DefinedType.prototype.get$isGeneric = function() {
|
| + return this.typeParameters != null;
|
| +}
|
| +DefinedType.prototype.get$span = function() {
|
| + return this.definition == null ? null : this.definition.span;
|
| +}
|
| +Object.defineProperty(DefinedType.prototype, "span", {
|
| + get: DefinedType.prototype.get$span
|
| +});
|
| +DefinedType.prototype.get$typeofName = function() {
|
| + if (!this.library.get$isCore()) return null;
|
| + if (this.get$isBool()) return 'boolean';
|
| + else if (this.get$isNum()) return 'number';
|
| + else if (this.get$isString()) return 'string';
|
| + else if (this.get$isFunction()) return 'function';
|
| + else return null;
|
| +}
|
| +DefinedType.prototype.get$isNum = function() {
|
| + return this.library != null && this.library.get$isCore() && (this.name == 'num' || this.name == 'int' || this.name == 'double');
|
| +}
|
| +DefinedType.prototype.getCallMethod = function() {
|
| + return this.members.$index(':call');
|
| +}
|
| +DefinedType.prototype.getAllMembers = function() {
|
| + return HashMapImplementation.HashMapImplementation$from$factory(this.members);
|
| +}
|
| +DefinedType.prototype.markUsed = function() {
|
| + if (this.isUsed) return;
|
| + this.isUsed = true;
|
| + this._checkExtends();
|
| + if (this._lazyGenMethods != null) {
|
| + var $$list = orderValuesByKeys(this._lazyGenMethods);
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var method = $$list.$index($$i);
|
| + $globals.world.gen.genMethod(method);
|
| + }
|
| + this._lazyGenMethods = null;
|
| + }
|
| + if (this.get$parent() != null) this.get$parent().markUsed();
|
| +}
|
| +DefinedType.prototype.genMethod = function(method) {
|
| + if (this.isUsed) {
|
| + $globals.world.gen.genMethod(method);
|
| + }
|
| + else if (this.isClass) {
|
| + if (this._lazyGenMethods == null) this._lazyGenMethods = new HashMapImplementation();
|
| + this._lazyGenMethods.$setindex(method.name, method);
|
| + }
|
| +}
|
| +DefinedType.prototype._resolveInterfaces = function(types) {
|
| + if (types == null) return [];
|
| + var interfaces = [];
|
| + for (var $$i = 0;$$i < types.length; $$i++) {
|
| + var type = types.$index($$i);
|
| + var resolvedInterface = this.resolveType(type, true);
|
| + if (resolvedInterface.get$isClosed() && !(this.library.get$isCore() || this.library.get$isCoreImpl())) {
|
| + $globals.world.error(('can not implement "' + resolvedInterface.name + '": ') + 'only native implementation allowed', type.span);
|
| + }
|
| + resolvedInterface.addDirectSubtype$1(this);
|
| + interfaces.add$1(resolvedInterface);
|
| + }
|
| + return interfaces;
|
| +}
|
| +DefinedType.prototype.addDirectSubtype = function(type) {
|
| + this.directSubtypes.add(type);
|
| +}
|
| +DefinedType.prototype.get$subtypes = function() {
|
| + if (this._subtypes == null) {
|
| + this._subtypes = new HashSetImplementation();
|
| + var $$list = this.directSubtypes;
|
| + for (var $$i = this.directSubtypes.iterator(); $$i.hasNext$0(); ) {
|
| + var st = $$i.next$0();
|
| + this._subtypes.add(st);
|
| + this._subtypes.addAll(st.get$subtypes());
|
| + }
|
| + }
|
| + return this._subtypes;
|
| +}
|
| +DefinedType.prototype._cycleInClassExtends = function() {
|
| + var seen = new HashSetImplementation();
|
| + seen.add(this);
|
| + var ancestor = this.get$parent();
|
| + while (ancestor != null) {
|
| + if (ancestor === this) {
|
| + return true;
|
| + }
|
| + if (seen.contains(ancestor)) {
|
| + return false;
|
| + }
|
| + seen.add(ancestor);
|
| + ancestor = ancestor.parent;
|
| + }
|
| + return false;
|
| +}
|
| +DefinedType.prototype._cycleInInterfaceExtends = function() {
|
| + var $this = this; // closure support
|
| + var seen = new HashSetImplementation();
|
| + seen.add(this);
|
| + function _helper(ancestor) {
|
| + if (ancestor == null) return false;
|
| + if (ancestor === $this) return true;
|
| + if (seen.contains(ancestor)) {
|
| + return false;
|
| + }
|
| + seen.add(ancestor);
|
| + if (ancestor.get$interfaces() != null) {
|
| + var $$list = ancestor.get$interfaces();
|
| + for (var $$i = ancestor.get$interfaces().iterator$0(); $$i.hasNext$0(); ) {
|
| + var parent = $$i.next$0();
|
| + if (_helper(parent)) return true;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| + for (var i = 0;
|
| + i < this.interfaces.length; i++) {
|
| + if (_helper(this.interfaces.$index(i))) return i;
|
| + }
|
| + return -1;
|
| +}
|
| +DefinedType.prototype.resolve = function() {
|
| + if ((this.definition instanceof TypeDefinition)) {
|
| + var typeDef = this.definition;
|
| + if (this.isClass) {
|
| + if (typeDef.extendsTypes != null && typeDef.extendsTypes.length > 0) {
|
| + if (typeDef.extendsTypes.length > 1) {
|
| + $globals.world.error('more than one base class', typeDef.extendsTypes.$index(1).span);
|
| + }
|
| + var extendsTypeRef = typeDef.extendsTypes.$index(0);
|
| + if ((extendsTypeRef instanceof GenericTypeReference)) {
|
| + var g = extendsTypeRef;
|
| + this.set$parent(this.resolveType(g.baseType, true));
|
| + }
|
| + this.set$parent(this.resolveType(extendsTypeRef, true));
|
| + if (!this.get$parent().get$isClass()) {
|
| + $globals.world.error('class may not extend an interface - use implements', typeDef.extendsTypes.$index(0).span);
|
| + }
|
| + this.get$parent().addDirectSubtype(this);
|
| + if (this._cycleInClassExtends()) {
|
| + $globals.world.error(('class "' + this.name + '" has a cycle in its inheritance chain'), extendsTypeRef.span);
|
| + }
|
| + }
|
| + else {
|
| + if (!this.get$isObject()) {
|
| + this.set$parent($globals.world.objectType);
|
| + this.get$parent().addDirectSubtype(this);
|
| + }
|
| + }
|
| + this.interfaces = this._resolveInterfaces(typeDef.implementsTypes);
|
| + if (typeDef.factoryType != null) {
|
| + $globals.world.error('factory not allowed on classes', typeDef.factoryType.span);
|
| + }
|
| + }
|
| + else {
|
| + if (typeDef.implementsTypes != null && typeDef.implementsTypes.length > 0) {
|
| + $globals.world.error('implements not allowed on interfaces (use extends)', typeDef.implementsTypes.$index(0).span);
|
| + }
|
| + this.interfaces = this._resolveInterfaces(typeDef.extendsTypes);
|
| + var res = this._cycleInInterfaceExtends();
|
| + if (res >= 0) {
|
| + $globals.world.error(('interface "' + this.name + '" has a cycle in its inheritance chain'), typeDef.extendsTypes.$index(res).span);
|
| + }
|
| + if (typeDef.factoryType != null) {
|
| + this.factory_ = this.resolveType(typeDef.factoryType, true);
|
| + if (this.factory_ == null) {
|
| + $globals.world.warning('unresolved factory', typeDef.factoryType.span);
|
| + }
|
| + }
|
| + }
|
| + }
|
| + else if ((this.definition instanceof FunctionTypeDefinition)) {
|
| + this.interfaces = [$globals.world.functionType];
|
| + }
|
| + if (this.typeParameters != null) {
|
| + var $$list = this.typeParameters;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var tp = $$list.$index($$i);
|
| + tp.set$enclosingElement(this);
|
| + tp.resolve$0();
|
| + }
|
| + }
|
| + if (this.get$isObject()) this._createNotEqualMember();
|
| + $globals.world._addType(this);
|
| + var $$list = this.constructors.getValues();
|
| + for (var $$i = this.constructors.getValues().iterator$0(); $$i.hasNext$0(); ) {
|
| + var c = $$i.next$0();
|
| + c.resolve$0();
|
| + }
|
| + var $list0 = this.members.getValues();
|
| + for (var $$i = this.members.getValues().iterator$0(); $$i.hasNext$0(); ) {
|
| + var m = $$i.next$0();
|
| + m.resolve$0();
|
| + }
|
| + this.factories.forEach((function (f) {
|
| + return f.resolve$0();
|
| + })
|
| + );
|
| + if (this.get$isJsGlobalObject()) {
|
| + var $list1 = this.members.getValues();
|
| + for (var $$i = this.members.getValues().iterator$0(); $$i.hasNext$0(); ) {
|
| + var m0 = $$i.next$0();
|
| + if (!m0.get$isStatic()) $globals.world._addTopName(m0);
|
| + }
|
| + }
|
| +}
|
| +DefinedType.prototype.addMethod = function(methodName, definition) {
|
| + if (methodName == null) methodName = definition.name.name;
|
| + var method = new MethodMember(methodName, this, definition);
|
| + if (method.get$isConstructor()) {
|
| + if (this.constructors.containsKey(method.get$constructorName())) {
|
| + $globals.world.error(('duplicate constructor definition of ' + method.name), definition.span);
|
| + return;
|
| + }
|
| + this.constructors.$setindex(method.get$constructorName(), method);
|
| + return;
|
| + }
|
| + if (definition.modifiers != null && definition.modifiers.length == 1 && $eq(definition.modifiers.$index(0).kind, 75/*TokenKind.FACTORY*/)) {
|
| + if (this.factories.getFactory(method.get$constructorName(), method.name) != null) {
|
| + $globals.world.error(('duplicate factory definition of "' + method.name + '"'), definition.span);
|
| + return;
|
| + }
|
| + this.factories.addFactory(method.get$constructorName(), method.name, method);
|
| + return;
|
| + }
|
| + if (methodName.startsWith('get:') || methodName.startsWith('set:')) {
|
| + var propName = methodName.substring(4);
|
| + var prop = this.members.$index(propName);
|
| + if (prop == null) {
|
| + prop = new PropertyMember(propName, this);
|
| + this.members.$setindex(propName, prop);
|
| + }
|
| + if (!(prop instanceof PropertyMember)) {
|
| + $globals.world.error(('property conflicts with field "' + propName + '"'), definition.span);
|
| + return;
|
| + }
|
| + if (methodName[0] == 'g') {
|
| + if (prop.get$getter() != null) {
|
| + $globals.world.error(('duplicate getter definition for "' + propName + '"'), definition.span);
|
| + }
|
| + prop.set$getter(method);
|
| + }
|
| + else {
|
| + if (prop.get$setter() != null) {
|
| + $globals.world.error(('duplicate setter definition for "' + propName + '"'), definition.span);
|
| + }
|
| + prop.set$setter(method);
|
| + }
|
| + return;
|
| + }
|
| + if (this.members.containsKey(methodName)) {
|
| + $globals.world.error(('duplicate method definition of "' + method.name + '"'), definition.span);
|
| + return;
|
| + }
|
| + this.members.$setindex(methodName, method);
|
| +}
|
| +DefinedType.prototype.addField = function(definition) {
|
| + for (var i = 0;
|
| + i < definition.names.length; i++) {
|
| + var name = definition.names.$index(i).name;
|
| + if (this.members.containsKey(name)) {
|
| + $globals.world.error(('duplicate field definition of "' + name + '"'), definition.span);
|
| + return;
|
| + }
|
| + var value = null;
|
| + if (definition.values != null) {
|
| + value = definition.values.$index(i);
|
| + }
|
| + var field = new FieldMember(name, this, definition, value);
|
| + this.members.$setindex(name, field);
|
| + if (this.isNative) {
|
| + field.set$isNative(true);
|
| + }
|
| + }
|
| +}
|
| +DefinedType.prototype.getFactory = function(type, constructorName) {
|
| + var ret = this.factories.getFactory(type.name, constructorName);
|
| + if (ret != null) return ret;
|
| + ret = this.factories.getFactory(this.name, constructorName);
|
| + if (ret != null) return ret;
|
| + ret = this.constructors.$index(constructorName);
|
| + if (ret != null) return ret;
|
| + return this._tryCreateDefaultConstructor(constructorName);
|
| +}
|
| +DefinedType.prototype.getConstructor = function(constructorName) {
|
| + var ret = this.constructors.$index(constructorName);
|
| + if (ret != null) {
|
| + if (this.factory_ != null) {
|
| + return this.factory_.getFactory(this, constructorName);
|
| + }
|
| + return ret;
|
| + }
|
| + ret = this.factories.getFactory(this.name, constructorName);
|
| + if (ret != null) return ret;
|
| + return this._tryCreateDefaultConstructor(constructorName);
|
| +}
|
| +DefinedType.prototype._tryCreateDefaultConstructor = function(name) {
|
| + if (name == '' && this.definition != null && this.isClass && this.constructors.get$length() == 0) {
|
| + var span = this.definition.span;
|
| + var inits = null, native_ = null, body = null;
|
| + if (this.isNative) {
|
| + native_ = '';
|
| + inits = null;
|
| + }
|
| + else {
|
| + body = null;
|
| + inits = [new CallExpression(new SuperExpression(span), [], span)];
|
| + }
|
| + var typeDef = this.definition;
|
| + var c = new FunctionDefinition(null, null, typeDef.name, [], null, inits, native_, body, span);
|
| + this.addMethod(null, c);
|
| + this.constructors.$index('').resolve$0();
|
| + return this.constructors.$index('');
|
| + }
|
| + return null;
|
| +}
|
| +DefinedType.prototype.getMember = function(memberName) {
|
| + var member = this.members.$index(memberName);
|
| + if (member != null) {
|
| + this._checkOverride(member);
|
| + return member;
|
| + }
|
| + if (this.get$isTop()) {
|
| + var libType = this.library.findTypeByName(memberName);
|
| + if (libType != null) {
|
| + return libType.get$typeMember();
|
| + }
|
| + }
|
| + return this._getMemberInParents(memberName);
|
| +}
|
| +DefinedType.prototype.resolveTypeParams = function(inType) {
|
| + return this;
|
| +}
|
| +DefinedType.prototype.getOrMakeConcreteType = function(typeArgs) {
|
| + var jsnames = [];
|
| + var names = [];
|
| + var typeMap = new HashMapImplementation();
|
| + for (var i = 0;
|
| + i < typeArgs.length; i++) {
|
| + var paramName = this.typeParameters.$index(i).name;
|
| + typeMap.$setindex(paramName, typeArgs.$index(i));
|
| + names.add$1(typeArgs.$index(i).name);
|
| + jsnames.add$1(typeArgs.$index(i).get$jsname());
|
| + }
|
| + var jsname = ('' + this.get$jsname() + '_' + Strings.join(jsnames, '\$'));
|
| + var simpleName = ('' + this.name + '<' + Strings.join(names, ', ') + '>');
|
| + var key = Strings.join(names, '\$');
|
| + var ret = this._concreteTypes.$index(key);
|
| + if (ret == null) {
|
| + ret = new ConcreteType(simpleName, this, typeMap, typeArgs);
|
| + ret.set$_jsname(jsname);
|
| + this._concreteTypes.$setindex(key, ret);
|
| + }
|
| + return ret;
|
| +}
|
| +DefinedType.prototype.getCallStub = function(args) {
|
| + var name = _getCallStubName('call', args);
|
| + var stub = this.varStubs.$index(name);
|
| + if (stub == null) {
|
| + stub = new VarFunctionStub(name, args);
|
| + this.varStubs.$setindex(name, stub);
|
| + }
|
| + return stub;
|
| +}
|
| +DefinedType.prototype.addDirectSubtype$1 = DefinedType.prototype.addDirectSubtype;
|
| +DefinedType.prototype.addMethod$2 = DefinedType.prototype.addMethod;
|
| +DefinedType.prototype.getConstructor$1 = DefinedType.prototype.getConstructor;
|
| +DefinedType.prototype.getFactory$2 = DefinedType.prototype.getFactory;
|
| +DefinedType.prototype.getMember$1 = DefinedType.prototype.getMember;
|
| +DefinedType.prototype.getOrMakeConcreteType$1 = DefinedType.prototype.getOrMakeConcreteType;
|
| +DefinedType.prototype.markUsed$0 = DefinedType.prototype.markUsed;
|
| +DefinedType.prototype.resolve$0 = DefinedType.prototype.resolve;
|
| +DefinedType.prototype.resolveTypeParams$1 = DefinedType.prototype.resolveTypeParams;
|
| +DefinedType.prototype.setDefinition$1 = DefinedType.prototype.setDefinition;
|
| +// ********** Code for NativeType **************
|
| +function NativeType(name) {
|
| + this.isConstructorHidden = false
|
| + this.isJsGlobalObject = false
|
| + this.isSingleton = false
|
| + this.name = name;
|
| + // Initializers done
|
| + while (true) {
|
| + if (this.name.startsWith('@')) {
|
| + this.name = this.name.substring(1);
|
| + this.isJsGlobalObject = true;
|
| + }
|
| + else if (this.name.startsWith('*')) {
|
| + this.name = this.name.substring(1);
|
| + this.isConstructorHidden = true;
|
| + }
|
| + else {
|
| + break;
|
| + }
|
| + }
|
| + if (this.name.startsWith('=')) {
|
| + this.name = this.name.substring(1);
|
| + this.isSingleton = true;
|
| + }
|
| +}
|
| +// ********** Code for FixedCollection **************
|
| +function FixedCollection(value, length) {
|
| + this.value = value;
|
| + this.length = length;
|
| + // Initializers done
|
| +}
|
| +FixedCollection.prototype.iterator = function() {
|
| + return new FixedIterator_E(this.value, this.length);
|
| +}
|
| +FixedCollection.prototype.forEach = function(f) {
|
| + Collections.forEach(this, f);
|
| +}
|
| +FixedCollection.prototype.filter = function(f) {
|
| + return Collections.filter(this, new ListFactory(), f);
|
| +}
|
| +FixedCollection.prototype.every = function(f) {
|
| + return Collections.every(this, f);
|
| +}
|
| +FixedCollection.prototype.some = function(f) {
|
| + return Collections.some(this, f);
|
| +}
|
| +FixedCollection.prototype.isEmpty = function() {
|
| + return this.length == 0;
|
| +}
|
| +FixedCollection.prototype.every$1 = function($0) {
|
| + return this.every(to$call$1($0));
|
| +};
|
| +FixedCollection.prototype.filter$1 = function($0) {
|
| + return this.filter(to$call$1($0));
|
| +};
|
| +FixedCollection.prototype.forEach$1 = function($0) {
|
| + return this.forEach(to$call$1($0));
|
| +};
|
| +FixedCollection.prototype.isEmpty$0 = FixedCollection.prototype.isEmpty;
|
| +FixedCollection.prototype.iterator$0 = FixedCollection.prototype.iterator;
|
| +FixedCollection.prototype.some$1 = function($0) {
|
| + return this.some(to$call$1($0));
|
| +};
|
| +// ********** Code for FixedCollection_Type **************
|
| +$inherits(FixedCollection_Type, FixedCollection);
|
| +function FixedCollection_Type(value, length) {
|
| + this.value = value;
|
| + this.length = length;
|
| + // Initializers done
|
| +}
|
| +// ********** Code for FixedIterator **************
|
| +function FixedIterator(value, length) {
|
| + this._index = 0
|
| + this.value = value;
|
| + this.length = length;
|
| + // Initializers done
|
| +}
|
| +FixedIterator.prototype.hasNext = function() {
|
| + return this._index < this.length;
|
| +}
|
| +FixedIterator.prototype.next = function() {
|
| + this._index++;
|
| + return this.value;
|
| +}
|
| +FixedIterator.prototype.hasNext$0 = FixedIterator.prototype.hasNext;
|
| +FixedIterator.prototype.next$0 = FixedIterator.prototype.next;
|
| +// ********** Code for FixedIterator_E **************
|
| +$inherits(FixedIterator_E, FixedIterator);
|
| +function FixedIterator_E(value, length) {
|
| + this._index = 0
|
| + this.value = value;
|
| + this.length = length;
|
| + // Initializers done
|
| +}
|
| +// ********** Code for Value **************
|
| +function Value(_type, code, span, needsTemp) {
|
| + this.isSuper = false
|
| + this.isType = false
|
| + this.isFinal = false
|
| + this.allowDynamic = true
|
| + this._type = _type;
|
| + this.code = code;
|
| + this.span = span;
|
| + this.needsTemp = needsTemp;
|
| + // Initializers done
|
| + if (this._type == null) $globals.world.internalError('type passed as null', this.span);
|
| +}
|
| +Value.type$ctor = function(_type, span) {
|
| + this.isSuper = false
|
| + this.isType = false
|
| + this.isFinal = false
|
| + this.allowDynamic = true
|
| + this._type = _type;
|
| + this.span = span;
|
| + this.code = null;
|
| + this.needsTemp = false;
|
| + this.isType = true;
|
| + // Initializers done
|
| + if (this._type == null) $globals.world.internalError('type passed as null', this.span);
|
| +}
|
| +Value.type$ctor.prototype = Value.prototype;
|
| +Value.prototype.get$isSuper = function() { return this.isSuper; };
|
| +Value.prototype.set$isSuper = function(value) { return this.isSuper = value; };
|
| +Value.prototype.get$isType = function() { return this.isType; };
|
| +Value.prototype.set$isType = function(value) { return this.isType = value; };
|
| +Value.prototype.get$isFinal = function() { return this.isFinal; };
|
| +Value.prototype.set$isFinal = function(value) { return this.isFinal = value; };
|
| +Value.prototype.get$allowDynamic = function() { return this.allowDynamic; };
|
| +Value.prototype.set$allowDynamic = function(value) { return this.allowDynamic = value; };
|
| +Value.prototype.get$needsTemp = function() { return this.needsTemp; };
|
| +Value.prototype.set$needsTemp = function(value) { return this.needsTemp = value; };
|
| +Value.prototype.get$_typeIsVarOrParameterType = function() {
|
| + return this.get$type().get$isVar() || (this.get$type() instanceof ParameterType);
|
| +}
|
| +Value.prototype.get$type = function() {
|
| + if (!$globals.options.forceDynamic || !this.allowDynamic || this.isType || this.isSuper || this.get$isConst()) {
|
| + return this._type;
|
| + }
|
| + else {
|
| + return $globals.world.varType;
|
| + }
|
| +}
|
| +Object.defineProperty(Value.prototype, "type", {
|
| + get: Value.prototype.get$type
|
| +});
|
| +Value.prototype.get$isConst = function() {
|
| + return false;
|
| +}
|
| +Value.prototype.get$canonicalCode = function() {
|
| + return null;
|
| +}
|
| +Value.prototype.get_ = function(context, name, node) {
|
| + var member = this._resolveMember(context, name, node, false);
|
| + if (member != null) {
|
| + return member._get$3(context, node, this);
|
| + }
|
| + else {
|
| + return this.invokeNoSuchMethod(context, ('get:' + name), node);
|
| + }
|
| +}
|
| +Value.prototype.set_ = function(context, name, node, value, isDynamic) {
|
| + var member = this._resolveMember(context, name, node, isDynamic);
|
| + if (member != null) {
|
| + return member._set$5(context, node, this, value, isDynamic);
|
| + }
|
| + else {
|
| + return this.invokeNoSuchMethod(context, ('set:' + name), node, new Arguments(null, [value]));
|
| + }
|
| +}
|
| +Value.prototype.invoke = function(context, name, node, args, isDynamic) {
|
| + if (name == ':call') {
|
| + if (this.isType) {
|
| + $globals.world.error('must use "new" or "const" to construct a new instance', node.span);
|
| + }
|
| + if (this.get$type().needsVarCall(args)) {
|
| + return this._varCall(context, args);
|
| + }
|
| + }
|
| + var member = this._resolveMember(context, name, node, isDynamic);
|
| + if (member == null) {
|
| + return this.invokeNoSuchMethod(context, name, node, args);
|
| + }
|
| + else {
|
| + return member.invoke$5(context, node, this, args, isDynamic);
|
| + }
|
| +}
|
| +Value.prototype.canInvoke = function(context, name, args) {
|
| + if (this.get$type().get$isVarOrFunction() && name == ':call') {
|
| + return true;
|
| + }
|
| + var member = this._resolveMember(context, name, null, true);
|
| + return member != null && member.canInvoke$2(context, args);
|
| +}
|
| +Value.prototype._hasOverriddenNoSuchMethod = function() {
|
| + if (this.isSuper) {
|
| + var m = this.get$type().getMember('noSuchMethod');
|
| + return m != null && !m.get$declaringType().get$isObject();
|
| + }
|
| + else {
|
| + var m = this.get$type().resolveMember('noSuchMethod');
|
| + return m != null && m.get$members().length > 1;
|
| + }
|
| +}
|
| +Value.prototype._tryResolveMember = function(context, name) {
|
| + if (this.isSuper) {
|
| + return this.get$type().getMember(name);
|
| + }
|
| + else {
|
| + return this.get$type().resolveMember(name);
|
| + }
|
| +}
|
| +Value.prototype._resolveMember = function(context, name, node, isDynamic) {
|
| + var member;
|
| + if (!this.get$_typeIsVarOrParameterType()) {
|
| + member = this._tryResolveMember(context, name);
|
| + if (member != null && this.isType && !member.get$isStatic()) {
|
| + if (!isDynamic) {
|
| + $globals.world.error('can not refer to instance member as static', node.span);
|
| + }
|
| + return null;
|
| + }
|
| + if (member == null && !isDynamic && !this._hasOverriddenNoSuchMethod()) {
|
| + var typeName = this.get$type().name == null ? this.get$type().get$library().name : this.get$type().name;
|
| + var message = ('can not resolve "' + name + '" on "' + typeName + '"');
|
| + if (this.isType) {
|
| + $globals.world.error(message, node.span);
|
| + }
|
| + else {
|
| + $globals.world.warning(message, node.span);
|
| + }
|
| + }
|
| + }
|
| + if (member == null && !this.isSuper && !this.isType) {
|
| + member = context.findMembers(name);
|
| + if (member == null && !isDynamic) {
|
| + var where = 'the world';
|
| + if (name.startsWith('_')) {
|
| + where = ('library "' + context.get$library().name + '"');
|
| + }
|
| + $globals.world.warning(('' + name + ' is not defined anywhere in ' + where + '.'), node.span);
|
| + }
|
| + }
|
| + return member;
|
| +}
|
| +Value.prototype.checkFirstClass = function(span) {
|
| + if (this.isType) {
|
| + $globals.world.error('Types are not first class', span);
|
| + }
|
| +}
|
| +Value.prototype._varCall = function(context, args) {
|
| + var stub = $globals.world.functionType.getCallStub(args);
|
| + return new Value($globals.world.varType, ('' + this.code + '.' + stub.name + '(' + args.getCode() + ')'), this.span, true);
|
| +}
|
| +Value.prototype.needsConversion = function(toType) {
|
| + var callMethod = toType.getCallMethod();
|
| + if (callMethod != null) {
|
| + var arity = callMethod.get$parameters().length;
|
| + var myCall = this.get$type().getCallMethod();
|
| + if (myCall == null || $ne(myCall.get$parameters().length, arity)) {
|
| + return true;
|
| + }
|
| + }
|
| + if ($globals.options.enableTypeChecks) {
|
| + var fromType = this.get$type();
|
| + if (this.get$type().get$isVar() && (this.code != 'null' || !toType.get$isNullable())) {
|
| + fromType = $globals.world.objectType;
|
| + }
|
| + var bothNum = this.get$type().get$isNum() && toType.get$isNum();
|
| + return !(fromType.isSubtypeOf(toType) || bothNum);
|
| + }
|
| + return false;
|
| +}
|
| +Value.prototype.convertTo = function(context, toType, node, isDynamic) {
|
| + var checked = !isDynamic;
|
| + var callMethod = toType.getCallMethod();
|
| + if (callMethod != null) {
|
| + if (checked && !toType.isAssignable(this.get$type())) {
|
| + this.convertWarning(toType, node);
|
| + }
|
| + var arity = callMethod.get$parameters().length;
|
| + var myCall = this.get$type().getCallMethod();
|
| + if (myCall == null || $ne(myCall.get$parameters().length, arity)) {
|
| + var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bare$factory(arity));
|
| + var val = new Value(toType, ('to\$' + stub.name + '(' + this.code + ')'), node.span, true);
|
| + return this._isDomCallback(toType) && !this._isDomCallback(this.get$type()) ? val._wrapDomCallback$2(toType, arity) : val;
|
| + }
|
| + else if (this._isDomCallback(toType) && !this._isDomCallback(this.get$type())) {
|
| + return this._wrapDomCallback(toType, arity);
|
| + }
|
| + }
|
| + var fromType = this.get$type();
|
| + if (this.get$type().get$isVar() && (this.code != 'null' || !toType.get$isNullable())) {
|
| + fromType = $globals.world.objectType;
|
| + }
|
| + var bothNum = this.get$type().get$isNum() && toType.get$isNum();
|
| + if (fromType.isSubtypeOf(toType) || bothNum) {
|
| + return this;
|
| + }
|
| + if (checked && !toType.isSubtypeOf(this.get$type())) {
|
| + this.convertWarning(toType, node);
|
| + }
|
| + if ($globals.options.enableTypeChecks) {
|
| + return this._typeAssert(context, toType, node, isDynamic);
|
| + }
|
| + else {
|
| + return this;
|
| + }
|
| +}
|
| +Value.prototype._isDomCallback = function(toType) {
|
| + return ((toType.get$definition() instanceof FunctionTypeDefinition) && $eq(toType.get$library(), $globals.world.get$dom()));
|
| +}
|
| +Value.prototype._wrapDomCallback = function(toType, arity) {
|
| + if (arity == 0) {
|
| + $globals.world.gen.corejs.useWrap0 = true;
|
| + }
|
| + else {
|
| + $globals.world.gen.corejs.useWrap1 = true;
|
| + }
|
| + return new Value(toType, ('\$wrap_call\$' + arity + '(' + this.code + ')'), this.span, true);
|
| +}
|
| +Value.prototype._typeAssert = function(context, toType, node, isDynamic) {
|
| + if ((toType instanceof ParameterType)) {
|
| + var p = toType;
|
| + toType = p.extendsType;
|
| + }
|
| + if (toType.get$isObject() || toType.get$isVar()) {
|
| + $globals.world.internalError(('We thought ' + this.get$type().name + ' is not a subtype of ' + toType.name + '?'));
|
| + }
|
| + function throwTypeError(paramName) {
|
| + return $globals.world.withoutForceDynamic((function () {
|
| + var typeError = $globals.world.corelib.types.$index('TypeError');
|
| + var typeErrorCtor = typeError.getConstructor$1('_internal');
|
| + $globals.world.gen.corejs.ensureTypeNameOf();
|
| + var result = typeErrorCtor.invoke$5(context, node, new Value.type$ctor(typeError, null), new Arguments(null, [new Value($globals.world.objectType, paramName, null, true), new Value($globals.world.stringType, ('"' + toType.name + '"'), null, true)]), isDynamic);
|
| + $globals.world.gen.corejs.useThrow = true;
|
| + return ('\$throw(' + result.code + ')');
|
| + })
|
| + );
|
| + }
|
| + if (toType.get$isNum()) toType = $globals.world.numType;
|
| + var check;
|
| + if (toType.get$isVoid()) {
|
| + check = ('\$assert_void(' + this.code + ')');
|
| + if (toType.typeCheckCode == null) {
|
| + toType.typeCheckCode = ("function $assert_void(x) {\n if (x == null) return null;\n " + throwTypeError("x") + "\n}");
|
| + }
|
| + }
|
| + else if ($eq(toType, $globals.world.nonNullBool)) {
|
| + $globals.world.gen.corejs.useNotNullBool = true;
|
| + check = ('\$notnull_bool(' + this.code + ')');
|
| + }
|
| + else if (toType.get$library().get$isCore() && toType.get$typeofName() != null) {
|
| + check = ('\$assert_' + toType.name + '(' + this.code + ')');
|
| + if (toType.typeCheckCode == null) {
|
| + toType.typeCheckCode = ("function $assert_" + toType.name + "(x) {\n if (x == null || typeof(x) == \"" + toType.get$typeofName() + "\") return x;\n " + throwTypeError("x") + "\n}");
|
| + }
|
| + }
|
| + else {
|
| + toType.isChecked = true;
|
| + var checkName = 'assert\$' + toType.get$jsname();
|
| + var temp = context.getTemp(this);
|
| + check = ('(' + context.assignTemp(temp, this).code + ' == null ? null :');
|
| + check = check + (' ' + temp.code + '.' + checkName + '())');
|
| + if ($ne(this, temp)) context.freeTemp(temp);
|
| + if (!$globals.world.objectType.varStubs.containsKey(checkName)) {
|
| + $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub(checkName, null, Arguments.get$EMPTY(), throwTypeError('this')));
|
| + }
|
| + }
|
| + return new Value(toType, check, this.span, true);
|
| +}
|
| +Value.prototype.instanceOf = function(context, toType, span, isTrue, forceCheck) {
|
| + if (toType.get$isVar()) {
|
| + $globals.world.error('can not resolve type', span);
|
| + }
|
| + var testCode = null;
|
| + if (toType.get$isVar() || toType.get$isObject() || (toType instanceof ParameterType)) {
|
| + if (this.needsTemp) {
|
| + return new Value($globals.world.nonNullBool, ('(' + this.code + ', true)'), span, true);
|
| + }
|
| + else {
|
| + return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, true, 'true', null);
|
| + }
|
| + }
|
| + if (toType.get$library().get$isCore()) {
|
| + var typeofName = toType.get$typeofName();
|
| + if (typeofName != null) {
|
| + testCode = ("(typeof(" + this.code + ") " + (isTrue ? '==' : '!=') + " '" + typeofName + "')");
|
| + }
|
| + }
|
| + if (toType.get$isClass() && !(toType instanceof ConcreteType) && !toType.get$isHiddenNativeType()) {
|
| + toType.markUsed();
|
| + testCode = ('(' + this.code + ' instanceof ' + toType.get$jsname() + ')');
|
| + if (!isTrue) {
|
| + testCode = '!' + testCode;
|
| + }
|
| + }
|
| + if (testCode == null) {
|
| + toType.isTested = true;
|
| + var temp = context.getTemp(this);
|
| + var checkName = ('is\$' + toType.get$jsname());
|
| + testCode = ('(' + context.assignTemp(temp, this).code + ' &&');
|
| + testCode = testCode + (' ' + temp.code + '.' + checkName + '())');
|
| + if (isTrue) {
|
| + testCode = '!!' + testCode;
|
| + }
|
| + else {
|
| + testCode = '!' + testCode;
|
| + }
|
| + if ($ne(this, temp)) context.freeTemp(temp);
|
| + if (!$globals.world.objectType.varStubs.containsKey(checkName)) {
|
| + $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub(checkName, null, Arguments.get$EMPTY(), 'return false'));
|
| + }
|
| + }
|
| + return new Value($globals.world.nonNullBool, testCode, span, true);
|
| +}
|
| +Value.prototype.convertWarning = function(toType, node) {
|
| + $globals.world.warning(('type "' + this.get$type().name + '" is not assignable to "' + toType.name + '"'), node.span);
|
| +}
|
| +Value.prototype.invokeNoSuchMethod = function(context, name, node, args) {
|
| + var pos = '';
|
| + if (args != null) {
|
| + var argsCode = [];
|
| + for (var i = 0;
|
| + i < args.get$length(); i++) {
|
| + argsCode.add$1(args.values.$index(i).code);
|
| + }
|
| + pos = Strings.join(argsCode, ", ");
|
| + }
|
| + var noSuchArgs = [new Value($globals.world.stringType, ('"' + name + '"'), node.span, true), new Value($globals.world.listType, ('[' + pos + ']'), node.span, true)];
|
| + return this._resolveMember(context, 'noSuchMethod', node, false).invoke$4(context, node, this, new Arguments(null, noSuchArgs));
|
| +}
|
| +Value.prototype._wrapDomCallback$2 = Value.prototype._wrapDomCallback;
|
| +Value.prototype.checkFirstClass$1 = Value.prototype.checkFirstClass;
|
| +Value.prototype.convertTo$3 = function($0, $1, $2) {
|
| + return this.convertTo($0, $1, $2, false);
|
| +};
|
| +Value.prototype.convertTo$4 = Value.prototype.convertTo;
|
| +Value.prototype.get_$3 = Value.prototype.get_;
|
| +Value.prototype.instanceOf$3$isTrue$forceCheck = Value.prototype.instanceOf;
|
| +Value.prototype.instanceOf$4 = function($0, $1, $2, $3) {
|
| + return this.instanceOf($0, $1, $2, $3, false);
|
| +};
|
| +Value.prototype.invoke$4 = function($0, $1, $2, $3) {
|
| + return this.invoke($0, $1, $2, $3, false);
|
| +};
|
| +Value.prototype.invoke$4$isDynamic = Value.prototype.invoke;
|
| +Value.prototype.invoke$5 = Value.prototype.invoke;
|
| +Value.prototype.needsConversion$1 = Value.prototype.needsConversion;
|
| +Value.prototype.set_$4 = function($0, $1, $2, $3) {
|
| + return this.set_($0, $1, $2, $3, false);
|
| +};
|
| +// ********** Code for EvaluatedValue **************
|
| +$inherits(EvaluatedValue, Value);
|
| +function EvaluatedValue() {}
|
| +EvaluatedValue._internal$ctor = function(type, actualValue, canonicalCode, span, code) {
|
| + this.actualValue = actualValue;
|
| + this.canonicalCode = canonicalCode;
|
| + // Initializers done
|
| + Value.call(this, type, code, span, false);
|
| +}
|
| +EvaluatedValue._internal$ctor.prototype = EvaluatedValue.prototype;
|
| +EvaluatedValue.EvaluatedValue$factory = function(type, actualValue, canonicalCode, span) {
|
| + return new EvaluatedValue._internal$ctor(type, actualValue, canonicalCode, span, EvaluatedValue.codeWithComments(canonicalCode, span));
|
| +}
|
| +EvaluatedValue.prototype.get$actualValue = function() { return this.actualValue; };
|
| +EvaluatedValue.prototype.set$actualValue = function(value) { return this.actualValue = value; };
|
| +EvaluatedValue.prototype.get$isConst = function() {
|
| + return true;
|
| +}
|
| +EvaluatedValue.prototype.get$canonicalCode = function() { return this.canonicalCode; };
|
| +EvaluatedValue.prototype.set$canonicalCode = function(value) { return this.canonicalCode = value; };
|
| +EvaluatedValue.codeWithComments = function(canonicalCode, span) {
|
| + return (span != null && span.get$text() != canonicalCode) ? ('' + canonicalCode + '/*' + _escapeForComment(span.get$text()) + '*/') : canonicalCode;
|
| +}
|
| +// ********** Code for ConstListValue **************
|
| +$inherits(ConstListValue, EvaluatedValue);
|
| +function ConstListValue() {}
|
| +ConstListValue._internal$ctor = function(type, values, actualValue, canonicalCode, span, code) {
|
| + this.values = values;
|
| + // Initializers done
|
| + EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, span, code);
|
| +}
|
| +ConstListValue._internal$ctor.prototype = ConstListValue.prototype;
|
| +ConstListValue.ConstListValue$factory = function(type, values, actualValue, canonicalCode, span) {
|
| + return new ConstListValue._internal$ctor(type, values, actualValue, canonicalCode, span, EvaluatedValue.codeWithComments(canonicalCode, span));
|
| +}
|
| +// ********** Code for ConstMapValue **************
|
| +$inherits(ConstMapValue, EvaluatedValue);
|
| +function ConstMapValue() {}
|
| +ConstMapValue._internal$ctor = function(type, values, actualValue, canonicalCode, span, code) {
|
| + this.values = values;
|
| + // Initializers done
|
| + EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, span, code);
|
| +}
|
| +ConstMapValue._internal$ctor.prototype = ConstMapValue.prototype;
|
| +ConstMapValue.ConstMapValue$factory = function(type, keyValuePairs, actualValue, canonicalCode, span) {
|
| + var values = new HashMapImplementation();
|
| + for (var i = 0;
|
| + i < keyValuePairs.length; i += 2) {
|
| + values.$setindex(keyValuePairs.$index(i).get$actualValue(), keyValuePairs.$index(i + 1));
|
| + }
|
| + return new ConstMapValue._internal$ctor(type, values, actualValue, canonicalCode, span, EvaluatedValue.codeWithComments(canonicalCode, span));
|
| +}
|
| +// ********** Code for ConstObjectValue **************
|
| +$inherits(ConstObjectValue, EvaluatedValue);
|
| +function ConstObjectValue() {}
|
| +ConstObjectValue._internal$ctor = function(type, fields, actualValue, canonicalCode, span, code) {
|
| + this.fields = fields;
|
| + // Initializers done
|
| + EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, span, code);
|
| +}
|
| +ConstObjectValue._internal$ctor.prototype = ConstObjectValue.prototype;
|
| +ConstObjectValue.ConstObjectValue$factory = function(type, fields, canonicalCode, span) {
|
| + var fieldValues = [];
|
| + var $$list = fields.getKeys();
|
| + for (var $$i = fields.getKeys().iterator$0(); $$i.hasNext$0(); ) {
|
| + var f = $$i.next$0();
|
| + fieldValues.add(('' + f + ' = ' + fields.$index(f).get$actualValue()));
|
| + }
|
| + fieldValues.sort((function (a, b) {
|
| + return a.compareTo$1(b);
|
| + })
|
| + );
|
| + var actualValue = ('const ' + type.get$jsname() + ' [') + Strings.join(fieldValues, ',') + ']';
|
| + return new ConstObjectValue._internal$ctor(type, fields, actualValue, canonicalCode, span, EvaluatedValue.codeWithComments(canonicalCode, span));
|
| +}
|
| +ConstObjectValue.prototype.get$fields = function() { return this.fields; };
|
| +ConstObjectValue.prototype.set$fields = function(value) { return this.fields = value; };
|
| +// ********** Code for GlobalValue **************
|
| +$inherits(GlobalValue, Value);
|
| +function GlobalValue(type, code, isConst, field, name, exp, canonicalCode, span, _dependencies) {
|
| + this.field = field;
|
| + this.name = name;
|
| + this.exp = exp;
|
| + this.canonicalCode = canonicalCode;
|
| + this.dependencies = [];
|
| + // Initializers done
|
| + Value.call(this, type, code, span, !isConst);
|
| + for (var $$i = 0;$$i < _dependencies.length; $$i++) {
|
| + var dep = _dependencies.$index($$i);
|
| + this.dependencies.add(dep);
|
| + this.dependencies.addAll(dep.get$dependencies());
|
| + }
|
| +}
|
| +GlobalValue.GlobalValue$fromStatic$factory = function(field, exp, dependencies) {
|
| + var code = (exp.get$isConst() ? exp.get$canonicalCode() : exp.code);
|
| + var codeWithComment = ('' + code + '/*' + field.get$declaringType().name + '.' + field.name + '*/');
|
| + return new GlobalValue(exp.get$type(), codeWithComment, field.get$isFinal(), field, null, exp, code, exp.span, dependencies.filter$1((function (d) {
|
| + return (d instanceof GlobalValue);
|
| + })
|
| + ));
|
| +}
|
| +GlobalValue.GlobalValue$fromConst$factory = function(uniqueId, exp, dependencies) {
|
| + var name = ("const\$" + uniqueId);
|
| + var codeWithComment = ("" + name + "/*" + _escapeForComment(exp.span.get$text()) + "*/");
|
| + return new GlobalValue(exp.get$type(), codeWithComment, true, null, name, exp, name, exp.span, dependencies.filter$1((function (d) {
|
| + return (d instanceof GlobalValue);
|
| + })
|
| + ));
|
| +}
|
| +GlobalValue.prototype.get$field = function() { return this.field; };
|
| +GlobalValue.prototype.set$field = function(value) { return this.field = value; };
|
| +GlobalValue.prototype.get$exp = function() { return this.exp; };
|
| +GlobalValue.prototype.set$exp = function(value) { return this.exp = value; };
|
| +GlobalValue.prototype.get$canonicalCode = function() { return this.canonicalCode; };
|
| +GlobalValue.prototype.set$canonicalCode = function(value) { return this.canonicalCode = value; };
|
| +GlobalValue.prototype.get$isConst = function() {
|
| + return this.exp.get$isConst() && (this.field == null || this.field.isFinal);
|
| +}
|
| +GlobalValue.prototype.get$actualValue = function() {
|
| + return this.exp.get$dynamic().get$actualValue();
|
| +}
|
| +GlobalValue.prototype.get$dependencies = function() { return this.dependencies; };
|
| +GlobalValue.prototype.set$dependencies = function(value) { return this.dependencies = value; };
|
| +GlobalValue.prototype.compareTo = function(other) {
|
| + if ($eq(other, this)) {
|
| + return 0;
|
| + }
|
| + else if (this.dependencies.indexOf(other) >= 0) {
|
| + return 1;
|
| + }
|
| + else if (other.dependencies.indexOf(this) >= 0) {
|
| + return -1;
|
| + }
|
| + else if (this.dependencies.length > other.dependencies.length) {
|
| + return 1;
|
| + }
|
| + else if (this.dependencies.length < other.dependencies.length) {
|
| + return -1;
|
| + }
|
| + else if (this.name == null && other.name != null) {
|
| + return 1;
|
| + }
|
| + else if (this.name != null && other.name == null) {
|
| + return -1;
|
| + }
|
| + else if (this.name != null) {
|
| + return this.name.compareTo(other.name);
|
| + }
|
| + else {
|
| + return this.field.name.compareTo(other.field.name);
|
| + }
|
| +}
|
| +GlobalValue.prototype.compareTo$1 = GlobalValue.prototype.compareTo;
|
| +// ********** Code for BareValue **************
|
| +$inherits(BareValue, Value);
|
| +function BareValue(home, outermost, span) {
|
| + this.home = home;
|
| + // Initializers done
|
| + Value.call(this, outermost.method.declaringType, null, span, false);
|
| + this.isType = outermost.get$isStatic();
|
| +}
|
| +BareValue.prototype.get$type = function() {
|
| + return this._type;
|
| +}
|
| +Object.defineProperty(BareValue.prototype, "type", {
|
| + get: BareValue.prototype.get$type
|
| +});
|
| +BareValue.prototype._ensureCode = function() {
|
| + if (this.code != null) return;
|
| + if (this.isType) {
|
| + this.code = this.get$type().get$jsname();
|
| + }
|
| + else {
|
| + this.code = this.home._makeThisCode();
|
| + }
|
| +}
|
| +BareValue.prototype._tryResolveMember = function(context, name) {
|
| + var member = this.get$type().resolveMember(name);
|
| + if (member != null) {
|
| + if ($globals.options.forceDynamic && !member.get$isStatic()) {
|
| + member = context.findMembers(name);
|
| + }
|
| + this._ensureCode();
|
| + return member;
|
| + }
|
| + member = this.home.get$library().lookup(name, this.span);
|
| + if (member != null) {
|
| + return member;
|
| + }
|
| + this._ensureCode();
|
| + return null;
|
| +}
|
| +// ********** Code for CompilerException **************
|
| +function CompilerException(_message, _location) {
|
| + this._message = _message;
|
| + this._location = _location;
|
| + // Initializers done
|
| +}
|
| +CompilerException.prototype.toString = function() {
|
| + if (this._location != null) {
|
| + return ('CompilerException: ' + this._location.toMessageString(this._message));
|
| + }
|
| + else {
|
| + return ('CompilerException: ' + this._message);
|
| + }
|
| +}
|
| +CompilerException.prototype.toString$0 = CompilerException.prototype.toString;
|
| +// ********** Code for World **************
|
| +function World(files) {
|
| + this.errors = 0
|
| + this.warnings = 0
|
| + this.dartBytesRead = 0
|
| + this.jsBytesWritten = 0
|
| + this.seenFatal = false
|
| + this.files = files;
|
| + this.libraries = new HashMapImplementation();
|
| + this._todo = [];
|
| + this._members = new HashMapImplementation();
|
| + this._topNames = new HashMapImplementation();
|
| + this.reader = new LibraryReader();
|
| + // Initializers done
|
| +}
|
| +World.prototype.get$coreimpl = function() {
|
| + return this.libraries.$index('dart:coreimpl');
|
| +}
|
| +World.prototype.get$dom = function() {
|
| + return this.libraries.$index('dart:dom');
|
| +}
|
| +World.prototype.get$functionType = function() { return this.functionType; };
|
| +World.prototype.set$functionType = function(value) { return this.functionType = value; };
|
| +World.prototype.reset = function() {
|
| + this.libraries = new HashMapImplementation();
|
| + this._todo = [];
|
| + this._members = new HashMapImplementation();
|
| + this._topNames = new HashMapImplementation();
|
| + this.errors = this.warnings = 0;
|
| + this.seenFatal = false;
|
| + this.init();
|
| +}
|
| +World.prototype.init = function() {
|
| + this.corelib = new Library(this.readFile('dart:core'));
|
| + this.libraries.$setindex('dart:core', this.corelib);
|
| + this._todo.add(this.corelib);
|
| + this.voidType = this._addToCoreLib('void', false);
|
| + this.dynamicType = this._addToCoreLib('Dynamic', false);
|
| + this.varType = this.dynamicType;
|
| + this.objectType = this._addToCoreLib('Object', true);
|
| + this.numType = this._addToCoreLib('num', false);
|
| + this.intType = this._addToCoreLib('int', false);
|
| + this.doubleType = this._addToCoreLib('double', false);
|
| + this.boolType = this._addToCoreLib('bool', false);
|
| + this.stringType = this._addToCoreLib('String', false);
|
| + this.listType = this._addToCoreLib('List', false);
|
| + this.mapType = this._addToCoreLib('Map', false);
|
| + this.functionType = this._addToCoreLib('Function', false);
|
| + this.nonNullBool = new NonNullableType(this.boolType);
|
| +}
|
| +World.prototype._addMember = function(member) {
|
| + if (member.get$isStatic()) {
|
| + if (member.declaringType.get$isTop()) {
|
| + this._addTopName(member);
|
| + }
|
| + return;
|
| + }
|
| + var mset = this._members.$index(member.name);
|
| + if (mset == null) {
|
| + mset = new MemberSet(member, true);
|
| + this._members.$setindex(mset.name, mset);
|
| + }
|
| + else {
|
| + mset.get$members().add$1(member);
|
| + }
|
| +}
|
| +World.prototype._addTopName = function(named) {
|
| + var existing = this._topNames.$index(named.get$jsname());
|
| + if (existing != null) {
|
| + this.info(('mangling matching top level name "' + named.get$jsname() + '" in ') + ('both "' + named.get$library().get$jsname() + '" and "' + existing.get$library().get$jsname() + '"'));
|
| + if (named.get$isNative()) {
|
| + if (existing.get$isNative()) {
|
| + $globals.world.internalError(('conflicting native names "' + named.get$jsname() + '" ') + ('(already defined in ' + existing.span.get$locationText() + ')'), named.get$span());
|
| + }
|
| + else {
|
| + this._topNames.$setindex(named.get$jsname(), named);
|
| + this._addJavascriptTopName(existing);
|
| + }
|
| + }
|
| + else if (named.get$library().get$isCore()) {
|
| + if (existing.get$library().get$isCore()) {
|
| + $globals.world.internalError(('conflicting top-level names in core "' + named.get$jsname() + '" ') + ('(previously defined in ' + existing.span.get$locationText() + ')'), named.get$span());
|
| + }
|
| + else {
|
| + this._topNames.$setindex(named.get$jsname(), named);
|
| + this._addJavascriptTopName(existing);
|
| + }
|
| + }
|
| + else {
|
| + this._addJavascriptTopName(named);
|
| + }
|
| + }
|
| + else {
|
| + this._topNames.$setindex(named.get$jsname(), named);
|
| + }
|
| +}
|
| +World.prototype._addJavascriptTopName = function(named) {
|
| + named._jsname = ('' + named.get$library().get$jsname() + '_' + named.get$jsname());
|
| + var existing = this._topNames.$index(named.get$jsname());
|
| + if (existing != null && $ne(existing, named)) {
|
| + $globals.world.internalError(('name mangling failed for "' + named.get$jsname() + '" ') + ('("' + named.get$jsname() + '" defined also in ' + existing.span.get$locationText() + ')'), named.get$span());
|
| + }
|
| + this._topNames.$setindex(named.get$jsname(), named);
|
| +}
|
| +World.prototype._addType = function(type) {
|
| + if (!type.get$isTop()) this._addTopName(type);
|
| +}
|
| +World.prototype._addToCoreLib = function(name, isClass) {
|
| + var ret = new DefinedType(name, this.corelib, null, isClass);
|
| + this.corelib.types.$setindex(name, ret);
|
| + return ret;
|
| +}
|
| +World.prototype.toJsIdentifier = function(name) {
|
| + if (name == null) return null;
|
| + if (this._jsKeywords == null) {
|
| + this._jsKeywords = HashSetImplementation.HashSetImplementation$from$factory(['break', 'case', 'catch', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'finally', 'for', 'function', 'if', 'in', 'instanceof', 'new', 'return', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'class', 'enum', 'export', 'extends', 'import', 'super', 'implements', 'interface', 'let', 'package', 'private', 'protected', 'public', 'static', 'yield', 'native']);
|
| + }
|
| + if (this._jsKeywords.contains(name)) {
|
| + return name + '_';
|
| + }
|
| + else {
|
| + return name.replaceAll("$", "$$").replaceAll(':', "$");
|
| + }
|
| +}
|
| +World.prototype.compile = function() {
|
| + if ($globals.options.dartScript == null) {
|
| + this.fatal('no script provided to compile');
|
| + return false;
|
| + }
|
| + try {
|
| + this.info(('compiling ' + $globals.options.dartScript + ' with corelib ' + this.corelib));
|
| + if (!this.runLeg()) this.runCompilationPhases();
|
| + } catch (exc) {
|
| + exc = _toDartException(exc);
|
| + if (this.get$hasErrors() && !$globals.options.throwOnErrors) {
|
| + }
|
| + else {
|
| + throw exc;
|
| + }
|
| + }
|
| + this.printStatus();
|
| + return !this.get$hasErrors();
|
| +}
|
| +World.prototype.runLeg = function() {
|
| + var $this = this; // closure support
|
| + if (!$globals.options.enableLeg) return false;
|
| + if ($globals.legCompile == null) {
|
| + this.fatal('requested leg enabled, but no leg compiler available');
|
| + }
|
| + var res = this.withTiming('try leg compile', (function () {
|
| + return $globals.legCompile($this);
|
| + })
|
| + );
|
| + if (!res && $globals.options.legOnly) {
|
| + this.fatal(("Leg could not compile " + $globals.options.dartScript));
|
| + return true;
|
| + }
|
| + return res;
|
| +}
|
| +World.prototype.runCompilationPhases = function() {
|
| + var $this = this; // closure support
|
| + var lib = this.withTiming('first pass', (function () {
|
| + return $this.processDartScript();
|
| + })
|
| + );
|
| + this.withTiming('resolve top level', this.get$resolveAll());
|
| + if ($globals.experimentalAwaitPhase != null) {
|
| + this.withTiming('await translation', to$call$0($globals.experimentalAwaitPhase));
|
| + }
|
| + this.withTiming('generate code', (function () {
|
| + $this.generateCode(lib);
|
| + })
|
| + );
|
| +}
|
| +World.prototype.getGeneratedCode = function() {
|
| + if (this.legCode != null) {
|
| + return this.legCode;
|
| + }
|
| + else {
|
| + return this.gen.writer.get$text();
|
| + }
|
| +}
|
| +World.prototype.readFile = function(filename) {
|
| + try {
|
| + var sourceFile = this.reader.readFile(filename);
|
| + this.dartBytesRead += sourceFile.get$text().length;
|
| + return sourceFile;
|
| + } catch (e) {
|
| + e = _toDartException(e);
|
| + this.warning(('Error reading file: ' + filename));
|
| + return new SourceFile(filename, '');
|
| + }
|
| +}
|
| +World.prototype.getOrAddLibrary = function(filename) {
|
| + var library = this.libraries.$index(filename);
|
| + if (library == null) {
|
| + library = new Library(this.readFile(filename));
|
| + this.info(('read library ' + filename));
|
| + if (!library.get$isCore() && !library.imports.some((function (li) {
|
| + return li.get$library().get$isCore();
|
| + })
|
| + )) {
|
| + library.imports.add(new LibraryImport(this.corelib));
|
| + }
|
| + this.libraries.$setindex(filename, library);
|
| + this._todo.add(library);
|
| + }
|
| + return library;
|
| +}
|
| +World.prototype.process = function() {
|
| + while (this._todo.length > 0) {
|
| + var todo = this._todo;
|
| + this._todo = [];
|
| + for (var $$i = 0;$$i < todo.length; $$i++) {
|
| + var lib = todo.$index($$i);
|
| + lib.visitSources$0();
|
| + }
|
| + }
|
| +}
|
| +World.prototype.processDartScript = function(script) {
|
| + if (script == null) script = $globals.options.dartScript;
|
| + var library = this.getOrAddLibrary(script);
|
| + this.process();
|
| + return library;
|
| +}
|
| +World.prototype.resolveAll = function() {
|
| + var $$list = this.libraries.getValues();
|
| + for (var $$i = this.libraries.getValues().iterator$0(); $$i.hasNext$0(); ) {
|
| + var lib = $$i.next$0();
|
| + lib.resolve$0();
|
| + }
|
| +}
|
| +World.prototype.get$resolveAll = function() {
|
| + return World.prototype.resolveAll.bind(this);
|
| +}
|
| +World.prototype.generateCode = function(lib) {
|
| + var mainMembers = lib.topType.resolveMember('main');
|
| + var main = null;
|
| + if (mainMembers == null || $eq(mainMembers.get$members().length, 0)) {
|
| + this.fatal('no main method specified');
|
| + }
|
| + else if (mainMembers.get$members().length > 1) {
|
| + var $$list = mainMembers.get$members();
|
| + for (var $$i = mainMembers.get$members().iterator$0(); $$i.hasNext$0(); ) {
|
| + var m = $$i.next$0();
|
| + main = m;
|
| + this.error('more than one main member (using last?)', main.span);
|
| + }
|
| + }
|
| + else {
|
| + main = mainMembers.get$members().$index(0);
|
| + }
|
| + var codeWriter = new CodeWriter();
|
| + this.gen = new WorldGenerator(main, codeWriter);
|
| + this.gen.run();
|
| + this.jsBytesWritten = codeWriter.text.length;
|
| +}
|
| +World.prototype._message = function(color, prefix, message, span, span1, span2, throwing) {
|
| + if (this.messageHandler != null) {
|
| + this.messageHandler(prefix, message, span);
|
| + if (span1 != null) {
|
| + this.messageHandler(prefix, message, span1);
|
| + }
|
| + if (span2 != null) {
|
| + this.messageHandler(prefix, message, span2);
|
| + }
|
| + }
|
| + var messageWithPrefix = $globals.options.useColors ? (color + prefix + $globals._NO_COLOR + message) : (prefix + message);
|
| + var text = messageWithPrefix;
|
| + if (span != null) {
|
| + text = span.toMessageString(messageWithPrefix);
|
| + }
|
| + print(text);
|
| + if (span1 != null) {
|
| + print(span1.toMessageString(messageWithPrefix));
|
| + }
|
| + if (span2 != null) {
|
| + print(span2.toMessageString(messageWithPrefix));
|
| + }
|
| + if (throwing) {
|
| + $throw(new CompilerException(messageWithPrefix, span));
|
| + }
|
| +}
|
| +World.prototype.error = function(message, span, span1, span2) {
|
| + this.errors++;
|
| + this._message($globals._RED_COLOR, 'error: ', message, span, span1, span2, $globals.options.throwOnErrors);
|
| +}
|
| +World.prototype.warning = function(message, span, span1, span2) {
|
| + if ($globals.options.warningsAsErrors) {
|
| + this.error(message, span, span1, span2);
|
| + return;
|
| + }
|
| + this.warnings++;
|
| + if ($globals.options.showWarnings) {
|
| + this._message($globals._MAGENTA_COLOR, 'warning: ', message, span, span1, span2, $globals.options.throwOnWarnings);
|
| + }
|
| +}
|
| +World.prototype.fatal = function(message, span, span1, span2) {
|
| + this.errors++;
|
| + this.seenFatal = true;
|
| + this._message($globals._RED_COLOR, 'fatal: ', message, span, span1, span2, $globals.options.throwOnFatal || $globals.options.throwOnErrors);
|
| +}
|
| +World.prototype.internalError = function(message, span, span1, span2) {
|
| + this._message($globals._NO_COLOR, 'We are sorry, but...', message, span, span1, span2, true);
|
| +}
|
| +World.prototype.info = function(message, span, span1, span2) {
|
| + if ($globals.options.showInfo) {
|
| + this._message($globals._GREEN_COLOR, 'info: ', message, span, span1, span2, false);
|
| + }
|
| +}
|
| +World.prototype.withoutForceDynamic = function(fn) {
|
| + var oldForceDynamic = $globals.options.forceDynamic;
|
| + $globals.options.forceDynamic = false;
|
| + try {
|
| + return fn();
|
| + } finally {
|
| + $globals.options.forceDynamic = oldForceDynamic;
|
| + }
|
| +}
|
| +World.prototype.get$hasErrors = function() {
|
| + return this.errors > 0;
|
| +}
|
| +World.prototype.printStatus = function() {
|
| + this.info(('compiled ' + this.dartBytesRead + ' bytes Dart -> ' + this.jsBytesWritten + ' bytes JS'));
|
| + if (this.get$hasErrors()) {
|
| + print(('compilation failed with ' + this.errors + ' errors'));
|
| + }
|
| + else {
|
| + if (this.warnings > 0) {
|
| + this.info(('compilation completed successfully with ' + this.warnings + ' warnings'));
|
| + }
|
| + else {
|
| + this.info('compilation completed sucessfully');
|
| + }
|
| + }
|
| +}
|
| +World.prototype.withTiming = function(name, f) {
|
| + var sw = new StopwatchImplementation();
|
| + sw.start();
|
| + var result = f();
|
| + sw.stop();
|
| + this.info(('' + name + ' in ' + sw.elapsedInMs() + 'msec'));
|
| + return result;
|
| +}
|
| +// ********** Code for FrogOptions **************
|
| +function FrogOptions(homedir, args, files) {
|
| + this.config = 'dev'
|
| + this.enableLeg = false
|
| + this.legOnly = false
|
| + this.enableAsserts = false
|
| + this.enableTypeChecks = false
|
| + this.warningsAsErrors = false
|
| + this.verifyImplements = false
|
| + this.compileAll = false
|
| + this.forceDynamic = false
|
| + this.dietParse = false
|
| + this.compileOnly = false
|
| + this.throwOnErrors = false
|
| + this.throwOnWarnings = false
|
| + this.throwOnFatal = false
|
| + this.showInfo = false
|
| + this.showWarnings = true
|
| + this.useColors = true
|
| + // Initializers done
|
| + if ($eq(this.config, 'dev')) {
|
| + this.libDir = joinPaths(homedir, '/lib');
|
| + }
|
| + else if ($eq(this.config, 'sdk')) {
|
| + this.libDir = joinPaths(homedir, '/../lib');
|
| + }
|
| + else {
|
| + $globals.world.error(('Invalid configuration ' + this.config));
|
| + $throw(('Invalid configuration'));
|
| + }
|
| + var ignoreUnrecognizedFlags = false;
|
| + var passedLibDir = false;
|
| + this.childArgs = [];
|
| + loop:
|
| + for (var i = 2;
|
| + i < args.length; i++) {
|
| + var arg = args.$index(i);
|
| + switch (arg) {
|
| + case '--enable_leg':
|
| +
|
| + this.enableLeg = true;
|
| + break;
|
| +
|
| + case '--leg_only':
|
| +
|
| + this.enableLeg = true;
|
| + this.legOnly = true;
|
| + break;
|
| +
|
| + case '--enable_asserts':
|
| +
|
| + this.enableAsserts = true;
|
| + break;
|
| +
|
| + case '--enable_type_checks':
|
| +
|
| + this.enableTypeChecks = true;
|
| + this.enableAsserts = true;
|
| + break;
|
| +
|
| + case '--verify_implements':
|
| +
|
| + this.verifyImplements = true;
|
| + break;
|
| +
|
| + case '--compile_all':
|
| +
|
| + this.compileAll = true;
|
| + break;
|
| +
|
| + case '--diet-parse':
|
| +
|
| + this.dietParse = true;
|
| + break;
|
| +
|
| + case '--ignore-unrecognized-flags':
|
| +
|
| + ignoreUnrecognizedFlags = true;
|
| + break;
|
| +
|
| + case '--verbose':
|
| +
|
| + this.showInfo = true;
|
| + break;
|
| +
|
| + case '--suppress_warnings':
|
| +
|
| + this.showWarnings = false;
|
| + break;
|
| +
|
| + case '--warnings_as_errors':
|
| +
|
| + this.warningsAsErrors = true;
|
| + break;
|
| +
|
| + case '--throw_on_errors':
|
| +
|
| + this.throwOnErrors = true;
|
| + break;
|
| +
|
| + case '--throw_on_warnings':
|
| +
|
| + this.throwOnWarnings = true;
|
| + break;
|
| +
|
| + case '--compile-only':
|
| +
|
| + this.compileOnly = true;
|
| + break;
|
| +
|
| + case '--force_dynamic':
|
| +
|
| + this.forceDynamic = true;
|
| + break;
|
| +
|
| + case '--no_colors':
|
| +
|
| + this.useColors = false;
|
| + break;
|
| +
|
| + default:
|
| +
|
| + if (arg.endsWith$1('.dart')) {
|
| + this.dartScript = arg;
|
| + this.childArgs = args.getRange(i + 1, args.length - i - 1);
|
| + break loop;
|
| + }
|
| + else if (arg.startsWith$1('--out=')) {
|
| + this.outfile = arg.substring$1('--out='.length);
|
| + }
|
| + else if (arg.startsWith$1('--libdir=')) {
|
| + this.libDir = arg.substring$1('--libdir='.length);
|
| + passedLibDir = true;
|
| + }
|
| + else {
|
| + if (!ignoreUnrecognizedFlags) {
|
| + print(('unrecognized flag: "' + arg + '"'));
|
| + }
|
| + }
|
| +
|
| + }
|
| + }
|
| + if (!passedLibDir && $eq(this.config, 'dev') && !files.fileExists(this.libDir)) {
|
| + var temp = 'frog/lib';
|
| + if (files.fileExists(temp)) {
|
| + this.libDir = temp;
|
| + }
|
| + else {
|
| + this.libDir = 'lib';
|
| + }
|
| + }
|
| +}
|
| +// ********** Code for LibraryReader **************
|
| +function LibraryReader() {
|
| + // Initializers done
|
| + if ($eq($globals.options.config, 'dev')) {
|
| + this._specialLibs = _map(['dart:core', joinPaths($globals.options.libDir, 'corelib.dart'), 'dart:coreimpl', joinPaths($globals.options.libDir, 'corelib_impl.dart'), 'dart:html', joinPaths($globals.options.libDir, '../../client/html/release/html.dart'), 'dart:htmlimpl', joinPaths($globals.options.libDir, '../../client/html/release/htmlimpl.dart'), 'dart:dom', joinPaths($globals.options.libDir, '../../client/dom/frog/frog_dom.dart'), 'dart:json', joinPaths($globals.options.libDir, 'json.dart')]);
|
| + }
|
| + else if ($eq($globals.options.config, 'sdk')) {
|
| + this._specialLibs = _map(['dart:core', joinPaths($globals.options.libDir, 'core/core_frog.dart'), 'dart:coreimpl', joinPaths($globals.options.libDir, 'coreimpl/coreimpl_frog.dart'), 'dart:html', joinPaths($globals.options.libDir, 'html/html.dart'), 'dart:htmlimpl', joinPaths($globals.options.libDir, 'htmlimpl/htmlimpl.dart'), 'dart:dom', joinPaths($globals.options.libDir, 'dom/frog/frog_dom.dart'), 'dart:json', joinPaths($globals.options.libDir, 'json/json_frog.dart')]);
|
| + }
|
| + else {
|
| + $globals.world.error(('Invalid configuration ' + $globals.options.config));
|
| + }
|
| +}
|
| +LibraryReader.prototype.readFile = function(fullname) {
|
| + var filename = this._specialLibs.$index(fullname);
|
| + if (filename == null) {
|
| + filename = fullname;
|
| + }
|
| + if ($globals.world.files.fileExists(filename)) {
|
| + return new SourceFile(filename, $globals.world.files.readAll(filename));
|
| + }
|
| + else {
|
| + $globals.world.error(('File not found: ' + filename));
|
| + return new SourceFile(filename, '');
|
| + }
|
| +}
|
| +// ********** Code for VarMember **************
|
| +function VarMember(name) {
|
| + this.name = name;
|
| + // Initializers done
|
| +}
|
| +VarMember.prototype.get$returnType = function() {
|
| + return $globals.world.varType;
|
| +}
|
| +VarMember.prototype.invoke = function(context, node, target, args) {
|
| + return new Value(this.get$returnType(), ('' + target.code + '.' + this.name + '(' + args.getCode() + ')'), node.span, true);
|
| +}
|
| +VarMember.prototype.generate$1 = VarMember.prototype.generate;
|
| +VarMember.prototype.invoke$4 = VarMember.prototype.invoke;
|
| +// ********** Code for VarFunctionStub **************
|
| +$inherits(VarFunctionStub, VarMember);
|
| +function VarFunctionStub(name, callArgs) {
|
| + this.args = callArgs.toCallStubArgs();
|
| + // Initializers done
|
| + VarMember.call(this, name);
|
| + $globals.world.gen.corejs.useGenStub = true;
|
| +}
|
| +VarFunctionStub.prototype.generate = function(code) {
|
| + if (this.args.get$hasNames()) {
|
| + this.generateNamed(code);
|
| + }
|
| + else {
|
| + this.generatePositional(code);
|
| + }
|
| +}
|
| +VarFunctionStub.prototype.generatePositional = function(w) {
|
| + var arity = this.args.get$length();
|
| + w.enterBlock(('Function.prototype.to\$' + this.name + ' = function() {'));
|
| + w.writeln(('this.' + this.name + ' = this.\$genStub(' + arity + ');'));
|
| + w.writeln(('this.to\$' + this.name + ' = function() { return this.' + this.name + '; };'));
|
| + w.writeln(('return this.' + this.name + ';'));
|
| + w.exitBlock('};');
|
| + var argsCode = this.args.getCode();
|
| + w.enterBlock(('Function.prototype.' + this.name + ' = function(' + argsCode + ') {'));
|
| + w.writeln(('return this.to\$' + this.name + '()(' + argsCode + ');'));
|
| + w.exitBlock('};');
|
| + w.writeln(('function to\$' + this.name + '(f) { return f && f.to\$' + this.name + '(); }'));
|
| +}
|
| +VarFunctionStub.prototype.generateNamed = function(w) {
|
| + var named = Strings.join(this.args.getNames(), '", "');
|
| + var argsCode = this.args.getCode();
|
| + w.enterBlock(('Function.prototype.' + this.name + ' = function(' + argsCode + ') {'));
|
| + w.writeln(('this.' + this.name + ' = this.\$genStub(' + this.args.get$length() + ', ["' + named + '"]);'));
|
| + w.writeln(('return this.' + this.name + '(' + argsCode + ');'));
|
| + w.exitBlock('}');
|
| +}
|
| +VarFunctionStub.prototype.generate$1 = VarFunctionStub.prototype.generate;
|
| +// ********** Code for VarMethodStub **************
|
| +$inherits(VarMethodStub, VarMember);
|
| +function VarMethodStub(name, member, args, body) {
|
| + this.member = member;
|
| + this.args = args;
|
| + this.body = body;
|
| + // Initializers done
|
| + VarMember.call(this, name);
|
| +}
|
| +VarMethodStub.prototype.get$isHidden = function() {
|
| + return this.member != null ? this.member.declaringType.get$isHiddenNativeType() : false;
|
| +}
|
| +VarMethodStub.prototype.get$returnType = function() {
|
| + return this.member != null ? this.member.get$returnType() : $globals.world.varType;
|
| +}
|
| +VarMethodStub.prototype.get$declaringType = function() {
|
| + return this.member != null ? this.member.declaringType : $globals.world.objectType;
|
| +}
|
| +VarMethodStub.prototype.generate = function(code) {
|
| + code.write($globals.world.gen._prototypeOf(this.get$declaringType(), this.name) + ' = ');
|
| + if (!this.get$isHidden() && this._useDirectCall(this.args)) {
|
| + code.writeln($globals.world.gen._prototypeOf(this.get$declaringType(), this.member.get$jsname()) + ';');
|
| + }
|
| + else if (this._needsExactTypeCheck()) {
|
| + code.enterBlock(('function(' + this.args.getCode() + ') {'));
|
| + code.enterBlock(('if (Object.getPrototypeOf(this).hasOwnProperty("' + this.name + '")) {'));
|
| + code.writeln(('' + this.body + ';'));
|
| + code.exitBlock('}');
|
| + var argsCode = this.args.getCode();
|
| + if (argsCode != '') argsCode = ', ' + argsCode;
|
| + code.writeln(('return Object.prototype.' + this.name + '.call(this' + argsCode + ');'));
|
| + code.exitBlock('};');
|
| + }
|
| + else {
|
| + code.enterBlock(('function(' + this.args.getCode() + ') {'));
|
| + code.writeln(('' + this.body + ';'));
|
| + code.exitBlock('};');
|
| + }
|
| +}
|
| +VarMethodStub.prototype._needsExactTypeCheck = function() {
|
| + var $this = this; // closure support
|
| + if (this.member == null || this.member.declaringType.get$isObject()) return false;
|
| + var members = this.member.declaringType.resolveMember(this.member.name).members;
|
| + return members.filter$1((function (m) {
|
| + return $ne(m, $this.member) && m.get$declaringType().get$isHiddenNativeType();
|
| + })
|
| + ).length >= 1;
|
| +}
|
| +VarMethodStub.prototype._useDirectCall = function(args) {
|
| + if ((this.member instanceof MethodMember) && !this.member.declaringType.get$hasNativeSubtypes()) {
|
| + var method = this.member;
|
| + if (method.needsArgumentConversion(args)) {
|
| + return false;
|
| + }
|
| + for (var i = args.get$length();
|
| + i < method.parameters.length; i++) {
|
| + if ($ne(method.parameters.$index(i).value.code, 'null')) {
|
| + return false;
|
| + }
|
| + }
|
| + return method.namesInOrder(args);
|
| + }
|
| + else {
|
| + return false;
|
| + }
|
| +}
|
| +VarMethodStub.prototype.generate$1 = VarMethodStub.prototype.generate;
|
| +// ********** Code for VarMethodSet **************
|
| +$inherits(VarMethodSet, VarMember);
|
| +function VarMethodSet(baseName, name, members, callArgs, returnType) {
|
| + this.invoked = false
|
| + this.baseName = baseName;
|
| + this.members = members;
|
| + this.returnType = returnType;
|
| + this.args = callArgs.toCallStubArgs();
|
| + // Initializers done
|
| + VarMember.call(this, name);
|
| +}
|
| +VarMethodSet.prototype.get$members = function() { return this.members; };
|
| +VarMethodSet.prototype.get$returnType = function() { return this.returnType; };
|
| +VarMethodSet.prototype.invoke = function(context, node, target, args) {
|
| + this._invokeMembers(context, node);
|
| + return VarMember.prototype.invoke.call(this, context, node, target, args);
|
| +}
|
| +VarMethodSet.prototype._invokeMembers = function(context, node) {
|
| + if (this.invoked) return;
|
| + this.invoked = true;
|
| + var hasObjectType = false;
|
| + var $$list = this.members;
|
| + for (var $$i = 0;$$i < $$list.length; $$i++) {
|
| + var member = $$list.$index($$i);
|
| + var type = member.get$declaringType();
|
| + var target = new Value(type, 'this', node.span, true);
|
| + var result = member.invoke$4$isDynamic(context, node, target, this.args, true);
|
| + var stub = new VarMethodStub(this.name, member, this.args, 'return ' + result.code);
|
| + type.get$varStubs().$setindex(stub.name, stub);
|
| + if (type.get$isObject()) hasObjectType = true;
|
| + }
|
| + if (!hasObjectType) {
|
| + var target = new Value($globals.world.objectType, 'this', node.span, true);
|
| + var result = target.invokeNoSuchMethod(context, this.baseName, node, this.args);
|
| + var stub = new VarMethodStub(this.name, null, this.args, 'return ' + result.code);
|
| + $globals.world.objectType.varStubs.$setindex(stub.name, stub);
|
| + }
|
| +}
|
| +VarMethodSet.prototype.generate = function(code) {
|
| +
|
| +}
|
| +VarMethodSet.prototype.generate$1 = VarMethodSet.prototype.generate;
|
| +VarMethodSet.prototype.invoke$4 = VarMethodSet.prototype.invoke;
|
| +// ********** Code for top level **************
|
| +function map(source, mapper) {
|
| + var result = new ListFactory();
|
| + if (!!(source && source.is$List())) {
|
| + var list = source;
|
| + result.length = list.length;
|
| + for (var i = 0;
|
| + i < list.length; i++) {
|
| + result.$setindex(i, mapper(list.$index(i)));
|
| + }
|
| + }
|
| + else {
|
| + for (var $$i = source.iterator(); $$i.hasNext$0(); ) {
|
| + var item = $$i.next$0();
|
| + result.add(mapper(item));
|
| + }
|
| + }
|
| + return result;
|
| +}
|
| +function reduce(source, callback, initialValue) {
|
| + var i = source.iterator();
|
| + var current = initialValue;
|
| + if (current == null && i.hasNext$0()) {
|
| + current = i.next$0();
|
| + }
|
| + while (i.hasNext$0()) {
|
| + current = callback.call$2(current, i.next$0());
|
| + }
|
| + return current;
|
| +}
|
| +function orderValuesByKeys(map) {
|
| + var keys = map.getKeys();
|
| + keys.sort((function (x, y) {
|
| + return x.compareTo$1(y);
|
| + })
|
| + );
|
| + var values = [];
|
| + for (var $$i = 0;$$i < keys.length; $$i++) {
|
| + var k = keys.$index($$i);
|
| + values.add(map.$index(k));
|
| + }
|
| + return values;
|
| +}
|
| +function isMultilineString(text) {
|
| + return text.startsWith('"""') || text.startsWith("'''");
|
| +}
|
| +function isRawMultilineString(text) {
|
| + return text.startsWith('@"""') || text.startsWith("@'''");
|
| +}
|
| +function toDoubleQuote(s) {
|
| + return s.replaceAll('"', '\\"').replaceAll("\\'", "'");
|
| +}
|
| +function parseStringLiteral(lit) {
|
| + if (lit.startsWith('@')) {
|
| + if (isRawMultilineString(lit)) {
|
| + return stripLeadingNewline(lit.substring(4, lit.length - 3));
|
| + }
|
| + else {
|
| + return lit.substring(2, lit.length - 1);
|
| + }
|
| + }
|
| + else if (isMultilineString(lit)) {
|
| + lit = lit.substring(3, lit.length - 3).replaceAll('\\\$', '\$');
|
| + return stripLeadingNewline(lit);
|
| + }
|
| + else {
|
| + return lit.substring(1, lit.length - 1).replaceAll('\\\$', '\$');
|
| + }
|
| +}
|
| +function stripLeadingNewline(text) {
|
| + if (text.startsWith('\n')) {
|
| + return text.substring(1);
|
| + }
|
| + else if (text.startsWith('\r')) {
|
| + if (text.startsWith('\r\n')) {
|
| + return text.substring(2);
|
| + }
|
| + else {
|
| + return text.substring(1);
|
| + }
|
| + }
|
| + else {
|
| + return text;
|
| + }
|
| +}
|
| +function _escapeForComment(text) {
|
| + return text.replaceAll('/*', '/ *').replaceAll('*/', '* /');
|
| +}
|
| +var world;
|
| +var experimentalAwaitPhase;
|
| +var legCompile;
|
| +function initializeWorld(files) {
|
| + $globals.world = new World(files);
|
| + $globals.world.init();
|
| +}
|
| +var options;
|
| +function parseOptions(homedir, args, files) {
|
| + $globals.options = new FrogOptions(homedir, args, files);
|
| +}
|
| +function _getCallStubName(name, args) {
|
| + var nameBuilder = new StringBufferImpl(('' + name + '\$' + args.get$bareCount()));
|
| + for (var i = args.get$bareCount();
|
| + i < args.get$length(); i++) {
|
| + nameBuilder.add('\$').add(args.getName(i));
|
| + }
|
| + return nameBuilder.toString();
|
| +}
|
| +// ********** Library file_system_dom **************
|
| +// ********** Code for DomFileSystem **************
|
| +function DomFileSystem(_path) {
|
| + this._path = _path;
|
| + this._fileCache = new HashMapImplementation();
|
| + // Initializers done
|
| +}
|
| +DomFileSystem.prototype.absPath = function(filename) {
|
| + if (this._path != null && !filename.startsWith('/') && !filename.startsWith('file:///') && !filename.startsWith('http://') && !filename.startsWith('dart:')) {
|
| + filename = joinPaths(this._path, filename);
|
| + }
|
| + return filename;
|
| +}
|
| +DomFileSystem.prototype.readAll = function(filename) {
|
| + filename = this.absPath(filename);
|
| + var result = this._fileCache.$index(filename);
|
| + if (result == null) {
|
| + var xhr = new XMLHttpRequest();
|
| + xhr.open('GET', filename, false);
|
| + try {
|
| + xhr.send(null);
|
| + } catch (e) {
|
| + e = _toDartException(e);
|
| + return ("_directory(" + filename + ")_");
|
| + }
|
| + if (xhr.status == 0 || xhr.status == 200) {
|
| + result = xhr.responseText;
|
| + if (result.isEmpty$0()) {
|
| + print(('Error: ' + filename + ' is not found or empty'));
|
| + return null;
|
| + }
|
| + }
|
| + else {
|
| + print(("Error: " + xhr.statusText));
|
| + }
|
| + this._fileCache.$setindex(filename, result);
|
| + }
|
| + return result;
|
| +}
|
| +DomFileSystem.prototype.writeString = function(outfile, text) {
|
| + outfile = this.absPath(outfile);
|
| + this._fileCache.$setindex(outfile, text);
|
| +}
|
| +DomFileSystem.prototype.fileExists = function(filename) {
|
| + return this.readAll(filename) != null;
|
| +}
|
| +// ********** Code for top level **************
|
| +// ********** Library tip **************
|
| +// ********** Code for Message **************
|
| +function Message(prefix, message, span) {
|
| + this.prefix = prefix;
|
| + this.message = message;
|
| + this.span = span;
|
| + // Initializers done
|
| + var col = this.prefix.indexOf(':');
|
| + if ($ne(col, -1)) {
|
| + this.prefix = this.prefix.substring(0, col);
|
| + }
|
| + this._node = get$document().createElement('div');
|
| + this._node.className = ('message ' + this.prefix);
|
| + this._node.innerText = ('' + this.message + ' at ' + this.span.get$locationText());
|
| + this._node.addEventListener$3('click', this.get$click(), false);
|
| +}
|
| +Message.prototype.get$_node = function() { return this._node; };
|
| +Message.prototype.set$_node = function(value) { return this._node = value; };
|
| +Message.prototype.click = function(event) {
|
| + $globals.shell.showSpan(this.span);
|
| +}
|
| +Message.prototype.get$click = function() {
|
| + return Message.prototype.click.bind(this);
|
| +}
|
| +// ********** Code for MessageWindow **************
|
| +function MessageWindow() {
|
| + // Initializers done
|
| + this.messages = [];
|
| + this._node = get$document().createElement('div');
|
| + this._node.className = 'errors';
|
| +}
|
| +MessageWindow.prototype.get$_node = function() { return this._node; };
|
| +MessageWindow.prototype.set$_node = function(value) { return this._node = value; };
|
| +MessageWindow.prototype.addMessage = function(message) {
|
| + this.messages.add(message);
|
| + this._node.appendChild$1(message._node);
|
| +}
|
| +MessageWindow.prototype.clear = function() {
|
| + this.messages.length = 0;
|
| + this._node.innerHTML = '';
|
| +}
|
| +MessageWindow.prototype.addMessage$1 = MessageWindow.prototype.addMessage;
|
| +MessageWindow.prototype.clear$0 = MessageWindow.prototype.clear;
|
| +// ********** Code for Shell **************
|
| +function Shell() {
|
| + var $this = this; // closure support
|
| + // Initializers done
|
| + this._node = get$document().createElement('div');
|
| + this._node.className = 'shell';
|
| + this._editor = new Editor(this);
|
| + this._editor._node.style.setProperty$2('height', '93%');
|
| + this._node.appendChild$1(this._editor._node);
|
| + this._textInputArea = get$document().createElement('textarea');
|
| + this._textInputArea.className = 'hiddenTextArea';
|
| + this._node.appendChild$1(this._textInputArea);
|
| + var outDiv = get$document().createElement('div');
|
| + outDiv.className = 'output';
|
| + outDiv.style.setProperty$2('height', '83%');
|
| + this._output = get$document().createElement('iframe');
|
| + outDiv.appendChild$1(this._output);
|
| + this._node.appendChild$1(outDiv);
|
| + this._repl = get$document().createElement('div');
|
| + this._repl.className = 'repl';
|
| + this._repl.style.setProperty$2('height', '5%');
|
| + this._repl.innerHTML = '<div>REPL Under Construction...</div>';
|
| + this._node.appendChild$1(this._repl);
|
| + this._errors = new MessageWindow();
|
| + this._errors.get$_node().style.setProperty$2('height', '15%');
|
| + this._node.appendChild$1(this._errors.get$_node());
|
| + get$window().setTimeout($wrap_call$0((function () {
|
| + $this._editor.focus();
|
| + $this._output.contentDocument.head.innerHTML = " <style>body {\n font-family: arial , sans-serif;\n }\n h3 {\n text-align: center;\n }\n </style>";
|
| + $this._output.contentDocument.body.innerHTML = '<h3>Output will go here</h3>';
|
| + })
|
| + ), .5);
|
| + var bindings = _map(['Left', (function () {
|
| + $this.cursor.clearSelection();
|
| + $this.cursor._pos = $this.cursor._pos.moveColumn(-1);
|
| + })
|
| + , 'Shift-Left', (function () {
|
| + if ($this.cursor._toPos == null) {
|
| + $this.cursor._toPos = $this.cursor._pos;
|
| + }
|
| + $this.cursor._pos = $this.cursor._pos.moveColumn(-1);
|
| + })
|
| + , 'Right', (function () {
|
| + $this.cursor.clearSelection();
|
| + $this.cursor._pos = $this.cursor._pos.moveColumn(1);
|
| + })
|
| + , 'Shift-Right', (function () {
|
| + if ($this.cursor._toPos == null) {
|
| + $this.cursor._toPos = $this.cursor._pos;
|
| + }
|
| + $this.cursor._pos = $this.cursor._pos.moveColumn(1);
|
| + })
|
| + , 'Up', (function () {
|
| + $this.cursor.clearSelection();
|
| + $this.cursor._pos = $this.cursor._pos.moveLine(-1);
|
| + })
|
| + , 'Shift-Up', (function () {
|
| + if ($this.cursor._toPos == null) {
|
| + $this.cursor._toPos = $this.cursor._pos;
|
| + }
|
| + $this.cursor._pos = $this.cursor._pos.moveLine(-1);
|
| + })
|
| + , 'Down', (function () {
|
| + $this.cursor.clearSelection();
|
| + $this.cursor._pos = $this.cursor._pos.moveLine(1);
|
| + })
|
| + , 'Shift-Down', (function () {
|
| + if ($this.cursor._toPos == null) {
|
| + $this.cursor._toPos = $this.cursor._pos;
|
| + }
|
| + $this.cursor._pos = $this.cursor._pos.moveLine(1);
|
| + })
|
| + , 'Meta-Up', (function () {
|
| + $this.cursor.clearSelection();
|
| + $this.cursor._pos = $this._editor._code.get$start();
|
| + })
|
| + , 'Meta-Shift-Up', (function () {
|
| + if ($this.cursor._toPos == null) {
|
| + $this.cursor._toPos = $this.cursor._pos;
|
| + }
|
| + $this.cursor._pos = $this._editor._code.get$start();
|
| + })
|
| + , 'Meta-Down', (function () {
|
| + $this.cursor.clearSelection();
|
| + $this.cursor._pos = $this._editor._code.get$end();
|
| + })
|
| + , 'Meta-Shift-Down', (function () {
|
| + if ($this.cursor._toPos == null) {
|
| + $this.cursor._toPos = $this.cursor._pos;
|
| + }
|
| + $this.cursor._pos = $this._editor._code.get$end();
|
| + })
|
| + , 'Delete', (function () {
|
| + if ($this.cursor._toPos == null) {
|
| + $this.cursor._toPos = $this.cursor._pos.moveColumn(-1);
|
| + }
|
| + $this.cursor.deleteSelection();
|
| + })
|
| + , 'Control-D', (function () {
|
| + if ($this.cursor._toPos == null) {
|
| + $this.cursor._toPos = $this.cursor._pos.moveColumn(1);
|
| + }
|
| + $this.cursor.deleteSelection();
|
| + })
|
| + , 'Meta-A', (function () {
|
| + $this.cursor._pos = $this._editor._code.get$start();
|
| + $this.cursor._toPos = $this._editor._code.get$end();
|
| + })
|
| + , '.', (function () {
|
| + $this.cursor.write('.');
|
| + })
|
| + , '}', (function () {
|
| + $this.cursor.write('}');
|
| + })
|
| + , 'Enter', (function () {
|
| + $this.cursor.write('\n');
|
| + })
|
| + , 'Tab', (function () {
|
| + $this.cursor.write(' ');
|
| + })
|
| + , 'Space', (function () {
|
| + return $this.cursor.write(' ');
|
| + })
|
| + , 'Shift-Space', (function () {
|
| + return $this.cursor.write(' ');
|
| + })
|
| + , 'Meta-G', (function () {
|
| + return $this.cursor.write("#import(\"dart:dom\");\n\n// This is an interesting field;\nfinal int y = 22;\nString name;\n\n/** This is my main method. */\nvoid main() {\n var element = document.createElement('div');\n element.innerHTML = \"Hello dom from Dart!\";\n document.body.appendChild(element);\n\n HTMLCanvasElement canvas = document.createElement('canvas');\n document.body.appendChild(canvas);\n\n var context = canvas.getContext('2d');\n context.setFillColor('purple');\n context.fillRect(10, 10, 30, 30);\n}\n\n/**\n * The usual method of computing factorial in the slowest possible way.\n */\nnum fact(n) {\n if (n == 0) return 1;\n return n * fact(n - 1);\n}\n\nfinal x = 22;\n\n"/*null.CODE*/);
|
| + })
|
| + , 'Meta-H', (function () {
|
| + return $this.cursor.write("#import(\"dart:html\");\n\nvoid main() {\n var element = document.createElement('div');\n element.innerHTML = \"Hello html from Dart!\";\n document.body.nodes.add(element);\n\n CanvasElement canvas = document.createElement('canvas');\n canvas.width = 100;\n canvas.height = 100;\n document.body.nodes.add(canvas);\n\n var context = canvas.getContext('2d');\n context.setFillColor('blue');\n context.fillRect(10, 10, 30, 30);\n}\n"/*null.HCODE*/);
|
| + })
|
| + , 'Meta-P', (function () {
|
| + return $this.cursor._pos.block.parse();
|
| + })
|
| + , 'Shift-Enter', this.get$run(), 'Meta-Enter', this.get$run()]);
|
| + this._bindings = new KeyBindings(this._textInputArea, bindings, (function (text) {
|
| + $this.cursor.write(text);
|
| + })
|
| + , (function (key) {
|
| + if (key == 'Meta-V') return false;
|
| + if (key == 'Control-V') return false;
|
| + if (key == 'Meta-X' || key == 'Control-X') {
|
| + get$window().setTimeout($wrap_call$0((function () {
|
| + $this.cursor.deleteSelection();
|
| + $this._editor._redraw();
|
| + })
|
| + ), 0);
|
| + return false;
|
| + }
|
| + if (key == 'Meta-C') return false;
|
| + if (key == 'Control-C') return false;
|
| + if (key == 'Alt-Meta-I') return false;
|
| + if (key == 'Control-Shift-I') return false;
|
| + get$window().console.log(('Unbound key "' + key + '"'));
|
| + return true;
|
| + })
|
| + );
|
| +}
|
| +Shell.prototype.get$_node = function() { return this._node; };
|
| +Shell.prototype.set$_node = function(value) { return this._node = value; };
|
| +Shell.prototype.handleMessage = function(prefix, message, span) {
|
| + var m = new Message(prefix, message, span);
|
| + this._errors.addMessage$1(m);
|
| +}
|
| +Shell.prototype.get$handleMessage = function() {
|
| + return Shell.prototype.handleMessage.bind(this);
|
| +}
|
| +Shell.prototype.showSpan = function(span) {
|
| + var code = this._editor._code;
|
| + var p1 = new CodePosition(code, span.start);
|
| + var p2 = new CodePosition(code, span.end);
|
| + this._editor._cursor._pos = p1.toLeaf$0();
|
| + this._editor._cursor._toPos = p2.toLeaf$0();
|
| + this._editor._redraw();
|
| +}
|
| +Shell.prototype.run = function() {
|
| + var $this = this; // closure support
|
| + this._output.contentDocument.body.innerHTML = '<h3 style="color:green">Compiling...</h3>';
|
| + this._errors.clear$0();
|
| + get$window().setTimeout($wrap_call$0((function () {
|
| + var sw = new StopwatchImplementation();
|
| + sw.start();
|
| + var code = $this._editor.getCode();
|
| + $globals.world.files.writeString('input.dart'/*null.DART_FILENAME*/, code);
|
| + $globals.options.enableAsserts = true;
|
| + $globals.options.enableTypeChecks = true;
|
| + $globals.world.reset();
|
| + var success = $globals.world.compile();
|
| + sw.stop();
|
| + if (success) {
|
| + $this._output.contentDocument.body.innerHTML = '';
|
| + inject($globals.world.getGeneratedCode(), $this._output.contentWindow, 'generated.js');
|
| + }
|
| + else {
|
| + $this._output.contentDocument.body.innerHTML = '<h3 style="color:red">Compilation failed</h3>';
|
| + }
|
| + print(('compiled in ' + sw.elapsedInMs() + 'msec'));
|
| + })
|
| + ), 0);
|
| +}
|
| +Shell.prototype.get$run = function() {
|
| + return Shell.prototype.run.bind(this);
|
| +}
|
| +Shell.prototype.focusKeys = function(editor) {
|
| + this._editor = editor;
|
| + this.cursor = editor._cursor;
|
| + this._textInputArea.focus$0();
|
| +}
|
| +// ********** Code for Editor **************
|
| +function Editor(_shell) {
|
| + this._shell = _shell;
|
| + // Initializers done
|
| + this._node = get$document().createElement('div');
|
| + this._node.className = 'editor';
|
| + this._code = new BlockBlock(null, 0);
|
| + this._code.set$text("#import(\"dart:dom\");\n\n// This is an interesting field;\nfinal int y = 22;\nString name;\n\n/** This is my main method. */\nvoid main() {\n var element = document.createElement('div');\n element.innerHTML = \"Hello dom from Dart!\";\n document.body.appendChild(element);\n\n HTMLCanvasElement canvas = document.createElement('canvas');\n document.body.appendChild(canvas);\n\n var context = canvas.getContext('2d');\n context.setFillColor('purple');\n context.fillRect(10, 10, 30, 30);\n}\n\n/**\n * The usual method of computing factorial in the slowest possible way.\n */\nnum fact(n) {\n if (n == 0) return 1;\n return n * fact(n - 1);\n}\n\nfinal x = 22;\n\n"/*null.CODE*/);
|
| + this._code.set$top(0);
|
| + this._node.appendChild$1(this._code._node);
|
| + this._cursor = new Cursor(this._code.get$start());
|
| + this._node.appendChild$1(this._cursor._node);
|
| + this._node.addEventListener$3('mousedown', this.get$mousedown(), false);
|
| + this._node.addEventListener$3('mousemove', this.get$mousemove(), false);
|
| + this._node.addEventListener$3('mouseup', this.get$mouseup(), false);
|
| +}
|
| +Editor.prototype.get$_node = function() { return this._node; };
|
| +Editor.prototype.set$_node = function(value) { return this._node = value; };
|
| +Editor.prototype.getCode = function() {
|
| + return this._code.get$text();
|
| +}
|
| +Editor.prototype.mousedown = function(e) {
|
| + if (e.shiftKey) {
|
| + this._cursor._toPos = this._cursor._pos;
|
| + }
|
| + else {
|
| + this._cursor.clearSelection();
|
| + }
|
| + this._cursor._pos = this._code.positionFromMouse(e);
|
| + this.focus();
|
| + e.preventDefault();
|
| + this._isSelecting = true;
|
| +}
|
| +Editor.prototype.get$mousedown = function() {
|
| + return Editor.prototype.mousedown.bind(this);
|
| +}
|
| +Editor.prototype.mousemove = function(e) {
|
| + if (this._isSelecting) {
|
| + if (this._cursor._toPos == null) {
|
| + this._cursor._toPos = this._cursor._pos;
|
| + }
|
| + this._cursor._pos = this._code.positionFromMouse(e);
|
| + e.preventDefault();
|
| + this._redraw();
|
| + }
|
| +}
|
| +Editor.prototype.get$mousemove = function() {
|
| + return Editor.prototype.mousemove.bind(this);
|
| +}
|
| +Editor.prototype.mouseup = function(e) {
|
| + this._isSelecting = false;
|
| + if (this._cursor.get$emptySelection()) {
|
| + this._cursor.clearSelection();
|
| + }
|
| +}
|
| +Editor.prototype.get$mouseup = function() {
|
| + return Editor.prototype.mouseup.bind(this);
|
| +}
|
| +Editor.prototype.scrollToVisible = function(pos) {
|
| + var top = this._node.scrollTop;
|
| + var height = this._node.getBoundingClientRect$0().height;
|
| + var pt = pos.getPoint();
|
| + if (pt.y < top) {
|
| + this._node.scrollTop = pt.y;
|
| + }
|
| + else if (pt.y > top + height - 22/*null.LINE_HEIGHT*/) {
|
| + var H = 22/*null.LINE_HEIGHT*/ * (($truncdiv(height, 22/*null.LINE_HEIGHT*/)) - 1);
|
| + this._node.scrollTop = Math.max(pt.y - H, 0);
|
| + }
|
| +}
|
| +Editor.prototype._redraw = function() {
|
| + this.scrollToVisible(this._cursor._pos);
|
| + this._code._redraw();
|
| + this._cursor._redraw();
|
| +}
|
| +Editor.prototype.focus = function() {
|
| + this._shell.focusKeys(this);
|
| + this._cursor._visible = true;
|
| + this._redraw();
|
| +}
|
| +Editor.prototype._redraw$0 = Editor.prototype._redraw;
|
| +Editor.prototype.focus$0 = Editor.prototype.focus;
|
| +// ********** Code for Point **************
|
| +function Point(x, y) {
|
| + this.x = x;
|
| + this.y = y;
|
| + // Initializers done
|
| +}
|
| +// ********** Code for LineColumn **************
|
| +function LineColumn(line, column) {
|
| + this.line = line;
|
| + this.column = column;
|
| + // Initializers done
|
| +}
|
| +// ********** Code for Cursor **************
|
| +function Cursor(_pos) {
|
| + this._visible = true
|
| + this._pos = _pos;
|
| + // Initializers done
|
| + this._node = get$document().createElement('div');
|
| + this._node.className = 'cursorDiv';
|
| +}
|
| +Cursor.prototype.get$_node = function() { return this._node; };
|
| +Cursor.prototype.set$_node = function(value) { return this._node = value; };
|
| +Cursor.prototype.get$emptySelection = function() {
|
| + return this._toPos == null || ($eq(this._toPos.block, this._pos.block) && this._toPos.offset == this._pos.offset);
|
| +}
|
| +Cursor.prototype._redraw = function() {
|
| + var $this = this; // closure support
|
| + this._node.innerHTML = '';
|
| + if (!this._visible) return;
|
| + this._cursorNode = get$document().createElement('div');
|
| + this._cursorNode.className = 'cursor blink';
|
| + this._cursorNode.style.setProperty$2('height', ('' + 22/*null.LINE_HEIGHT*/ + 'px'));
|
| + var p = this._pos.getPoint();
|
| + this._cursorNode.style.setProperty$2('left', ('' + p.x + 'px'));
|
| + this._cursorNode.style.setProperty$2('top', ('' + p.y + 'px'));
|
| + this._node.appendChild$1(this._cursorNode);
|
| + if (this._toPos == null) return;
|
| + function addDiv(top, left, height, width) {
|
| + var child = get$document().createElement('div');
|
| + child.className = 'selection';
|
| + child.style.setProperty$2('left', ('' + left + 'px'));
|
| + child.style.setProperty$2('top', ('' + top + 'px'));
|
| + child.style.setProperty$2('height', ('' + height + 'px'));
|
| + if (width == null) {
|
| + child.style.setProperty$2('right', '0px');
|
| + }
|
| + else {
|
| + child.style.setProperty$2('width', ('' + width + 'px'));
|
| + }
|
| + $this._node.appendChild$1(child);
|
| + }
|
| + var toP = this._toPos.getPoint();
|
| + if ($eq(toP.y, p.y)) {
|
| + if (toP.x < p.x) {
|
| + addDiv(p.y, toP.x, 22/*null.LINE_HEIGHT*/, p.x - toP.x);
|
| + }
|
| + else {
|
| + addDiv(p.y, p.x, 22/*null.LINE_HEIGHT*/, toP.x - p.x);
|
| + }
|
| + }
|
| + else {
|
| + if (toP.y < p.y) {
|
| + var tmp = toP;
|
| + toP = p;
|
| + p = tmp;
|
| + }
|
| + addDiv(p.y, p.x, 22/*null.LINE_HEIGHT*/, null);
|
| + if (toP.y > p.y + 22/*null.LINE_HEIGHT*/) {
|
| + addDiv(p.y + 22/*null.LINE_HEIGHT*/, 0, toP.y - p.y - 22/*null.LINE_HEIGHT*/, null);
|
| + }
|
| + addDiv(toP.y, 0, 22/*null.LINE_HEIGHT*/, toP.x);
|
| + }
|
| + var p0 = this._pos.toRoot();
|
| + var p1 = this._toPos.toRoot();
|
| + var i0 = p0.offset;
|
| + var i1 = p1.offset;
|
| + if (i1 < i0) {
|
| + var tmp = i1;
|
| + i1 = i0;
|
| + i0 = tmp;
|
| + }
|
| + var text = p0.get$block().text.substring$2(i0, i1);
|
| + $globals.shell._textInputArea.value = text;
|
| + $globals.shell._textInputArea.select$0();
|
| +}
|
| +Cursor.prototype.clearSelection = function() {
|
| + this._toPos = null;
|
| +}
|
| +Cursor.prototype.deleteSelection = function() {
|
| + if (this._toPos == null) return;
|
| + var p0 = this._pos;
|
| + var p1 = this._toPos;
|
| + if ($ne(p0.get$block(), p1.get$block())) {
|
| + p0 = p0.toRoot$0();
|
| + p1 = p1.toRoot$0();
|
| + }
|
| + if (p1.offset < p0.offset) {
|
| + var tmp = p0;
|
| + p0 = p1;
|
| + p1 = tmp;
|
| + }
|
| + p0.get$block().delete$2(p0.offset, p1.offset);
|
| + this._pos = p0.toLeaf$0();
|
| + this._toPos = null;
|
| +}
|
| +Cursor.prototype.write = function(text) {
|
| + this.deleteSelection();
|
| + this._pos.block.insertText(this._pos.offset, text);
|
| + this._pos.block._redraw();
|
| + this._pos = this._pos.moveColumn(text.length);
|
| +}
|
| +Cursor.prototype._redraw$0 = Cursor.prototype._redraw;
|
| +// ********** Code for CodePosition **************
|
| +function CodePosition(block, offset) {
|
| + this.block = block;
|
| + this.offset = offset;
|
| + // Initializers done
|
| +}
|
| +CodePosition.prototype.get$block = function() { return this.block; };
|
| +CodePosition.prototype.moveLine = function(delta) {
|
| + if (delta == 0) return this;
|
| + var lineCol = this.getLineColumn();
|
| + return this.block.getPosition(lineCol.line + delta, lineCol.column);
|
| +}
|
| +CodePosition.prototype.moveColumn = function(delta) {
|
| + return this.block.moveToOffset(this.offset + delta);
|
| +}
|
| +CodePosition.prototype.getPoint = function() {
|
| + return this.block.offsetToPoint(this.offset);
|
| +}
|
| +CodePosition.prototype.getLineColumn = function() {
|
| + return this.block.getLineColumn(this.offset);
|
| +}
|
| +CodePosition.prototype.toRoot = function() {
|
| + if (this.block._parent == null) return this;
|
| + var ret = new CodePosition(this.block._parent, this.block._parent.getOffset(this.block) + this.offset);
|
| + return ret.toRoot$0();
|
| +}
|
| +CodePosition.prototype.toLeaf = function() {
|
| + return this.block.moveToOffset(this.offset);
|
| +}
|
| +CodePosition.prototype.block$0 = function() {
|
| + return this.block();
|
| +};
|
| +CodePosition.prototype.toLeaf$0 = CodePosition.prototype.toLeaf;
|
| +CodePosition.prototype.toRoot$0 = CodePosition.prototype.toRoot;
|
| +// ********** Code for BlockChildren **************
|
| +function BlockChildren(_parent) {
|
| + this._parent = _parent;
|
| + // Initializers done
|
| +}
|
| +BlockChildren.prototype.iterator = function() {
|
| + return new BlockChildrenIterator(this._parent._firstChild);
|
| +}
|
| +BlockChildren.prototype.iterator$0 = BlockChildren.prototype.iterator;
|
| +// ********** Code for BlockChildrenIterator **************
|
| +function BlockChildrenIterator(_child) {
|
| + this._child = _child;
|
| + // Initializers done
|
| +}
|
| +BlockChildrenIterator.prototype.next = function() {
|
| + var ret = this._child;
|
| + this._child = this._child._nextSibling;
|
| + return ret;
|
| +}
|
| +BlockChildrenIterator.prototype.hasNext = function() {
|
| + return this._child != null;
|
| +}
|
| +BlockChildrenIterator.prototype.hasNext$0 = BlockChildrenIterator.prototype.hasNext;
|
| +BlockChildrenIterator.prototype.next$0 = BlockChildrenIterator.prototype.next;
|
| +// ********** Code for CodeBlock **************
|
| +function CodeBlock(_parent, _depth) {
|
| + this._depth = 0
|
| + this._dirty = true
|
| + this._parent = _parent;
|
| + this._depth = _depth;
|
| + // Initializers done
|
| + this._node = get$document().createElement('div');
|
| + this._node.className = 'code';
|
| +}
|
| +CodeBlock.prototype.get$_nextSibling = function() { return this._nextSibling; };
|
| +CodeBlock.prototype.set$_nextSibling = function(value) { return this._nextSibling = value; };
|
| +CodeBlock.prototype.get$_node = function() { return this._node; };
|
| +CodeBlock.prototype.set$_node = function(value) { return this._node = value; };
|
| +Object.defineProperty(CodeBlock.prototype, "text", {
|
| + get: CodeBlock.prototype.get$text,
|
| + set: CodeBlock.prototype.set$text
|
| +});
|
| +CodeBlock.prototype.get$start = function() {
|
| + return new CodePosition(this, 0);
|
| +}
|
| +Object.defineProperty(CodeBlock.prototype, "start", {
|
| + get: CodeBlock.prototype.get$start
|
| +});
|
| +CodeBlock.prototype.get$end = function() {
|
| + return new CodePosition(this, this.get$size());
|
| +}
|
| +CodeBlock.prototype.getOffset = function(forChild) {
|
| + $throw("child missing");
|
| +}
|
| +CodeBlock.prototype.getLine = function(forChild) {
|
| + $throw("child missing");
|
| +}
|
| +CodeBlock.prototype._removeChild = function(child) {
|
| + $throw("child missing");
|
| +}
|
| +CodeBlock.prototype.parse = function() {
|
| + var source = new SourceFile('fake.dart', this.get$text());
|
| + var p = new Parser(source, false, false, false, 0);
|
| + var cu = p.compilationUnit$0();
|
| +}
|
| +CodeBlock.prototype.markDirty = function() {
|
| + if (!this._dirty) {
|
| + this._dirty = true;
|
| + if (this._parent != null) {
|
| + this._parent._dirty = true;
|
| + }
|
| + }
|
| +}
|
| +CodeBlock.prototype.get$top = function() {
|
| + return this._top;
|
| +}
|
| +CodeBlock.prototype.set$top = function(newTop) {
|
| + if (newTop != this._top) {
|
| + this._top = newTop;
|
| + this._node.style.setProperty$2('top', ('' + this._top + 'px'));
|
| + }
|
| +}
|
| +Object.defineProperty(CodeBlock.prototype, "top", {
|
| + get: CodeBlock.prototype.get$top,
|
| + set: CodeBlock.prototype.set$top
|
| +});
|
| +CodeBlock.prototype.get$height = function() {
|
| + return this._height;
|
| +}
|
| +CodeBlock.prototype.set$height = function(newHeight) {
|
| + if (newHeight != this._height) {
|
| + this._height = newHeight;
|
| + this._node.style.setProperty$2('height', ('' + this._height + 'px'));
|
| + }
|
| +}
|
| +Object.defineProperty(CodeBlock.prototype, "height", {
|
| + get: CodeBlock.prototype.get$height,
|
| + set: CodeBlock.prototype.set$height
|
| +});
|
| +CodeBlock.prototype.positionFromMouse = function(p) {
|
| + var box = this._node.getBoundingClientRect$0();
|
| + var y = p.clientY - box.top;
|
| + var x = p.clientX - box.left;
|
| + return this.positionFromPoint(x, y);
|
| +}
|
| +CodeBlock.prototype._redraw$0 = CodeBlock.prototype._redraw;
|
| +CodeBlock.prototype.delete$2 = CodeBlock.prototype.delete_;
|
| +CodeBlock.prototype.end$0 = function() {
|
| + return this.get$end()();
|
| +};
|
| +CodeBlock.prototype.getLine$1 = CodeBlock.prototype.getLine;
|
| +CodeBlock.prototype.getLineColumn$1 = CodeBlock.prototype.getLineColumn;
|
| +CodeBlock.prototype.getPosition$2 = CodeBlock.prototype.getPosition;
|
| +CodeBlock.prototype.insertText$2 = CodeBlock.prototype.insertText;
|
| +CodeBlock.prototype.moveToOffset$1 = CodeBlock.prototype.moveToOffset;
|
| +CodeBlock.prototype.offsetToPoint$1 = CodeBlock.prototype.offsetToPoint;
|
| +CodeBlock.prototype.positionFromPoint$2 = CodeBlock.prototype.positionFromPoint;
|
| +CodeBlock.prototype.start$0 = function() {
|
| + return this.get$start()();
|
| +};
|
| +// ********** Code for BlockBlock **************
|
| +$inherits(BlockBlock, CodeBlock);
|
| +function BlockBlock(parent, depth) {
|
| + // Initializers done
|
| + CodeBlock.call(this, parent, depth);
|
| + this.set$text('');
|
| + this.children = new BlockChildren(this);
|
| +}
|
| +BlockBlock.prototype.get$start = function() {
|
| + return this._firstChild.get$start();
|
| +}
|
| +Object.defineProperty(BlockBlock.prototype, "start", {
|
| + get: BlockBlock.prototype.get$start
|
| +});
|
| +BlockBlock.prototype.get$end = function() {
|
| + return this._lastChild.get$end();
|
| +}
|
| +BlockBlock.prototype.get$size = function() {
|
| + var ret = 0;
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + ret = ret + child.size;
|
| + }
|
| + return ret;
|
| +}
|
| +Object.defineProperty(BlockBlock.prototype, "size", {
|
| + get: BlockBlock.prototype.get$size
|
| +});
|
| +BlockBlock.prototype.get$lineCount = function() {
|
| + var ret = 0;
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + ret = ret + child.get$lineCount();
|
| + }
|
| + return ret;
|
| +}
|
| +BlockBlock.prototype.get$text = function() {
|
| + var ret = new StringBufferImpl("");
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + ret.add$1(child.text);
|
| + }
|
| + return ret.toString$0();
|
| +}
|
| +BlockBlock.prototype.set$text = function(newText) {
|
| + var sw = new StopwatchImplementation();
|
| + sw.start();
|
| + this._firstChild = this._lastChild = null;
|
| + var src = new SourceFile('fake.dart', newText);
|
| + var start = 0;
|
| + while (start != -1) {
|
| + var child = new TextBlock(this, null, this._depth + 1);
|
| + if (this._lastChild == null) {
|
| + this._firstChild = this._lastChild = child;
|
| + this._node.appendChild$1(child.get$_node());
|
| + }
|
| + else {
|
| + this._addChildAfter(this._lastChild, child);
|
| + }
|
| + start = child.tokenizeInto$2(src, start);
|
| + }
|
| + sw.stop();
|
| + print(('create structure in ' + sw.elapsedInMs() + 'msec'));
|
| +}
|
| +Object.defineProperty(BlockBlock.prototype, "text", {
|
| + get: BlockBlock.prototype.get$text,
|
| + set: BlockBlock.prototype.set$text
|
| +});
|
| +BlockBlock.prototype.getOffset = function(forChild) {
|
| + var ret = 0;
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + if ($eq(child, forChild)) return ret;
|
| + ret = ret + child.size;
|
| + }
|
| + $throw("child missing");
|
| +}
|
| +BlockBlock.prototype.getLine = function(forChild) {
|
| + var ret = 0;
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + if ($eq(child, forChild)) return ret;
|
| + ret = ret + child.get$lineCount();
|
| + }
|
| + $throw("child missing");
|
| +}
|
| +BlockBlock.prototype._addChildAfter = function(addAfterChild, child) {
|
| + this.markDirty();
|
| + child._nextSibling = addAfterChild._nextSibling;
|
| + child._previousSibling = addAfterChild;
|
| + addAfterChild._nextSibling = child;
|
| + if (child._nextSibling == null) {
|
| + this._node.appendChild$1(child._node);
|
| + this._lastChild = child;
|
| + }
|
| + else {
|
| + this._node.insertBefore$2(child._node, child._nextSibling._node);
|
| + }
|
| +}
|
| +BlockBlock.prototype._removeChild = function(child) {
|
| + this.markDirty();
|
| + if (child._previousSibling != null) {
|
| + child._previousSibling._nextSibling = child._nextSibling;
|
| + }
|
| + else {
|
| + this._firstChild = child._nextSibling;
|
| + }
|
| + if (child._nextSibling != null) {
|
| + child._nextSibling._previousSibling = child._previousSibling;
|
| + }
|
| + else {
|
| + this._lastChild = child._previousSibling;
|
| + }
|
| + this._node.removeChild$1(child._node);
|
| +}
|
| +BlockBlock.prototype.insertText = function(offset, newText) {
|
| + var index = 0;
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + var childSize = child.size;
|
| + if (offset < childSize) {
|
| + child.insertText$2(offset, newText);
|
| + return;
|
| + }
|
| + else if (offset == childSize) {
|
| + var newChild = new TextBlock(this, newText, this._depth + 1);
|
| + this._addChildAfter(child, newChild);
|
| + return;
|
| + }
|
| + offset = offset - childSize;
|
| + index = index + 1;
|
| + }
|
| + $throw("help");
|
| +}
|
| +BlockBlock.prototype.delete_ = function(from, to) {
|
| + var keepChild = null;
|
| + for (var child = this._firstChild;
|
| + child != null; child = child.get$_nextSibling()) {
|
| + var childSize = child.size;
|
| + if (keepChild != null) {
|
| + this._removeChild(child);
|
| + if (to <= childSize) {
|
| + keepChild.set$_text(keepChild.get$_text() + child.get$_text().substring$1(to));
|
| + return;
|
| + }
|
| + }
|
| + else if (from <= childSize) {
|
| + if (to < childSize) {
|
| + child.delete$2(from, to);
|
| + return;
|
| + }
|
| + else {
|
| + child.delete$2(from, childSize);
|
| + keepChild = child;
|
| + }
|
| + }
|
| + from = from - childSize;
|
| + to = to - childSize;
|
| + }
|
| + $throw("help");
|
| +}
|
| +BlockBlock.prototype._redraw = function() {
|
| + if (!this._dirty) return;
|
| + this._dirty = false;
|
| + var childTop = 0;
|
| + for (var child = this._firstChild;
|
| + child != null; child = child.get$_nextSibling()) {
|
| + child.top = childTop;
|
| + child._redraw$0();
|
| + childTop = childTop + child.height;
|
| + }
|
| + this.set$height(childTop);
|
| +}
|
| +BlockBlock.prototype.moveToOffset = function(offset) {
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + var childSize = child.size;
|
| + if (offset < childSize) {
|
| + return child.moveToOffset$1(offset);
|
| + }
|
| + offset = offset - childSize;
|
| + }
|
| + return this.get$end();
|
| +}
|
| +BlockBlock.prototype.positionFromPoint = function(x, y) {
|
| + if (y < this.get$top()) return this.get$start();
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + if (child.top <= y && (child.top + child.height) >= y) {
|
| + return child.positionFromPoint$2(x, y - child.top);
|
| + }
|
| + }
|
| + return this.get$end();
|
| +}
|
| +BlockBlock.prototype.getPosition = function(line, column) {
|
| + if (line < 0) return this.get$start();
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + if (line < child.get$lineCount()) return child.getPosition$2(line, column);
|
| + line = line - child.get$lineCount();
|
| + }
|
| + return this.get$end();
|
| +}
|
| +BlockBlock.prototype.getLineColumn = function(offset) {
|
| + if (offset < 0) return new LineColumn(0, 0);
|
| + var childLine = 0;
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + var childSize = child.size;
|
| + if (offset < childSize) {
|
| + var ret = child.getLineColumn$1(offset);
|
| + return new LineColumn(ret.line + childLine, ret.column);
|
| + }
|
| + offset = offset - childSize;
|
| + childLine = childLine + child.get$lineCount();
|
| + }
|
| + return new LineColumn(this.get$lineCount(), 0);
|
| +}
|
| +BlockBlock.prototype.offsetToPoint = function(offset) {
|
| + if (offset < 0) return new Point(0, 0);
|
| + var $$list = this.children;
|
| + for (var $$i = this.children.iterator(); $$i.hasNext$0(); ) {
|
| + var child = $$i.next$0();
|
| + var childSize = child.size;
|
| + if (offset < childSize) {
|
| + var ret = child.offsetToPoint$1(offset);
|
| + return new Point(ret.x, ret.y + child.top);
|
| + }
|
| + offset = offset - childSize;
|
| + }
|
| + return new Point(0, this.get$top() + this.get$height());
|
| +}
|
| +BlockBlock.prototype._redraw$0 = BlockBlock.prototype._redraw;
|
| +BlockBlock.prototype.delete$2 = BlockBlock.prototype.delete_;
|
| +BlockBlock.prototype.end$0 = function() {
|
| + return this.get$end()();
|
| +};
|
| +BlockBlock.prototype.getLine$1 = BlockBlock.prototype.getLine;
|
| +BlockBlock.prototype.getLineColumn$1 = BlockBlock.prototype.getLineColumn;
|
| +BlockBlock.prototype.getPosition$2 = BlockBlock.prototype.getPosition;
|
| +BlockBlock.prototype.insertText$2 = BlockBlock.prototype.insertText;
|
| +BlockBlock.prototype.moveToOffset$1 = BlockBlock.prototype.moveToOffset;
|
| +BlockBlock.prototype.offsetToPoint$1 = BlockBlock.prototype.offsetToPoint;
|
| +BlockBlock.prototype.positionFromPoint$2 = BlockBlock.prototype.positionFromPoint;
|
| +BlockBlock.prototype.start$0 = function() {
|
| + return this.get$start()();
|
| +};
|
| +// ********** Code for TextBlock **************
|
| +$inherits(TextBlock, CodeBlock);
|
| +function TextBlock(parent, _text, depth) {
|
| + this._text = _text;
|
| + // Initializers done
|
| + CodeBlock.call(this, parent, depth);
|
| +}
|
| +TextBlock.prototype.get$_text = function() { return this._text; };
|
| +TextBlock.prototype.set$_text = function(value) { return this._text = value; };
|
| +TextBlock.prototype.get$size = function() {
|
| + return this._text.length;
|
| +}
|
| +Object.defineProperty(TextBlock.prototype, "size", {
|
| + get: TextBlock.prototype.get$size
|
| +});
|
| +TextBlock.prototype.get$lineCount = function() {
|
| + return this._lineStarts.length;
|
| +}
|
| +TextBlock.prototype.get$text = function() {
|
| + return this._text;
|
| +}
|
| +TextBlock.prototype.set$text = function(newText) {
|
| + this._text = newText;
|
| + this.markDirty();
|
| +}
|
| +Object.defineProperty(TextBlock.prototype, "text", {
|
| + get: TextBlock.prototype.get$text,
|
| + set: TextBlock.prototype.set$text
|
| +});
|
| +TextBlock.prototype.insertText = function(offset, newText) {
|
| + this._text = this._text.substring(0, offset) + newText + this._text.substring(offset);
|
| + this.markDirty();
|
| +}
|
| +TextBlock.prototype.delete_ = function(from, to) {
|
| + this.markDirty();
|
| + if (to == this._text.length) {
|
| + if (from == 0) {
|
| + this._parent._removeChild(this);
|
| + }
|
| + else {
|
| + this._text = this._text.substring(0, from);
|
| + }
|
| + }
|
| + else {
|
| + this._text = this._text.substring(0, from) + this._text.substring(to);
|
| + }
|
| +}
|
| +TextBlock.prototype.tokenizeInto = function(src, start) {
|
| + var $this = this; // closure support
|
| + this._lineStarts = new ListFactory();
|
| + this._lineStarts.add(start);
|
| + var html = new StringBufferImpl("");
|
| + var tokenizer = new Tokenizer(src, false, start);
|
| + var depth = 0;
|
| + function addLineStarts(token) {
|
| + var text = src.get$text();
|
| + for (var index = token.start;
|
| + index < token.end; index++) {
|
| + if (text.charCodeAt(index) == 10) {
|
| + $this._lineStarts.add(index - start + 1);
|
| + }
|
| + }
|
| + }
|
| + while (true) {
|
| + var token = tokenizer.next();
|
| + if ($eq(token.kind, 1/*TokenKind.END_OF_FILE*/)) {
|
| + this._node.innerHTML = html.toString$0();
|
| + if (start == 0) this._text = src.get$text();
|
| + else this._text = src.get$text().substring(start);
|
| + this.set$height(this.get$lineCount() * 22/*null.LINE_HEIGHT*/);
|
| + return -1;
|
| + }
|
| + else if ($eq(token.kind, 63/*TokenKind.WHITESPACE*/)) {
|
| + if (src.get$text().charCodeAt(token.get$end() - 1) == 10) {
|
| + this._text = src.get$text().substring(start, token.get$end());
|
| + this._node.innerHTML = html.toString$0();
|
| + this.set$height(this.get$lineCount() * 22/*null.LINE_HEIGHT*/);
|
| + return token.get$end();
|
| + }
|
| + }
|
| + else if ($eq(token.kind, 64/*TokenKind.COMMENT*/)) {
|
| + addLineStarts(token);
|
| + }
|
| + else if ($eq(token.kind, 58/*TokenKind.STRING*/)) {
|
| + addLineStarts(token);
|
| + }
|
| + else if ($eq(token.kind, 59/*TokenKind.STRING_PART*/)) {
|
| + addLineStarts(token);
|
| + }
|
| + var kind = classify(token);
|
| + var stringClass = '';
|
| + var text = htmlEscape(token.text);
|
| + if (kind != null) {
|
| + html.add$1(('<span class="' + kind + ' ' + stringClass + '">' + text + '</span>'));
|
| + }
|
| + else {
|
| + html.add$1(('<span>' + text + '</span>'));
|
| + }
|
| + }
|
| +}
|
| +TextBlock.prototype._redraw = function() {
|
| + if (!this._dirty) return;
|
| + this._dirty = false;
|
| + var initialText = this._text;
|
| + var end = this.tokenizeInto(new SourceFile('fake.dart', this._text), 0);
|
| + if (this._text.length < initialText.length) {
|
| + var extraText = initialText.substring$1(this._text.length);
|
| + this._parent.insertText(this._parent.getOffset(this) + this._text.length, extraText);
|
| + }
|
| +}
|
| +TextBlock.prototype.moveToOffset = function(offset) {
|
| + if (offset < 0 || offset >= this._text.length) {
|
| + return this._parent.moveToOffset(this._parent.getOffset(this) + offset);
|
| + }
|
| + return new CodePosition(this, offset);
|
| +}
|
| +TextBlock.prototype.positionFromPoint = function(x, y) {
|
| + return this.getPosition((y / 22/*null.LINE_HEIGHT*/).floor(), (x / 8/*null.CHAR_WIDTH*/).round());
|
| +}
|
| +TextBlock.prototype.getPosition = function(line, column) {
|
| + if (line < 0 || line >= this.get$lineCount()) {
|
| + return this._parent.getPosition(this._parent.getLine(this) + line, column);
|
| + }
|
| + var maxOffset;
|
| + if (line < this._lineStarts.length - 1) {
|
| + maxOffset = this._lineStarts.$index(line + 1) - 1;
|
| + }
|
| + else {
|
| + maxOffset = this._text.length - 1;
|
| + }
|
| + var offset = Math.min(this._lineStarts.$index(line) + column, maxOffset);
|
| + return new CodePosition(this, offset);
|
| +}
|
| +TextBlock.prototype.getLineColumn = function(offset) {
|
| + if (this._lineStarts == null) {
|
| + return new LineColumn(0, 0);
|
| + }
|
| + var previousStart = 0;
|
| + var line = 1;
|
| + for (; line < this._lineStarts.length; line++) {
|
| + var start = this._lineStarts.$index(line);
|
| + if (start > offset) {
|
| + break;
|
| + }
|
| + previousStart = start;
|
| + }
|
| + return new LineColumn(line - 1, offset - previousStart);
|
| +}
|
| +TextBlock.prototype.offsetToPoint = function(offset) {
|
| + var lc = this.getLineColumn(offset);
|
| + return new Point(lc.column * 8/*null.CHAR_WIDTH*/, this.get$top() + (lc.line * 22/*null.LINE_HEIGHT*/));
|
| +}
|
| +TextBlock.prototype._redraw$0 = TextBlock.prototype._redraw;
|
| +TextBlock.prototype.delete$2 = TextBlock.prototype.delete_;
|
| +TextBlock.prototype.getLineColumn$1 = TextBlock.prototype.getLineColumn;
|
| +TextBlock.prototype.getPosition$2 = TextBlock.prototype.getPosition;
|
| +TextBlock.prototype.insertText$2 = TextBlock.prototype.insertText;
|
| +TextBlock.prototype.moveToOffset$1 = TextBlock.prototype.moveToOffset;
|
| +TextBlock.prototype.offsetToPoint$1 = TextBlock.prototype.offsetToPoint;
|
| +TextBlock.prototype.positionFromPoint$2 = TextBlock.prototype.positionFromPoint;
|
| +TextBlock.prototype.tokenizeInto$2 = TextBlock.prototype.tokenizeInto;
|
| +// ********** Code for KeyBindings **************
|
| +function KeyBindings(node, bindings, handleText, handleUnknown) {
|
| + this.node = node;
|
| + this.bindings = bindings;
|
| + this.handleText = handleText;
|
| + this.handleUnknown = handleUnknown;
|
| + // Initializers done
|
| + this.node.addEventListener$3('textInput', this.get$onTextInput(), false);
|
| + this.node.addEventListener$3('keydown', this.get$onKeydown(), false);
|
| +}
|
| +KeyBindings._getModifiers = function(event) {
|
| + var ret = '';
|
| + if (event.ctrlKey) {
|
| + ret = ret + 'Control-';
|
| + }
|
| + if (event.altKey) {
|
| + ret = ret + 'Alt-';
|
| + }
|
| + if (event.metaKey) {
|
| + ret = ret + 'Meta-';
|
| + }
|
| + if (event.shiftKey) {
|
| + ret = ret + 'Shift-';
|
| + }
|
| + return ret;
|
| +}
|
| +KeyBindings._hexDigit = function(c) {
|
| + if (c >= 48 && c <= 57) {
|
| + return c - 48;
|
| + }
|
| + else if (c >= 97 && c <= 102) {
|
| + return c - 87;
|
| + }
|
| + else if (c >= 65 && c <= 70) {
|
| + return c - 55;
|
| + }
|
| + else {
|
| + return -1;
|
| + }
|
| +}
|
| +KeyBindings.parseHex = function(hex) {
|
| + var result = 0;
|
| + for (var i = 0;
|
| + i < hex.length; i++) {
|
| + var digit = KeyBindings._hexDigit(hex.charCodeAt(i));
|
| + result = (result << 4) + digit;
|
| + }
|
| + return result;
|
| +}
|
| +KeyBindings.translate = function(event) {
|
| + var ret = const$144/*KeyBindings._remap*/.$index(event.keyIdentifier);
|
| + if (ret == null) ret = event.keyIdentifier;
|
| + if ($eq(ret, '')) {
|
| + return null;
|
| + }
|
| + else if (ret.startsWith$1('U+')) {
|
| + if (event.ctrlKey || event.altKey || event.metaKey) {
|
| + return KeyBindings._getModifiers(event) + Strings.String$fromCharCodes$factory([KeyBindings.parseHex(ret.substring$2(2, ret.length))]);
|
| + }
|
| + else {
|
| + return null;
|
| + }
|
| + }
|
| + else {
|
| + return KeyBindings._getModifiers(event) + ret;
|
| + }
|
| +}
|
| +KeyBindings.prototype.onTextInput = function(event) {
|
| + var text = event.data;
|
| + var ret;
|
| + if (this.bindings.$index(text) != null) {
|
| + ret = this.bindings.$index(text)();
|
| + }
|
| + else {
|
| + ret = this.handleText.call$1(text);
|
| + }
|
| + $globals.shell._editor._redraw();
|
| + return ret;
|
| +}
|
| +KeyBindings.prototype.get$onTextInput = function() {
|
| + return KeyBindings.prototype.onTextInput.bind(this);
|
| +}
|
| +KeyBindings.prototype.onKeydown = function(event) {
|
| + var key = KeyBindings.translate(event);
|
| + if (key != null) {
|
| + if (this.bindings.$index(key) != null) {
|
| + this.bindings.$index(key)();
|
| + event.preventDefault();
|
| + }
|
| + else {
|
| + if (this.handleUnknown.call$1(key)) {
|
| + event.preventDefault();
|
| + }
|
| + else {
|
| + event.stopPropagation();
|
| + }
|
| + }
|
| + }
|
| + else {
|
| + event.stopPropagation();
|
| + }
|
| + $globals.shell._editor._redraw();
|
| + return false;
|
| +}
|
| +KeyBindings.prototype.get$onKeydown = function() {
|
| + return KeyBindings.prototype.onKeydown.bind(this);
|
| +}
|
| +// ********** Code for Classification **************
|
| +function Classification() {}
|
| +// ********** Code for top level **************
|
| +function main() {
|
| + var systemPath = getRootPath(get$window()) + '/..';
|
| + var userPath = getRootPath(get$window().parent);
|
| + if (get$window() !== get$window().parent) {
|
| + if (!get$document().implementation.hasFeature('dart', '')) {
|
| + initialize(systemPath, userPath, ['--suppress_warnings']);
|
| + get$window().addEventListener('DOMContentLoaded', $wrap_call$1((function (e) {
|
| + return frogify(get$window().parent);
|
| + })
|
| + ), false);
|
| + }
|
| + }
|
| + else {
|
| + $globals.shell = new Shell();
|
| + get$document().body.appendChild($globals.shell._node);
|
| + initialize(systemPath, userPath, const$146/*const []*/);
|
| + $globals.world.messageHandler = $globals.shell.get$handleMessage();
|
| + }
|
| +}
|
| +function getRootPath(window) {
|
| + var url = window.location.href;
|
| + var tail = url.lastIndexOf('/', url.length);
|
| + var dir = url.substring(0, tail);
|
| + return dir;
|
| +}
|
| +function inject(code, win, name) {
|
| + var doc = win.document;
|
| + var script = doc.createElement('script');
|
| + script.innerHTML = code + ('\n//@ sourceURL=' + name);
|
| + script.type = 'application/javascript';
|
| + doc.body.appendChild(script);
|
| +}
|
| +function frogify(win) {
|
| + var doc = win.document;
|
| + var n = doc.scripts.length;
|
| + for (var i = 0;
|
| + i < n; ++i) {
|
| + var script = doc.scripts.$index(i);
|
| + if ($eq(script.type, 'application/dart')) {
|
| + var src = script.src;
|
| + var input = null;
|
| + var name = null;
|
| + if ($eq(src, '')) {
|
| + input = script.innerHTML;
|
| + name = null;
|
| + }
|
| + else {
|
| + input = $globals.world.files.readAll(src);
|
| + name = ('' + src + '.js');
|
| + }
|
| + $globals.world.files.writeString('input.dart'/*null.DART_FILENAME*/, input);
|
| + $globals.world.reset();
|
| + var success = $globals.world.compile();
|
| + if (success) {
|
| + inject($globals.world.getGeneratedCode(), win, name);
|
| + }
|
| + else {
|
| + inject('window.alert("compilation failed");', win, name);
|
| + }
|
| + }
|
| + }
|
| +}
|
| +function initialize(systemPath, userPath, flags) {
|
| + var fs = new DomFileSystem(userPath);
|
| + var options0 = [null, null, ('--libdir=' + systemPath + '/lib')];
|
| + options0.addAll(flags);
|
| + options0.add('input.dart'/*null.DART_FILENAME*/);
|
| + parseOptions(systemPath, options0, fs);
|
| + initializeWorld(fs);
|
| +}
|
| +var shell;
|
| +function htmlEscape(text) {
|
| + return text.replaceAll('&', '&').replaceAll('>', '>').replaceAll('<', '<');
|
| +}
|
| +function _looksLikeType(name) {
|
| + return _looksLikePublicType(name) || _looksLikePrivateType(name);
|
| +}
|
| +function _looksLikePublicType(name) {
|
| + return name.length >= 2 && isUpper(name[0]) && isLower(name[1]);
|
| +}
|
| +function _looksLikePrivateType(name) {
|
| + return (name.length >= 3 && name[0] == '_' && isUpper(name[1]) && isLower(name[2]));
|
| +}
|
| +function isUpper(s) {
|
| + return s.toLowerCase() != s;
|
| +}
|
| +function isLower(s) {
|
| + return s.toUpperCase() != s;
|
| +}
|
| +function classify(token) {
|
| + switch (token.kind) {
|
| + case 65/*TokenKind.ERROR*/:
|
| +
|
| + return "e"/*Classification.ERROR*/;
|
| +
|
| + case 70/*TokenKind.IDENTIFIER*/:
|
| +
|
| + if (_looksLikeType(token.get$text()) || token.get$text() == 'num' || token.get$text() == 'bool' || token.get$text() == 'int' || token.get$text() == 'double') {
|
| + return "t"/*Classification.TYPE_IDENTIFIER*/;
|
| + }
|
| + return "i"/*Classification.IDENTIFIER*/;
|
| +
|
| + case 114/*TokenKind.VOID*/:
|
| +
|
| + return "t"/*Classification.TYPE_IDENTIFIER*/;
|
| +
|
| + case 109/*TokenKind.THIS*/:
|
| + case 107/*TokenKind.SUPER*/:
|
| +
|
| + return "r"/*Classification.SPECIAL_IDENTIFIER*/;
|
| +
|
| + case 58/*TokenKind.STRING*/:
|
| + case 59/*TokenKind.STRING_PART*/:
|
| + case 66/*TokenKind.INCOMPLETE_STRING*/:
|
| + case 68/*TokenKind.INCOMPLETE_MULTILINE_STRING_DQ*/:
|
| + case 69/*TokenKind.INCOMPLETE_MULTILINE_STRING_SQ*/:
|
| +
|
| + return "s"/*Classification.STRING*/;
|
| +
|
| + case 60/*TokenKind.INTEGER*/:
|
| + case 61/*TokenKind.HEX_INTEGER*/:
|
| + case 62/*TokenKind.DOUBLE*/:
|
| +
|
| + return "n"/*Classification.NUMBER*/;
|
| +
|
| + case 64/*TokenKind.COMMENT*/:
|
| + case 67/*TokenKind.INCOMPLETE_COMMENT*/:
|
| +
|
| + return "c"/*Classification.COMMENT*/;
|
| +
|
| + case 9/*TokenKind.ARROW*/:
|
| +
|
| + return "a"/*Classification.ARROW_OPERATOR*/;
|
| +
|
| + case 13/*TokenKind.HASHBANG*/:
|
| + case 2/*TokenKind.LPAREN*/:
|
| + case 3/*TokenKind.RPAREN*/:
|
| + case 4/*TokenKind.LBRACK*/:
|
| + case 5/*TokenKind.RBRACK*/:
|
| + case 6/*TokenKind.LBRACE*/:
|
| + case 7/*TokenKind.RBRACE*/:
|
| + case 8/*TokenKind.COLON*/:
|
| + case 10/*TokenKind.SEMICOLON*/:
|
| + case 11/*TokenKind.COMMA*/:
|
| + case 14/*TokenKind.DOT*/:
|
| + case 15/*TokenKind.ELLIPSIS*/:
|
| +
|
| + return "p"/*Classification.PUNCTUATION*/;
|
| +
|
| + case 16/*TokenKind.INCR*/:
|
| + case 17/*TokenKind.DECR*/:
|
| + case 18/*TokenKind.BIT_NOT*/:
|
| + case 19/*TokenKind.NOT*/:
|
| + case 20/*TokenKind.ASSIGN*/:
|
| + case 21/*TokenKind.ASSIGN_OR*/:
|
| + case 22/*TokenKind.ASSIGN_XOR*/:
|
| + case 23/*TokenKind.ASSIGN_AND*/:
|
| + case 24/*TokenKind.ASSIGN_SHL*/:
|
| + case 25/*TokenKind.ASSIGN_SAR*/:
|
| + case 26/*TokenKind.ASSIGN_SHR*/:
|
| + case 27/*TokenKind.ASSIGN_ADD*/:
|
| + case 28/*TokenKind.ASSIGN_SUB*/:
|
| + case 29/*TokenKind.ASSIGN_MUL*/:
|
| + case 30/*TokenKind.ASSIGN_DIV*/:
|
| + case 31/*TokenKind.ASSIGN_TRUNCDIV*/:
|
| + case 32/*TokenKind.ASSIGN_MOD*/:
|
| + case 33/*TokenKind.CONDITIONAL*/:
|
| + case 34/*TokenKind.OR*/:
|
| + case 35/*TokenKind.AND*/:
|
| + case 36/*TokenKind.BIT_OR*/:
|
| + case 37/*TokenKind.BIT_XOR*/:
|
| + case 38/*TokenKind.BIT_AND*/:
|
| + case 39/*TokenKind.SHL*/:
|
| + case 40/*TokenKind.SAR*/:
|
| + case 41/*TokenKind.SHR*/:
|
| + case 42/*TokenKind.ADD*/:
|
| + case 43/*TokenKind.SUB*/:
|
| + case 44/*TokenKind.MUL*/:
|
| + case 45/*TokenKind.DIV*/:
|
| + case 46/*TokenKind.TRUNCDIV*/:
|
| + case 47/*TokenKind.MOD*/:
|
| + case 48/*TokenKind.EQ*/:
|
| + case 49/*TokenKind.NE*/:
|
| + case 50/*TokenKind.EQ_STRICT*/:
|
| + case 51/*TokenKind.NE_STRICT*/:
|
| + case 52/*TokenKind.LT*/:
|
| + case 53/*TokenKind.GT*/:
|
| + case 54/*TokenKind.LTE*/:
|
| + case 55/*TokenKind.GTE*/:
|
| + case 56/*TokenKind.INDEX*/:
|
| + case 57/*TokenKind.SETINDEX*/:
|
| +
|
| + return "o"/*Classification.OPERATOR*/;
|
| +
|
| + case 12/*TokenKind.HASH*/:
|
| + case 71/*TokenKind.ABSTRACT*/:
|
| + case 72/*TokenKind.ASSERT*/:
|
| + case 73/*TokenKind.CLASS*/:
|
| + case 74/*TokenKind.EXTENDS*/:
|
| + case 75/*TokenKind.FACTORY*/:
|
| + case 76/*TokenKind.GET*/:
|
| + case 77/*TokenKind.IMPLEMENTS*/:
|
| + case 78/*TokenKind.IMPORT*/:
|
| + case 79/*TokenKind.INTERFACE*/:
|
| + case 80/*TokenKind.LIBRARY*/:
|
| + case 81/*TokenKind.NATIVE*/:
|
| + case 82/*TokenKind.NEGATE*/:
|
| + case 83/*TokenKind.OPERATOR*/:
|
| + case 84/*TokenKind.SET*/:
|
| + case 85/*TokenKind.SOURCE*/:
|
| + case 86/*TokenKind.STATIC*/:
|
| + case 87/*TokenKind.TYPEDEF*/:
|
| + case 89/*TokenKind.BREAK*/:
|
| + case 90/*TokenKind.CASE*/:
|
| + case 91/*TokenKind.CATCH*/:
|
| + case 92/*TokenKind.CONST*/:
|
| + case 93/*TokenKind.CONTINUE*/:
|
| + case 94/*TokenKind.DEFAULT*/:
|
| + case 95/*TokenKind.DO*/:
|
| + case 96/*TokenKind.ELSE*/:
|
| + case 97/*TokenKind.FALSE*/:
|
| + case 99/*TokenKind.FINALLY*/:
|
| + case 100/*TokenKind.FOR*/:
|
| + case 101/*TokenKind.IF*/:
|
| + case 102/*TokenKind.IN*/:
|
| + case 103/*TokenKind.IS*/:
|
| + case 104/*TokenKind.NEW*/:
|
| + case 105/*TokenKind.NULL*/:
|
| + case 106/*TokenKind.RETURN*/:
|
| + case 108/*TokenKind.SWITCH*/:
|
| + case 110/*TokenKind.THROW*/:
|
| + case 111/*TokenKind.TRUE*/:
|
| + case 112/*TokenKind.TRY*/:
|
| + case 115/*TokenKind.WHILE*/:
|
| + case 113/*TokenKind.VAR*/:
|
| + case 98/*TokenKind.FINAL*/:
|
| +
|
| + return "k"/*Classification.KEYWORD*/;
|
| +
|
| + case 63/*TokenKind.WHITESPACE*/:
|
| + case 1/*TokenKind.END_OF_FILE*/:
|
| +
|
| + return null/*Classification.NONE*/;
|
| +
|
| + default:
|
| +
|
| + return null/*Classification.NONE*/;
|
| +
|
| + }
|
| +}
|
| +// ********** Generic Type Inheritance **************
|
| +/** Implements extends for generic types. */
|
| +function $inheritsMembers(child, parent) {
|
| + child = child.prototype;
|
| + parent = parent.prototype;
|
| + Object.getOwnPropertyNames(parent).forEach(function(name) {
|
| + if (typeof(child[name]) == 'undefined') child[name] = parent[name];
|
| + });
|
| +}
|
| +$inheritsMembers(_DoubleLinkedQueueEntrySentinel_E, DoubleLinkedQueueEntry_E);
|
| +$inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQueueEntry_KeyValuePair_K$V);
|
| +// ********** Globals **************
|
| +function $static_init(){
|
| + $globals._GREEN_COLOR = '\u001b[32m';
|
| + $globals._MAGENTA_COLOR = '\u001b[35m';
|
| + $globals._NO_COLOR = '\u001b[0m';
|
| + $globals._RED_COLOR = '\u001b[31m';
|
| +}
|
| +var const$1 = new NoMoreElementsException()/*const NoMoreElementsException()*/;
|
| +var const$143 = new IllegalAccessException()/*const IllegalAccessException()*/;
|
| +var const$144 = _constMap(['U+001B', 'Esc', 'U+0008', 'Delete', 'U+0009', 'Tab', 'U+0020', 'Space', 'Shift', '', 'Control', '', 'Alt', '', 'Meta', ''])/*const {
|
| + 'U+001B':'Esc', 'U+0008':'Delete', 'U+0009':'Tab', 'U+0020':'Space',
|
| + 'Shift':'', 'Control':'', 'Alt':'', 'Meta':''
|
| + }*/;
|
| +var const$146 = ImmutableList.ImmutableList$from$factory([])/*const []*/;
|
| +var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/;
|
| +var const$5 = new EmptyQueueException()/*const EmptyQueueException()*/;
|
| +var $globals = {};
|
| +$static_init();
|
| +main();
|
|
|