// ********** Library dart:core ************** // ********** Natives dart:core ************** function $defProp(obj, prop, value) { Object.defineProperty(obj, prop, {value: value, enumerable: false, writable: true, configurable: true}); } 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; } $defProp(Object.prototype, '$index', function(i) { $throw(new NoSuchMethodException(this, "operator []", [i])); }); $defProp(Array.prototype, '$index', function(index) { var i = index | 0; if (i !== index) { throw new IllegalArgumentException('index is not int'); } else if (i = this.length) { throw new IndexOutOfRangeException(index); } return this[i]; }); $defProp(String.prototype, '$index', function(i) { return this[i]; }); function $$add$complex(x, y) { if (typeof(x) == 'number') { $throw(new IllegalArgumentException(y)); } else if (typeof(x) == 'string') { var str = (y == null) ? 'null' : y.toString(); if (typeof(str) != 'string') { throw new Error("calling toString() on right hand operand of operator " + "+ did not return a String"); } return x + str; } else if (typeof(x) == 'object') { return x.$add(y); } else { $throw(new NoSuchMethodException(x, "operator +", [y])); } } function $$add(x, y) { if (typeof(x) == 'number' && typeof(y) == 'number') return x + y; return $$add$complex(x, y); } function $$eq(x, y) { if (x == null) return y == null; return (typeof(x) != 'object') ? x === y : x.$eq(y); } // TODO(jimhug): Should this or should it not match equals? $defProp(Object.prototype, '$eq', function(other) { return this === other; }); // ********** Code for Object ************** $defProp(Object.prototype, "is$Collection", function() { return false; }); $defProp(Object.prototype, "is$List", function() { return false; }); $defProp(Object.prototype, "is$Map", function() { return false; }); // ********** Code for IndexOutOfRangeException ************** function IndexOutOfRangeException(_index) { this._index = _index; } IndexOutOfRangeException.prototype.is$IndexOutOfRangeException = function(){return true}; IndexOutOfRangeException.prototype.toString = function() { return ("IndexOutOfRangeException: " + this._index); } // ********** Code for NoSuchMethodException ************** function NoSuchMethodException(_receiver, _functionName, _arguments, _existingArgumentNames) { this._receiver = _receiver; this._functionName = _functionName; this._arguments = _arguments; this._existingArgumentNames = _existingArgumentNames; } NoSuchMethodException.prototype.is$NoSuchMethodException = function(){return true}; NoSuchMethodException.prototype.toString = function() { var sb = new StringBufferImpl(""); for (var i = (0); i (0)) { sb.add(", "); } sb.add(this._arguments.$index(i)); } if (null == this._existingArgumentNames) { return $$add($$add(("NoSuchMethodException : method not found: '" + this._functionName + "'n"), ("Receiver: " + this._receiver + "n")), ("Arguments: [" + sb + "]")); } else { var actualParameters = sb.toString(); sb = new StringBufferImpl(""); for (var i = (0); i (0)) { sb.add(", "); } sb.add(this._existingArgumentNames.$index(i)); } var formalParameters = sb.toString(); return $$add($$add($$add("NoSuchMethodException: incorrect number of arguments passed to ", ("method named '" + this._functionName + "'nReceiver: " + this._receiver + "n")), ("Tried calling: " + this._functionName + "(" + actualParameters + ")n")), ("Found: " + this._functionName + "(" + formalParameters + ")")); } } // ********** Code for ClosureArgumentMismatchException ************** function ClosureArgumentMismatchException() { } ClosureArgumentMismatchException.prototype.toString = function() { return "Closure argument mismatch"; } // ********** Code for IllegalArgumentException ************** function IllegalArgumentException(arg) { this._arg = arg; } IllegalArgumentException.prototype.is$IllegalArgumentException = function(){return true}; IllegalArgumentException.prototype.toString = function() { return ("Illegal argument(s): " + this._arg); } // ********** Code for NoMoreElementsException ************** function NoMoreElementsException() { } NoMoreElementsException.prototype.toString = function() { return "NoMoreElementsException"; } // ********** Code for dart_core_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 top level ************** function print(obj) { return _print(obj); } function _print(obj) { if (typeof console == 'object') { if (obj) obj = obj.toString(); console.log(obj); } else if (typeof write === 'function') { write(obj); write('n'); } } // ********** Library dart:coreimpl ************** // ********** Code for ListFactory ************** ListFactory = Array; $defProp(ListFactory.prototype, "is$List", function(){return true}); $defProp(ListFactory.prototype, "is$Collection", function(){return true}); $defProp(ListFactory.prototype, "get$length", function() { return this.length; }); $defProp(ListFactory.prototype, "set$length", function(value) { return this.length = value; }); $defProp(ListFactory.prototype, "add", function(value) { this.push(value); }); $defProp(ListFactory.prototype, "clear", function() { this.set$length((0)); }); $defProp(ListFactory.prototype, "removeLast", function() { return this.pop(); }); $defProp(ListFactory.prototype, "iterator", function() { return new ListIterator(this); }); $defProp(ListFactory.prototype, "toString", function() { return Collections.collectionToString(this); }); // ********** Code for ListIterator ************** function ListIterator(array) { this._array = array; this._pos = (0); } ListIterator.prototype.hasNext = function() { return this._array.get$length() > this._pos; } ListIterator.prototype.next = function() { if (!this.hasNext()) { $throw(const$0000); } return this._array.$index(this._pos++); } // ********** Code for NumImplementation ************** NumImplementation = Number; // ********** Code for Collections ************** function Collections() {} Collections.collectionToString = function(c) { var result = new StringBufferImpl(""); Collections._emitCollection(c, result, new Array()); return result.toString(); } Collections._emitCollection = function(c, result, visiting) { visiting.add(c); var isList = !!(c && c.is$List()); result.add(isList ? "[" : "{"); var first = true; for (var $$i = c.iterator(); $$i.hasNext(); ) { var e = $$i.next(); if (!first) { result.add(", "); } first = false; Collections._emitObject(e, result, visiting); } result.add(isList ? "]" : "}"); visiting.removeLast(); } Collections._emitObject = function(o, result, visiting) { if (!!(o && o.is$Collection())) { if (Collections._containsRef(visiting, o)) { result.add(!!(o && o.is$List()) ? "[...]" : "{...}"); } else { Collections._emitCollection(o, result, visiting); } } else if (!!(o && o.is$Map())) { if (Collections._containsRef(visiting, o)) { result.add("{...}"); } else { Maps._emitMap(o, result, visiting); } } else { result.add($$eq(o) ? "null" : o); } } Collections._containsRef = function(c, ref) { for (var $$i = c.iterator(); $$i.hasNext(); ) { var e = $$i.next(); if ((null == e ? null == (ref) : e === ref)) return true; } return false; } // ********** Code for HashMapImplementation ************** function HashMapImplementation() {} HashMapImplementation.prototype.is$Map = function(){return true}; HashMapImplementation.prototype.forEach = function(f) { var length = this._keys.get$length(); for (var i = (0); i this.length || argsNamed > paramsNamed) { return function() { $throw(new _ArgumentMismatchException( 'Wrong number of arguments to function. Expected ' + paramsBare + ' positional arguments and at most ' + paramsNamed + ' named arguments, but got ' + argsBare + ' positional arguments and ' + argsNamed + ' named arguments.')); }; } // 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 = paramsNamed) { return function() { $throw(new _ArgumentMismatchException( 'Named argument "' + name + '" was not expected by function.' + ' Did you forget to mark the function parameter [optional]?')); }; } 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 and all supplied. 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); } // ********** Code for top level ************** // ********** Library hello ************** // ********** Code for top level ************** function main() { print("Hello, Dart World!"); } // ********** Globals ************** function $static_init(){ } var const$0000 = Object.create(NoMoreElementsException.prototype, {}); var const$0001 = Object.create(_DeletedKeySentinel.prototype, {}); $static_init(); main();