OLD | NEW |
1 #!/usr/bin/env node | 1 #!/usr/bin/env node |
2 // ********** Library dart:core ************** | 2 // ********** Library dart:core ************** |
3 // ********** Natives dart:core ************** | 3 // ********** Natives dart:core ************** |
4 function $throw(e) { | 4 function $throw(e) { |
5 // If e is not a value, we can use V8's captureStackTrace utility method. | 5 // If e is not a value, we can use V8's captureStackTrace utility method. |
6 // TODO(jmesserly): capture the stack trace on other JS engines. | 6 // TODO(jmesserly): capture the stack trace on other JS engines. |
7 if (e && (typeof e == 'object') && Error.captureStackTrace) { | 7 if (e && (typeof e == 'object') && Error.captureStackTrace) { |
8 // TODO(jmesserly): this will clobber the e.stack property | 8 // TODO(jmesserly): this will clobber the e.stack property |
9 Error.captureStackTrace(e, $throw); | 9 Error.captureStackTrace(e, $throw); |
10 } | 10 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 }; | 93 }; |
94 Object.prototype._set$4 = function($0, $1, $2, $3) { | 94 Object.prototype._set$4 = function($0, $1, $2, $3) { |
95 return this.noSuchMethod("_set", [$0, $1, $2, $3]); | 95 return this.noSuchMethod("_set", [$0, $1, $2, $3]); |
96 }; | 96 }; |
97 Object.prototype._set$4$isDynamic = function($0, $1, $2, $3, isDynamic) { | 97 Object.prototype._set$4$isDynamic = function($0, $1, $2, $3, isDynamic) { |
98 return this.noSuchMethod("_set", [$0, $1, $2, $3, isDynamic]); | 98 return this.noSuchMethod("_set", [$0, $1, $2, $3, isDynamic]); |
99 }; | 99 }; |
100 Object.prototype._set$5 = function($0, $1, $2, $3, $4) { | 100 Object.prototype._set$5 = function($0, $1, $2, $3, $4) { |
101 return this.noSuchMethod("_set", [$0, $1, $2, $3, $4]); | 101 return this.noSuchMethod("_set", [$0, $1, $2, $3, $4]); |
102 }; | 102 }; |
103 Object.prototype._wrapDomCallback$2 = function($0, $1) { | |
104 return this.noSuchMethod("_wrapDomCallback", [$0, $1]); | |
105 }; | |
106 Object.prototype.add$1 = function($0) { | 103 Object.prototype.add$1 = function($0) { |
107 return this.noSuchMethod("add", [$0]); | 104 return this.noSuchMethod("add", [$0]); |
108 }; | 105 }; |
109 Object.prototype.addAll$1 = function($0) { | 106 Object.prototype.addAll$1 = function($0) { |
110 return this.noSuchMethod("addAll", [$0]); | 107 return this.noSuchMethod("addAll", [$0]); |
111 }; | 108 }; |
112 Object.prototype.addDirectSubtype$1 = function($0) { | 109 Object.prototype.addDirectSubtype$1 = function($0) { |
113 return this.noSuchMethod("addDirectSubtype", [$0]); | 110 return this.noSuchMethod("addDirectSubtype", [$0]); |
114 }; | 111 }; |
115 Object.prototype.addMethod$2 = function($0, $1) { | 112 Object.prototype.addMethod$2 = function($0, $1) { |
(...skipping 16 matching lines...) Expand all Loading... |
132 }; | 129 }; |
133 Object.prototype.computeValue$0 = function() { | 130 Object.prototype.computeValue$0 = function() { |
134 return this.noSuchMethod("computeValue", []); | 131 return this.noSuchMethod("computeValue", []); |
135 }; | 132 }; |
136 Object.prototype.contains$1 = function($0) { | 133 Object.prototype.contains$1 = function($0) { |
137 return this.noSuchMethod("contains", [$0]); | 134 return this.noSuchMethod("contains", [$0]); |
138 }; | 135 }; |
139 Object.prototype.containsKey$1 = function($0) { | 136 Object.prototype.containsKey$1 = function($0) { |
140 return this.noSuchMethod("containsKey", [$0]); | 137 return this.noSuchMethod("containsKey", [$0]); |
141 }; | 138 }; |
| 139 Object.prototype.convertTo$2 = function($0, $1) { |
| 140 return this.noSuchMethod("convertTo", [$0, $1]); |
| 141 }; |
142 Object.prototype.convertTo$3 = function($0, $1, $2) { | 142 Object.prototype.convertTo$3 = function($0, $1, $2) { |
143 return this.noSuchMethod("convertTo", [$0, $1, $2]); | 143 return this.noSuchMethod("convertTo", [$0, $1, $2]); |
144 }; | 144 }; |
145 Object.prototype.convertTo$4 = function($0, $1, $2, $3) { | |
146 return this.noSuchMethod("convertTo", [$0, $1, $2, $3]); | |
147 }; | |
148 Object.prototype.copyWithNewType$2 = function($0, $1) { | 145 Object.prototype.copyWithNewType$2 = function($0, $1) { |
149 return this.noSuchMethod("copyWithNewType", [$0, $1]); | 146 return this.noSuchMethod("copyWithNewType", [$0, $1]); |
150 }; | 147 }; |
151 Object.prototype.end$0 = function() { | 148 Object.prototype.end$0 = function() { |
152 return this.noSuchMethod("end", []); | 149 return this.noSuchMethod("end", []); |
153 }; | 150 }; |
154 Object.prototype.endsWith$1 = function($0) { | 151 Object.prototype.endsWith$1 = function($0) { |
155 return this.noSuchMethod("endsWith", [$0]); | 152 return this.noSuchMethod("endsWith", [$0]); |
156 }; | 153 }; |
157 Object.prototype.ensureSubtypeOf$3 = function($0, $1, $2) { | 154 Object.prototype.ensureSubtypeOf$3 = function($0, $1, $2) { |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 function tmp() {}; | 634 function tmp() {}; |
638 tmp.prototype = parent.prototype; | 635 tmp.prototype = parent.prototype; |
639 child.prototype = new tmp(); | 636 child.prototype = new tmp(); |
640 child.prototype.constructor = child; | 637 child.prototype.constructor = child; |
641 } | 638 } |
642 } | 639 } |
643 $inherits(ImmutableList, ListFactory_E); | 640 $inherits(ImmutableList, ListFactory_E); |
644 function ImmutableList(length) { | 641 function ImmutableList(length) { |
645 this._length = length; | 642 this._length = length; |
646 // Initializers done | 643 // Initializers done |
647 ListFactory_E.call(this, length); | 644 Array.call(this, length); |
648 } | 645 } |
649 ImmutableList.ImmutableList$from$factory = function(other) { | 646 ImmutableList.ImmutableList$from$factory = function(other) { |
650 var list = new ImmutableList(other.get$length()); | 647 var list = new ImmutableList(other.get$length()); |
651 for (var i = 0; | 648 for (var i = 0; |
652 i < other.get$length(); i++) { | 649 i < other.get$length(); i++) { |
653 list._setindex(i, other.$index(i)); | 650 list._setindex(i, other.$index(i)); |
654 } | 651 } |
655 return list; | 652 return list; |
656 } | 653 } |
657 ImmutableList.prototype.get$length = function() { | 654 ImmutableList.prototype.get$length = function() { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 this._numberOfEntries++; | 849 this._numberOfEntries++; |
853 } | 850 } |
854 this._keys.$setindex(index, key); | 851 this._keys.$setindex(index, key); |
855 this._values.$setindex(index, value); | 852 this._values.$setindex(index, value); |
856 } | 853 } |
857 HashMapImplementation.prototype.$index = function(key) { | 854 HashMapImplementation.prototype.$index = function(key) { |
858 var index = this._probeForLookup(key); | 855 var index = this._probeForLookup(key); |
859 if (index < 0) return null; | 856 if (index < 0) return null; |
860 return this._values.$index(index); | 857 return this._values.$index(index); |
861 } | 858 } |
| 859 HashMapImplementation.prototype.putIfAbsent = function(key, ifAbsent) { |
| 860 var index = this._probeForLookup(key); |
| 861 if (index >= 0) return this._values.$index(index); |
| 862 var value = ifAbsent(); |
| 863 this.$setindex(key, value); |
| 864 return value; |
| 865 } |
862 HashMapImplementation.prototype.remove = function(key) { | 866 HashMapImplementation.prototype.remove = function(key) { |
863 var index = this._probeForLookup(key); | 867 var index = this._probeForLookup(key); |
864 if (index >= 0) { | 868 if (index >= 0) { |
865 this._numberOfEntries--; | 869 this._numberOfEntries--; |
866 var value = this._values.$index(index); | 870 var value = this._values.$index(index); |
867 this._values.$setindex(index); | 871 this._values.$setindex(index); |
868 this._keys.$setindex(index, const$2/*HashMapImplementation._DELETED_KEY*/); | 872 this._keys.$setindex(index, const$2/*HashMapImplementation._DELETED_KEY*/); |
869 this._numberOfDeleted++; | 873 this._numberOfDeleted++; |
870 return value; | 874 return value; |
871 } | 875 } |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 else { | 1246 else { |
1243 this._list.addLast(new KeyValuePair_K$V(key, value)); | 1247 this._list.addLast(new KeyValuePair_K$V(key, value)); |
1244 this._map.$setindex(key, this._list.lastEntry()); | 1248 this._map.$setindex(key, this._list.lastEntry()); |
1245 } | 1249 } |
1246 } | 1250 } |
1247 LinkedHashMapImplementation.prototype.$index = function(key) { | 1251 LinkedHashMapImplementation.prototype.$index = function(key) { |
1248 var entry = this._map.$index(key); | 1252 var entry = this._map.$index(key); |
1249 if (entry == null) return null; | 1253 if (entry == null) return null; |
1250 return entry.get$element().get$value(); | 1254 return entry.get$element().get$value(); |
1251 } | 1255 } |
| 1256 LinkedHashMapImplementation.prototype.putIfAbsent = function(key, ifAbsent) { |
| 1257 var value = this.$index(key); |
| 1258 if ((this.$index(key) == null) && !(this.containsKey(key))) { |
| 1259 value = ifAbsent(); |
| 1260 this.$setindex(key, value); |
| 1261 } |
| 1262 return value; |
| 1263 } |
1252 LinkedHashMapImplementation.prototype.getKeys = function() { | 1264 LinkedHashMapImplementation.prototype.getKeys = function() { |
1253 var list = new Array(this.get$length()); | 1265 var list = new Array(this.get$length()); |
1254 var index = 0; | 1266 var index = 0; |
1255 this._list.forEach(function _(entry) { | 1267 this._list.forEach(function _(entry) { |
1256 list.$setindex(index++, entry.key); | 1268 list.$setindex(index++, entry.key); |
1257 } | 1269 } |
1258 ); | 1270 ); |
1259 return list; | 1271 return list; |
1260 } | 1272 } |
1261 LinkedHashMapImplementation.prototype.getValues = function() { | 1273 LinkedHashMapImplementation.prototype.getValues = function() { |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2208 } | 2220 } |
2209 if (this.useWrap1) { | 2221 if (this.useWrap1) { |
2210 w.writeln("function $wrap_call$1(fn) { return fn; }"/*null._EMPTY_WRAP_CAL
L1_FUNCTION*/); | 2222 w.writeln("function $wrap_call$1(fn) { return fn; }"/*null._EMPTY_WRAP_CAL
L1_FUNCTION*/); |
2211 } | 2223 } |
2212 } | 2224 } |
2213 var $$list = orderValuesByKeys(this._usedOperators); | 2225 var $$list = orderValuesByKeys(this._usedOperators); |
2214 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 2226 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { |
2215 var opImpl = $$list.$index($$i); | 2227 var opImpl = $$list.$index($$i); |
2216 w.writeln(opImpl); | 2228 w.writeln(opImpl); |
2217 } | 2229 } |
| 2230 if ($globals.world.dom != null) { |
| 2231 this.ensureTypeNameOf(); |
| 2232 w.writeln('Object.prototype.get\$typeName = Object.prototype.\$typeNameOf;'
/*'Object.prototype.get\$typeName = ' + |
| 2233 ' Object.prototype.\$typeNameOf;'*/); |
| 2234 } |
2218 } | 2235 } |
2219 CoreJs.prototype.generate$1 = CoreJs.prototype.generate; | 2236 CoreJs.prototype.generate$1 = CoreJs.prototype.generate; |
2220 // ********** Code for Element ************** | 2237 // ********** Code for Element ************** |
2221 function Element(name, _enclosingElement) { | 2238 function Element(name, _enclosingElement) { |
2222 this.name = name; | 2239 this.name = name; |
2223 this._enclosingElement = _enclosingElement; | 2240 this._enclosingElement = _enclosingElement; |
2224 // Initializers done | 2241 // Initializers done |
2225 this._jsname = $globals.world.toJsIdentifier(this.name); | 2242 this._jsname = $globals.world.toJsIdentifier(this.name); |
2226 } | 2243 } |
2227 Element.prototype.get$name = function() { return this.name; }; | 2244 Element.prototype.get$name = function() { return this.name; }; |
2228 Element.prototype.set$name = function(value) { return this.name = value; }; | 2245 Element.prototype.set$name = function(value) { return this.name = value; }; |
2229 Element.prototype.get$_jsname = function() { return this._jsname; }; | 2246 Element.prototype.get$_jsname = function() { return this._jsname; }; |
2230 Element.prototype.set$_jsname = function(value) { return this._jsname = value; }
; | 2247 Element.prototype.set$_jsname = function(value) { return this._jsname = value; }
; |
2231 Element.prototype.get$library = function() { | 2248 Element.prototype.get$library = function() { |
2232 return null; | 2249 return null; |
2233 } | 2250 } |
2234 Element.prototype.get$span = function() { | 2251 Element.prototype.get$span = function() { |
2235 return null; | 2252 return null; |
2236 } | 2253 } |
2237 Element.prototype.get$isNative = function() { | 2254 Element.prototype.get$isNative = function() { |
2238 return false; | 2255 return false; |
2239 } | 2256 } |
2240 Element.prototype.hashCode = function() { | 2257 Element.prototype.hashCode = function() { |
2241 return this.name.hashCode(); | 2258 return this.name.hashCode(); |
2242 } | 2259 } |
2243 Element.prototype.get$jsname = function() { | 2260 Element.prototype.get$jsname = function() { |
2244 return this._jsname; | 2261 return this._jsname; |
2245 } | 2262 } |
2246 Element.prototype.get$nativeName = function() { | 2263 Element.prototype.get$nativeName = function() { |
2247 return null; | 2264 return this._jsname; |
2248 } | 2265 } |
2249 Element.prototype.get$avoidNativeName = function() { | 2266 Element.prototype.get$avoidNativeName = function() { |
2250 return false; | 2267 return false; |
2251 } | 2268 } |
2252 Element.prototype.get$jsnamePriority = function() { | 2269 Element.prototype.get$jsnamePriority = function() { |
2253 return this.get$isNative() ? 2 : (this.get$library().get$isCore() ? 1 : 0); | 2270 return this.get$isNative() ? 2 : (this.get$library().get$isCore() ? 1 : 0); |
2254 } | 2271 } |
2255 Element.prototype.resolve = function() { | 2272 Element.prototype.resolve = function() { |
2256 | 2273 |
2257 } | 2274 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 this.globals = new HashMapImplementation(); | 2348 this.globals = new HashMapImplementation(); |
2332 this.corejs = new CoreJs(); | 2349 this.corejs = new CoreJs(); |
2333 // Initializers done | 2350 // Initializers done |
2334 } | 2351 } |
2335 WorldGenerator.prototype.run = function() { | 2352 WorldGenerator.prototype.run = function() { |
2336 var metaGen = new MethodGenerator(this.main, null); | 2353 var metaGen = new MethodGenerator(this.main, null); |
2337 var mainTarget = new Value.type$ctor(this.main.declaringType, this.main.get$sp
an()); | 2354 var mainTarget = new Value.type$ctor(this.main.declaringType, this.main.get$sp
an()); |
2338 var mainCall = this.main.invoke(metaGen, null, mainTarget, Arguments.get$EMPTY
(), false); | 2355 var mainCall = this.main.invoke(metaGen, null, mainTarget, Arguments.get$EMPTY
(), false); |
2339 this.main.declaringType.markUsed(); | 2356 this.main.declaringType.markUsed(); |
2340 if ($globals.options.compileAll) { | 2357 if ($globals.options.compileAll) { |
2341 this.markLibrariesUsed([$globals.world.get$coreimpl(), $globals.world.coreli
b, this.main.declaringType.get$library()]); | 2358 this.markLibrariesUsed([$globals.world.coreimpl, $globals.world.corelib, thi
s.main.declaringType.get$library()]); |
2342 } | 2359 } |
2343 if ($globals.world.corelib.types.$index('Isolate').get$isUsed() || $globals.wo
rld.get$coreimpl().types.$index('ReceivePortImpl').get$isUsed()) { | 2360 if ($globals.world.corelib.types.$index('Isolate').get$isUsed() || $globals.wo
rld.coreimpl.types.$index('ReceivePortImpl').get$isUsed()) { |
2344 if (this.corejs.useWrap0 || this.corejs.useWrap1) { | 2361 if (this.corejs.useWrap0 || this.corejs.useWrap1) { |
2345 this.genMethod($globals.world.get$coreimpl().types.$index('IsolateContext'
).getMember$1('eval')); | 2362 this.genMethod($globals.world.coreimpl.types.$index('IsolateContext').getM
ember$1('eval')); |
2346 this.genMethod($globals.world.get$coreimpl().types.$index('EventLoop').get
Member$1('run')); | 2363 this.genMethod($globals.world.coreimpl.types.$index('EventLoop').getMember
$1('run')); |
2347 } | 2364 } |
2348 this.corejs.useIsolates = true; | 2365 this.corejs.useIsolates = true; |
2349 var isolateMain = $globals.world.get$coreimpl().topType.resolveMember('start
RootIsolate').members.$index(0); | 2366 var isolateMain = $globals.world.coreimpl.topType.resolveMember('startRootIs
olate').members.$index(0); |
2350 var isolateMainTarget = new Value.type$ctor($globals.world.get$coreimpl().to
pType, this.main.get$span()); | 2367 var isolateMainTarget = new Value.type$ctor($globals.world.coreimpl.topType,
this.main.get$span()); |
2351 mainCall = isolateMain.invoke(metaGen, null, isolateMainTarget, new Argument
s(null, [this.main._get(metaGen, this.main.definition, null, false)]), false); | 2368 mainCall = isolateMain.invoke(metaGen, null, isolateMainTarget, new Argument
s(null, [this.main._get(metaGen, this.main.definition, null, false)]), false); |
2352 } | 2369 } |
2353 this.writeTypes($globals.world.get$coreimpl()); | 2370 this.writeTypes($globals.world.coreimpl); |
2354 this.writeTypes($globals.world.corelib); | 2371 this.writeTypes($globals.world.corelib); |
2355 this.writeTypes(this.main.declaringType.get$library()); | 2372 this.writeTypes(this.main.declaringType.get$library()); |
2356 if (this._mixins != null) this.writer.write(this._mixins.get$text()); | 2373 if (this._mixins != null) this.writer.write(this._mixins.get$text()); |
2357 this.writeDynamicDispatchMetadata(); | 2374 this.writeDynamicDispatchMetadata(); |
2358 this.writeGlobals(); | 2375 this.writeGlobals(); |
2359 this.writer.writeln(('' + mainCall.get$code() + ';')); | 2376 this.writer.writeln(('' + mainCall.get$code() + ';')); |
2360 } | 2377 } |
2361 WorldGenerator.prototype.markLibrariesUsed = function(libs) { | 2378 WorldGenerator.prototype.markLibrariesUsed = function(libs) { |
2362 return this.getAllTypes(libs).forEach(this.get$markTypeUsed()); | 2379 return this.getAllTypes(libs).forEach(this.get$markTypeUsed()); |
2363 } | 2380 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2445 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 2462 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { |
2446 var file = $$list.$index($$i); | 2463 var file = $$list.$index($$i); |
2447 var filename = basename(file.get$filename()); | 2464 var filename = basename(file.get$filename()); |
2448 this.writer.comment(('// ********** Natives ' + filename + ' **************
')); | 2465 this.writer.comment(('// ********** Natives ' + filename + ' **************
')); |
2449 this.writer.writeln(file.get$text()); | 2466 this.writer.writeln(file.get$text()); |
2450 } | 2467 } |
2451 lib.topType.markUsed(); | 2468 lib.topType.markUsed(); |
2452 var $$list = this._orderValues(lib.types); | 2469 var $$list = this._orderValues(lib.types); |
2453 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 2470 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { |
2454 var type = $$list.$index($$i); | 2471 var type = $$list.$index($$i); |
2455 if ((type.get$isUsed() || $eq(type.get$library(), $globals.world.get$dom())
|| type.get$isHiddenNativeType()) && type.get$isClass()) { | 2472 if ((type.get$isUsed() || type.get$library().get$isDom() || type.get$isHidde
nNativeType()) && type.get$isClass()) { |
2456 this.writeType(type); | 2473 this.writeType(type); |
2457 if (type.get$isGeneric()) { | 2474 if (type.get$isGeneric()) { |
2458 var $list0 = this._orderValues(type.get$_concreteTypes()); | 2475 var $list0 = this._orderValues(type.get$_concreteTypes()); |
2459 for (var $i0 = 0;$i0 < $list0.get$length(); $i0++) { | 2476 for (var $i0 = 0;$i0 < $list0.get$length(); $i0++) { |
2460 var ct = $list0.$index($i0); | 2477 var ct = $list0.$index($i0); |
2461 this.writeType(ct); | 2478 this.writeType(ct); |
2462 } | 2479 } |
2463 } | 2480 } |
2464 } | 2481 } |
2465 else if (type.get$isFunction() && type.get$varStubs().get$length() > 0) { | 2482 else if (type.get$isFunction() && type.get$varStubs().get$length() > 0) { |
(...skipping 27 matching lines...) Expand all Loading... |
2493 var isSubtype = onType.isSubtypeOf(checkType); | 2510 var isSubtype = onType.isSubtypeOf(checkType); |
2494 if (checkType.isTested) { | 2511 if (checkType.isTested) { |
2495 this.writer.writeln(this._prototypeOf(onType, ('is\$' + checkType.get$jsname
())) + (' = function(){return ' + isSubtype + '};')); | 2512 this.writer.writeln(this._prototypeOf(onType, ('is\$' + checkType.get$jsname
())) + (' = function(){return ' + isSubtype + '};')); |
2496 } | 2513 } |
2497 if (checkType.isChecked) { | 2514 if (checkType.isChecked) { |
2498 var body = 'return this'; | 2515 var body = 'return this'; |
2499 var checkName = ('assert\$' + checkType.get$jsname()); | 2516 var checkName = ('assert\$' + checkType.get$jsname()); |
2500 if (!isSubtype) { | 2517 if (!isSubtype) { |
2501 body = $globals.world.objectType.varStubs.$index(checkName).get$body(); | 2518 body = $globals.world.objectType.varStubs.$index(checkName).get$body(); |
2502 } | 2519 } |
2503 else if (onType.name == 'StringImplementation' || onType.name == 'NumImpleme
ntation') { | 2520 else if ($eq(onType, $globals.world.stringImplType) || $eq(onType, $globals.
world.numImplType)) { |
2504 body = ('return ' + onType.get$nativeType().name + '(this)'); | 2521 body = ('return ' + onType.get$nativeType().name + '(this)'); |
2505 } | 2522 } |
2506 this.writer.writeln(this._prototypeOf(onType, checkName) + (' = function(){'
+ body + '};')); | 2523 this.writer.writeln(this._prototypeOf(onType, checkName) + (' = function(){'
+ body + '};')); |
2507 } | 2524 } |
2508 } | 2525 } |
2509 WorldGenerator.prototype.writeType = function(type) { | 2526 WorldGenerator.prototype.writeType = function(type) { |
2510 if (type.isWritten) return; | 2527 if (type.isWritten) return; |
2511 type.isWritten = true; | 2528 type.isWritten = true; |
2512 if (type.get$parent() != null && !type.get$isNative()) { | 2529 if (type.get$parent() != null && !type.get$isNative()) { |
2513 this.writeType(type.get$parent()); | 2530 this.writeType(type.get$parent()); |
2514 } | 2531 } |
2515 if (type.name != null && (type instanceof ConcreteType) && $eq(type.get$librar
y(), $globals.world.get$coreimpl()) && type.name.startsWith('ListFactory')) { | 2532 if (type.name != null && (type instanceof ConcreteType) && $eq(type.get$librar
y(), $globals.world.coreimpl) && type.name.startsWith('ListFactory')) { |
2516 this.writer.writeln(('' + type.get$jsname() + ' = ' + type.get$genericType()
.get$jsname() + ';')); | 2533 this.writer.writeln(('' + type.get$jsname() + ' = ' + type.get$genericType()
.get$jsname() + ';')); |
2517 return; | 2534 return; |
2518 } | 2535 } |
2519 var typeName = type.get$jsname() != null ? type.get$jsname() : 'top level'; | 2536 var typeName = type.get$jsname() != null ? type.get$jsname() : 'top level'; |
2520 this.writer.comment(('// ********** Code for ' + typeName + ' **************')
); | 2537 this.writer.comment(('// ********** Code for ' + typeName + ' **************')
); |
2521 if (type.get$isNative() && !type.get$isTop()) { | 2538 if (type.get$isNative() && !type.get$isTop()) { |
2522 var nativeName = type.get$definition().get$nativeType().get$name(); | 2539 var nativeName = type.get$definition().get$nativeType().get$name(); |
2523 if ($eq(nativeName, '')) { | 2540 if ($eq(nativeName, '')) { |
2524 this.writer.writeln(('function ' + type.get$jsname() + '() {}')); | 2541 this.writer.writeln(('function ' + type.get$jsname() + '() {}')); |
2525 } | 2542 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2738 } | 2755 } |
2739 } | 2756 } |
2740 WorldGenerator.prototype._usedDynamicDispatchOnType = function(type) { | 2757 WorldGenerator.prototype._usedDynamicDispatchOnType = function(type) { |
2741 if (this.typesWithDynamicDispatch == null) this.typesWithDynamicDispatch = new
HashSetImplementation(); | 2758 if (this.typesWithDynamicDispatch == null) this.typesWithDynamicDispatch = new
HashSetImplementation(); |
2742 this.typesWithDynamicDispatch.add(type); | 2759 this.typesWithDynamicDispatch.add(type); |
2743 } | 2760 } |
2744 WorldGenerator.prototype.writeDynamicDispatchMetadata = function() { | 2761 WorldGenerator.prototype.writeDynamicDispatchMetadata = function() { |
2745 var $this = this; // closure support | 2762 var $this = this; // closure support |
2746 if (this.typesWithDynamicDispatch == null) return; | 2763 if (this.typesWithDynamicDispatch == null) return; |
2747 this.writer.comment(('// ' + this.typesWithDynamicDispatch.get$length() + ' dy
namic types.')); | 2764 this.writer.comment(('// ' + this.typesWithDynamicDispatch.get$length() + ' dy
namic types.')); |
2748 function typeTag(type) { | |
2749 return type.get$definition().get$nativeType().get$name(); | |
2750 } | |
2751 var seen = new HashSetImplementation(); | 2765 var seen = new HashSetImplementation(); |
2752 var types = []; | 2766 var types = []; |
2753 function visit(type) { | 2767 function visit(type) { |
2754 if (seen.contains$1(type)) return; | 2768 if (seen.contains$1(type)) return; |
2755 seen.add$1(type); | 2769 seen.add$1(type); |
2756 var $$list = $this._orderCollectionValues(type.get$directSubtypes()); | 2770 var $$list = $this._orderCollectionValues(type.get$directSubtypes()); |
2757 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 2771 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { |
2758 var subtype = $$list.$index($$i); | 2772 var subtype = $$list.$index($$i); |
2759 visit(subtype); | 2773 visit(subtype); |
2760 } | 2774 } |
(...skipping 11 matching lines...) Expand all Loading... |
2772 this.writer.comment(('// ' + types.get$length() + ' types')); | 2786 this.writer.comment(('// ' + types.get$length() + ' types')); |
2773 this.writer.comment(('// ' + types.filter$1((function (t) { | 2787 this.writer.comment(('// ' + types.filter$1((function (t) { |
2774 return !t.get$directSubtypes().isEmpty$0(); | 2788 return !t.get$directSubtypes().isEmpty$0(); |
2775 }) | 2789 }) |
2776 ).get$length() + ' !leaf')); | 2790 ).get$length() + ' !leaf')); |
2777 var varNames = []; | 2791 var varNames = []; |
2778 var varDefns = new HashMapImplementation(); | 2792 var varDefns = new HashMapImplementation(); |
2779 var tagDefns = new HashMapImplementation(); | 2793 var tagDefns = new HashMapImplementation(); |
2780 function makeExpression(type) { | 2794 function makeExpression(type) { |
2781 var expressions = []; | 2795 var expressions = []; |
2782 var subtags = [typeTag(type)]; | 2796 var subtags = [type.get$nativeName()]; |
2783 function walk(type) { | 2797 function walk(type) { |
2784 var $$list = $this._orderCollectionValues(type.get$directSubtypes()); | 2798 var $$list = $this._orderCollectionValues(type.get$directSubtypes()); |
2785 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 2799 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { |
2786 var subtype = $$list.$index($$i); | 2800 var subtype = $$list.$index($$i); |
2787 var tag = typeTag(subtype); | 2801 var tag = subtype.get$nativeName(); |
2788 var existing = tagDefns.$index(tag); | 2802 var existing = tagDefns.$index(tag); |
2789 if (existing == null) { | 2803 if (existing == null) { |
2790 subtags.add$1(tag); | 2804 subtags.add$1(tag); |
2791 walk(subtype); | 2805 walk(subtype); |
2792 } | 2806 } |
2793 else { | 2807 else { |
2794 if (varDefns.containsKey$1(existing)) { | 2808 if (varDefns.containsKey$1(existing)) { |
2795 expressions.add$1(existing); | 2809 expressions.add$1(existing); |
2796 } | 2810 } |
2797 else { | 2811 else { |
(...skipping 13 matching lines...) Expand all Loading... |
2811 if ($eq(expressions.get$length(), 1)) { | 2825 if ($eq(expressions.get$length(), 1)) { |
2812 expression = expressions.$index(0); | 2826 expression = expressions.$index(0); |
2813 } | 2827 } |
2814 else { | 2828 else { |
2815 expression = ("[" + Strings.join(expressions, ',') + "].join('|')"); | 2829 expression = ("[" + Strings.join(expressions, ',') + "].join('|')"); |
2816 } | 2830 } |
2817 return expression; | 2831 return expression; |
2818 } | 2832 } |
2819 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) { | 2833 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) { |
2820 var type = $$i.next$0(); | 2834 var type = $$i.next$0(); |
2821 tagDefns.$setindex(typeTag(type), makeExpression(type)); | 2835 tagDefns.$setindex(type.get$nativeName(), makeExpression(type)); |
2822 } | 2836 } |
2823 if (!tagDefns.isEmpty$0()) { | 2837 if (!tagDefns.isEmpty$0()) { |
2824 this.writer.enterBlock('(function(){'); | 2838 this.writer.enterBlock('(function(){'); |
2825 for (var $$i = varNames.iterator$0(); $$i.hasNext$0(); ) { | 2839 for (var $$i = varNames.iterator$0(); $$i.hasNext$0(); ) { |
2826 var varName = $$i.next$0(); | 2840 var varName = $$i.next$0(); |
2827 this.writer.writeln(('var ' + varName + ' = ' + varDefns.$index(varName) +
';')); | 2841 this.writer.writeln(('var ' + varName + ' = ' + varDefns.$index(varName) +
';')); |
2828 } | 2842 } |
2829 this.writer.enterBlock('var table = ['); | 2843 this.writer.enterBlock('var table = ['); |
2830 this.writer.comment('// [dynamic-dispatch-tag, tags of classes implementing
dynamic-dispatch-tag]'/*'// [dynamic-dispatch-tag, ' | 2844 this.writer.comment('// [dynamic-dispatch-tag, tags of classes implementing
dynamic-dispatch-tag]'/*'// [dynamic-dispatch-tag, ' |
2831 + 'tags of classes implementing dynamic-dispatch-tag]'*/); | 2845 + 'tags of classes implementing dynamic-dispatch-tag]'*/); |
2832 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) { | 2846 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) { |
2833 var type0 = $$i.next$0(); | 2847 var type0 = $$i.next$0(); |
2834 this.writer.writeln(("['" + typeTag(type0) + "', " + tagDefns.$index(typeT
ag(type0)) + "],")); | 2848 this.writer.writeln(("['" + type0.get$nativeName() + "', " + tagDefns.$ind
ex(type0.get$nativeName()) + "],")); |
2835 } | 2849 } |
2836 this.writer.exitBlock('];'); | 2850 this.writer.exitBlock('];'); |
2837 this.writer.writeln('\$dynamicSetMetadata(table);'); | 2851 this.writer.writeln('\$dynamicSetMetadata(table);'); |
2838 this.writer.exitBlock('})();'); | 2852 this.writer.exitBlock('})();'); |
2839 } | 2853 } |
2840 } | 2854 } |
2841 WorldGenerator.prototype._orderValues = function(map) { | 2855 WorldGenerator.prototype._orderValues = function(map) { |
2842 var values = map.getValues(); | 2856 var values = map.getValues(); |
2843 values.sort(this.get$_compareMembers()); | 2857 values.sort(this.get$_compareMembers()); |
2844 return values; | 2858 return values; |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3370 this._scope = this._scope.parent; | 3384 this._scope = this._scope.parent; |
3371 } | 3385 } |
3372 MethodGenerator.prototype._makeLambdaMethod = function(name, func) { | 3386 MethodGenerator.prototype._makeLambdaMethod = function(name, func) { |
3373 var meth = new MethodMember(name, this.method.declaringType, func); | 3387 var meth = new MethodMember(name, this.method.declaringType, func); |
3374 meth.set$isLambda(true); | 3388 meth.set$isLambda(true); |
3375 meth.set$enclosingElement(this.method); | 3389 meth.set$enclosingElement(this.method); |
3376 meth.resolve$0(); | 3390 meth.resolve$0(); |
3377 return meth; | 3391 return meth; |
3378 } | 3392 } |
3379 MethodGenerator.prototype.visitBool = function(node) { | 3393 MethodGenerator.prototype.visitBool = function(node) { |
3380 return this.visitValue(node).convertTo$3(this, $globals.world.nonNullBool, nod
e); | 3394 return this.visitValue(node).convertTo$2(this, $globals.world.nonNullBool); |
3381 } | 3395 } |
3382 MethodGenerator.prototype.visitValue = function(node) { | 3396 MethodGenerator.prototype.visitValue = function(node) { |
3383 if (node == null) return null; | 3397 if (node == null) return null; |
3384 var value = node.visit(this); | 3398 var value = node.visit(this); |
3385 value.checkFirstClass$1(node.span); | 3399 value.checkFirstClass$1(node.span); |
3386 return value; | 3400 return value; |
3387 } | 3401 } |
3388 MethodGenerator.prototype.visitTypedValue = function(node, expectedType) { | 3402 MethodGenerator.prototype.visitTypedValue = function(node, expectedType) { |
3389 var val = this.visitValue(node); | 3403 var val = this.visitValue(node); |
3390 return expectedType == null ? val : val.convertTo$3(this, expectedType, node); | 3404 return expectedType == null ? val : val.convertTo$2(this, expectedType); |
3391 } | 3405 } |
3392 MethodGenerator.prototype.visitVoid = function(node) { | 3406 MethodGenerator.prototype.visitVoid = function(node) { |
3393 if ((node instanceof PostfixExpression)) { | 3407 if ((node instanceof PostfixExpression)) { |
3394 var value = this.visitPostfixExpression(node, true); | 3408 var value = this.visitPostfixExpression(node, true); |
3395 value.checkFirstClass$1(node.span); | 3409 value.checkFirstClass$1(node.span); |
3396 return value; | 3410 return value; |
3397 } | 3411 } |
3398 else if ((node instanceof BinaryExpression)) { | 3412 else if ((node instanceof BinaryExpression)) { |
3399 var value = this.visitBinaryExpression(node, true); | 3413 var value = this.visitBinaryExpression(node, true); |
3400 value.checkFirstClass$1(node.span); | 3414 value.checkFirstClass$1(node.span); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3433 var val = this._scope.create(name, thisType, node.names.$index(i).get$span()
, isFinal, false); | 3447 var val = this._scope.create(name, thisType, node.names.$index(i).get$span()
, isFinal, false); |
3434 if (value == null) { | 3448 if (value == null) { |
3435 if (this._scope.reentrant) { | 3449 if (this._scope.reentrant) { |
3436 this.writer.write(('' + val.get$code() + ' = null')); | 3450 this.writer.write(('' + val.get$code() + ' = null')); |
3437 } | 3451 } |
3438 else { | 3452 else { |
3439 this.writer.write(('' + val.get$code())); | 3453 this.writer.write(('' + val.get$code())); |
3440 } | 3454 } |
3441 } | 3455 } |
3442 else { | 3456 else { |
3443 value = value.convertTo$3(this, type, node.values.$index(i)); | 3457 value = value.convertTo$2(this, type); |
3444 this.writer.write(('' + val.get$code() + ' = ' + value.get$code())); | 3458 this.writer.write(('' + val.get$code() + ' = ' + value.get$code())); |
3445 } | 3459 } |
3446 } | 3460 } |
3447 this.writer.writeln(';'); | 3461 this.writer.writeln(';'); |
3448 return false; | 3462 return false; |
3449 } | 3463 } |
3450 MethodGenerator.prototype.visitFunctionDefinition = function(node) { | 3464 MethodGenerator.prototype.visitFunctionDefinition = function(node) { |
3451 var meth = this._makeLambdaMethod(node.name.name, node); | 3465 var meth = this._makeLambdaMethod(node.name.name, node); |
3452 var funcValue = this._scope.create(meth.get$name(), meth.get$functionType(), t
his.method.get$definition().get$span(), true, false); | 3466 var funcValue = this._scope.create(meth.get$name(), meth.get$functionType(), t
his.method.get$definition().get$span(), true, false); |
3453 $globals.world.gen.genMethod(meth, this); | 3467 $globals.world.gen.genMethod(meth, this); |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3999 return members._set$4(this, position, x, y); | 4013 return members._set$4(this, position, x, y); |
4000 } | 4014 } |
4001 else { | 4015 else { |
4002 x = members._get$3(this, position, x); | 4016 x = members._get$3(this, position, x); |
4003 } | 4017 } |
4004 } | 4018 } |
4005 } | 4019 } |
4006 if (x.get$isFinal()) { | 4020 if (x.get$isFinal()) { |
4007 $globals.world.error(('final variable "' + x.get$code() + '" is not assignab
le'), position.span); | 4021 $globals.world.error(('final variable "' + x.get$code() + '" is not assignab
le'), position.span); |
4008 } | 4022 } |
4009 y = y.convertTo$3(this, x.get$type(), yn); | 4023 y = y.convertTo$2(this, x.get$type()); |
4010 if (kind == 0) { | 4024 if (kind == 0) { |
4011 x = captureOriginal(x); | 4025 x = captureOriginal(x); |
4012 return new Value(y.get$type(), ('' + x.get$code() + ' = ' + y.get$code()), p
osition.span, true); | 4026 return new Value(y.get$type(), ('' + x.get$code() + ' = ' + y.get$code()), p
osition.span, true); |
4013 } | 4027 } |
4014 else if (x.get$type().get$isNum() && y.get$type().get$isNum() && (kind != 46/*
TokenKind.TRUNCDIV*/)) { | 4028 else if (x.get$type().get$isNum() && y.get$type().get$isNum() && (kind != 46/*
TokenKind.TRUNCDIV*/)) { |
4015 x = captureOriginal(x); | 4029 x = captureOriginal(x); |
4016 var op = TokenKind.kindToString(kind); | 4030 var op = TokenKind.kindToString(kind); |
4017 return new Value(y.get$type(), ('' + x.get$code() + ' ' + op + '= ' + y.get$
code()), position.span, true); | 4031 return new Value(y.get$type(), ('' + x.get$code() + ' ' + op + '= ' + y.get$
code()), position.span, true); |
4018 } | 4032 } |
4019 else { | 4033 else { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4081 return new Value(assignValue.get$type(), ('(' + assignValue.get$code() +
')'), node.span, true); | 4095 return new Value(assignValue.get$type(), ('(' + assignValue.get$code() +
')'), node.span, true); |
4082 } | 4096 } |
4083 | 4097 |
4084 case 19/*TokenKind.NOT*/: | 4098 case 19/*TokenKind.NOT*/: |
4085 | 4099 |
4086 if (value.get$type().get$isBool() && value.get$isConst()) { | 4100 if (value.get$type().get$isBool() && value.get$isConst()) { |
4087 var newVal = !value.get$actualValue(); | 4101 var newVal = !value.get$actualValue(); |
4088 return EvaluatedValue.EvaluatedValue$factory(value.get$type(), newVal, (
'' + newVal), node.span); | 4102 return EvaluatedValue.EvaluatedValue$factory(value.get$type(), newVal, (
'' + newVal), node.span); |
4089 } | 4103 } |
4090 else { | 4104 else { |
4091 var newVal = value.convertTo$3(this, $globals.world.nonNullBool, node); | 4105 var newVal = value.convertTo$2(this, $globals.world.nonNullBool); |
4092 return new Value(newVal.get$type(), ('!' + newVal.get$code()), node.span
, true); | 4106 return new Value(newVal.get$type(), ('!' + newVal.get$code()), node.span
, true); |
4093 } | 4107 } |
4094 | 4108 |
4095 case 42/*TokenKind.ADD*/: | 4109 case 42/*TokenKind.ADD*/: |
4096 | 4110 |
4097 return value.convertTo$3(this, $globals.world.numType, node); | 4111 return value.convertTo$2(this, $globals.world.numType); |
4098 | 4112 |
4099 case 43/*TokenKind.SUB*/: | 4113 case 43/*TokenKind.SUB*/: |
4100 case 18/*TokenKind.BIT_NOT*/: | 4114 case 18/*TokenKind.BIT_NOT*/: |
4101 | 4115 |
4102 if (node.op.kind == 18/*TokenKind.BIT_NOT*/) { | 4116 if (node.op.kind == 18/*TokenKind.BIT_NOT*/) { |
4103 return value.invoke$4(this, ':bit_not', node, Arguments.get$EMPTY()); | 4117 return value.invoke$4(this, ':bit_not', node, Arguments.get$EMPTY()); |
4104 } | 4118 } |
4105 else if (node.op.kind == 43/*TokenKind.SUB*/) { | 4119 else if (node.op.kind == 43/*TokenKind.SUB*/) { |
4106 return value.invoke$4(this, ':negate', node, Arguments.get$EMPTY()); | 4120 return value.invoke$4(this, ':negate', node, Arguments.get$EMPTY()); |
4107 } | 4121 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4216 argsCode.add$1(arg.get$code()); | 4230 argsCode.add$1(arg.get$code()); |
4217 } | 4231 } |
4218 else { | 4232 else { |
4219 argsCode.add$1(arg.get$canonicalCode()); | 4233 argsCode.add$1(arg.get$canonicalCode()); |
4220 } | 4234 } |
4221 } | 4235 } |
4222 else { | 4236 else { |
4223 argsCode.add$1(arg.get$code()); | 4237 argsCode.add$1(arg.get$code()); |
4224 } | 4238 } |
4225 } | 4239 } |
4226 $globals.world.get$coreimpl().types.$index('ListFactory').markUsed$0(); | 4240 $globals.world.listFactoryType.markUsed(); |
4227 var code = ('[' + Strings.join(argsCode, ", ") + ']'); | 4241 var code = ('[' + Strings.join(argsCode, ", ") + ']'); |
4228 var value = new Value($globals.world.listType, code, node.span, true); | 4242 var value = new Value($globals.world.listType, code, node.span, true); |
4229 if (node.isConst) { | 4243 if (node.isConst) { |
4230 var immutableList = $globals.world.get$coreimpl().types.$index('ImmutableLis
t'); | 4244 var immutableList = $globals.world.immutableListType; |
4231 var immutableListCtor = immutableList.getConstructor$1('from'); | 4245 var immutableListCtor = immutableList.getConstructor('from'); |
4232 var result = immutableListCtor.invoke$4(this, node, new Value.type$ctor(valu
e.get$type(), node.span), new Arguments(null, [value])); | 4246 var result = immutableListCtor.invoke$4(this, node, new Value.type$ctor(valu
e.get$type(), node.span), new Arguments(null, [value])); |
4233 value = $globals.world.gen.globalForConst(ConstListValue.ConstListValue$fact
ory(immutableList, argValues, ('const ' + code), result.get$code(), node.span),
argValues); | 4247 value = $globals.world.gen.globalForConst(ConstListValue.ConstListValue$fact
ory(immutableList, argValues, ('const ' + code), result.get$code(), node.span),
argValues); |
4234 } | 4248 } |
4235 return value; | 4249 return value; |
4236 } | 4250 } |
4237 MethodGenerator.prototype.visitMapExpression = function(node) { | 4251 MethodGenerator.prototype.visitMapExpression = function(node) { |
4238 if (node.items.get$length() == 0 && !node.isConst) { | 4252 if (node.items.get$length() == 0 && !node.isConst) { |
4239 return $globals.world.mapType.getConstructor('').invoke$4(this, node, new Va
lue.type$ctor($globals.world.mapType, node.span), Arguments.get$EMPTY()); | 4253 return $globals.world.mapType.getConstructor('').invoke$4(this, node, new Va
lue.type$ctor($globals.world.mapType, node.span), Arguments.get$EMPTY()); |
4240 } | 4254 } |
4241 var argValues = []; | 4255 var argValues = []; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4350 if (this._expressionNeedsParens(item)) { | 4364 if (this._expressionNeedsParens(item)) { |
4351 code = ('(' + code + ')'); | 4365 code = ('(' + code + ')'); |
4352 } | 4366 } |
4353 if ($eq(items.get$length(), 0) || ($ne(code, "''") && $ne(code, '""'))) { | 4367 if ($eq(items.get$length(), 0) || ($ne(code, "''") && $ne(code, '""'))) { |
4354 items.add$1(code); | 4368 items.add$1(code); |
4355 } | 4369 } |
4356 } | 4370 } |
4357 return new Value(type, ('(' + Strings.join(items, " + ") + ')'), node.span,
true); | 4371 return new Value(type, ('(' + Strings.join(items, " + ") + ')'), node.span,
true); |
4358 } | 4372 } |
4359 if ((typeof(node.value) == 'number')) { | 4373 if ((typeof(node.value) == 'number')) { |
4360 $globals.world.get$coreimpl().types.$index('NumImplementation').markUsed$0()
; | 4374 $globals.world.numImplType.markUsed(); |
4361 } | 4375 } |
4362 var text = node.text; | 4376 var text = node.text; |
4363 if (type.get$isString()) { | 4377 if (type.get$isString()) { |
4364 $globals.world.get$coreimpl().types.$index('StringImplementation').markUsed$
0(); | 4378 $globals.world.stringImplType.markUsed(); |
4365 if (text.startsWith$1('@')) { | 4379 if (text.startsWith$1('@')) { |
4366 text = MethodGenerator._escapeString(parseStringLiteral(text)); | 4380 text = MethodGenerator._escapeString(parseStringLiteral(text)); |
4367 text = ('"' + text + '"'); | 4381 text = ('"' + text + '"'); |
4368 } | 4382 } |
4369 else if (isMultilineString(text)) { | 4383 else if (isMultilineString(text)) { |
4370 text = parseStringLiteral(text); | 4384 text = parseStringLiteral(text); |
4371 text = text.replaceAll$2('\n', '\\n'); | 4385 text = text.replaceAll$2('\n', '\\n'); |
4372 text = toDoubleQuote(text); | 4386 text = toDoubleQuote(text); |
4373 text = ('"' + text + '"'); | 4387 text = ('"' + text + '"'); |
4374 } | 4388 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4525 Library.prototype.get$library = function() { | 4539 Library.prototype.get$library = function() { |
4526 return this; | 4540 return this; |
4527 } | 4541 } |
4528 Library.prototype.get$isNative = function() { | 4542 Library.prototype.get$isNative = function() { |
4529 return this.topType.isNative; | 4543 return this.topType.isNative; |
4530 } | 4544 } |
4531 Library.prototype.get$isCore = function() { | 4545 Library.prototype.get$isCore = function() { |
4532 return $eq(this, $globals.world.corelib); | 4546 return $eq(this, $globals.world.corelib); |
4533 } | 4547 } |
4534 Library.prototype.get$isCoreImpl = function() { | 4548 Library.prototype.get$isCoreImpl = function() { |
4535 return $eq(this, $globals.world.get$coreimpl()); | 4549 return $eq(this, $globals.world.coreimpl); |
| 4550 } |
| 4551 Library.prototype.get$isDom = function() { |
| 4552 return $eq(this, $globals.world.dom); |
4536 } | 4553 } |
4537 Library.prototype.get$span = function() { | 4554 Library.prototype.get$span = function() { |
4538 return new SourceSpan(this.baseSource, 0, 0); | 4555 return new SourceSpan(this.baseSource, 0, 0); |
4539 } | 4556 } |
4540 Library.prototype.makeFullPath = function(filename) { | 4557 Library.prototype.makeFullPath = function(filename) { |
4541 if (filename.startsWith('dart:')) return filename; | 4558 if (filename.startsWith('dart:')) return filename; |
4542 if (filename.startsWith('/')) return filename; | 4559 if (filename.startsWith('/')) return filename; |
4543 if (filename.startsWith('file:///')) return filename; | 4560 if (filename.startsWith('file:///')) return filename; |
4544 if (filename.startsWith('http://')) return filename; | 4561 if (filename.startsWith('http://')) return filename; |
4545 return joinPaths(this.sourceDir, filename); | 4562 return joinPaths(this.sourceDir, filename); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4595 type.addMethod(':call', func); | 4612 type.addMethod(':call', func); |
4596 var m = type.members.$index(':call'); | 4613 var m = type.members.$index(':call'); |
4597 m.set$enclosingElement(enclosingElement); | 4614 m.set$enclosingElement(enclosingElement); |
4598 m.resolve$0(); | 4615 m.resolve$0(); |
4599 type.interfaces = [$globals.world.functionType]; | 4616 type.interfaces = [$globals.world.functionType]; |
4600 return type; | 4617 return type; |
4601 } | 4618 } |
4602 Library.prototype.addType = function(name, definition, isClass) { | 4619 Library.prototype.addType = function(name, definition, isClass) { |
4603 if (this.types.containsKey(name)) { | 4620 if (this.types.containsKey(name)) { |
4604 var existingType = this.types.$index(name); | 4621 var existingType = this.types.$index(name); |
4605 if (this.get$isCore() && existingType.get$definition() == null) { | 4622 if ((this.get$isCore() || this.get$isCoreImpl()) && existingType.get$definit
ion() == null) { |
4606 existingType.setDefinition$1(definition); | 4623 existingType.setDefinition$1(definition); |
4607 } | 4624 } |
4608 else { | 4625 else { |
4609 $globals.world.warning(('duplicate definition of ' + name), definition.spa
n, existingType.get$span()); | 4626 $globals.world.warning(('duplicate definition of ' + name), definition.spa
n, existingType.get$span()); |
4610 } | 4627 } |
4611 } | 4628 } |
4612 else { | 4629 else { |
4613 this.types.$setindex(name, new DefinedType(name, this, definition, isClass))
; | 4630 this.types.$setindex(name, new DefinedType(name, this, definition, isClass))
; |
4614 } | 4631 } |
4615 return this.types.$index(name); | 4632 return this.types.$index(name); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4984 } | 5001 } |
4985 Parameter.prototype.genValue = function(method, context) { | 5002 Parameter.prototype.genValue = function(method, context) { |
4986 if (this.definition.value == null || this.value != null) return; | 5003 if (this.definition.value == null || this.value != null) return; |
4987 if (context == null) { | 5004 if (context == null) { |
4988 context = new MethodGenerator(method, null); | 5005 context = new MethodGenerator(method, null); |
4989 } | 5006 } |
4990 this.value = this.definition.value.visit(context); | 5007 this.value = this.definition.value.visit(context); |
4991 if (!this.value.get$isConst()) { | 5008 if (!this.value.get$isConst()) { |
4992 $globals.world.error('default parameter values must be constant', this.value
.span); | 5009 $globals.world.error('default parameter values must be constant', this.value
.span); |
4993 } | 5010 } |
4994 this.value = this.value.convertTo(context, this.type, this.definition.value, f
alse); | 5011 this.value = this.value.convertTo(context, this.type, false); |
4995 } | 5012 } |
4996 Parameter.prototype.copyWithNewType = function(newMethod, newType) { | 5013 Parameter.prototype.copyWithNewType = function(newMethod, newType) { |
4997 var ret = new Parameter(this.definition, newMethod); | 5014 var ret = new Parameter(this.definition, newMethod); |
4998 ret.set$type(newType); | 5015 ret.set$type(newType); |
4999 ret.set$name(this.name); | 5016 ret.set$name(this.name); |
5000 ret.set$isInitializer(this.isInitializer); | 5017 ret.set$isInitializer(this.isInitializer); |
5001 return ret; | 5018 return ret; |
5002 } | 5019 } |
5003 Parameter.prototype.get$isOptional = function() { | 5020 Parameter.prototype.get$isOptional = function() { |
5004 return this.definition != null && this.definition.value != null; | 5021 return this.definition != null && this.definition.value != null; |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5327 } | 5344 } |
5328 } | 5345 } |
5329 if (this.isStatic) { | 5346 if (this.isStatic) { |
5330 this.declaringType.markUsed(); | 5347 this.declaringType.markUsed(); |
5331 var cv = this.computeValue(); | 5348 var cv = this.computeValue(); |
5332 if (this.isFinal) { | 5349 if (this.isFinal) { |
5333 return cv; | 5350 return cv; |
5334 } | 5351 } |
5335 $globals.world.gen.hasStatics = true; | 5352 $globals.world.gen.hasStatics = true; |
5336 if (this.declaringType.get$isTop()) { | 5353 if (this.declaringType.get$isTop()) { |
5337 if ($eq(this.declaringType.get$library(), $globals.world.get$dom())) { | 5354 if (this.declaringType.get$library().get$isDom()) { |
5338 return new Value(this.type, ('' + this.get$jsname()), node.span, true); | 5355 return new Value(this.type, ('' + this.get$jsname()), node.span, true); |
5339 } | 5356 } |
5340 else { | 5357 else { |
5341 return new Value(this.type, ('\$globals.' + this.get$jsname()), node.spa
n, true); | 5358 return new Value(this.type, ('\$globals.' + this.get$jsname()), node.spa
n, true); |
5342 } | 5359 } |
5343 } | 5360 } |
5344 else if (this.declaringType.get$isNative()) { | 5361 else if (this.declaringType.get$isNative()) { |
5345 if (this.declaringType.get$isHiddenNativeType()) { | 5362 if (this.declaringType.get$isHiddenNativeType()) { |
5346 $globals.world.error('static field of hidden native type is inaccessible
', node.span); | 5363 $globals.world.error('static field of hidden native type is inaccessible
', node.span); |
5347 } | 5364 } |
5348 return new Value(this.type, ('' + this.declaringType.get$jsname() + '.' +
this.get$jsname()), node.span, true); | 5365 return new Value(this.type, ('' + this.declaringType.get$jsname() + '.' +
this.get$jsname()), node.span, true); |
5349 } | 5366 } |
5350 else { | 5367 else { |
5351 return new Value(this.type, ('\$globals.' + this.declaringType.get$jsname(
) + '_' + this.get$jsname()), node.span, true); | 5368 return new Value(this.type, ('\$globals.' + this.declaringType.get$jsname(
) + '_' + this.get$jsname()), node.span, true); |
5352 } | 5369 } |
5353 } | 5370 } |
5354 else if (target.get$isConst() && this.isFinal) { | 5371 else if (target.get$isConst() && this.isFinal) { |
5355 var constTarget = (target instanceof GlobalValue) ? target.get$dynamic().get
$exp() : target; | 5372 var constTarget = (target instanceof GlobalValue) ? target.get$dynamic().get
$exp() : target; |
5356 if ((constTarget instanceof ConstObjectValue)) { | 5373 if ((constTarget instanceof ConstObjectValue)) { |
5357 return constTarget.get$fields().$index(this.name); | 5374 return constTarget.get$fields().$index(this.name); |
5358 } | 5375 } |
5359 else if ($eq(constTarget.get$type(), $globals.world.stringType) && this.name
== 'length') { | 5376 else if ($eq(constTarget.get$type(), $globals.world.stringType) && this.name
== 'length') { |
5360 return new Value(this.type, ('' + constTarget.get$actualValue().get$length
()), node.span, true); | 5377 return new Value(this.type, ('' + constTarget.get$actualValue().get$length
()), node.span, true); |
5361 } | 5378 } |
5362 } | 5379 } |
5363 return new Value(this.type, ('' + target.code + '.' + this.get$jsname()), node
.span, true); | 5380 return new Value(this.type, ('' + target.code + '.' + this.get$jsname()), node
.span, true); |
5364 } | 5381 } |
5365 FieldMember.prototype._set = function(context, node, target, value, isDynamic) { | 5382 FieldMember.prototype._set = function(context, node, target, value, isDynamic) { |
5366 var lhs = this._get(context, node, target, isDynamic); | 5383 var lhs = this._get(context, node, target, isDynamic); |
5367 value = value.convertTo(context, this.type, node, isDynamic); | 5384 value = value.convertTo(context, this.type, isDynamic); |
5368 return new Value(this.type, ('' + lhs.get$code() + ' = ' + value.code), node.s
pan, true); | 5385 return new Value(this.type, ('' + lhs.get$code() + ' = ' + value.code), node.s
pan, true); |
5369 } | 5386 } |
5370 FieldMember.prototype._get$3 = function($0, $1, $2) { | 5387 FieldMember.prototype._get$3 = function($0, $1, $2) { |
5371 return this._get($0, $1, $2, false); | 5388 return this._get($0, $1, $2, false); |
5372 }; | 5389 }; |
5373 FieldMember.prototype._get$3$isDynamic = FieldMember.prototype._get; | 5390 FieldMember.prototype._get$3$isDynamic = FieldMember.prototype._get; |
5374 FieldMember.prototype._get$4 = FieldMember.prototype._get; | 5391 FieldMember.prototype._get$4 = FieldMember.prototype._get; |
5375 FieldMember.prototype._set$4 = function($0, $1, $2, $3) { | 5392 FieldMember.prototype._set$4 = function($0, $1, $2, $3) { |
5376 return this._set($0, $1, $2, $3, false); | 5393 return this._set($0, $1, $2, $3, false); |
5377 }; | 5394 }; |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5862 argsCode.add$1('this'); | 5879 argsCode.add$1('this'); |
5863 } | 5880 } |
5864 var bareCount = args.get$bareCount(); | 5881 var bareCount = args.get$bareCount(); |
5865 for (var i = 0; | 5882 for (var i = 0; |
5866 i < bareCount; i++) { | 5883 i < bareCount; i++) { |
5867 var arg = args.values.$index(i); | 5884 var arg = args.values.$index(i); |
5868 if (i >= this.parameters.get$length()) { | 5885 if (i >= this.parameters.get$length()) { |
5869 var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.get
$length(), false); | 5886 var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.get
$length(), false); |
5870 return this._argError(context, node, target, args, msg, i); | 5887 return this._argError(context, node, target, args, msg, i); |
5871 } | 5888 } |
5872 arg = arg.convertTo$4(context, this.parameters.$index(i).get$type(), node, i
sDynamic); | 5889 arg = arg.convertTo$3(context, this.parameters.$index(i).get$type(), isDynam
ic); |
5873 if (this.isConst && arg.get$isConst()) { | 5890 if (this.isConst && arg.get$isConst()) { |
5874 argsCode.add$1(arg.get$canonicalCode()); | 5891 argsCode.add$1(arg.get$canonicalCode()); |
5875 } | 5892 } |
5876 else { | 5893 else { |
5877 argsCode.add$1(arg.get$code()); | 5894 argsCode.add$1(arg.get$code()); |
5878 } | 5895 } |
5879 } | 5896 } |
5880 var namedArgsUsed = 0; | 5897 var namedArgsUsed = 0; |
5881 if (bareCount < this.parameters.get$length()) { | 5898 if (bareCount < this.parameters.get$length()) { |
5882 this.genParameterValues(); | 5899 this.genParameterValues(); |
5883 for (var i = bareCount; | 5900 for (var i = bareCount; |
5884 i < this.parameters.get$length(); i++) { | 5901 i < this.parameters.get$length(); i++) { |
5885 var arg = args.getValue(this.parameters.$index(i).get$name()); | 5902 var arg = args.getValue(this.parameters.$index(i).get$name()); |
5886 if (arg == null) { | 5903 if (arg == null) { |
5887 arg = this.parameters.$index(i).get$value(); | 5904 arg = this.parameters.$index(i).get$value(); |
5888 } | 5905 } |
5889 else { | 5906 else { |
5890 arg = arg.convertTo$4(context, this.parameters.$index(i).get$type(), nod
e, isDynamic); | 5907 arg = arg.convertTo$3(context, this.parameters.$index(i).get$type(), isD
ynamic); |
5891 namedArgsUsed++; | 5908 namedArgsUsed++; |
5892 } | 5909 } |
5893 if (arg == null || !this.parameters.$index(i).get$isOptional()) { | 5910 if (arg == null || !this.parameters.$index(i).get$isOptional()) { |
5894 var msg = MethodMember._argCountMsg(Math.min(i, args.get$length()), i +
1, true); | 5911 var msg = MethodMember._argCountMsg(Math.min(i, args.get$length()), i +
1, true); |
5895 return this._argError(context, node, target, args, msg, i); | 5912 return this._argError(context, node, target, args, msg, i); |
5896 } | 5913 } |
5897 else { | 5914 else { |
5898 argsCode.add$1(this.isConst && arg.get$isConst() ? arg.get$canonicalCode
() : arg.get$code()); | 5915 argsCode.add$1(this.isConst && arg.get$isConst() ? arg.get$canonicalCode
() : arg.get$code()); |
5899 } | 5916 } |
5900 } | 5917 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5947 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue
)) { | 5964 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue
)) { |
5948 code = ('' + target.get$dynamic().get$values().get$length()); | 5965 code = ('' + target.get$dynamic().get$values().get$length()); |
5949 } | 5966 } |
5950 } | 5967 } |
5951 else if (this.name == 'isEmpty') { | 5968 else if (this.name == 'isEmpty') { |
5952 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue
)) { | 5969 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue
)) { |
5953 code = ('' + target.get$dynamic().get$values().isEmpty$0()); | 5970 code = ('' + target.get$dynamic().get$values().isEmpty$0()); |
5954 } | 5971 } |
5955 } | 5972 } |
5956 } | 5973 } |
5957 if (this.name == 'get:typeName' && $eq(this.declaringType.get$library(), $glob
als.world.get$dom())) { | 5974 if (this.name == 'get:typeName' && this.declaringType.get$library().get$isDom(
)) { |
5958 $globals.world.gen.corejs.ensureTypeNameOf(); | 5975 $globals.world.gen.corejs.ensureTypeNameOf(); |
5959 } | 5976 } |
5960 return new Value(this.get$inferredResult(), code, node.span, true); | 5977 return new Value(this.get$inferredResult(), code, node.span, true); |
5961 } | 5978 } |
5962 MethodMember.prototype._invokeConstructor = function(context, node, target, args
, argsString) { | 5979 MethodMember.prototype._invokeConstructor = function(context, node, target, args
, argsString) { |
5963 this.declaringType.markUsed(); | 5980 this.declaringType.markUsed(); |
| 5981 var ctor = this.get$constructorName(); |
| 5982 if (ctor != '') ctor = ('.' + ctor + '\$ctor'); |
5964 if (!target.isType) { | 5983 if (!target.isType) { |
5965 var code = (this.get$constructorName() != '') ? ('' + this.declaringType.get
$jsname() + '.' + this.get$constructorName() + '\$ctor.call(' + argsString + ')'
) : ('' + this.declaringType.get$jsname() + '.call(' + argsString + ')'); | 5984 var code = ('' + this.declaringType.get$nativeName() + ctor + '.call(' + arg
sString + ')'); |
5966 return new Value(target.get$type(), code, node.span, true); | 5985 return new Value(target.get$type(), code, node.span, true); |
5967 } | 5986 } |
5968 else { | 5987 else { |
5969 var typeName = this.declaringType.get$isNative() ? this.declaringType.get$na
tiveType().name : this.declaringType.get$jsname(); | 5988 var code = ('new ' + this.declaringType.get$nativeName() + ctor + '(' + args
String + ')'); |
5970 var code = (this.get$constructorName() != '') ? ('new ' + typeName + '.' + t
his.get$constructorName() + '\$ctor(' + argsString + ')') : ('new ' + typeName +
'(' + argsString + ')'); | |
5971 if (this.isConst && (node instanceof NewExpression) && node.get$dynamic().ge
t$isConst()) { | 5989 if (this.isConst && (node instanceof NewExpression) && node.get$dynamic().ge
t$isConst()) { |
5972 return this._invokeConstConstructor(node, code, target, args); | 5990 return this._invokeConstConstructor(node, code, target, args); |
5973 } | 5991 } |
5974 else { | 5992 else { |
5975 return new Value(target.get$type(), code, node.span, true); | 5993 var span = node != null ? node.span : target.span; |
| 5994 return new Value(target.get$type(), code, span, true); |
5976 } | 5995 } |
5977 } | 5996 } |
5978 } | 5997 } |
5979 MethodMember.prototype._invokeConstConstructor = function(node, code, target, ar
gs) { | 5998 MethodMember.prototype._invokeConstConstructor = function(node, code, target, ar
gs) { |
5980 var fields = new HashMapImplementation(); | 5999 var fields = new HashMapImplementation(); |
5981 for (var i = 0; | 6000 for (var i = 0; |
5982 i < this.parameters.get$length(); i++) { | 6001 i < this.parameters.get$length(); i++) { |
5983 var param = this.parameters.$index(i); | 6002 var param = this.parameters.$index(i); |
5984 if (param.get$isInitializer()) { | 6003 if (param.get$isInitializer()) { |
5985 var value = null; | 6004 var value = null; |
(...skipping 5165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11151 Type.prototype.get$interfaces = function() { | 11170 Type.prototype.get$interfaces = function() { |
11152 return null; | 11171 return null; |
11153 } | 11172 } |
11154 Type.prototype.get$parent = function() { | 11173 Type.prototype.get$parent = function() { |
11155 return null; | 11174 return null; |
11156 } | 11175 } |
11157 Type.prototype.getAllMembers = function() { | 11176 Type.prototype.getAllMembers = function() { |
11158 return new HashMapImplementation(); | 11177 return new HashMapImplementation(); |
11159 } | 11178 } |
11160 Type.prototype.get$nativeName = function() { | 11179 Type.prototype.get$nativeName = function() { |
11161 return this.get$isNative() ? this.get$definition().get$nativeType().get$name()
: null; | 11180 return this.get$isNative() ? this.get$definition().get$nativeType().get$name()
: this.get$jsname(); |
11162 } | 11181 } |
11163 Type.prototype.get$avoidNativeName = function() { | 11182 Type.prototype.get$avoidNativeName = function() { |
11164 return this.get$isHiddenNativeType(); | 11183 return this.get$isHiddenNativeType(); |
11165 } | 11184 } |
11166 Type.prototype.get$hasNativeSubtypes = function() { | 11185 Type.prototype.get$hasNativeSubtypes = function() { |
11167 if (this._hasNativeSubtypes == null) { | 11186 if (this._hasNativeSubtypes == null) { |
11168 this._hasNativeSubtypes = this.get$subtypes().some((function (t) { | 11187 this._hasNativeSubtypes = this.get$subtypes().some((function (t) { |
11169 return t.get$isNative(); | 11188 return t.get$isNative(); |
11170 }) | 11189 }) |
11171 ); | 11190 ); |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12483 Value.prototype.checkFirstClass = function(span) { | 12502 Value.prototype.checkFirstClass = function(span) { |
12484 if (this.isType) { | 12503 if (this.isType) { |
12485 $globals.world.error('Types are not first class', span); | 12504 $globals.world.error('Types are not first class', span); |
12486 } | 12505 } |
12487 } | 12506 } |
12488 Value.prototype._varCall = function(context, node, args) { | 12507 Value.prototype._varCall = function(context, node, args) { |
12489 var stub = $globals.world.functionType.getCallStub(args); | 12508 var stub = $globals.world.functionType.getCallStub(args); |
12490 return stub.invoke$4(context, node, this, args); | 12509 return stub.invoke$4(context, node, this, args); |
12491 } | 12510 } |
12492 Value.prototype.needsConversion = function(toType) { | 12511 Value.prototype.needsConversion = function(toType) { |
12493 var callMethod = toType.getCallMethod(); | 12512 return $ne(this, this.convertTo(null, toType, true)); |
12494 if (callMethod != null) { | |
12495 var arity = callMethod.get$parameters().get$length(); | |
12496 var myCall = this.get$type().getCallMethod(); | |
12497 if (myCall == null || $ne(myCall.get$parameters().get$length(), arity)) { | |
12498 return true; | |
12499 } | |
12500 } | |
12501 if ($globals.options.enableTypeChecks) { | |
12502 var fromType = this.get$type(); | |
12503 if (this.get$type().get$isVar() && (this.code != 'null' || !toType.get$isNul
lable())) { | |
12504 fromType = $globals.world.objectType; | |
12505 } | |
12506 var bothNum = this.get$type().get$isNum() && toType.get$isNum(); | |
12507 return !(fromType.isSubtypeOf(toType) || bothNum); | |
12508 } | |
12509 return false; | |
12510 } | 12513 } |
12511 Value.prototype.convertTo = function(context, toType, node, isDynamic) { | 12514 Value.prototype.convertTo = function(context, toType, isDynamic) { |
12512 var checked = !isDynamic; | 12515 var checked = !isDynamic; |
12513 var callMethod = toType.getCallMethod(); | 12516 var callMethod = toType.getCallMethod(); |
12514 if (callMethod != null) { | 12517 if (callMethod != null) { |
12515 if (checked && !toType.isAssignable(this.get$type())) { | 12518 if (checked && !toType.isAssignable(this.get$type())) { |
12516 this.convertWarning(toType, node); | 12519 this.convertWarning(toType); |
12517 } | 12520 } |
12518 var arity = callMethod.get$parameters().get$length(); | 12521 return this._maybeWrapFunction(toType, callMethod); |
12519 var myCall = this.get$type().getCallMethod(); | |
12520 if (myCall == null || $ne(myCall.get$parameters().get$length(), arity)) { | |
12521 var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bar
e$factory(arity)); | |
12522 var val = new Value(toType, ('to\$' + stub.name + '(' + this.code + ')'),
node.span, true); | |
12523 return this._isDomCallback(toType) && !this._isDomCallback(this.get$type()
) ? val._wrapDomCallback$2(toType, arity) : val; | |
12524 } | |
12525 else if (this._isDomCallback(toType) && !this._isDomCallback(this.get$type()
)) { | |
12526 return this._wrapDomCallback(toType, arity); | |
12527 } | |
12528 } | 12522 } |
12529 var fromType = this.get$type(); | 12523 var fromType = this.get$type(); |
12530 if (this.get$type().get$isVar() && (this.code != 'null' || !toType.get$isNulla
ble())) { | 12524 if (this.get$type().get$isVar() && (this.code != 'null' || !toType.get$isNulla
ble())) { |
12531 fromType = $globals.world.objectType; | 12525 fromType = $globals.world.objectType; |
12532 } | 12526 } |
12533 var bothNum = this.get$type().get$isNum() && toType.get$isNum(); | 12527 var bothNum = this.get$type().get$isNum() && toType.get$isNum(); |
12534 if (fromType.isSubtypeOf(toType) || bothNum) { | 12528 if (fromType.isSubtypeOf(toType) || bothNum) { |
12535 return this; | 12529 return this; |
12536 } | 12530 } |
12537 if (checked && !toType.isSubtypeOf(this.get$type())) { | 12531 if (checked && !toType.isSubtypeOf(this.get$type())) { |
12538 this.convertWarning(toType, node); | 12532 this.convertWarning(toType); |
12539 } | 12533 } |
12540 if ($globals.options.enableTypeChecks) { | 12534 if ($globals.options.enableTypeChecks) { |
12541 return this._typeAssert(context, toType, node, isDynamic); | 12535 if (context == null && isDynamic) { |
| 12536 return null; |
| 12537 } |
| 12538 return this._typeAssert(context, toType, isDynamic); |
12542 } | 12539 } |
12543 else { | 12540 else { |
12544 return this; | 12541 return this; |
12545 } | 12542 } |
12546 } | 12543 } |
12547 Value.prototype._isDomCallback = function(toType) { | 12544 Value.prototype._maybeWrapFunction = function(toType, callMethod) { |
12548 return ((toType.get$definition() instanceof FunctionTypeDefinition) && $eq(toT
ype.get$library(), $globals.world.get$dom())); | 12545 var arity = callMethod.parameters.get$length(); |
| 12546 var myCall = this.get$type().getCallMethod(); |
| 12547 var result = this; |
| 12548 if (myCall == null || $ne(myCall.get$parameters().get$length(), arity)) { |
| 12549 var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bare$
factory(arity)); |
| 12550 result = new Value(toType, ('to\$' + stub.name + '(' + this.code + ')'), thi
s.span, true); |
| 12551 } |
| 12552 if (toType.get$library().get$isDom() && !this.get$type().get$library().get$isD
om()) { |
| 12553 if (arity == 0) { |
| 12554 $globals.world.gen.corejs.useWrap0 = true; |
| 12555 } |
| 12556 else { |
| 12557 $globals.world.gen.corejs.useWrap1 = true; |
| 12558 } |
| 12559 result = new Value(toType, ('\$wrap_call\$' + arity + '(' + result.code + ')
'), this.span, true); |
| 12560 } |
| 12561 return result; |
12549 } | 12562 } |
12550 Value.prototype._wrapDomCallback = function(toType, arity) { | 12563 Value.prototype._typeAssert = function(context, toType, isDynamic) { |
12551 if (arity == 0) { | |
12552 $globals.world.gen.corejs.useWrap0 = true; | |
12553 } | |
12554 else { | |
12555 $globals.world.gen.corejs.useWrap1 = true; | |
12556 } | |
12557 return new Value(toType, ('\$wrap_call\$' + arity + '(' + this.code + ')'), th
is.span, true); | |
12558 } | |
12559 Value.prototype._typeAssert = function(context, toType, node, isDynamic) { | |
12560 if ((toType instanceof ParameterType)) { | 12564 if ((toType instanceof ParameterType)) { |
12561 var p = toType; | 12565 var p = toType; |
12562 toType = p.extendsType; | 12566 toType = p.extendsType; |
12563 } | 12567 } |
12564 if (toType.get$isObject() || toType.get$isVar()) { | 12568 if (toType.get$isObject() || toType.get$isVar()) { |
12565 $globals.world.internalError(('We thought ' + this.get$type().name + ' is no
t a subtype of ' + toType.name + '?')); | 12569 $globals.world.internalError(('We thought ' + this.get$type().name + ' is no
t a subtype of ' + toType.name + '?')); |
12566 } | 12570 } |
12567 function throwTypeError(paramName) { | 12571 function throwTypeError(paramName) { |
12568 return $globals.world.withoutForceDynamic((function () { | 12572 return $globals.world.withoutForceDynamic((function () { |
12569 var typeError = $globals.world.corelib.types.$index('TypeError'); | 12573 var typeErrorCtor = $globals.world.typeErrorType.getConstructor('_internal
'); |
12570 var typeErrorCtor = typeError.getConstructor$1('_internal'); | |
12571 $globals.world.gen.corejs.ensureTypeNameOf(); | 12574 $globals.world.gen.corejs.ensureTypeNameOf(); |
12572 var result = typeErrorCtor.invoke$5(context, node, new Value.type$ctor(typ
eError, null), new Arguments(null, [new Value($globals.world.objectType, paramNa
me, null, true), new Value($globals.world.stringType, ('"' + toType.name + '"'),
null, true)]), isDynamic); | 12575 var result = typeErrorCtor.invoke$5(context, null, new Value.type$ctor($gl
obals.world.typeErrorType, null), new Arguments(null, [new Value($globals.world.
objectType, paramName, null, true), new Value($globals.world.stringType, ('"' +
toType.name + '"'), null, true)]), isDynamic); |
12573 $globals.world.gen.corejs.useThrow = true; | 12576 $globals.world.gen.corejs.useThrow = true; |
12574 return ('\$throw(' + result.get$code() + ')'); | 12577 return ('\$throw(' + result.get$code() + ')'); |
12575 }) | 12578 }) |
12576 ); | 12579 ); |
12577 } | 12580 } |
12578 if (toType.get$isNum()) toType = $globals.world.numType; | 12581 if (toType.get$isNum()) toType = $globals.world.numType; |
12579 var check; | 12582 var check; |
12580 if (toType.get$isVoid()) { | 12583 if (toType.get$isVoid()) { |
12581 check = ('\$assert_void(' + this.code + ')'); | 12584 check = ('\$assert_void(' + this.code + ')'); |
12582 if (toType.typeCheckCode == null) { | 12585 if (toType.typeCheckCode == null) { |
(...skipping 10 matching lines...) Expand all Loading... |
12593 toType.typeCheckCode = ("function $assert_" + toType.name + "(x) {\n if (
x == null || typeof(x) == \"" + toType.get$typeofName() + "\") return x;\n " +
throwTypeError("x") + "\n}"); | 12596 toType.typeCheckCode = ("function $assert_" + toType.name + "(x) {\n if (
x == null || typeof(x) == \"" + toType.get$typeofName() + "\") return x;\n " +
throwTypeError("x") + "\n}"); |
12594 } | 12597 } |
12595 } | 12598 } |
12596 else { | 12599 else { |
12597 toType.isChecked = true; | 12600 toType.isChecked = true; |
12598 var checkName = 'assert\$' + toType.get$jsname(); | 12601 var checkName = 'assert\$' + toType.get$jsname(); |
12599 var temp = context.getTemp(this); | 12602 var temp = context.getTemp(this); |
12600 check = ('(' + context.assignTemp(temp, this).code + ' == null ? null :'); | 12603 check = ('(' + context.assignTemp(temp, this).code + ' == null ? null :'); |
12601 check = check + (' ' + temp.get$code() + '.' + checkName + '())'); | 12604 check = check + (' ' + temp.get$code() + '.' + checkName + '())'); |
12602 if ($ne(this, temp)) context.freeTemp(temp); | 12605 if ($ne(this, temp)) context.freeTemp(temp); |
12603 if (!$globals.world.objectType.varStubs.containsKey(checkName)) { | 12606 $globals.world.objectType.varStubs.putIfAbsent(checkName, (function () { |
12604 $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub(
checkName, null, Arguments.get$EMPTY(), throwTypeError('this'))); | 12607 return new VarMethodStub(checkName, null, Arguments.get$EMPTY(), throwType
Error('this')); |
12605 } | 12608 }) |
| 12609 ); |
12606 } | 12610 } |
12607 return new Value(toType, check, this.span, true); | 12611 return new Value(toType, check, this.span, true); |
12608 } | 12612 } |
12609 Value.prototype.instanceOf = function(context, toType, span, isTrue, forceCheck)
{ | 12613 Value.prototype.instanceOf = function(context, toType, span, isTrue, forceCheck)
{ |
12610 if (toType.get$isVar()) { | 12614 if (toType.get$isVar()) { |
12611 $globals.world.error('can not resolve type', span); | 12615 $globals.world.error('can not resolve type', span); |
12612 } | 12616 } |
12613 var testCode = null; | 12617 var testCode = null; |
12614 if (toType.get$isVar() || toType.get$isObject() || (toType instanceof Paramete
rType)) { | 12618 if (toType.get$isVar() || toType.get$isObject() || (toType instanceof Paramete
rType)) { |
12615 if (this.needsTemp) { | 12619 if (this.needsTemp) { |
(...skipping 28 matching lines...) Expand all Loading... |
12644 else { | 12648 else { |
12645 testCode = '!' + testCode; | 12649 testCode = '!' + testCode; |
12646 } | 12650 } |
12647 if ($ne(this, temp)) context.freeTemp(temp); | 12651 if ($ne(this, temp)) context.freeTemp(temp); |
12648 if (!$globals.world.objectType.varStubs.containsKey(checkName)) { | 12652 if (!$globals.world.objectType.varStubs.containsKey(checkName)) { |
12649 $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub(
checkName, null, Arguments.get$EMPTY(), 'return false')); | 12653 $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub(
checkName, null, Arguments.get$EMPTY(), 'return false')); |
12650 } | 12654 } |
12651 } | 12655 } |
12652 return new Value($globals.world.nonNullBool, testCode, span, true); | 12656 return new Value($globals.world.nonNullBool, testCode, span, true); |
12653 } | 12657 } |
12654 Value.prototype.convertWarning = function(toType, node) { | 12658 Value.prototype.convertWarning = function(toType) { |
12655 $globals.world.warning(('type "' + this.get$type().name + '" is not assignable
to "' + toType.name + '"'), node.span); | 12659 $globals.world.warning(('type "' + this.get$type().name + '" is not assignable
to "' + toType.name + '"'), this.span); |
12656 } | 12660 } |
12657 Value.prototype.invokeNoSuchMethod = function(context, name, node, args) { | 12661 Value.prototype.invokeNoSuchMethod = function(context, name, node, args) { |
12658 var pos = ''; | 12662 var pos = ''; |
12659 if (args != null) { | 12663 if (args != null) { |
12660 var argsCode = []; | 12664 var argsCode = []; |
12661 for (var i = 0; | 12665 for (var i = 0; |
12662 i < args.get$length(); i++) { | 12666 i < args.get$length(); i++) { |
12663 argsCode.add$1(args.values.$index(i).get$code()); | 12667 argsCode.add$1(args.values.$index(i).get$code()); |
12664 } | 12668 } |
12665 pos = Strings.join(argsCode, ", "); | 12669 pos = Strings.join(argsCode, ", "); |
12666 } | 12670 } |
12667 var noSuchArgs = [new Value($globals.world.stringType, ('"' + name + '"'), nod
e.span, true), new Value($globals.world.listType, ('[' + pos + ']'), node.span,
true)]; | 12671 var noSuchArgs = [new Value($globals.world.stringType, ('"' + name + '"'), nod
e.span, true), new Value($globals.world.listType, ('[' + pos + ']'), node.span,
true)]; |
12668 return this._resolveMember(context, 'noSuchMethod', node, false).invoke$4(cont
ext, node, this, new Arguments(null, noSuchArgs)); | 12672 return this._resolveMember(context, 'noSuchMethod', node, false).invoke$4(cont
ext, node, this, new Arguments(null, noSuchArgs)); |
12669 } | 12673 } |
12670 Value.prototype._wrapDomCallback$2 = Value.prototype._wrapDomCallback; | |
12671 Value.prototype.checkFirstClass$1 = Value.prototype.checkFirstClass; | 12674 Value.prototype.checkFirstClass$1 = Value.prototype.checkFirstClass; |
12672 Value.prototype.convertTo$3 = function($0, $1, $2) { | 12675 Value.prototype.convertTo$2 = function($0, $1) { |
12673 return this.convertTo($0, $1, $2, false); | 12676 return this.convertTo($0, $1, false); |
12674 }; | 12677 }; |
12675 Value.prototype.convertTo$4 = Value.prototype.convertTo; | 12678 Value.prototype.convertTo$3 = Value.prototype.convertTo; |
12676 Value.prototype.get_$3 = Value.prototype.get_; | 12679 Value.prototype.get_$3 = Value.prototype.get_; |
12677 Value.prototype.instanceOf$3$isTrue$forceCheck = Value.prototype.instanceOf; | 12680 Value.prototype.instanceOf$3$isTrue$forceCheck = Value.prototype.instanceOf; |
12678 Value.prototype.instanceOf$4 = function($0, $1, $2, $3) { | 12681 Value.prototype.instanceOf$4 = function($0, $1, $2, $3) { |
12679 return this.instanceOf($0, $1, $2, $3, false); | 12682 return this.instanceOf($0, $1, $2, $3, false); |
12680 }; | 12683 }; |
12681 Value.prototype.invoke$4 = function($0, $1, $2, $3) { | 12684 Value.prototype.invoke$4 = function($0, $1, $2, $3) { |
12682 return this.invoke($0, $1, $2, $3, false); | 12685 return this.invoke($0, $1, $2, $3, false); |
12683 }; | 12686 }; |
12684 Value.prototype.invoke$4$isDynamic = Value.prototype.invoke; | 12687 Value.prototype.invoke$4$isDynamic = Value.prototype.invoke; |
12685 Value.prototype.invoke$5 = Value.prototype.invoke; | 12688 Value.prototype.invoke$5 = Value.prototype.invoke; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12911 this.jsBytesWritten = 0 | 12914 this.jsBytesWritten = 0 |
12912 this.seenFatal = false | 12915 this.seenFatal = false |
12913 this.files = files; | 12916 this.files = files; |
12914 this.libraries = new HashMapImplementation(); | 12917 this.libraries = new HashMapImplementation(); |
12915 this._todo = []; | 12918 this._todo = []; |
12916 this._members = new HashMapImplementation(); | 12919 this._members = new HashMapImplementation(); |
12917 this._topNames = new HashMapImplementation(); | 12920 this._topNames = new HashMapImplementation(); |
12918 this.reader = new LibraryReader(); | 12921 this.reader = new LibraryReader(); |
12919 // Initializers done | 12922 // Initializers done |
12920 } | 12923 } |
12921 World.prototype.get$coreimpl = function() { | |
12922 return this.libraries.$index('dart:coreimpl'); | |
12923 } | |
12924 World.prototype.get$dom = function() { | |
12925 return this.libraries.$index('dart:dom'); | |
12926 } | |
12927 World.prototype.get$functionType = function() { return this.functionType; }; | 12924 World.prototype.get$functionType = function() { return this.functionType; }; |
12928 World.prototype.set$functionType = function(value) { return this.functionType =
value; }; | 12925 World.prototype.set$functionType = function(value) { return this.functionType =
value; }; |
12929 World.prototype.init = function() { | 12926 World.prototype.init = function() { |
12930 this.corelib = new Library(this.readFile('dart:core')); | 12927 this.corelib = new Library(this.readFile('dart:core')); |
12931 this.libraries.$setindex('dart:core', this.corelib); | 12928 this.libraries.$setindex('dart:core', this.corelib); |
12932 this._todo.add(this.corelib); | 12929 this._todo.add(this.corelib); |
12933 this.voidType = this._addToCoreLib('void', false); | 12930 this.coreimpl = this.getOrAddLibrary('dart:coreimpl'); |
12934 this.dynamicType = this._addToCoreLib('Dynamic', false); | 12931 this.voidType = this.corelib.addType('void', null, false); |
| 12932 this.dynamicType = this.corelib.addType('Dynamic', null, false); |
12935 this.varType = this.dynamicType; | 12933 this.varType = this.dynamicType; |
12936 this.objectType = this._addToCoreLib('Object', true); | 12934 this.objectType = this.corelib.addType('Object', null, true); |
12937 this.numType = this._addToCoreLib('num', false); | 12935 this.numType = this.corelib.addType('num', null, false); |
12938 this.intType = this._addToCoreLib('int', false); | 12936 this.intType = this.corelib.addType('int', null, false); |
12939 this.doubleType = this._addToCoreLib('double', false); | 12937 this.doubleType = this.corelib.addType('double', null, false); |
12940 this.boolType = this._addToCoreLib('bool', false); | 12938 this.boolType = this.corelib.addType('bool', null, false); |
12941 this.stringType = this._addToCoreLib('String', false); | 12939 this.stringType = this.corelib.addType('String', null, false); |
12942 this.listType = this._addToCoreLib('List', false); | 12940 this.listType = this.corelib.addType('List', null, false); |
12943 this.mapType = this._addToCoreLib('Map', false); | 12941 this.mapType = this.corelib.addType('Map', null, false); |
12944 this.functionType = this._addToCoreLib('Function', false); | 12942 this.functionType = this.corelib.addType('Function', null, false); |
| 12943 this.typeErrorType = this.corelib.addType('TypeError', null, false); |
| 12944 this.numImplType = this.coreimpl.addType('NumImplementation', null, true); |
| 12945 this.stringImplType = this.coreimpl.addType('StringImplementation', null, true
); |
| 12946 this.immutableListType = this.coreimpl.addType('ImmutableList', null, true); |
| 12947 this.listFactoryType = this.coreimpl.addType('ListFactory', null, true); |
| 12948 this.functionImplType = this.coreimpl.addType('_FunctionImplementation', null,
true); |
12945 this.nonNullBool = new NonNullableType(this.boolType); | 12949 this.nonNullBool = new NonNullableType(this.boolType); |
12946 } | 12950 } |
12947 World.prototype._addMember = function(member) { | 12951 World.prototype._addMember = function(member) { |
12948 if (member.get$isStatic()) { | 12952 if (member.get$isStatic()) { |
12949 if (member.declaringType.get$isTop()) { | 12953 if (member.declaringType.get$isTop()) { |
12950 this._addTopName(member); | 12954 this._addTopName(member); |
12951 } | 12955 } |
12952 return; | 12956 return; |
12953 } | 12957 } |
12954 var mset = this._members.$index(member.name); | 12958 var mset = this._members.$index(member.name); |
12955 if (mset == null) { | 12959 if (mset == null) { |
12956 mset = new MemberSet(member, true); | 12960 mset = new MemberSet(member, true); |
12957 this._members.$setindex(mset.get$name(), mset); | 12961 this._members.$setindex(mset.get$name(), mset); |
12958 } | 12962 } |
12959 else { | 12963 else { |
12960 mset.get$members().add$1(member); | 12964 mset.get$members().add$1(member); |
12961 } | 12965 } |
12962 } | 12966 } |
12963 World.prototype._addTopName = function(named) { | 12967 World.prototype._addTopName = function(named) { |
12964 if (named.get$nativeName() != null) { | 12968 if ((named instanceof Type) && named.get$isNative()) { |
12965 this._addJavascriptTopName(named, named.get$nativeName()); | 12969 this._addJavascriptTopName(named, named.get$nativeName()); |
12966 } | 12970 } |
12967 this._addJavascriptTopName(named, named.get$jsname()); | 12971 this._addJavascriptTopName(named, named.get$jsname()); |
12968 } | 12972 } |
12969 World.prototype._addJavascriptTopName = function(named, name) { | 12973 World.prototype._addJavascriptTopName = function(named, name) { |
12970 var existing = this._topNames.$index(name); | 12974 var existing = this._topNames.$index(name); |
12971 if (existing === named) { | 12975 if (existing === named) { |
12972 if (named.get$avoidNativeName()) { | 12976 if (named.get$avoidNativeName()) { |
12973 this._renameJavascriptTopName(named); | 12977 this._renameJavascriptTopName(named); |
12974 } | 12978 } |
(...skipping 26 matching lines...) Expand all Loading... |
13001 named._jsname = ('' + named.get$library().get$jsname() + '_' + named.get$jsnam
e()); | 13005 named._jsname = ('' + named.get$library().get$jsname() + '_' + named.get$jsnam
e()); |
13002 var existing = this._topNames.$index(named.get$jsname()); | 13006 var existing = this._topNames.$index(named.get$jsname()); |
13003 if (existing != null && $ne(existing, named)) { | 13007 if (existing != null && $ne(existing, named)) { |
13004 $globals.world.internalError(('name mangling failed for "' + named.get$jsnam
e() + '" ') + ('("' + named.get$jsname() + '" defined also in ' + existing.get$s
pan().get$locationText() + ')'), named.get$span()); | 13008 $globals.world.internalError(('name mangling failed for "' + named.get$jsnam
e() + '" ') + ('("' + named.get$jsname() + '" defined also in ' + existing.get$s
pan().get$locationText() + ')'), named.get$span()); |
13005 } | 13009 } |
13006 this._topNames.$setindex(named.get$jsname(), named); | 13010 this._topNames.$setindex(named.get$jsname(), named); |
13007 } | 13011 } |
13008 World.prototype._addType = function(type) { | 13012 World.prototype._addType = function(type) { |
13009 if (!type.get$isTop()) this._addTopName(type); | 13013 if (!type.get$isTop()) this._addTopName(type); |
13010 } | 13014 } |
13011 World.prototype._addToCoreLib = function(name, isClass) { | |
13012 var ret = new DefinedType(name, this.corelib, null, isClass); | |
13013 this.corelib.types.$setindex(name, ret); | |
13014 return ret; | |
13015 } | |
13016 World.prototype.toJsIdentifier = function(name) { | 13015 World.prototype.toJsIdentifier = function(name) { |
13017 if (name == null) return null; | 13016 if (name == null) return null; |
13018 if (this._jsKeywords == null) { | 13017 if (this._jsKeywords == null) { |
13019 this._jsKeywords = HashSetImplementation.HashSetImplementation$from$factory(
['break', 'case', 'catch', 'continue', 'debugger', 'default', 'delete', 'do', 'e
lse', 'finally', 'for', 'function', 'if', 'in', 'instanceof', 'new', 'return', '
switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'clas
s', 'enum', 'export', 'extends', 'import', 'super', 'implements', 'interface', '
let', 'package', 'private', 'protected', 'public', 'static', 'yield', 'native'])
; | 13018 this._jsKeywords = HashSetImplementation.HashSetImplementation$from$factory(
['break', 'case', 'catch', 'continue', 'debugger', 'default', 'delete', 'do', 'e
lse', 'finally', 'for', 'function', 'if', 'in', 'instanceof', 'new', 'return', '
switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'clas
s', 'enum', 'export', 'extends', 'import', 'super', 'implements', 'interface', '
let', 'package', 'private', 'protected', 'public', 'static', 'yield', 'native'])
; |
13020 } | 13019 } |
13021 if (this._jsKeywords.contains(name)) { | 13020 if (this._jsKeywords.contains(name)) { |
13022 return name + '_'; | 13021 return name + '_'; |
13023 } | 13022 } |
13024 else { | 13023 else { |
13025 return name.replaceAll("$", "$$").replaceAll(':', "$"); | 13024 return name.replaceAll("$", "$$").replaceAll(':', "$"); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13117 library = new Library(this.readFile(filename)); | 13116 library = new Library(this.readFile(filename)); |
13118 this.info(('read library ' + filename)); | 13117 this.info(('read library ' + filename)); |
13119 if (!library.get$isCore() && !library.imports.some((function (li) { | 13118 if (!library.get$isCore() && !library.imports.some((function (li) { |
13120 return li.get$library().get$isCore(); | 13119 return li.get$library().get$isCore(); |
13121 }) | 13120 }) |
13122 )) { | 13121 )) { |
13123 library.imports.add(new LibraryImport(this.corelib)); | 13122 library.imports.add(new LibraryImport(this.corelib)); |
13124 } | 13123 } |
13125 this.libraries.$setindex(filename, library); | 13124 this.libraries.$setindex(filename, library); |
13126 this._todo.add(library); | 13125 this._todo.add(library); |
| 13126 if (filename == 'dart:dom') { |
| 13127 this.dom = library; |
| 13128 } |
13127 } | 13129 } |
13128 return library; | 13130 return library; |
13129 } | 13131 } |
13130 World.prototype.process = function() { | 13132 World.prototype.process = function() { |
13131 while (this._todo.get$length() > 0) { | 13133 while (this._todo.get$length() > 0) { |
13132 var todo = this._todo; | 13134 var todo = this._todo; |
13133 this._todo = []; | 13135 this._todo = []; |
13134 for (var $$i = 0;$$i < todo.get$length(); $$i++) { | 13136 for (var $$i = 0;$$i < todo.get$length(); $$i++) { |
13135 var lib = todo.$index($$i); | 13137 var lib = todo.$index($$i); |
13136 lib.visitSources$0(); | 13138 lib.visitSources$0(); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13461 return new Value(this.get$returnType(), ('' + target.code + '.' + this.name +
'(' + args.getCode() + ')'), node.span, true); | 13463 return new Value(this.get$returnType(), ('' + target.code + '.' + this.name +
'(' + args.getCode() + ')'), node.span, true); |
13462 } | 13464 } |
13463 VarMember.prototype.generate$1 = VarMember.prototype.generate; | 13465 VarMember.prototype.generate$1 = VarMember.prototype.generate; |
13464 VarMember.prototype.invoke$4 = VarMember.prototype.invoke; | 13466 VarMember.prototype.invoke$4 = VarMember.prototype.invoke; |
13465 // ********** Code for VarFunctionStub ************** | 13467 // ********** Code for VarFunctionStub ************** |
13466 $inherits(VarFunctionStub, VarMember); | 13468 $inherits(VarFunctionStub, VarMember); |
13467 function VarFunctionStub(name, callArgs) { | 13469 function VarFunctionStub(name, callArgs) { |
13468 this.args = callArgs.toCallStubArgs(); | 13470 this.args = callArgs.toCallStubArgs(); |
13469 // Initializers done | 13471 // Initializers done |
13470 VarMember.call(this, name); | 13472 VarMember.call(this, name); |
13471 var funcImpl = $globals.world.get$coreimpl().types.$index('_FunctionImplementa
tion'); | 13473 $globals.world.functionImplType.markUsed(); |
13472 funcImpl.markUsed$0(); | 13474 $globals.world.gen.genMethod($globals.world.functionImplType.getMember('_genSt
ub')); |
13473 $globals.world.gen.genMethod(funcImpl.getMember$1('_genStub')); | |
13474 } | 13475 } |
13475 VarFunctionStub.prototype.invoke = function(context, node, target, args) { | 13476 VarFunctionStub.prototype.invoke = function(context, node, target, args) { |
13476 return VarMember.prototype.invoke.call(this, context, node, target, args); | 13477 return VarMember.prototype.invoke.call(this, context, node, target, args); |
13477 } | 13478 } |
13478 VarFunctionStub.prototype.generate = function(code) { | 13479 VarFunctionStub.prototype.generate = function(code) { |
13479 this.isGenerated = true; | 13480 this.isGenerated = true; |
13480 if (this.args.get$hasNames()) { | 13481 if (this.args.get$hasNames()) { |
13481 this.generateNamed(code); | 13482 this.generateNamed(code); |
13482 } | 13483 } |
13483 else { | 13484 else { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13796 $globals._RED_COLOR = '\u001b[31m'; | 13797 $globals._RED_COLOR = '\u001b[31m'; |
13797 } | 13798 } |
13798 var const$1 = new EmptyQueueException()/*const EmptyQueueException()*/; | 13799 var const$1 = new EmptyQueueException()/*const EmptyQueueException()*/; |
13799 var const$126 = new IllegalAccessException()/*const IllegalAccessException()*/; | 13800 var const$126 = new IllegalAccessException()/*const IllegalAccessException()*/; |
13800 var const$127 = ImmutableList.ImmutableList$from$factory([])/*const []*/; | 13801 var const$127 = ImmutableList.ImmutableList$from$factory([])/*const []*/; |
13801 var const$2 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; | 13802 var const$2 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; |
13802 var const$7 = new NoMoreElementsException()/*const NoMoreElementsException()*/; | 13803 var const$7 = new NoMoreElementsException()/*const NoMoreElementsException()*/; |
13803 var $globals = {}; | 13804 var $globals = {}; |
13804 $static_init(); | 13805 $static_init(); |
13805 main(); | 13806 main(); |
OLD | NEW |