| 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 /** | 4 /** |
| 5 * Generates a dynamic call stub for a function. | 5 * Generates a dynamic call stub for a function. |
| 6 * Our goal is to create a stub method like this on-the-fly: | 6 * Our goal is to create a stub method like this on-the-fly: |
| 7 * function($0, $1, capture) { return this($0, $1, true, capture); } | 7 * function($0, $1, capture) { return this($0, $1, true, capture); } |
| 8 * | 8 * |
| 9 * This stub then replaces the dynamic one on Function, with one that is | 9 * This stub then replaces the dynamic one on Function, with one that is |
| 10 * specialized for that particular function, taking into account its default | 10 * specialized for that particular function, taking into account its default |
| (...skipping 6250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6261 var buf = new StringBufferImpl(('' + this.filename + ':' + (line + 1) + ':' +
(column + 1) + ': ' + message)); | 6261 var buf = new StringBufferImpl(('' + this.filename + ':' + (line + 1) + ':' +
(column + 1) + ': ' + message)); |
| 6262 if (includeText) { | 6262 if (includeText) { |
| 6263 buf.add$1('\n'); | 6263 buf.add$1('\n'); |
| 6264 var textLine; | 6264 var textLine; |
| 6265 if ((line + 2) < this._lineStarts.length) { | 6265 if ((line + 2) < this._lineStarts.length) { |
| 6266 textLine = this.get$text().substring(this._lineStarts.$index(line), this._
lineStarts.$index(line + 1)); | 6266 textLine = this.get$text().substring(this._lineStarts.$index(line), this._
lineStarts.$index(line + 1)); |
| 6267 } | 6267 } |
| 6268 else { | 6268 else { |
| 6269 textLine = this.get$text().substring(this._lineStarts.$index(line)) + '\n'
; | 6269 textLine = this.get$text().substring(this._lineStarts.$index(line)) + '\n'
; |
| 6270 } | 6270 } |
| 6271 buf.add$1(textLine); | 6271 var toColumn = Math.min(column + (end - start), textLine.length); |
| 6272 if ($globals.options.useColors) { |
| 6273 buf.add$1(textLine.substring$2(0, column)); |
| 6274 buf.add$1($globals._RED_COLOR); |
| 6275 buf.add$1(textLine.substring$2(column, toColumn)); |
| 6276 buf.add$1($globals._NO_COLOR); |
| 6277 buf.add$1(textLine.substring$1(toColumn)); |
| 6278 } |
| 6279 else { |
| 6280 buf.add$1(textLine); |
| 6281 } |
| 6272 var i = 0; | 6282 var i = 0; |
| 6273 for (; i < column; i++) { | 6283 for (; i < column; i++) { |
| 6274 buf.add$1(' '); | 6284 buf.add$1(' '); |
| 6275 } | 6285 } |
| 6276 var toColumn = Math.min(column + (end - start), textLine.length); | 6286 if ($globals.options.useColors) buf.add$1($globals._RED_COLOR); |
| 6277 for (; i < toColumn; i++) { | 6287 for (; i < toColumn; i++) { |
| 6278 buf.add$1('^'); | 6288 buf.add$1('^'); |
| 6279 } | 6289 } |
| 6290 if ($globals.options.useColors) buf.add$1($globals._NO_COLOR); |
| 6280 } | 6291 } |
| 6281 return buf.toString$0(); | 6292 return buf.toString$0(); |
| 6282 } | 6293 } |
| 6283 SourceFile.prototype.compareTo = function(other) { | 6294 SourceFile.prototype.compareTo = function(other) { |
| 6284 if (this.orderInLibrary != null && other.orderInLibrary != null) { | 6295 if (this.orderInLibrary != null && other.orderInLibrary != null) { |
| 6285 return this.orderInLibrary - other.orderInLibrary; | 6296 return this.orderInLibrary - other.orderInLibrary; |
| 6286 } | 6297 } |
| 6287 else { | 6298 else { |
| 6288 return this.filename.compareTo(other.filename); | 6299 return this.filename.compareTo(other.filename); |
| 6289 } | 6300 } |
| (...skipping 6231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12521 } | 12532 } |
| 12522 } | 12533 } |
| 12523 else { | 12534 else { |
| 12524 main = mainMembers.get$members().$index(0); | 12535 main = mainMembers.get$members().$index(0); |
| 12525 } | 12536 } |
| 12526 var codeWriter = new CodeWriter(); | 12537 var codeWriter = new CodeWriter(); |
| 12527 this.gen = new WorldGenerator(main, codeWriter); | 12538 this.gen = new WorldGenerator(main, codeWriter); |
| 12528 this.gen.run(); | 12539 this.gen.run(); |
| 12529 this.jsBytesWritten = codeWriter.get$text().length; | 12540 this.jsBytesWritten = codeWriter.get$text().length; |
| 12530 } | 12541 } |
| 12531 World.prototype._message = function(message, span, span1, span2, throwing) { | 12542 World.prototype._message = function(color, prefix, message, span, span1, span2,
throwing) { |
| 12532 var text = message; | 12543 var messageWithPrefix = $globals.options.useColors ? (color + prefix + $global
s._NO_COLOR + message) : (prefix + message); |
| 12544 var text = messageWithPrefix; |
| 12533 if (span != null) { | 12545 if (span != null) { |
| 12534 text = span.toMessageString(message); | 12546 text = span.toMessageString(messageWithPrefix); |
| 12535 } | 12547 } |
| 12536 print(text); | 12548 print(text); |
| 12537 if (span1 != null) { | 12549 if (span1 != null) { |
| 12538 print(span1.toMessageString(message)); | 12550 print(span1.toMessageString(messageWithPrefix)); |
| 12539 } | 12551 } |
| 12540 if (span2 != null) { | 12552 if (span2 != null) { |
| 12541 print(span2.toMessageString(message)); | 12553 print(span2.toMessageString(messageWithPrefix)); |
| 12542 } | 12554 } |
| 12543 if (throwing) { | 12555 if (throwing) { |
| 12544 $throw(new CompilerException(message, span)); | 12556 $throw(new CompilerException(messageWithPrefix, span)); |
| 12545 } | 12557 } |
| 12546 } | 12558 } |
| 12547 World.prototype.error = function(message, span, span1, span2) { | 12559 World.prototype.error = function(message, span, span1, span2) { |
| 12548 this.errors++; | 12560 this.errors++; |
| 12549 this._message(('error: ' + message), span, span1, span2, $globals.options.thro
wOnErrors); | 12561 this._message($globals._RED_COLOR, 'error: ', message, span, span1, span2, $gl
obals.options.throwOnErrors); |
| 12550 } | 12562 } |
| 12551 World.prototype.warning = function(message, span, span1, span2) { | 12563 World.prototype.warning = function(message, span, span1, span2) { |
| 12552 if ($globals.options.warningsAsErrors) { | 12564 if ($globals.options.warningsAsErrors) { |
| 12553 this.error(message, span, span1, span2); | 12565 this.error(message, span, span1, span2); |
| 12554 return; | 12566 return; |
| 12555 } | 12567 } |
| 12556 this.warnings++; | 12568 this.warnings++; |
| 12557 if ($globals.options.showWarnings) { | 12569 if ($globals.options.showWarnings) { |
| 12558 this._message(('warning: ' + message), span, span1, span2, $globals.options.
throwOnWarnings); | 12570 this._message($globals._MAGENTA_COLOR, 'warning: ', message, span, span1, sp
an2, $globals.options.throwOnWarnings); |
| 12559 } | 12571 } |
| 12560 } | 12572 } |
| 12561 World.prototype.fatal = function(message, span, span1, span2) { | 12573 World.prototype.fatal = function(message, span, span1, span2) { |
| 12562 this.errors++; | 12574 this.errors++; |
| 12563 this.seenFatal = true; | 12575 this.seenFatal = true; |
| 12564 this._message(('fatal: ' + message), span, span1, span2, $globals.options.thro
wOnFatal || $globals.options.throwOnErrors); | 12576 this._message($globals._RED_COLOR, 'fatal: ', message, span, span1, span2, $gl
obals.options.throwOnFatal || $globals.options.throwOnErrors); |
| 12565 } | 12577 } |
| 12566 World.prototype.internalError = function(message, span, span1, span2) { | 12578 World.prototype.internalError = function(message, span, span1, span2) { |
| 12567 this._message(('We are sorry, but... ' + message), span, span1, span2, true); | 12579 this._message($globals._NO_COLOR, 'We are sorry, but...', message, span, span1
, span2, true); |
| 12568 } | 12580 } |
| 12569 World.prototype.info = function(message, span, span1, span2) { | 12581 World.prototype.info = function(message, span, span1, span2) { |
| 12570 if ($globals.options.showInfo) { | 12582 if ($globals.options.showInfo) { |
| 12571 this._message(('info: ' + message), span, span1, span2, false); | 12583 this._message($globals._GREEN_COLOR, 'info: ', message, span, span1, span2,
false); |
| 12572 } | 12584 } |
| 12573 } | 12585 } |
| 12574 World.prototype.withoutForceDynamic = function(fn) { | 12586 World.prototype.withoutForceDynamic = function(fn) { |
| 12575 var oldForceDynamic = $globals.options.forceDynamic; | 12587 var oldForceDynamic = $globals.options.forceDynamic; |
| 12576 $globals.options.forceDynamic = false; | 12588 $globals.options.forceDynamic = false; |
| 12577 try { | 12589 try { |
| 12578 return fn(); | 12590 return fn(); |
| 12579 } finally { | 12591 } finally { |
| 12580 $globals.options.forceDynamic = oldForceDynamic; | 12592 $globals.options.forceDynamic = oldForceDynamic; |
| 12581 } | 12593 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12616 this.verifyImplements = false | 12628 this.verifyImplements = false |
| 12617 this.compileAll = false | 12629 this.compileAll = false |
| 12618 this.forceDynamic = false | 12630 this.forceDynamic = false |
| 12619 this.dietParse = false | 12631 this.dietParse = false |
| 12620 this.compileOnly = false | 12632 this.compileOnly = false |
| 12621 this.throwOnErrors = false | 12633 this.throwOnErrors = false |
| 12622 this.throwOnWarnings = false | 12634 this.throwOnWarnings = false |
| 12623 this.throwOnFatal = false | 12635 this.throwOnFatal = false |
| 12624 this.showInfo = false | 12636 this.showInfo = false |
| 12625 this.showWarnings = true | 12637 this.showWarnings = true |
| 12638 this.useColors = true |
| 12626 // Initializers done | 12639 // Initializers done |
| 12627 if ($eq(this.config, 'dev')) { | 12640 if ($eq(this.config, 'dev')) { |
| 12628 this.libDir = joinPaths(homedir, '/lib'); | 12641 this.libDir = joinPaths(homedir, '/lib'); |
| 12629 } | 12642 } |
| 12630 else if ($eq(this.config, 'sdk')) { | 12643 else if ($eq(this.config, 'sdk')) { |
| 12631 this.libDir = joinPaths(homedir, '/../lib'); | 12644 this.libDir = joinPaths(homedir, '/../lib'); |
| 12632 } | 12645 } |
| 12633 else { | 12646 else { |
| 12634 $globals.world.error(('Invalid configuration ' + this.config)); | 12647 $globals.world.error(('Invalid configuration ' + this.config)); |
| 12635 $throw(('Invalid configuration')); | 12648 $throw(('Invalid configuration')); |
| 12636 } | 12649 } |
| 12637 var ignoreUnrecognizedFlags = false; | 12650 var ignoreUnrecognizedFlags = false; |
| 12638 var passedLibDir = false; | 12651 var passedLibDir = false; |
| 12639 this.childArgs = []; | 12652 this.childArgs = []; |
| 12640 loop: | 12653 loop: |
| 12641 for (var i = 2; | 12654 for (var i = 2; |
| 12642 i < args.length; i++) { | 12655 i < args.length; i++) { |
| 12643 var arg = args.$index(i); | 12656 var arg = args.$index(i); |
| 12644 switch (arg) { | 12657 switch (arg) { |
| 12645 case '--enable_leg': | 12658 case '--enable_leg': |
| 12646 | 12659 |
| 12647 this.enableLeg = true; | 12660 this.enableLeg = true; |
| 12648 continue loop; | 12661 break; |
| 12649 | 12662 |
| 12650 case '--leg_only': | 12663 case '--leg_only': |
| 12651 | 12664 |
| 12652 this.enableLeg = true; | 12665 this.enableLeg = true; |
| 12653 this.legOnly = true; | 12666 this.legOnly = true; |
| 12654 continue loop; | 12667 break; |
| 12655 | 12668 |
| 12656 case '--enable_asserts': | 12669 case '--enable_asserts': |
| 12657 | 12670 |
| 12658 this.enableAsserts = true; | 12671 this.enableAsserts = true; |
| 12659 continue loop; | 12672 break; |
| 12660 | 12673 |
| 12661 case '--enable_type_checks': | 12674 case '--enable_type_checks': |
| 12662 | 12675 |
| 12663 this.enableTypeChecks = true; | 12676 this.enableTypeChecks = true; |
| 12664 this.enableAsserts = true; | 12677 this.enableAsserts = true; |
| 12665 continue loop; | 12678 break; |
| 12666 | 12679 |
| 12667 case '--verify_implements': | 12680 case '--verify_implements': |
| 12668 | 12681 |
| 12669 this.verifyImplements = true; | 12682 this.verifyImplements = true; |
| 12670 continue loop; | 12683 break; |
| 12671 | 12684 |
| 12672 case '--compile_all': | 12685 case '--compile_all': |
| 12673 | 12686 |
| 12674 this.compileAll = true; | 12687 this.compileAll = true; |
| 12675 continue loop; | 12688 break; |
| 12676 | 12689 |
| 12677 case '--diet-parse': | 12690 case '--diet-parse': |
| 12678 | 12691 |
| 12679 this.dietParse = true; | 12692 this.dietParse = true; |
| 12680 continue loop; | 12693 break; |
| 12681 | 12694 |
| 12682 case '--ignore-unrecognized-flags': | 12695 case '--ignore-unrecognized-flags': |
| 12683 | 12696 |
| 12684 ignoreUnrecognizedFlags = true; | 12697 ignoreUnrecognizedFlags = true; |
| 12685 continue loop; | 12698 break; |
| 12686 | 12699 |
| 12687 case '--verbose': | 12700 case '--verbose': |
| 12688 | 12701 |
| 12689 this.showInfo = true; | 12702 this.showInfo = true; |
| 12690 continue loop; | 12703 break; |
| 12691 | 12704 |
| 12692 case '--suppress_warnings': | 12705 case '--suppress_warnings': |
| 12693 | 12706 |
| 12694 this.showWarnings = false; | 12707 this.showWarnings = false; |
| 12695 continue loop; | 12708 break; |
| 12696 | 12709 |
| 12697 case '--warnings_as_errors': | 12710 case '--warnings_as_errors': |
| 12698 | 12711 |
| 12699 this.warningsAsErrors = true; | 12712 this.warningsAsErrors = true; |
| 12700 continue loop; | 12713 break; |
| 12701 | 12714 |
| 12702 case '--throw_on_errors': | 12715 case '--throw_on_errors': |
| 12703 | 12716 |
| 12704 this.throwOnErrors = true; | 12717 this.throwOnErrors = true; |
| 12705 continue loop; | 12718 break; |
| 12706 | 12719 |
| 12707 case '--throw_on_warnings': | 12720 case '--throw_on_warnings': |
| 12708 | 12721 |
| 12709 this.throwOnWarnings = true; | 12722 this.throwOnWarnings = true; |
| 12710 continue loop; | 12723 break; |
| 12711 | 12724 |
| 12712 case '--compile-only': | 12725 case '--compile-only': |
| 12713 | 12726 |
| 12714 this.compileOnly = true; | 12727 this.compileOnly = true; |
| 12715 continue loop; | 12728 break; |
| 12716 | 12729 |
| 12717 case '--force_dynamic': | 12730 case '--force_dynamic': |
| 12718 | 12731 |
| 12719 this.forceDynamic = true; | 12732 this.forceDynamic = true; |
| 12720 continue loop; | 12733 break; |
| 12734 |
| 12735 case '--no_colors': |
| 12736 |
| 12737 this.useColors = false; |
| 12738 break; |
| 12721 | 12739 |
| 12722 default: | 12740 default: |
| 12723 | 12741 |
| 12724 if (arg.endsWith$1('.dart')) { | 12742 if (arg.endsWith$1('.dart')) { |
| 12725 this.dartScript = arg; | 12743 this.dartScript = arg; |
| 12726 this.childArgs = args.getRange(i + 1, args.length - i - 1); | 12744 this.childArgs = args.getRange(i + 1, args.length - i - 1); |
| 12727 break loop; | 12745 break loop; |
| 12728 } | 12746 } |
| 12729 else if (arg.startsWith$1('--out=')) { | 12747 else if (arg.startsWith$1('--out=')) { |
| 12730 this.outfile = arg.substring$1('--out='.length); | 12748 this.outfile = arg.substring$1('--out='.length); |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13065 } | 13083 } |
| 13066 return nameBuilder.toString(); | 13084 return nameBuilder.toString(); |
| 13067 } | 13085 } |
| 13068 // ********** Library minfrog ************** | 13086 // ********** Library minfrog ************** |
| 13069 // ********** Code for top level ************** | 13087 // ********** Code for top level ************** |
| 13070 function main() { | 13088 function main() { |
| 13071 var homedir = path.dirname(fs.realpathSync(process.argv.$index(1))); | 13089 var homedir = path.dirname(fs.realpathSync(process.argv.$index(1))); |
| 13072 var argv = ListFactory.ListFactory$from$factory(process.argv); | 13090 var argv = ListFactory.ListFactory$from$factory(process.argv); |
| 13073 if (compile(homedir, argv, new NodeFileSystem())) { | 13091 if (compile(homedir, argv, new NodeFileSystem())) { |
| 13074 var code = $globals.world.getGeneratedCode(); | 13092 var code = $globals.world.getGeneratedCode(); |
| 13075 if (!$globals.options.compileOnly) { | 13093 if ($globals.options.compileOnly) { |
| 13094 if ($globals.options.outfile != null) { |
| 13095 print(('Compilation succeded. Code generated in: ' + $globals.options.ou
tfile)); |
| 13096 } |
| 13097 else { |
| 13098 print('Compilation succeded.'); |
| 13099 } |
| 13100 } |
| 13101 else { |
| 13076 process.argv = [argv.$index(0), argv.$index(1)]; | 13102 process.argv = [argv.$index(0), argv.$index(1)]; |
| 13077 process.argv.addAll($globals.options.childArgs); | 13103 process.argv.addAll($globals.options.childArgs); |
| 13078 vm.runInNewContext(code, createSandbox()); | 13104 vm.runInNewContext(code, createSandbox()); |
| 13079 } | 13105 } |
| 13080 } | 13106 } |
| 13081 else { | 13107 else { |
| 13082 process.exit(1); | 13108 process.exit(1); |
| 13083 } | 13109 } |
| 13084 } | 13110 } |
| 13085 // ********** Generic Type Inheritance ************** | 13111 // ********** Generic Type Inheritance ************** |
| 13086 /** Implements extends for generic types. */ | 13112 /** Implements extends for generic types. */ |
| 13087 function $inheritsMembers(child, parent) { | 13113 function $inheritsMembers(child, parent) { |
| 13088 child = child.prototype; | 13114 child = child.prototype; |
| 13089 parent = parent.prototype; | 13115 parent = parent.prototype; |
| 13090 Object.getOwnPropertyNames(parent).forEach(function(name) { | 13116 Object.getOwnPropertyNames(parent).forEach(function(name) { |
| 13091 if (typeof(child[name]) == 'undefined') child[name] = parent[name]; | 13117 if (typeof(child[name]) == 'undefined') child[name] = parent[name]; |
| 13092 }); | 13118 }); |
| 13093 } | 13119 } |
| 13094 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_E, DoubleLinkedQueueEntry_E); | 13120 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_E, DoubleLinkedQueueEntry_E); |
| 13095 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ
ueueEntry_KeyValuePair_K$V); | 13121 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ
ueueEntry_KeyValuePair_K$V); |
| 13096 // ********** Globals ************** | 13122 // ********** Globals ************** |
| 13097 function $static_init(){ | 13123 function $static_init(){ |
| 13124 $globals._GREEN_COLOR = '\u001b[32m'; |
| 13125 $globals._MAGENTA_COLOR = '\u001b[35m'; |
| 13126 $globals._NO_COLOR = '\u001b[0m'; |
| 13127 $globals._RED_COLOR = '\u001b[31m'; |
| 13098 } | 13128 } |
| 13099 var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/; | 13129 var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/; |
| 13100 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/; | 13130 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/; |
| 13101 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; | 13131 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; |
| 13102 var $globals = {}; | 13132 var $globals = {}; |
| 13103 $static_init(); | 13133 $static_init(); |
| 13104 main(); | 13134 main(); |
| OLD | NEW |