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 var i = 0; | 6272 if ($globals.options.useColors) { |
6273 for (; i < column; i++) { | 6273 buf.add$1(textLine.substring$2(0, column)); |
6274 buf.add$1(' '); | 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)); |
6275 } | 6278 } |
6276 var toColumn = Math.min(column + (end - start), textLine.length); | 6279 else { |
6277 for (; i < toColumn; i++) { | 6280 buf.add$1(textLine); |
6278 buf.add$1('^'); | 6281 var i = 0; |
| 6282 for (; i < column; i++) { |
| 6283 buf.add$1(' '); |
| 6284 } |
| 6285 for (; i < toColumn; i++) { |
| 6286 buf.add$1('^'); |
| 6287 } |
6279 } | 6288 } |
6280 } | 6289 } |
6281 return buf.toString$0(); | 6290 return buf.toString$0(); |
6282 } | 6291 } |
6283 SourceFile.prototype.compareTo = function(other) { | 6292 SourceFile.prototype.compareTo = function(other) { |
6284 if (this.orderInLibrary != null && other.orderInLibrary != null) { | 6293 if (this.orderInLibrary != null && other.orderInLibrary != null) { |
6285 return this.orderInLibrary - other.orderInLibrary; | 6294 return this.orderInLibrary - other.orderInLibrary; |
6286 } | 6295 } |
6287 else { | 6296 else { |
6288 return this.filename.compareTo(other.filename); | 6297 return this.filename.compareTo(other.filename); |
(...skipping 6250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12539 } | 12548 } |
12540 if (span2 != null) { | 12549 if (span2 != null) { |
12541 print(span2.toMessageString(message)); | 12550 print(span2.toMessageString(message)); |
12542 } | 12551 } |
12543 if (throwing) { | 12552 if (throwing) { |
12544 $throw(new CompilerException(message, span)); | 12553 $throw(new CompilerException(message, span)); |
12545 } | 12554 } |
12546 } | 12555 } |
12547 World.prototype.error = function(message, span, span1, span2) { | 12556 World.prototype.error = function(message, span, span1, span2) { |
12548 this.errors++; | 12557 this.errors++; |
12549 this._message(('error: ' + message), span, span1, span2, $globals.options.thro
wOnErrors); | 12558 this._message($globals.options.useColors ? ('' + $globals._RED_COLOR + 'error'
+ $globals._NO_COLOR + ': ' + message) : ('error: ' + message), span, span1, sp
an2, $globals.options.throwOnErrors); |
12550 } | 12559 } |
12551 World.prototype.warning = function(message, span, span1, span2) { | 12560 World.prototype.warning = function(message, span, span1, span2) { |
12552 if ($globals.options.warningsAsErrors) { | 12561 if ($globals.options.warningsAsErrors) { |
12553 this.error(message, span, span1, span2); | 12562 this.error(message, span, span1, span2); |
12554 return; | 12563 return; |
12555 } | 12564 } |
12556 this.warnings++; | 12565 this.warnings++; |
12557 if ($globals.options.showWarnings) { | 12566 if ($globals.options.showWarnings) { |
12558 this._message(('warning: ' + message), span, span1, span2, $globals.options.
throwOnWarnings); | 12567 this._message($globals.options.useColors ? ('' + $globals._MAGENTA_COLOR + '
warning' + $globals._NO_COLOR + ': ' + message) : ('warning: ' + message), span,
span1, span2, $globals.options.throwOnWarnings); |
12559 } | 12568 } |
12560 } | 12569 } |
12561 World.prototype.fatal = function(message, span, span1, span2) { | 12570 World.prototype.fatal = function(message, span, span1, span2) { |
12562 this.errors++; | 12571 this.errors++; |
12563 this.seenFatal = true; | 12572 this.seenFatal = true; |
12564 this._message(('fatal: ' + message), span, span1, span2, $globals.options.thro
wOnFatal || $globals.options.throwOnErrors); | 12573 this._message($globals.options.useColors ? ('' + $globals._RED_COLOR + 'fatal'
+ $globals._NO_COLOR + ': ' + message) : ('fatal: ' + message), span, span1, sp
an2, $globals.options.throwOnFatal || $globals.options.throwOnErrors); |
12565 } | 12574 } |
12566 World.prototype.internalError = function(message, span, span1, span2) { | 12575 World.prototype.internalError = function(message, span, span1, span2) { |
12567 this._message(('We are sorry, but... ' + message), span, span1, span2, true); | 12576 this._message(('We are sorry, but... ' + message), span, span1, span2, true); |
12568 } | 12577 } |
12569 World.prototype.info = function(message, span, span1, span2) { | 12578 World.prototype.info = function(message, span, span1, span2) { |
12570 if ($globals.options.showInfo) { | 12579 if ($globals.options.showInfo) { |
12571 this._message(('info: ' + message), span, span1, span2, false); | 12580 this._message(('info: ' + message), span, span1, span2, false); |
12572 } | 12581 } |
12573 } | 12582 } |
12574 World.prototype.withoutForceDynamic = function(fn) { | 12583 World.prototype.withoutForceDynamic = function(fn) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12616 this.verifyImplements = false | 12625 this.verifyImplements = false |
12617 this.compileAll = false | 12626 this.compileAll = false |
12618 this.forceDynamic = false | 12627 this.forceDynamic = false |
12619 this.dietParse = false | 12628 this.dietParse = false |
12620 this.compileOnly = false | 12629 this.compileOnly = false |
12621 this.throwOnErrors = false | 12630 this.throwOnErrors = false |
12622 this.throwOnWarnings = false | 12631 this.throwOnWarnings = false |
12623 this.throwOnFatal = false | 12632 this.throwOnFatal = false |
12624 this.showInfo = false | 12633 this.showInfo = false |
12625 this.showWarnings = true | 12634 this.showWarnings = true |
| 12635 this.useColors = true |
12626 // Initializers done | 12636 // Initializers done |
12627 if ($eq(this.config, 'dev')) { | 12637 if ($eq(this.config, 'dev')) { |
12628 this.libDir = joinPaths(homedir, '/lib'); | 12638 this.libDir = joinPaths(homedir, '/lib'); |
12629 } | 12639 } |
12630 else if ($eq(this.config, 'sdk')) { | 12640 else if ($eq(this.config, 'sdk')) { |
12631 this.libDir = joinPaths(homedir, '/../lib'); | 12641 this.libDir = joinPaths(homedir, '/../lib'); |
12632 } | 12642 } |
12633 else { | 12643 else { |
12634 $globals.world.error(('Invalid configuration ' + this.config)); | 12644 $globals.world.error(('Invalid configuration ' + this.config)); |
12635 $throw(('Invalid configuration')); | 12645 $throw(('Invalid configuration')); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12712 case '--compile-only': | 12722 case '--compile-only': |
12713 | 12723 |
12714 this.compileOnly = true; | 12724 this.compileOnly = true; |
12715 continue loop; | 12725 continue loop; |
12716 | 12726 |
12717 case '--force_dynamic': | 12727 case '--force_dynamic': |
12718 | 12728 |
12719 this.forceDynamic = true; | 12729 this.forceDynamic = true; |
12720 continue loop; | 12730 continue loop; |
12721 | 12731 |
| 12732 case '--no_colors': |
| 12733 |
| 12734 this.useColors = false; |
| 12735 continue loop; |
| 12736 |
12722 default: | 12737 default: |
12723 | 12738 |
12724 if (arg.endsWith$1('.dart')) { | 12739 if (arg.endsWith$1('.dart')) { |
12725 this.dartScript = arg; | 12740 this.dartScript = arg; |
12726 this.childArgs = args.getRange(i + 1, args.length - i - 1); | 12741 this.childArgs = args.getRange(i + 1, args.length - i - 1); |
12727 break loop; | 12742 break loop; |
12728 } | 12743 } |
12729 else if (arg.startsWith$1('--out=')) { | 12744 else if (arg.startsWith$1('--out=')) { |
12730 this.outfile = arg.substring$1('--out='.length); | 12745 this.outfile = arg.substring$1('--out='.length); |
12731 } | 12746 } |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13064 nameBuilder.add('\$').add(args.getName(i)); | 13079 nameBuilder.add('\$').add(args.getName(i)); |
13065 } | 13080 } |
13066 return nameBuilder.toString(); | 13081 return nameBuilder.toString(); |
13067 } | 13082 } |
13068 // ********** Library minfrog ************** | 13083 // ********** Library minfrog ************** |
13069 // ********** Code for top level ************** | 13084 // ********** Code for top level ************** |
13070 function main() { | 13085 function main() { |
13071 var homedir = path.dirname(fs.realpathSync(process.argv.$index(1))); | 13086 var homedir = path.dirname(fs.realpathSync(process.argv.$index(1))); |
13072 var argv = ListFactory.ListFactory$from$factory(process.argv); | 13087 var argv = ListFactory.ListFactory$from$factory(process.argv); |
13073 if (compile(homedir, argv, new NodeFileSystem())) { | 13088 if (compile(homedir, argv, new NodeFileSystem())) { |
| 13089 if ($globals.options.outfile != null) { |
| 13090 print(('Compilation succeded. Code generated in ' + $globals.options.outfi
le)); |
| 13091 } |
| 13092 else { |
| 13093 print('Compilation succeded.'); |
| 13094 } |
13074 var code = $globals.world.getGeneratedCode(); | 13095 var code = $globals.world.getGeneratedCode(); |
13075 if (!$globals.options.compileOnly) { | 13096 if (!$globals.options.compileOnly) { |
13076 process.argv = [argv.$index(0), argv.$index(1)]; | 13097 process.argv = [argv.$index(0), argv.$index(1)]; |
13077 process.argv.addAll($globals.options.childArgs); | 13098 process.argv.addAll($globals.options.childArgs); |
13078 vm.runInNewContext(code, createSandbox()); | 13099 vm.runInNewContext(code, createSandbox()); |
13079 } | 13100 } |
13080 } | 13101 } |
13081 else { | 13102 else { |
13082 process.exit(1); | 13103 process.exit(1); |
13083 } | 13104 } |
13084 } | 13105 } |
13085 // ********** Generic Type Inheritance ************** | 13106 // ********** Generic Type Inheritance ************** |
13086 /** Implements extends for generic types. */ | 13107 /** Implements extends for generic types. */ |
13087 function $inheritsMembers(child, parent) { | 13108 function $inheritsMembers(child, parent) { |
13088 child = child.prototype; | 13109 child = child.prototype; |
13089 parent = parent.prototype; | 13110 parent = parent.prototype; |
13090 Object.getOwnPropertyNames(parent).forEach(function(name) { | 13111 Object.getOwnPropertyNames(parent).forEach(function(name) { |
13091 if (typeof(child[name]) == 'undefined') child[name] = parent[name]; | 13112 if (typeof(child[name]) == 'undefined') child[name] = parent[name]; |
13092 }); | 13113 }); |
13093 } | 13114 } |
13094 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_E, DoubleLinkedQueueEntry_E); | 13115 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_E, DoubleLinkedQueueEntry_E); |
13095 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ
ueueEntry_KeyValuePair_K$V); | 13116 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ
ueueEntry_KeyValuePair_K$V); |
13096 // ********** Globals ************** | 13117 // ********** Globals ************** |
13097 function $static_init(){ | 13118 function $static_init(){ |
| 13119 $globals._MAGENTA_COLOR = '\u001b[35m'; |
| 13120 $globals._NO_COLOR = '\u001b[0m'; |
| 13121 $globals._RED_COLOR = '\u001b[31m'; |
13098 } | 13122 } |
13099 var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/; | 13123 var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/; |
13100 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/; | 13124 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/; |
13101 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; | 13125 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; |
13102 var $globals = {}; | 13126 var $globals = {}; |
13103 $static_init(); | 13127 $static_init(); |
13104 main(); | 13128 main(); |
OLD | NEW |