| OLD | NEW |
| 1 #!/usr/bin/env node | 1 #!/usr/bin/env node |
| 2 // ********** Library dart:core ************** | 2 // ********** Library dart:core ************** |
| 3 // ********** Natives core.js ************** | 3 // ********** Natives core.js ************** |
| 4 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 4 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 5 // for details. All rights reserved. Use of this source code is governed by a | 5 // for details. All rights reserved. Use of this source code is governed by a |
| 6 // BSD-style license that can be found in the LICENSE file. | 6 // BSD-style license that can be found in the LICENSE file. |
| 7 | 7 |
| 8 // TODO(jimhug): Completeness - see tests/corelib | 8 // TODO(jimhug): Completeness - see tests/corelib |
| 9 | 9 |
| 10 /** Implements extends for dart classes on javascript prototypes. */ | 10 /** Implements extends for dart classes on javascript prototypes. */ |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; | 804 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; |
| 805 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; | 805 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; |
| 806 if ($notnull_bool(this._numberOfDeleted > numberOfFree)) { | 806 if ($notnull_bool(this._numberOfDeleted > numberOfFree)) { |
| 807 this._grow(this._keys.length); | 807 this._grow(this._keys.length); |
| 808 } | 808 } |
| 809 } | 809 } |
| 810 HashMapImplementation._isPowerOfTwo = function(x) { | 810 HashMapImplementation._isPowerOfTwo = function(x) { |
| 811 return ((x & (x - 1)) == 0); | 811 return ((x & (x - 1)) == 0); |
| 812 } | 812 } |
| 813 HashMapImplementation.prototype._grow = function(newCapacity) { | 813 HashMapImplementation.prototype._grow = function(newCapacity) { |
| 814 $assert(HashMapImplementation._isPowerOfTwo(newCapacity), "_isPowerOfTwo(newCa
pacity)", "/Volumes/Data/dart/dart/corelib/src/implementation/hash_map_set.dart"
, 153, 12); | 814 $assert(HashMapImplementation._isPowerOfTwo(newCapacity), "_isPowerOfTwo(newCa
pacity)", "/Users/jimhug/dartfrog/dart/corelib/src/implementation/hash_map_set.d
art", 153, 12); |
| 815 var capacity = this._keys.length; | 815 var capacity = this._keys.length; |
| 816 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); | 816 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); |
| 817 var oldKeys = this._keys; | 817 var oldKeys = this._keys; |
| 818 var oldValues = this._values; | 818 var oldValues = this._values; |
| 819 this._keys = new ListFactory(newCapacity); | 819 this._keys = new ListFactory(newCapacity); |
| 820 this._values = new ListFactory$V(newCapacity); | 820 this._values = new ListFactory$V(newCapacity); |
| 821 for (var i = 0; | 821 for (var i = 0; |
| 822 $notnull_bool(i < capacity); i++) { | 822 $notnull_bool(i < capacity); i++) { |
| 823 var key = oldKeys.$index(i); | 823 var key = oldKeys.$index(i); |
| 824 if ($notnull_bool(key == null || key === HashMapImplementation._deletedKey))
{ | 824 if ($notnull_bool(key == null || key === HashMapImplementation._deletedKey))
{ |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; | 971 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; |
| 972 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; | 972 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; |
| 973 if ($notnull_bool(this._numberOfDeleted > numberOfFree)) { | 973 if ($notnull_bool(this._numberOfDeleted > numberOfFree)) { |
| 974 this._grow(this._keys.length); | 974 this._grow(this._keys.length); |
| 975 } | 975 } |
| 976 } | 976 } |
| 977 HashMapImplementation$E$E._isPowerOfTwo = function(x) { | 977 HashMapImplementation$E$E._isPowerOfTwo = function(x) { |
| 978 return ((x & (x - 1)) == 0); | 978 return ((x & (x - 1)) == 0); |
| 979 } | 979 } |
| 980 HashMapImplementation$E$E.prototype._grow = function(newCapacity) { | 980 HashMapImplementation$E$E.prototype._grow = function(newCapacity) { |
| 981 $assert(HashMapImplementation._isPowerOfTwo(newCapacity), "_isPowerOfTwo(newCa
pacity)", "/Volumes/Data/dart/dart/corelib/src/implementation/hash_map_set.dart"
, 153, 12); | 981 $assert(HashMapImplementation._isPowerOfTwo(newCapacity), "_isPowerOfTwo(newCa
pacity)", "/Users/jimhug/dartfrog/dart/corelib/src/implementation/hash_map_set.d
art", 153, 12); |
| 982 var capacity = this._keys.length; | 982 var capacity = this._keys.length; |
| 983 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); | 983 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); |
| 984 var oldKeys = this._keys; | 984 var oldKeys = this._keys; |
| 985 var oldValues = this._values; | 985 var oldValues = this._values; |
| 986 this._keys = new ListFactory(newCapacity); | 986 this._keys = new ListFactory(newCapacity); |
| 987 this._values = new ListFactory$E(newCapacity); | 987 this._values = new ListFactory$E(newCapacity); |
| 988 for (var i = 0; | 988 for (var i = 0; |
| 989 $notnull_bool(i < capacity); i++) { | 989 $notnull_bool(i < capacity); i++) { |
| 990 var key = oldKeys.$index(i); | 990 var key = oldKeys.$index(i); |
| 991 if ($notnull_bool(key == null || key === HashMapImplementation._deletedKey))
{ | 991 if ($notnull_bool(key == null || key === HashMapImplementation._deletedKey))
{ |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 if ($notnull_bool(entry == null)) return null; | 1336 if ($notnull_bool(entry == null)) return null; |
| 1337 return entry.get$element().get$value(); | 1337 return entry.get$element().get$value(); |
| 1338 } | 1338 } |
| 1339 LinkedHashMapImplementation.prototype.getKeys = function() { | 1339 LinkedHashMapImplementation.prototype.getKeys = function() { |
| 1340 var list = new ListFactory$K(this.get$length()); | 1340 var list = new ListFactory$K(this.get$length()); |
| 1341 var index = 0; | 1341 var index = 0; |
| 1342 this._list.forEach(function _(entry) { | 1342 this._list.forEach(function _(entry) { |
| 1343 list.$setindex(index++, entry.key); | 1343 list.$setindex(index++, entry.key); |
| 1344 } | 1344 } |
| 1345 ); | 1345 ); |
| 1346 $assert(index == this.get$length(), "index == length", "/Volumes/Data/dart/dar
t/corelib/src/implementation/linked_hash_map.dart", 75, 12); | 1346 $assert(index == this.get$length(), "index == length", "/Users/jimhug/dartfrog
/dart/corelib/src/implementation/linked_hash_map.dart", 75, 12); |
| 1347 return list; | 1347 return list; |
| 1348 } | 1348 } |
| 1349 LinkedHashMapImplementation.prototype.getValues = function() { | 1349 LinkedHashMapImplementation.prototype.getValues = function() { |
| 1350 var list = new ListFactory$V(this.get$length()); | 1350 var list = new ListFactory$V(this.get$length()); |
| 1351 var index = 0; | 1351 var index = 0; |
| 1352 this._list.forEach(function _(entry) { | 1352 this._list.forEach(function _(entry) { |
| 1353 list.$setindex(index++, entry.value); | 1353 list.$setindex(index++, entry.value); |
| 1354 } | 1354 } |
| 1355 ); | 1355 ); |
| 1356 $assert(index == this.get$length(), "index == length", "/Volumes/Data/dart/dar
t/corelib/src/implementation/linked_hash_map.dart", 86, 12); | 1356 $assert(index == this.get$length(), "index == length", "/Users/jimhug/dartfrog
/dart/corelib/src/implementation/linked_hash_map.dart", 86, 12); |
| 1357 return list; | 1357 return list; |
| 1358 } | 1358 } |
| 1359 LinkedHashMapImplementation.prototype.forEach = function(f) { | 1359 LinkedHashMapImplementation.prototype.forEach = function(f) { |
| 1360 this._list.forEach(function _(entry) { | 1360 this._list.forEach(function _(entry) { |
| 1361 f(entry.key, entry.value); | 1361 f(entry.key, entry.value); |
| 1362 } | 1362 } |
| 1363 ); | 1363 ); |
| 1364 } | 1364 } |
| 1365 LinkedHashMapImplementation.prototype.containsKey = function(key) { | 1365 LinkedHashMapImplementation.prototype.containsKey = function(key) { |
| 1366 return this._map.containsKey(key); | 1366 return this._map.containsKey(key); |
| (...skipping 8822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10189 return new SourceSpan(this.baseSource, 0, 0); | 10189 return new SourceSpan(this.baseSource, 0, 0); |
| 10190 } | 10190 } |
| 10191 Library.prototype.makeFullPath = function(filename) { | 10191 Library.prototype.makeFullPath = function(filename) { |
| 10192 if ($notnull_bool(filename.startsWith('dart:'))) return filename; | 10192 if ($notnull_bool(filename.startsWith('dart:'))) return filename; |
| 10193 if ($notnull_bool(filename.startsWith('/'))) return filename; | 10193 if ($notnull_bool(filename.startsWith('/'))) return filename; |
| 10194 if ($notnull_bool(filename.startsWith('file:///'))) return filename; | 10194 if ($notnull_bool(filename.startsWith('file:///'))) return filename; |
| 10195 if ($notnull_bool(filename.startsWith('http://'))) return filename; | 10195 if ($notnull_bool(filename.startsWith('http://'))) return filename; |
| 10196 return joinPaths(this.sourceDir, filename); | 10196 return joinPaths(this.sourceDir, filename); |
| 10197 } | 10197 } |
| 10198 Library.prototype.addImport = function(fullname, prefix) { | 10198 Library.prototype.addImport = function(fullname, prefix) { |
| 10199 this.imports.add(new LibraryImport(world.getOrAddLibrary(fullname), prefix)); | 10199 var newLib = world.getOrAddLibrary(fullname); |
| 10200 this.imports.add(new LibraryImport(newLib, prefix)); |
| 10201 return newLib; |
| 10200 } | 10202 } |
| 10201 Library.prototype.addNative = function(fullname) { | 10203 Library.prototype.addNative = function(fullname) { |
| 10202 this.natives.add(world.reader.readFile(fullname)); | 10204 this.natives.add(world.reader.readFile(fullname)); |
| 10203 } | 10205 } |
| 10204 Library.prototype._findMembers = function(name0) { | 10206 Library.prototype._findMembers = function(name0) { |
| 10205 if ($notnull_bool(name0.startsWith('_'))) { | 10207 if ($notnull_bool(name0.startsWith('_'))) { |
| 10206 return this._privateMembers.$index(name0); | 10208 return this._privateMembers.$index(name0); |
| 10207 } | 10209 } |
| 10208 else { | 10210 else { |
| 10209 return world._members.$index(name0); | 10211 return world._members.$index(name0); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10348 if ($notnull_bool(index > 0)) { | 10350 if ($notnull_bool(index > 0)) { |
| 10349 this.name = this.name.substring(0, index); | 10351 this.name = this.name.substring(0, index); |
| 10350 } | 10352 } |
| 10351 } | 10353 } |
| 10352 var $list = this.types.getValues(); | 10354 var $list = this.types.getValues(); |
| 10353 for (var $i = this.types.getValues().iterator(); $i.hasNext(); ) { | 10355 for (var $i = this.types.getValues().iterator(); $i.hasNext(); ) { |
| 10354 var type = $i.next(); | 10356 var type = $i.next(); |
| 10355 type.resolve(); | 10357 type.resolve(); |
| 10356 } | 10358 } |
| 10357 } | 10359 } |
| 10360 Library.prototype.visitSources = function() { |
| 10361 var visitor = new _LibraryVisitor(this); |
| 10362 visitor.addSource(this.baseSource); |
| 10363 } |
| 10358 Library.prototype.toString = function() { | 10364 Library.prototype.toString = function() { |
| 10359 return this.baseSource.filename; | 10365 return this.baseSource.filename; |
| 10360 } | 10366 } |
| 10361 // ********** Code for LibraryVisitor ************** | 10367 // ********** Code for _LibraryVisitor ************** |
| 10362 function LibraryVisitor(library) { | 10368 function _LibraryVisitor(library) { |
| 10369 this.seenImport = false |
| 10370 this.seenSource = false |
| 10371 this.seenResource = false |
| 10372 this.isTop = true |
| 10363 this.library = library; | 10373 this.library = library; |
| 10364 // Initializers done | 10374 // Initializers done |
| 10365 this.currentType = this.library.topType; | 10375 this.currentType = this.library.topType; |
| 10366 this.sources = []; | 10376 this.sources = []; |
| 10367 this.addSource(this.library.baseSource); | |
| 10368 } | 10377 } |
| 10369 LibraryVisitor.prototype.get$library = function() { return this.library; }; | 10378 _LibraryVisitor.prototype.get$library = function() { return this.library; }; |
| 10370 LibraryVisitor.prototype.addSourceFromName = function(name) { | 10379 _LibraryVisitor.prototype.get$isTop = function() { return this.isTop; }; |
| 10380 _LibraryVisitor.prototype.set$isTop = function(value) { return this.isTop = valu
e; }; |
| 10381 _LibraryVisitor.prototype.addSourceFromName = function(name, span) { |
| 10382 var filename = this.library.makeFullPath(name); |
| 10383 if ($notnull_bool($eq(filename, this.library.baseSource.filename))) { |
| 10384 world.error('library can not source itself', span); |
| 10385 return; |
| 10386 } |
| 10387 else if ($notnull_bool(this.sources.some((function (s) { |
| 10388 return s.filename == filename; |
| 10389 }) |
| 10390 ))) { |
| 10391 world.error(('file "' + filename + '" has already been sourced'), span); |
| 10392 return; |
| 10393 } |
| 10371 var source = world.readFile(this.library.makeFullPath(name)); | 10394 var source = world.readFile(this.library.makeFullPath(name)); |
| 10372 this.sources.add(source); | 10395 this.sources.add(source); |
| 10373 } | 10396 } |
| 10374 LibraryVisitor.prototype.addSource = function(source) { | 10397 _LibraryVisitor.prototype.addSource = function(source) { |
| 10398 var $this = this; // closure support |
| 10375 var $0; | 10399 var $0; |
| 10400 if ($notnull_bool(this.library.sources.some((function (s) { |
| 10401 return s.filename == source.filename; |
| 10402 }) |
| 10403 ))) { |
| 10404 world.error(('duplicate source file "' + source.filename + '"')); |
| 10405 return; |
| 10406 } |
| 10376 this.library.sources.add(source); | 10407 this.library.sources.add(source); |
| 10377 var parser = new lang_Parser(source, options.dietParse, 0); | 10408 var parser = new lang_Parser(source, options.dietParse, 0); |
| 10378 var unit = parser.compilationUnit(); | 10409 var unit = parser.compilationUnit(); |
| 10379 for (var $i = 0;$i < unit.length; $i++) { | 10410 unit.forEach((function (def) { |
| 10380 var def = unit.$index($i); | 10411 return def.visit($this); |
| 10381 def.visit(this); | 10412 }) |
| 10382 } | 10413 ); |
| 10414 $assert(this.sources.length == 0 || this.isTop, "sources.length == 0 || isTop"
, "library.dart", 296, 12); |
| 10415 this.isTop = false; |
| 10383 var newSources = this.sources; | 10416 var newSources = this.sources; |
| 10384 this.sources = []; | 10417 this.sources = []; |
| 10385 for (var $i = newSources.iterator(); $i.hasNext(); ) { | 10418 for (var $i = newSources.iterator(); $i.hasNext(); ) { |
| 10386 var source0 = $i.next(); | 10419 var source0 = $i.next(); |
| 10387 this.addSource((source0 && source0.is$SourceFile())); | 10420 this.addSource((source0 && source0.is$SourceFile())); |
| 10388 } | 10421 } |
| 10389 } | 10422 } |
| 10390 LibraryVisitor.prototype.visitDirectiveDefinition = function(node) { | 10423 _LibraryVisitor.prototype.visitDirectiveDefinition = function(node) { |
| 10424 if ($notnull_bool(!this.isTop)) { |
| 10425 world.error('directives not allowed in sourced file', node.span); |
| 10426 return; |
| 10427 } |
| 10391 var name; | 10428 var name; |
| 10392 switch (node.name.name) { | 10429 switch (node.name.name) { |
| 10393 case "library": | 10430 case "library": |
| 10394 | 10431 |
| 10395 name = this.getSingleStringArg(node); | 10432 name = this.getSingleStringArg(node); |
| 10396 if ($notnull_bool(this.library.name == null)) { | 10433 if ($notnull_bool(this.library.name == null)) { |
| 10397 this.library.name = $assert_String(name); | 10434 this.library.name = $assert_String(name); |
| 10398 if ($notnull_bool($eq(name, 'node') || $eq(name, 'dom'))) { | 10435 if ($notnull_bool($eq(name, 'node') || $eq(name, 'dom'))) { |
| 10399 this.library.topType.isNativeType = true; | 10436 this.library.topType.isNativeType = true; |
| 10400 } | 10437 } |
| 10438 if ($notnull_bool(this.seenImport || this.seenSource || this.seenResourc
e)) { |
| 10439 world.error('#library must be first directive in file', node.span); |
| 10440 } |
| 10401 } | 10441 } |
| 10402 else { | 10442 else { |
| 10403 world.error('already specified library name', node.span); | 10443 world.error('already specified library name', node.span); |
| 10404 } | 10444 } |
| 10405 break; | 10445 break; |
| 10406 | 10446 |
| 10407 case "import": | 10447 case "import": |
| 10408 | 10448 |
| 10449 this.seenImport = true; |
| 10409 name = this.getFirstStringArg(node); | 10450 name = this.getFirstStringArg(node); |
| 10410 var prefix = this.tryGetNamedStringArg(node, 'prefix'); | 10451 var prefix = this.tryGetNamedStringArg(node, 'prefix'); |
| 10411 if ($notnull_bool(node.arguments.length > 2 || node.arguments.length == 2
&& prefix == null)) { | 10452 if ($notnull_bool(node.arguments.length > 2 || node.arguments.length == 2
&& prefix == null)) { |
| 10412 world.error('expected at most one "name" argument and one optional "pref
ix"' + (' but found ' + node.arguments.length + ''), node.span); | 10453 world.error('expected at most one "name" argument and one optional "pref
ix"' + (' but found ' + node.arguments.length + ''), node.span); |
| 10413 } | 10454 } |
| 10414 else if ($notnull_bool($ne(prefix, null) && prefix.indexOf('.', 0) >= 0))
{ | 10455 else if ($notnull_bool($ne(prefix, null) && prefix.indexOf('.', 0) >= 0))
{ |
| 10415 world.error('library prefix canot contain "."', node.span); | 10456 world.error('library prefix canot contain "."', node.span); |
| 10416 } | 10457 } |
| 10458 else if ($notnull_bool(this.seenSource || this.seenResource)) { |
| 10459 world.error('#imports must come before any #source or #resource', node.s
pan); |
| 10460 } |
| 10417 if ($notnull_bool($eq(prefix, ''))) prefix = null; | 10461 if ($notnull_bool($eq(prefix, ''))) prefix = null; |
| 10418 this.library.addImport(this.library.makeFullPath($assert_String(name)), $a
ssert_String(prefix)); | 10462 var filename = this.library.makeFullPath($assert_String(name)); |
| 10463 if ($notnull_bool(this.library.imports.some((function (li) { |
| 10464 return $eq(li.get$library().baseSource, filename); |
| 10465 }) |
| 10466 ))) { |
| 10467 world.error(('duplicate import of "' + name + '"'), node.span); |
| 10468 return; |
| 10469 } |
| 10470 var newLib = this.library.addImport($assert_String(filename), $assert_Stri
ng(prefix)); |
| 10471 if ($notnull_bool(newLib.get$name() == null && !filename.startsWith('dart:
'))) { |
| 10472 world.info(('imported library "' + name + '" has no #library directive')
, node.span); |
| 10473 } |
| 10419 break; | 10474 break; |
| 10420 | 10475 |
| 10421 case "source": | 10476 case "source": |
| 10422 | 10477 |
| 10478 this.seenSource = true; |
| 10423 name = this.getSingleStringArg(node); | 10479 name = this.getSingleStringArg(node); |
| 10424 this.addSourceFromName($assert_String(name)); | 10480 this.addSourceFromName($assert_String(name), node.span); |
| 10481 if ($notnull_bool(this.seenResource)) { |
| 10482 world.error('#sources must come before any #resource', node.span); |
| 10483 } |
| 10425 break; | 10484 break; |
| 10426 | 10485 |
| 10427 case "native": | 10486 case "native": |
| 10428 | 10487 |
| 10429 name = this.getSingleStringArg(node); | 10488 name = this.getSingleStringArg(node); |
| 10430 this.library.addNative(this.library.makeFullPath($assert_String(name))); | 10489 this.library.addNative(this.library.makeFullPath($assert_String(name))); |
| 10431 break; | 10490 break; |
| 10432 | 10491 |
| 10433 case "resource": | 10492 case "resource": |
| 10434 | 10493 |
| 10494 this.seenResource = true; |
| 10435 this.getFirstStringArg(node); | 10495 this.getFirstStringArg(node); |
| 10436 break; | 10496 break; |
| 10437 | 10497 |
| 10438 default: | 10498 default: |
| 10439 | 10499 |
| 10440 world.error(('unknown directive: ' + node.name.name + ''), node.span); | 10500 world.error(('unknown directive: ' + node.name.name + ''), node.span); |
| 10441 | 10501 |
| 10442 } | 10502 } |
| 10443 } | 10503 } |
| 10444 LibraryVisitor.prototype.getSingleStringArg = function(node) { | 10504 _LibraryVisitor.prototype.getSingleStringArg = function(node) { |
| 10445 if ($notnull_bool(node.arguments.length != 1)) { | 10505 if ($notnull_bool(node.arguments.length != 1)) { |
| 10446 world.error(('expected exactly one argument but found ' + node.arguments.len
gth + ''), node.span); | 10506 world.error(('expected exactly one argument but found ' + node.arguments.len
gth + ''), node.span); |
| 10447 } | 10507 } |
| 10448 return this.getFirstStringArg(node); | 10508 return this.getFirstStringArg(node); |
| 10449 } | 10509 } |
| 10450 LibraryVisitor.prototype.getFirstStringArg = function(node) { | 10510 _LibraryVisitor.prototype.getFirstStringArg = function(node) { |
| 10451 if ($notnull_bool(node.arguments.length < 1)) { | 10511 if ($notnull_bool(node.arguments.length < 1)) { |
| 10452 world.error(('expected at least one argument but found ' + node.arguments.le
ngth + ''), node.span); | 10512 world.error(('expected at least one argument but found ' + node.arguments.le
ngth + ''), node.span); |
| 10453 } | 10513 } |
| 10454 var arg = node.arguments.$index(0); | 10514 var arg = node.arguments.$index(0); |
| 10455 if ($notnull_bool(arg.label != null)) { | 10515 if ($notnull_bool(arg.label != null)) { |
| 10456 world.error('label not allowed for directive', node.span); | 10516 world.error('label not allowed for directive', node.span); |
| 10457 } | 10517 } |
| 10458 return this._parseStringArgument((arg && arg.is$ArgumentNode())); | 10518 return this._parseStringArgument((arg && arg.is$ArgumentNode())); |
| 10459 } | 10519 } |
| 10460 LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) { | 10520 _LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) { |
| 10461 var $0; | 10521 var $0; |
| 10462 var args = node.arguments.filter((function (a) { | 10522 var args = node.arguments.filter((function (a) { |
| 10463 return a.label != null && a.label.name == argName; | 10523 return a.label != null && a.label.name == argName; |
| 10464 }) | 10524 }) |
| 10465 ); | 10525 ); |
| 10466 if ($notnull_bool(args.length == 0)) { | 10526 if ($notnull_bool(args.length == 0)) { |
| 10467 return null; | 10527 return null; |
| 10468 } | 10528 } |
| 10469 if ($notnull_bool(args.length > 1)) { | 10529 if ($notnull_bool(args.length > 1)) { |
| 10470 world.error(('expected at most one "' + argName + '" argument but found ') +
node.arguments.length, node.span); | 10530 world.error(('expected at most one "' + argName + '" argument but found ') +
node.arguments.length, node.span); |
| 10471 } | 10531 } |
| 10472 for (var $i = args.iterator(); $i.hasNext(); ) { | 10532 for (var $i = args.iterator(); $i.hasNext(); ) { |
| 10473 var arg = $i.next(); | 10533 var arg = $i.next(); |
| 10474 return this._parseStringArgument((arg && arg.is$ArgumentNode())); | 10534 return this._parseStringArgument((arg && arg.is$ArgumentNode())); |
| 10475 } | 10535 } |
| 10476 } | 10536 } |
| 10477 LibraryVisitor.prototype._parseStringArgument = function(arg) { | 10537 _LibraryVisitor.prototype._parseStringArgument = function(arg) { |
| 10478 var expr = arg.value; | 10538 var expr = arg.value; |
| 10479 if ($notnull_bool(!(expr instanceof LiteralExpression) || !expr.type.type.get$
isString())) { | 10539 if ($notnull_bool(!(expr instanceof LiteralExpression) || !expr.type.type.get$
isString())) { |
| 10480 world.error('expected string', expr.get$span()); | 10540 world.error('expected string', expr.get$span()); |
| 10481 } | 10541 } |
| 10482 return parseStringLiteral($assert_String(expr.get$value())); | 10542 return parseStringLiteral($assert_String(expr.get$value())); |
| 10483 } | 10543 } |
| 10484 LibraryVisitor.prototype.visitTypeDefinition = function(node) { | 10544 _LibraryVisitor.prototype.visitTypeDefinition = function(node) { |
| 10485 var oldType = this.currentType; | 10545 var oldType = this.currentType; |
| 10486 this.currentType = this.library.addType(node.name.name, node, node.isClass); | 10546 this.currentType = this.library.addType(node.name.name, node, node.isClass); |
| 10487 var $list = node.body; | 10547 var $list = node.body; |
| 10488 for (var $i = 0;$i < $list.length; $i++) { | 10548 for (var $i = 0;$i < $list.length; $i++) { |
| 10489 var member = $list.$index($i); | 10549 var member = $list.$index($i); |
| 10490 member.visit(this); | 10550 member.visit(this); |
| 10491 } | 10551 } |
| 10492 this.currentType = (oldType && oldType.is$lang_Type()); | 10552 this.currentType = (oldType && oldType.is$lang_Type()); |
| 10493 } | 10553 } |
| 10494 LibraryVisitor.prototype.visitVariableDefinition = function(node) { | 10554 _LibraryVisitor.prototype.visitVariableDefinition = function(node) { |
| 10495 this.currentType.addField(node); | 10555 this.currentType.addField(node); |
| 10496 } | 10556 } |
| 10497 LibraryVisitor.prototype.visitFunctionDefinition = function(node) { | 10557 _LibraryVisitor.prototype.visitFunctionDefinition = function(node) { |
| 10498 this.currentType.addMethod(node.name.name, node); | 10558 this.currentType.addMethod(node.name.name, node); |
| 10499 } | 10559 } |
| 10500 LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) { | 10560 _LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) { |
| 10501 var type = this.library.addType(node.func.name.name, node, false); | 10561 var type = this.library.addType(node.func.name.name, node, false); |
| 10502 type.addMethod('\$call', node.func); | 10562 type.addMethod('\$call', node.func); |
| 10503 } | 10563 } |
| 10504 // ********** Code for lang_Parameter ************** | 10564 // ********** Code for lang_Parameter ************** |
| 10505 function lang_Parameter(definition) { | 10565 function lang_Parameter(definition) { |
| 10506 this.definition = definition; | 10566 this.definition = definition; |
| 10507 // Initializers done | 10567 // Initializers done |
| 10508 } | 10568 } |
| 10509 lang_Parameter.prototype.get$definition = function() { return this.definition; }
; | 10569 lang_Parameter.prototype.get$definition = function() { return this.definition; }
; |
| 10510 lang_Parameter.prototype.set$definition = function(value) { return this.definiti
on = value; }; | 10570 lang_Parameter.prototype.set$definition = function(value) { return this.definiti
on = value; }; |
| 10511 lang_Parameter.prototype.get$name = function() { return this.name; }; | 10571 lang_Parameter.prototype.get$name = function() { return this.name; }; |
| 10512 lang_Parameter.prototype.set$name = function(value) { return this.name = value;
}; | 10572 lang_Parameter.prototype.set$name = function(value) { return this.name = value;
}; |
| 10513 lang_Parameter.prototype.get$value = function() { return this.value; }; | 10573 lang_Parameter.prototype.get$value = function() { return this.value; }; |
| 10514 lang_Parameter.prototype.set$value = function(value) { return this.value = value
; }; | 10574 lang_Parameter.prototype.set$value = function(value) { return this.value = value
; }; |
| 10515 lang_Parameter.prototype.resolve = function(inType) { | 10575 lang_Parameter.prototype.resolve = function(method, inType) { |
| 10516 this.name = this.definition.name.name; | 10576 this.name = this.definition.name.name; |
| 10517 this.type = inType.resolveType(this.definition.type, false); | 10577 this.type = inType.resolveType(this.definition.type, false); |
| 10578 if ($notnull_bool(method.get$isStatic() && this.type.get$hasTypeParams())) { |
| 10579 world.error('using type parameter in static context', this.definition.span); |
| 10580 } |
| 10581 if ($notnull_bool(this.definition.value != null)) { |
| 10582 if ($notnull_bool((this.definition.value instanceof NullExpression) && this.
definition.value.span.start == this.definition.span.start)) { |
| 10583 return; |
| 10584 } |
| 10585 if ($notnull_bool(method.get$isAbstract())) { |
| 10586 world.error('default value not allowed on abstract methods', this.definiti
on.span); |
| 10587 } |
| 10588 else if ($notnull_bool(!inType.get$isClass())) { |
| 10589 world.error('default value not allowed on interface methods', this.definit
ion.span); |
| 10590 } |
| 10591 else if ($notnull_bool(method.name == '\$call' && method.get$definition().bo
dy == null)) { |
| 10592 world.error('default value not allowed on function type', this.definition.
span); |
| 10593 } |
| 10594 } |
| 10518 } | 10595 } |
| 10519 lang_Parameter.prototype.genValue = function(method, context) { | 10596 lang_Parameter.prototype.genValue = function(method, context) { |
| 10520 var $0; | 10597 var $0; |
| 10521 if ($notnull_bool(this.definition.value == null || this.value != null)) return
; | 10598 if ($notnull_bool(this.definition.value == null || this.value != null)) return
; |
| 10522 if ($notnull_bool(context == null)) { | 10599 if ($notnull_bool(context == null)) { |
| 10523 context = new MethodGenerator(method, null); | 10600 context = new MethodGenerator(method, null); |
| 10524 } | 10601 } |
| 10525 this.value = (($0 = this.definition.value.visit(context)) && $0.is$Value()); | 10602 this.value = (($0 = this.definition.value.visit(context)) && $0.is$Value()); |
| 10526 this.value = this.value.convertTo(context, this.type, this.definition.value, f
alse); | 10603 this.value = this.value.convertTo(context, this.type, this.definition.value, f
alse); |
| 10527 } | 10604 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10607 world.error('static members can not hide parent members', this.get$span(), o
ther.get$span()); | 10684 world.error('static members can not hide parent members', this.get$span(), o
ther.get$span()); |
| 10608 return false; | 10685 return false; |
| 10609 } | 10686 } |
| 10610 else if ($notnull_bool(other.get$isStatic())) { | 10687 else if ($notnull_bool(other.get$isStatic())) { |
| 10611 world.error('can not override static member', this.get$span(), other.get$spa
n()); | 10688 world.error('can not override static member', this.get$span(), other.get$spa
n()); |
| 10612 return false; | 10689 return false; |
| 10613 } | 10690 } |
| 10614 return true; | 10691 return true; |
| 10615 } | 10692 } |
| 10616 Member.prototype.get$generatedFactoryName = function() { | 10693 Member.prototype.get$generatedFactoryName = function() { |
| 10617 $assert(this.get$isFactory(), "this.isFactory", "member.dart", 132, 12); | 10694 $assert(this.get$isFactory(), "this.isFactory", "member.dart", 157, 12); |
| 10618 var prefix = ('' + this.declaringType.get$jsname() + '.' + this.get$constructo
rName() + '\$'); | 10695 var prefix = ('' + this.declaringType.get$jsname() + '.' + this.get$constructo
rName() + '\$'); |
| 10619 if ($notnull_bool(this.name == '')) { | 10696 if ($notnull_bool(this.name == '')) { |
| 10620 return ('' + prefix + 'factory'); | 10697 return ('' + prefix + 'factory'); |
| 10621 } | 10698 } |
| 10622 else { | 10699 else { |
| 10623 return ('' + prefix + '' + this.name + '\$factory'); | 10700 return ('' + prefix + '' + this.name + '\$factory'); |
| 10624 } | 10701 } |
| 10625 } | 10702 } |
| 10626 Member.prototype.get_$3 = function($0, $1, $2) { | 10703 Member.prototype.get_$3 = function($0, $1, $2) { |
| 10627 return this.get_(($0 && $0.is$MethodGenerator()), ($1 && $1.is$lang_Node()), (
$2 && $2.is$Value())); | 10704 return this.get_(($0 && $0.is$MethodGenerator()), ($1 && $1.is$lang_Node()), (
$2 && $2.is$Value())); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 10657 TypeMember.prototype.get$canGet = function() { | 10734 TypeMember.prototype.get$canGet = function() { |
| 10658 return true; | 10735 return true; |
| 10659 } | 10736 } |
| 10660 TypeMember.prototype.get$canSet = function() { | 10737 TypeMember.prototype.get$canSet = function() { |
| 10661 return false; | 10738 return false; |
| 10662 } | 10739 } |
| 10663 TypeMember.prototype.resolve = function(inType) { | 10740 TypeMember.prototype.resolve = function(inType) { |
| 10664 | 10741 |
| 10665 } | 10742 } |
| 10666 TypeMember.prototype.get_ = function(context, node, target, isDynamic) { | 10743 TypeMember.prototype.get_ = function(context, node, target, isDynamic) { |
| 10667 $assert(target == null || target.type.get$isTop(), "target == null || target.t
ype.isTop", "member.dart", 170, 12); | 10744 $assert(target == null || target.type.get$isTop(), "target == null || target.t
ype.isTop", "member.dart", 195, 12); |
| 10668 return new Value(this.type, this.type.get$jsname(), false, false, true); | 10745 return new Value(this.type, this.type.get$jsname(), false, false, true); |
| 10669 } | 10746 } |
| 10670 TypeMember.prototype.set_ = function(context, node, target, value, isDynamic) { | 10747 TypeMember.prototype.set_ = function(context, node, target, value, isDynamic) { |
| 10671 world.error('can not set type', this.type.definition.span); | 10748 world.error('can not set type', this.type.definition.span); |
| 10672 } | 10749 } |
| 10673 TypeMember.prototype.invoke = function(context, node, target, args, isDynamic) { | 10750 TypeMember.prototype.invoke = function(context, node, target, args, isDynamic) { |
| 10674 world.error('can not invoke type', this.type.definition.span); | 10751 world.error('can not invoke type', this.type.definition.span); |
| 10675 } | 10752 } |
| 10676 TypeMember.prototype.get_$3 = function($0, $1, $2) { | 10753 TypeMember.prototype.get_$3 = function($0, $1, $2) { |
| 10677 return this.get_(($0 && $0.is$MethodGenerator()), ($1 && $1.is$lang_Node()), (
$2 && $2.is$Value()), false); | 10754 return this.get_(($0 && $0.is$MethodGenerator()), ($1 && $1.is$lang_Node()), (
$2 && $2.is$Value()), false); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11097 if ($notnull_bool(this.definition.returnType.names != null)) { | 11174 if ($notnull_bool(this.definition.returnType.names != null)) { |
| 11098 return this.definition.returnType.names.$index(0).get$name(); | 11175 return this.definition.returnType.names.$index(0).get$name(); |
| 11099 } | 11176 } |
| 11100 else if ($notnull_bool($ne(this.definition.returnType.get$name(), null))) { | 11177 else if ($notnull_bool($ne(this.definition.returnType.get$name(), null))) { |
| 11101 return this.definition.returnType.get$name().get$name(); | 11178 return this.definition.returnType.get$name().get$name(); |
| 11102 } | 11179 } |
| 11103 world.internalError('no valid constructor name', this.definition.span); | 11180 world.internalError('no valid constructor name', this.definition.span); |
| 11104 } | 11181 } |
| 11105 MethodMember.prototype.get$functionType = function() { | 11182 MethodMember.prototype.get$functionType = function() { |
| 11106 if ($notnull_bool(this._functionType == null)) { | 11183 if ($notnull_bool(this._functionType == null)) { |
| 11107 this._functionType = this.declaringType.get$library().getOrAddFunctionType(t
his.name, this.definition, this.declaringType); | 11184 this._functionType = this.get$library().getOrAddFunctionType(this.name, this
.definition, this.declaringType); |
| 11108 if ($notnull_bool(this.parameters == null)) { | 11185 if ($notnull_bool(this.parameters == null)) { |
| 11109 this.resolve(this.declaringType); | 11186 this.resolve(this.declaringType); |
| 11110 } | 11187 } |
| 11111 } | 11188 } |
| 11112 return this._functionType; | 11189 return this._functionType; |
| 11113 } | 11190 } |
| 11114 MethodMember.prototype.override = function(other) { | 11191 MethodMember.prototype.override = function(other) { |
| 11115 if ($notnull_bool(!Member.prototype.override.call(this, other))) return false; | 11192 if ($notnull_bool(!Member.prototype.override.call(this, other))) return false; |
| 11116 if ($notnull_bool(other.get$isMethod())) { | 11193 if ($notnull_bool(other.get$isMethod())) { |
| 11117 return true; | 11194 return true; |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11687 this.returnType = inType.resolveType(this.definition.returnType, false); | 11764 this.returnType = inType.resolveType(this.definition.returnType, false); |
| 11688 if ($notnull_bool(this.isStatic && this.returnType.get$hasTypeParams())) { | 11765 if ($notnull_bool(this.isStatic && this.returnType.get$hasTypeParams())) { |
| 11689 world.error('using type parameter in static context', this.definition.retu
rnType.span); | 11766 world.error('using type parameter in static context', this.definition.retu
rnType.span); |
| 11690 } | 11767 } |
| 11691 } | 11768 } |
| 11692 this.parameters = []; | 11769 this.parameters = []; |
| 11693 var $list = this.definition.formals; | 11770 var $list = this.definition.formals; |
| 11694 for (var $i = 0;$i < $list.length; $i++) { | 11771 for (var $i = 0;$i < $list.length; $i++) { |
| 11695 var formal = $list.$index($i); | 11772 var formal = $list.$index($i); |
| 11696 var param = new lang_Parameter(formal); | 11773 var param = new lang_Parameter(formal); |
| 11697 param.resolve(inType); | 11774 param.resolve(this, inType); |
| 11698 this.parameters.add(param); | 11775 this.parameters.add(param); |
| 11699 if ($notnull_bool(this.isStatic && param.type.get$hasTypeParams())) { | |
| 11700 world.error('using type parameter in static context', formal.get$span()); | |
| 11701 } | |
| 11702 } | 11776 } |
| 11703 if ($notnull_bool(!this.isLambda)) { | 11777 if ($notnull_bool(!this.isLambda)) { |
| 11704 this.get$library()._addMember(this); | 11778 this.get$library()._addMember(this); |
| 11705 } | 11779 } |
| 11706 } | 11780 } |
| 11707 MethodMember.prototype.get_$3 = function($0, $1, $2) { | 11781 MethodMember.prototype.get_$3 = function($0, $1, $2) { |
| 11708 return this.get_(($0 && $0.is$MethodGenerator()), ($1 && $1.is$lang_Node()), (
$2 && $2.is$Value()), false); | 11782 return this.get_(($0 && $0.is$MethodGenerator()), ($1 && $1.is$lang_Node()), (
$2 && $2.is$Value()), false); |
| 11709 } | 11783 } |
| 11710 ; | 11784 ; |
| 11711 MethodMember.prototype.invoke$4 = function($0, $1, $2, $3) { | 11785 MethodMember.prototype.invoke$4 = function($0, $1, $2, $3) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 11736 } | 11810 } |
| 11737 MemberSet.prototype.add = function(member) { | 11811 MemberSet.prototype.add = function(member) { |
| 11738 return this.members.add(member); | 11812 return this.members.add(member); |
| 11739 } | 11813 } |
| 11740 MemberSet.prototype.canInvoke = function(context, args) { | 11814 MemberSet.prototype.canInvoke = function(context, args) { |
| 11741 return this.members.some((function (m) { | 11815 return this.members.some((function (m) { |
| 11742 return m.canInvoke(context, args); | 11816 return m.canInvoke(context, args); |
| 11743 }) | 11817 }) |
| 11744 ); | 11818 ); |
| 11745 } | 11819 } |
| 11746 MemberSet.prototype.get$library = function() { | |
| 11747 var ret = this.members.$index(0).declaringType.get$library(); | |
| 11748 var $list = this.members; | |
| 11749 for (var $i = 0;$i < $list.length; $i++) { | |
| 11750 var m = $list.$index($i); | |
| 11751 if ($notnull_bool($ne(m.declaringType.get$library(), ret))) return null; | |
| 11752 } | |
| 11753 return ret; | |
| 11754 } | |
| 11755 MemberSet.prototype._makeError = function(node, target, action) { | 11820 MemberSet.prototype._makeError = function(node, target, action) { |
| 11756 if ($notnull_bool(!target.type.get$isVar())) { | 11821 if ($notnull_bool(!target.type.get$isVar())) { |
| 11757 world.warning(('could not find applicable ' + action + ' for "' + this.name
+ '"'), node.span); | 11822 world.warning(('could not find applicable ' + action + ' for "' + this.name
+ '"'), node.span); |
| 11758 } | 11823 } |
| 11759 return new Value(null, ('' + target.code + '.' + this.jsname + '() /*no applic
able ' + action + '*/'), false, true, false); | 11824 return new Value(null, ('' + target.code + '.' + this.jsname + '() /*no applic
able ' + action + '*/'), false, true, false); |
| 11760 } | 11825 } |
| 11761 MemberSet.prototype.get$treatAsField = function() { | 11826 MemberSet.prototype.get$treatAsField = function() { |
| 11762 if ($notnull_bool(this._treatAsField == null)) { | 11827 if ($notnull_bool(this._treatAsField == null)) { |
| 11763 this._treatAsField = true; | 11828 this._treatAsField = true; |
| 11764 var $list = this.members; | 11829 var $list = this.members; |
| (...skipping 5874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17639 e = $toDartException(e); | 17704 e = $toDartException(e); |
| 17640 this.warning(('Error reading file: ' + filename + '')); | 17705 this.warning(('Error reading file: ' + filename + '')); |
| 17641 return new SourceFile(filename, ''); | 17706 return new SourceFile(filename, ''); |
| 17642 } | 17707 } |
| 17643 } | 17708 } |
| 17644 World.prototype.getOrAddLibrary = function(filename) { | 17709 World.prototype.getOrAddLibrary = function(filename) { |
| 17645 var library = this.libraries.$index(filename); | 17710 var library = this.libraries.$index(filename); |
| 17646 if ($notnull_bool(library == null)) { | 17711 if ($notnull_bool(library == null)) { |
| 17647 library = new Library(this.readFile(filename)); | 17712 library = new Library(this.readFile(filename)); |
| 17648 this.info(('read library ' + filename + '')); | 17713 this.info(('read library ' + filename + '')); |
| 17649 if ($notnull_bool(!library.get$isCore())) { | 17714 if ($notnull_bool(!library.get$isCore() && !library.imports.some((function (
li) { |
| 17715 return li.get$library().get$isCore(); |
| 17716 }) |
| 17717 ))) { |
| 17650 library.imports.add(new LibraryImport(this.corelib)); | 17718 library.imports.add(new LibraryImport(this.corelib)); |
| 17651 } | 17719 } |
| 17652 this.libraries.$setindex(filename, library); | 17720 this.libraries.$setindex(filename, library); |
| 17653 this._todo.add(library); | 17721 this._todo.add(library); |
| 17654 } | 17722 } |
| 17655 return library; | 17723 return library; |
| 17656 } | 17724 } |
| 17657 World.prototype.process = function() { | 17725 World.prototype.process = function() { |
| 17658 while ($notnull_bool(this._todo.length > 0)) { | 17726 while ($notnull_bool(this._todo.length > 0)) { |
| 17659 var todo = this._todo; | 17727 var todo = this._todo; |
| 17660 this._todo = []; | 17728 this._todo = []; |
| 17661 for (var $i = 0;$i < todo.length; $i++) { | 17729 for (var $i = 0;$i < todo.length; $i++) { |
| 17662 var lib = todo.$index($i); | 17730 var lib = todo.$index($i); |
| 17663 new LibraryVisitor(lib); | 17731 lib.visitSources(); |
| 17664 } | 17732 } |
| 17665 } | 17733 } |
| 17666 } | 17734 } |
| 17667 World.prototype.processScript = function(filename) { | 17735 World.prototype.processScript = function(filename) { |
| 17668 var library = this.getOrAddLibrary(filename); | 17736 var library = this.getOrAddLibrary(filename); |
| 17669 this.process(); | 17737 this.process(); |
| 17670 return library; | 17738 return library; |
| 17671 } | 17739 } |
| 17672 World.prototype.resolveAll = function() { | 17740 World.prototype.resolveAll = function() { |
| 17673 var $0; | 17741 var $0; |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18341 INTERFACE, | 18409 INTERFACE, |
| 18342 LIBRARY, | 18410 LIBRARY, |
| 18343 NATIVE, | 18411 NATIVE, |
| 18344 NEGATE, | 18412 NEGATE, |
| 18345 OPERATOR, | 18413 OPERATOR, |
| 18346 SET, | 18414 SET, |
| 18347 SOURCE, | 18415 SOURCE, |
| 18348 STATIC, | 18416 STATIC, |
| 18349 TYPEDEF ]*/; | 18417 TYPEDEF ]*/; |
| 18350 main(); | 18418 main(); |
| OLD | NEW |