| 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 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 } | 1472 } |
| 1473 PromiseImpl.prototype.isDone = function() { | 1473 PromiseImpl.prototype.isDone = function() { |
| 1474 return this._state != 0/*PromiseImpl.CREATED*/ && this._state != 1/*PromiseImp
l.RUNNING*/; | 1474 return this._state != 0/*PromiseImpl.CREATED*/ && this._state != 1/*PromiseImp
l.RUNNING*/; |
| 1475 } | 1475 } |
| 1476 PromiseImpl.prototype.hasError = function() { | 1476 PromiseImpl.prototype.hasError = function() { |
| 1477 return this._state == 3/*PromiseImpl.COMPLETE_ERROR*/ || this._state == 6/*Pro
miseImpl.COMPLETE_ERROR_AFTER_CANCELLED*/; | 1477 return this._state == 3/*PromiseImpl.COMPLETE_ERROR*/ || this._state == 6/*Pro
miseImpl.COMPLETE_ERROR_AFTER_CANCELLED*/; |
| 1478 } | 1478 } |
| 1479 // ********** Code for PromiseImpl$T ************** | 1479 // ********** Code for PromiseImpl$T ************** |
| 1480 function PromiseImpl$T() {} | 1480 function PromiseImpl$T() {} |
| 1481 $inherits(PromiseImpl$T, PromiseImpl); | 1481 $inherits(PromiseImpl$T, PromiseImpl); |
| 1482 // ********** Code for PromiseImpl$bool ************** |
| 1483 function PromiseImpl$bool() {} |
| 1484 $inherits(PromiseImpl$bool, PromiseImpl); |
| 1482 // ********** Code for ProxyBase ************** | 1485 // ********** Code for ProxyBase ************** |
| 1483 function ProxyBase() {} | 1486 function ProxyBase() {} |
| 1487 $inherits(ProxyBase, PromiseImpl$bool); |
| 1484 ProxyBase.prototype.$eq = function(other) { | 1488 ProxyBase.prototype.$eq = function(other) { |
| 1485 return ((other instanceof ProxyBase)) && $eq(this._promise.get$value(), other.
_promise.get$value()); | 1489 return ((other instanceof ProxyBase)) && $eq(this._promise.get$value(), other.
_promise.get$value()); |
| 1486 } | 1490 } |
| 1487 // ********** Code for DoubleLinkedQueueEntry ************** | 1491 // ********** Code for DoubleLinkedQueueEntry ************** |
| 1488 function DoubleLinkedQueueEntry(e) { | 1492 function DoubleLinkedQueueEntry(e) { |
| 1489 // Initializers done | 1493 // Initializers done |
| 1490 this._element = e; | 1494 this._element = e; |
| 1491 } | 1495 } |
| 1492 DoubleLinkedQueueEntry.prototype._link = function(p, n) { | 1496 DoubleLinkedQueueEntry.prototype._link = function(p, n) { |
| 1493 this._next = n; | 1497 this._next = n; |
| (...skipping 16174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17668 } | 17672 } |
| 17669 World.prototype.withTiming = function(name, f) { | 17673 World.prototype.withTiming = function(name, f) { |
| 17670 var sw = new StopWatchImplementation(); | 17674 var sw = new StopWatchImplementation(); |
| 17671 sw.start(); | 17675 sw.start(); |
| 17672 var result = f(); | 17676 var result = f(); |
| 17673 sw.stop(); | 17677 sw.stop(); |
| 17674 this.info(('' + name + ' in ' + sw.elapsedInMs() + 'msec')); | 17678 this.info(('' + name + ' in ' + sw.elapsedInMs() + 'msec')); |
| 17675 return result; | 17679 return result; |
| 17676 } | 17680 } |
| 17677 // ********** Code for Options ************** | 17681 // ********** Code for Options ************** |
| 17678 function Options(homedir, args) { | 17682 function Options(homedir, args, files) { |
| 17679 this.enableLeg = false | 17683 this.enableLeg = false |
| 17680 this.enableAsserts = false | 17684 this.enableAsserts = false |
| 17681 this.enableTypeChecks = false | 17685 this.enableTypeChecks = false |
| 17682 this.verifyImplements = false | 17686 this.verifyImplements = false |
| 17683 this.compileAll = false | 17687 this.compileAll = false |
| 17684 this.dietParse = false | 17688 this.dietParse = false |
| 17685 this.compileOnly = false | 17689 this.compileOnly = false |
| 17686 this.throwOnErrors = false | 17690 this.throwOnErrors = false |
| 17687 this.throwOnWarnings = false | 17691 this.throwOnWarnings = false |
| 17688 this.throwOnFatal = false | 17692 this.throwOnFatal = false |
| 17689 this.showInfo = false | 17693 this.showInfo = false |
| 17690 this.showWarnings = true | 17694 this.showWarnings = true |
| 17691 // Initializers done | 17695 // Initializers done |
| 17692 this.libDir = homedir + '/lib'; | 17696 this.libDir = homedir + '/lib'; |
| 17693 var ignoreUnrecognizedFlags = false; | 17697 var ignoreUnrecognizedFlags = false; |
| 17698 var passedLibDir = false; |
| 17699 this.childArgs = []; |
| 17694 loop: | 17700 loop: |
| 17695 for (var i = 2; | 17701 for (var i = 2; |
| 17696 i < args.length; i++) { | 17702 i < args.length; i++) { |
| 17697 var arg = args.$index(i); | 17703 var arg = args.$index(i); |
| 17698 switch (arg) { | 17704 switch (arg) { |
| 17699 case '--enable_leg': | 17705 case '--enable_leg': |
| 17700 | 17706 |
| 17701 this.enableLeg = true; | 17707 this.enableLeg = true; |
| 17702 continue loop; | 17708 continue loop; |
| 17703 | 17709 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17750 case '--compile-only': | 17756 case '--compile-only': |
| 17751 | 17757 |
| 17752 this.compileOnly = true; | 17758 this.compileOnly = true; |
| 17753 continue loop; | 17759 continue loop; |
| 17754 | 17760 |
| 17755 default: | 17761 default: |
| 17756 | 17762 |
| 17757 if (arg.endsWith('.dart')) { | 17763 if (arg.endsWith('.dart')) { |
| 17758 this.dartScript = arg; | 17764 this.dartScript = arg; |
| 17759 this.childArgs = args.getRange(i + 1, args.length - i - 1); | 17765 this.childArgs = args.getRange(i + 1, args.length - i - 1); |
| 17760 return; | 17766 break loop; |
| 17761 } | 17767 } |
| 17762 else if (arg.startsWith('--out=')) { | 17768 else if (arg.startsWith('--out=')) { |
| 17763 this.outfile = arg.substring('--out='.length); | 17769 this.outfile = arg.substring('--out='.length); |
| 17764 } | 17770 } |
| 17765 else if (arg.startsWith('--libdir=')) { | 17771 else if (arg.startsWith('--libdir=')) { |
| 17766 this.libDir = arg.substring('--libdir='.length); | 17772 this.libDir = arg.substring('--libdir='.length); |
| 17773 passedLibDir = true; |
| 17767 } | 17774 } |
| 17768 else { | 17775 else { |
| 17769 if (!ignoreUnrecognizedFlags) { | 17776 if (!ignoreUnrecognizedFlags) { |
| 17770 print(('unrecognized flag: "' + arg + '"')); | 17777 print(('unrecognized flag: "' + arg + '"')); |
| 17771 } | 17778 } |
| 17772 } | 17779 } |
| 17773 | 17780 |
| 17774 } | 17781 } |
| 17775 } | 17782 } |
| 17776 this.childArgs = []; | 17783 if (!passedLibDir && !files.fileExists(this.libDir)) { |
| 17784 var temp = 'frog/lib'; |
| 17785 if (files.fileExists(temp)) { |
| 17786 this.libDir = temp; |
| 17787 } |
| 17788 else { |
| 17789 this.libDir = 'lib'; |
| 17790 } |
| 17791 } |
| 17777 } | 17792 } |
| 17778 // ********** Code for LibraryReader ************** | 17793 // ********** Code for LibraryReader ************** |
| 17779 function LibraryReader() { | 17794 function LibraryReader() { |
| 17780 // Initializers done | 17795 // Initializers done |
| 17781 this._specialLibs = $map(['dart:core', joinPaths(options.libDir, 'corelib.dart
'), 'dart:coreimpl', joinPaths(options.libDir, 'corelib_impl.dart'), 'dart:html'
, joinPaths(options.libDir, '../../client/html/release/html.dart'), 'dart:dom',
joinPaths(options.libDir, 'dom/dom.dart'), 'dart:json', joinPaths(options.libDir
, 'json.dart')]); | 17796 this._specialLibs = $map(['dart:core', joinPaths(options.libDir, 'corelib.dart
'), 'dart:coreimpl', joinPaths(options.libDir, 'corelib_impl.dart'), 'dart:html'
, joinPaths(options.libDir, '../../client/html/release/html.dart'), 'dart:dom',
joinPaths(options.libDir, 'dom/dom.dart'), 'dart:json', joinPaths(options.libDir
, 'json.dart')]); |
| 17782 } | 17797 } |
| 17783 LibraryReader.prototype.readFile = function(fullname) { | 17798 LibraryReader.prototype.readFile = function(fullname) { |
| 17784 var filename = this._specialLibs.$index(fullname); | 17799 var filename = this._specialLibs.$index(fullname); |
| 17785 if (filename == null) { | 17800 if (filename == null) { |
| 17786 filename = fullname; | 17801 filename = fullname; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18030 else { | 18045 else { |
| 18031 return text; | 18046 return text; |
| 18032 } | 18047 } |
| 18033 } | 18048 } |
| 18034 var world; | 18049 var world; |
| 18035 function initializeWorld(files) { | 18050 function initializeWorld(files) { |
| 18036 world = new World(files); | 18051 world = new World(files); |
| 18037 world.init(); | 18052 world.init(); |
| 18038 } | 18053 } |
| 18039 function lang_compile(homedir, args, files) { | 18054 function lang_compile(homedir, args, files) { |
| 18040 parseOptions(homedir, args); | 18055 parseOptions(homedir, args, files); |
| 18041 initializeWorld(files); | 18056 initializeWorld(files); |
| 18042 var success = world.compile(); | 18057 var success = world.compile(); |
| 18043 if (options.outfile != null) { | 18058 if (options.outfile != null) { |
| 18044 if (success) { | 18059 if (success) { |
| 18045 var code = world.getGeneratedCode(); | 18060 var code = world.getGeneratedCode(); |
| 18046 if (!options.outfile.endsWith('.js')) { | 18061 if (!options.outfile.endsWith('.js')) { |
| 18047 code = '#!/usr/bin/env node\n' + code; | 18062 code = '#!/usr/bin/env node\n' + code; |
| 18048 } | 18063 } |
| 18049 world.files.writeString(options.outfile, code); | 18064 world.files.writeString(options.outfile, code); |
| 18050 } | 18065 } |
| 18051 else { | 18066 else { |
| 18052 world.files.writeString(options.outfile, "throw 'Sorry, but I could not ge
nerate reasonable code to run.\\n';"); | 18067 world.files.writeString(options.outfile, "throw 'Sorry, but I could not ge
nerate reasonable code to run.\\n';"); |
| 18053 } | 18068 } |
| 18054 } | 18069 } |
| 18055 return success; | 18070 return success; |
| 18056 } | 18071 } |
| 18057 var options; | 18072 var options; |
| 18058 function parseOptions(homedir, args) { | 18073 function parseOptions(homedir, args, files) { |
| 18059 options = new Options(homedir, args); | 18074 options = new Options(homedir, args, files); |
| 18060 } | 18075 } |
| 18061 function _getCallStubName(name, args) { | 18076 function _getCallStubName(name, args) { |
| 18062 var nameBuilder = new StringBufferImpl(('' + name + '\$' + args.get$bareCount(
) + '')); | 18077 var nameBuilder = new StringBufferImpl(('' + name + '\$' + args.get$bareCount(
) + '')); |
| 18063 for (var i = args.get$bareCount(); | 18078 for (var i = args.get$bareCount(); |
| 18064 i < args.get$length(); i++) { | 18079 i < args.get$length(); i++) { |
| 18065 nameBuilder.add('\$').add(args.getName(i)); | 18080 nameBuilder.add('\$').add(args.getName(i)); |
| 18066 } | 18081 } |
| 18067 return nameBuilder.toString(); | 18082 return nameBuilder.toString(); |
| 18068 } | 18083 } |
| 18069 // ********** Library frog ************** | 18084 // ********** Library frog ************** |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18230 INTERFACE, | 18245 INTERFACE, |
| 18231 LIBRARY, | 18246 LIBRARY, |
| 18232 NATIVE, | 18247 NATIVE, |
| 18233 NEGATE, | 18248 NEGATE, |
| 18234 OPERATOR, | 18249 OPERATOR, |
| 18235 SET, | 18250 SET, |
| 18236 SOURCE, | 18251 SOURCE, |
| 18237 STATIC, | 18252 STATIC, |
| 18238 TYPEDEF ]*/; | 18253 TYPEDEF ]*/; |
| 18239 main(); | 18254 main(); |
| OLD | NEW |