Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: frog/minfrog

Issue 8788004: Fixing parsing of factories. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated minfrog Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | frog/parser.dart » ('j') | frog/parser.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8110 matching lines...) Expand 10 before | Expand all | Expand 10 after
8121 if (this._maybeEat(77/*TokenKind.IMPLEMENTS*/)) { 8121 if (this._maybeEat(77/*TokenKind.IMPLEMENTS*/)) {
8122 _implements = this.typeList(); 8122 _implements = this.typeList();
8123 } 8123 }
8124 var _native = null; 8124 var _native = null;
8125 if (this._maybeEat(81/*TokenKind.NATIVE*/)) { 8125 if (this._maybeEat(81/*TokenKind.NATIVE*/)) {
8126 _native = this.maybeStringLiteral(); 8126 _native = this.maybeStringLiteral();
8127 if (_native != null) _native = new NativeType(_native); 8127 if (_native != null) _native = new NativeType(_native);
8128 } 8128 }
8129 var _factory = null; 8129 var _factory = null;
8130 if (this._maybeEat(75/*TokenKind.FACTORY*/)) { 8130 if (this._maybeEat(75/*TokenKind.FACTORY*/)) {
8131 _factory = this.type(0); 8131 _factory = this.nameTypeReference();
8132 if (this._peekKind(52/*TokenKind.LT*/)) {
8133 this.typeParameters();
8134 }
8132 } 8135 }
8133 var body = []; 8136 var body = [];
8134 if (this._maybeEat(6/*TokenKind.LBRACE*/)) { 8137 if (this._maybeEat(6/*TokenKind.LBRACE*/)) {
8135 while (!this._maybeEat(7/*TokenKind.RBRACE*/)) { 8138 while (!this._maybeEat(7/*TokenKind.RBRACE*/)) {
8136 if (this.isPrematureEndOfFile()) break; 8139 if (this.isPrematureEndOfFile()) break;
8137 body.add$1(this.declaration(true)); 8140 body.add$1(this.declaration(true));
8138 } 8141 }
8139 } 8142 }
8140 else { 8143 else {
8141 this._errorExpected('block starting with "{" or ";"'); 8144 this._errorExpected('block starting with "{" or ";"');
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
9338 return new GenericTypeReference(baseType, types, depth, span); 9341 return new GenericTypeReference(baseType, types, depth, span);
9339 } 9342 }
9340 Parser.prototype.typeList = function() { 9343 Parser.prototype.typeList = function() {
9341 var types = []; 9344 var types = [];
9342 do { 9345 do {
9343 types.add$1(this.type(0)); 9346 types.add$1(this.type(0));
9344 } 9347 }
9345 while (this._maybeEat(11/*TokenKind.COMMA*/)) 9348 while (this._maybeEat(11/*TokenKind.COMMA*/))
9346 return types; 9349 return types;
9347 } 9350 }
9348 Parser.prototype.type = function(depth) { 9351 Parser.prototype.nameTypeReference = function() {
9349 var start = this._peekToken.start; 9352 var start = this._peekToken.start;
9350 var name; 9353 var name;
9351 var names = null; 9354 var names = null;
9352 var typeArgs = null; 9355 var typeArgs = null;
9353 var isFinal = false; 9356 var isFinal = false;
9354 switch (this._peek()) { 9357 switch (this._peek()) {
9355 case 114/*TokenKind.VOID*/: 9358 case 114/*TokenKind.VOID*/:
9356 9359
9357 return new TypeReference(this._next().get$span(), $globals.world.voidType) ; 9360 return new TypeReference(this._next().get$span(), $globals.world.voidType) ;
9358 9361
(...skipping 11 matching lines...) Expand all
9370 default: 9373 default:
9371 9374
9372 name = this.identifier(); 9375 name = this.identifier();
9373 break; 9376 break;
9374 9377
9375 } 9378 }
9376 while (this._maybeEat(14/*TokenKind.DOT*/)) { 9379 while (this._maybeEat(14/*TokenKind.DOT*/)) {
9377 if (names == null) names = []; 9380 if (names == null) names = [];
9378 names.add$1(this.identifier()); 9381 names.add$1(this.identifier());
9379 } 9382 }
9380 var typeRef = new NameTypeReference(isFinal, name, names, this._makeSpan(start )); 9383 return new NameTypeReference(isFinal, name, names, this._makeSpan(start));
9384 }
9385 Parser.prototype.type = function(depth) {
9386 var typeRef = this.nameTypeReference();
9381 if (this._peekKind(52/*TokenKind.LT*/)) { 9387 if (this._peekKind(52/*TokenKind.LT*/)) {
9382 return this.addTypeArguments(typeRef, depth); 9388 return this.addTypeArguments(typeRef, depth);
9383 } 9389 }
9384 else { 9390 else {
9385 return typeRef; 9391 return typeRef;
9386 } 9392 }
9387 } 9393 }
9388 Parser.prototype.get$type = function() { 9394 Parser.prototype.get$type = function() {
9389 return Parser.prototype.type.bind(this); 9395 return Parser.prototype.type.bind(this);
9390 } 9396 }
(...skipping 3046 matching lines...) Expand 10 before | Expand all | Expand 10 after
12437 World.prototype.withTiming = function(name, f) { 12443 World.prototype.withTiming = function(name, f) {
12438 var sw = new StopwatchImplementation(); 12444 var sw = new StopwatchImplementation();
12439 sw.start(); 12445 sw.start();
12440 var result = f(); 12446 var result = f();
12441 sw.stop(); 12447 sw.stop();
12442 this.info(('' + name + ' in ' + sw.elapsedInMs() + 'msec')); 12448 this.info(('' + name + ' in ' + sw.elapsedInMs() + 'msec'));
12443 return result; 12449 return result;
12444 } 12450 }
12445 // ********** Code for FrogOptions ************** 12451 // ********** Code for FrogOptions **************
12446 function FrogOptions(homedir, args, files) { 12452 function FrogOptions(homedir, args, files) {
12453 this.config = 'dev'
12447 this.enableLeg = false 12454 this.enableLeg = false
12448 this.legOnly = false 12455 this.legOnly = false
12449 this.enableAsserts = false 12456 this.enableAsserts = false
12450 this.enableTypeChecks = false 12457 this.enableTypeChecks = false
12451 this.warningsAsErrors = false 12458 this.warningsAsErrors = false
12452 this.verifyImplements = false 12459 this.verifyImplements = false
12453 this.compileAll = false 12460 this.compileAll = false
12454 this.forceDynamic = false 12461 this.forceDynamic = false
12455 this.dietParse = false 12462 this.dietParse = false
12456 this.compileOnly = false 12463 this.compileOnly = false
12457 this.throwOnErrors = false 12464 this.throwOnErrors = false
12458 this.throwOnWarnings = false 12465 this.throwOnWarnings = false
12459 this.throwOnFatal = false 12466 this.throwOnFatal = false
12460 this.showInfo = false 12467 this.showInfo = false
12461 this.showWarnings = true 12468 this.showWarnings = true
12462 // Initializers done 12469 // Initializers done
12463 this.libDir = homedir + '/lib'; 12470 if ($eq(this.config, 'dev')) {
12471 this.libDir = joinPaths(homedir, '/lib');
12472 }
12473 else if ($eq(this.config, 'sdk')) {
12474 this.libDir = joinPaths(homedir, '/../lib');
12475 }
12476 else {
12477 $globals.world.error(('Invalid configuration ' + this.config));
12478 $throw(('Invalid configuration'));
12479 }
12464 var ignoreUnrecognizedFlags = false; 12480 var ignoreUnrecognizedFlags = false;
12465 var passedLibDir = false; 12481 var passedLibDir = false;
12466 this.childArgs = []; 12482 this.childArgs = [];
12467 loop: 12483 loop:
12468 for (var i = 2; 12484 for (var i = 2;
12469 i < args.length; i++) { 12485 i < args.length; i++) {
12470 var arg = args.$index(i); 12486 var arg = args.$index(i);
12471 switch (arg) { 12487 switch (arg) {
12472 case '--enable_leg': 12488 case '--enable_leg':
12473 12489
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
12561 passedLibDir = true; 12577 passedLibDir = true;
12562 } 12578 }
12563 else { 12579 else {
12564 if (!ignoreUnrecognizedFlags) { 12580 if (!ignoreUnrecognizedFlags) {
12565 print(('unrecognized flag: "' + arg + '"')); 12581 print(('unrecognized flag: "' + arg + '"'));
12566 } 12582 }
12567 } 12583 }
12568 12584
12569 } 12585 }
12570 } 12586 }
12571 if (!passedLibDir && !files.fileExists(this.libDir)) { 12587 if (!passedLibDir && $eq(this.config, 'dev') && !files.fileExists(this.libDir) ) {
12572 var temp = 'frog/lib'; 12588 var temp = 'frog/lib';
12573 if (files.fileExists(temp)) { 12589 if (files.fileExists(temp)) {
12574 this.libDir = temp; 12590 this.libDir = temp;
12575 } 12591 }
12576 else { 12592 else {
12577 this.libDir = 'lib'; 12593 this.libDir = 'lib';
12578 } 12594 }
12579 } 12595 }
12580 } 12596 }
12581 // ********** Code for LibraryReader ************** 12597 // ********** Code for LibraryReader **************
12582 function LibraryReader() { 12598 function LibraryReader() {
12583 // Initializers done 12599 // Initializers done
12584 this._specialLibs = _map(['dart:core', joinPaths($globals.options.libDir, 'cor elib.dart'), 'dart:coreimpl', joinPaths($globals.options.libDir, 'corelib_impl.d art'), 'dart:html', joinPaths($globals.options.libDir, '../../client/html/releas e/html.dart'), 'dart:htmlimpl', joinPaths($globals.options.libDir, '../../client /html/release/htmlimpl.dart'), 'dart:dom', joinPaths($globals.options.libDir, '. ./../client/dom/frog/frog_dom.dart'), 'dart:json', joinPaths($globals.options.li bDir, 'json.dart')]); 12600 if ($eq($globals.options.config, 'dev')) {
12601 this._specialLibs = _map(['dart:core', joinPaths($globals.options.libDir, 'c orelib.dart'), 'dart:coreimpl', joinPaths($globals.options.libDir, 'corelib_impl .dart'), 'dart:html', joinPaths($globals.options.libDir, '../../client/html/rele ase/html.dart'), 'dart:htmlimpl', joinPaths($globals.options.libDir, '../../clie nt/html/release/htmlimpl.dart'), 'dart:dom', joinPaths($globals.options.libDir, '../../client/dom/frog/frog_dom.dart'), 'dart:json', joinPaths($globals.options. libDir, 'json.dart')]);
12602 }
12603 else if ($eq($globals.options.config, 'sdk')) {
12604 this._specialLibs = _map(['dart:core', joinPaths($globals.options.libDir, 'c ore/core_frog.dart'), 'dart:coreimpl', joinPaths($globals.options.libDir, 'corei mpl/coreimpl_frog.dart'), 'dart:html', joinPaths($globals.options.libDir, 'html/ html.dart'), 'dart:htmlimpl', joinPaths($globals.options.libDir, 'htmlimpl/htmli mpl.dart'), 'dart:dom', joinPaths($globals.options.libDir, 'dom/frog/frog_dom.da rt'), 'dart:json', joinPaths($globals.options.libDir, 'coreimpl/frog/json.dart') ]);
12605 }
12606 else {
12607 $globals.world.error(('Invalid configuration ' + $globals.options.config));
12608 }
12585 } 12609 }
12586 LibraryReader.prototype.readFile = function(fullname) { 12610 LibraryReader.prototype.readFile = function(fullname) {
12587 var filename = this._specialLibs.$index(fullname); 12611 var filename = this._specialLibs.$index(fullname);
12588 if (filename == null) { 12612 if (filename == null) {
12589 filename = fullname; 12613 filename = fullname;
12590 } 12614 }
12591 if ($globals.world.files.fileExists(filename)) { 12615 if ($globals.world.files.fileExists(filename)) {
12592 return new SourceFile(filename, $globals.world.files.readAll(filename)); 12616 return new SourceFile(filename, $globals.world.files.readAll(filename));
12593 } 12617 }
12594 else { 12618 else {
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
12914 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ ueueEntry_KeyValuePair_K$V); 12938 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ ueueEntry_KeyValuePair_K$V);
12915 // ********** Globals ************** 12939 // ********** Globals **************
12916 function $static_init(){ 12940 function $static_init(){
12917 } 12941 }
12918 var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/; 12942 var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/;
12919 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/; 12943 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/;
12920 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; 12944 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/;
12921 var $globals = {}; 12945 var $globals = {};
12922 $static_init(); 12946 $static_init();
12923 main(); 12947 main();
OLDNEW
« no previous file with comments | « no previous file | frog/parser.dart » ('j') | frog/parser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698