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

Side by Side Diff: dart/frog/frogsh

Issue 8497011: Parse formal parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased, frogsh, type warning Created 9 years, 1 month 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 | dart/frog/leg/elements/elements.dart » ('j') | no next file with comments »
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) { this($0, $1, true, capture); } 7 * function($0, $1, capture) { 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 5174 matching lines...) Expand 10 before | Expand all | Expand 10 after
5185 Parser.prototype.parseInterfaceBody = function(token) { 5185 Parser.prototype.parseInterfaceBody = function(token) {
5186 token = this.skipBlock(token); 5186 token = this.skipBlock(token);
5187 this.listener.endInterface(token); 5187 this.listener.endInterface(token);
5188 return token.next; 5188 return token.next;
5189 } 5189 }
5190 Parser.prototype.parseNamedFunctionAlias = function(token) { 5190 Parser.prototype.parseNamedFunctionAlias = function(token) {
5191 this.listener.beginFunctionTypeAlias(token); 5191 this.listener.beginFunctionTypeAlias(token);
5192 token = this.parseReturnTypeOpt(this.next(token)); 5192 token = this.parseReturnTypeOpt(this.next(token));
5193 token = this.parseIdentifier(token); 5193 token = this.parseIdentifier(token);
5194 token = this.parseTypeVariablesOpt(token); 5194 token = this.parseTypeVariablesOpt(token);
5195 token = this.parseParameters(token); 5195 token = this.parseFormalParameters(token);
5196 this.listener.endFunctionTypeAlias(token); 5196 this.listener.endFunctionTypeAlias(token);
5197 return this.expect(';', token); 5197 return this.expect(';', token);
5198 } 5198 }
5199 Parser.prototype.parseReturnTypeOpt = function(token) { 5199 Parser.prototype.parseReturnTypeOpt = function(token) {
5200 if ($notnull_bool(token.get$stringValue() === 'void')) { 5200 if ($notnull_bool(token.get$stringValue() === 'void')) {
5201 this.listener.voidType(token); 5201 this.listener.voidType(token);
5202 return this.next(token); 5202 return this.next(token);
5203 } 5203 }
5204 else { 5204 else {
5205 return this.parseTypeOpt(token); 5205 return this.parseTypeOpt(token);
5206 } 5206 }
5207 } 5207 }
5208 Parser.prototype.parseParameters = function(token) { 5208 Parser.prototype.parseFormalParameters = function(token) {
5209 var begin = token;
5210 this.listener.beginFormalParameters(begin);
5209 this.expect('(', token); 5211 this.expect('(', token);
5210 if ($notnull_bool(this.optional(')', this.next(token)))) { 5212 var parameterCount = 0;
5211 return this.next(this.next(token)); 5213 if ($notnull_bool(this.optional(')', token.next))) {
5214 this.listener.endFormalParameters(parameterCount, begin, token.next);
5215 return token.next.next;
5212 } 5216 }
5213 do { 5217 do {
5218 this.listener.beginFormalParameter(token);
5214 token = this.parseTypeOpt(this.next(token)); 5219 token = this.parseTypeOpt(this.next(token));
5215 token = this.parseIdentifier(token); 5220 token = this.parseIdentifier(token);
5221 this.listener.endFormalParameter(token);
5222 ++parameterCount;
5216 } 5223 }
5217 while ($notnull_bool(this.optional(',', token))) 5224 while ($notnull_bool(this.optional(',', token)))
5225 this.listener.endFormalParameters(parameterCount, begin, token);
5218 return this.expect(')', token); 5226 return this.expect(')', token);
5219 } 5227 }
5220 Parser.prototype.parseTypeOpt = function(token) { 5228 Parser.prototype.parseTypeOpt = function(token) {
5221 var nextValue = token.next.get$stringValue(); 5229 var nextValue = token.next.get$stringValue();
5222 switch (true) { 5230 switch (true) {
5223 case nextValue === '<': 5231 case nextValue === '<':
5224 case nextValue === '.': 5232 case nextValue === '.':
5225 case this.isIdentifier(token.next): 5233 case this.isIdentifier(token.next):
5226 5234
5227 return this.parseType(token); 5235 return this.parseType(token);
5228 5236
5229 default: 5237 default:
5230 5238
5239 this.listener.handleNoType(token);
5231 return token; 5240 return token;
5232 5241
5233 } 5242 }
5234 } 5243 }
5235 Parser.prototype.isIdentifier = function(token) { 5244 Parser.prototype.isIdentifier = function(token) {
5236 var kind = token.kind; 5245 var kind = token.kind;
5237 switch (true) { 5246 switch (true) {
5238 case kind === 97/*null.IDENTIFIER_TOKEN*/: 5247 case kind === 97/*null.IDENTIFIER_TOKEN*/:
5239 5248
5240 return true; 5249 return true;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
5467 $inherits(BodyParser, Parser); 5476 $inherits(BodyParser, Parser);
5468 BodyParser.prototype.parseFunction = function(token) { 5477 BodyParser.prototype.parseFunction = function(token) {
5469 this.listener.beginFunction(token); 5478 this.listener.beginFunction(token);
5470 token = this.parseReturnTypeOpt(token); 5479 token = this.parseReturnTypeOpt(token);
5471 this.listener.beginFunctionName(token); 5480 this.listener.beginFunctionName(token);
5472 token = this.parseIdentifier(token); 5481 token = this.parseIdentifier(token);
5473 this.listener.endFunctionName(token); 5482 this.listener.endFunctionName(token);
5474 token = this.parseFormalParameters(token); 5483 token = this.parseFormalParameters(token);
5475 return this.parseFunctionBody(token); 5484 return this.parseFunctionBody(token);
5476 } 5485 }
5477 BodyParser.prototype.parseFormalParameters = function(token) {
5478 var begin = token;
5479 this.listener.beginFormalParameters(begin);
5480 this.expect('(', token);
5481 var parameterCount = 0;
5482 if ($notnull_bool(this.optional(')', token.next))) {
5483 this.listener.endFormalParameters(parameterCount, begin, token.next);
5484 return token.next.next;
5485 }
5486 do {
5487 token = this.parseType(this.next(token));
5488 token = this.parseIdentifier(token);
5489 ++parameterCount;
5490 }
5491 while ($notnull_bool(this.optional(',', token)))
5492 this.listener.endFormalParameters(parameterCount, begin, token);
5493 return this.expect(')', token);
5494 }
5495 BodyParser.prototype.parseFunctionBody = function(token) { 5486 BodyParser.prototype.parseFunctionBody = function(token) {
5496 if ($notnull_bool(this.optional(';', token))) { 5487 if ($notnull_bool(this.optional(';', token))) {
5497 this.listener.endFunctionBody(0, null, token); 5488 this.listener.endFunctionBody(0, null, token);
5498 return token.next; 5489 return token.next;
5499 } 5490 }
5500 var begin = token; 5491 var begin = token;
5501 var statementCount = 0; 5492 var statementCount = 0;
5502 this.listener.beginFunctionBody(begin); 5493 this.listener.beginFunctionBody(begin);
5503 token = this.checkEof(this.expect('{', token)); 5494 token = this.checkEof(this.expect('{', token));
5504 while ($notnull_bool(!$notnull_bool(this.optional('}', token)))) { 5495 while ($notnull_bool(!$notnull_bool(this.optional('}', token)))) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5537 return this.parseExpressionStatement(token); 5528 return this.parseExpressionStatement(token);
5538 5529
5539 } 5530 }
5540 } 5531 }
5541 BodyParser.prototype.expectSemicolon = function(token) { 5532 BodyParser.prototype.expectSemicolon = function(token) {
5542 return this.expect(';', token); 5533 return this.expect(';', token);
5543 } 5534 }
5544 BodyParser.prototype.parseReturnStatement = function(token) { 5535 BodyParser.prototype.parseReturnStatement = function(token) {
5545 var begin = token; 5536 var begin = token;
5546 this.listener.beginReturnStatement(begin); 5537 this.listener.beginReturnStatement(begin);
5547 $assert('return' === token.get$stringValue(), "'return' === token.stringValue" , "parser.dart", 409, 12); 5538 $assert('return' === token.get$stringValue(), "'return' === token.stringValue" , "parser.dart", 399, 12);
5548 token = this.parseExpression(this.next(token)); 5539 token = this.parseExpression(this.next(token));
5549 this.listener.endReturnStatement(true, begin, token); 5540 this.listener.endReturnStatement(true, begin, token);
5550 return this.expectSemicolon(token); 5541 return this.expectSemicolon(token);
5551 } 5542 }
5552 BodyParser.prototype.parseExpressionStatementOrDeclaration = function(token) { 5543 BodyParser.prototype.parseExpressionStatementOrDeclaration = function(token) {
5553 $assert(token.kind === 97/*null.IDENTIFIER_TOKEN*/, "token.kind === IDENTIFIER _TOKEN", "parser.dart", 416, 12); 5544 $assert(token.kind === 97/*null.IDENTIFIER_TOKEN*/, "token.kind === IDENTIFIER _TOKEN", "parser.dart", 406, 12);
5554 var peek1 = this.next(token); 5545 var peek1 = this.next(token);
5555 if ($notnull_bool(peek1.kind === 97/*null.IDENTIFIER_TOKEN*/)) { 5546 if ($notnull_bool(peek1.kind === 97/*null.IDENTIFIER_TOKEN*/)) {
5556 return this.parseLocalDeclaration(token, peek1); 5547 return this.parseLocalDeclaration(token, peek1);
5557 } 5548 }
5558 else { 5549 else {
5559 return this.parseExpressionStatement(token); 5550 return this.parseExpressionStatement(token);
5560 } 5551 }
5561 } 5552 }
5562 BodyParser.prototype.parseLocalDeclaration = function(token, peek1) { 5553 BodyParser.prototype.parseLocalDeclaration = function(token, peek1) {
5563 var peek2 = this.next(peek1); 5554 var peek2 = this.next(peek1);
(...skipping 28 matching lines...) Expand all
5592 var question = token; 5583 var question = token;
5593 token = this.parseExpression(this.next(token)); 5584 token = this.parseExpression(this.next(token));
5594 var colon = token; 5585 var colon = token;
5595 token = this.expect(':', token); 5586 token = this.expect(':', token);
5596 token = this.parseExpression(token); 5587 token = this.parseExpression(token);
5597 this.listener.handleConditionalExpression(question, colon); 5588 this.listener.handleConditionalExpression(question, colon);
5598 } 5589 }
5599 return token; 5590 return token;
5600 } 5591 }
5601 BodyParser.prototype.parseBinaryExpression = function(token, precedence) { 5592 BodyParser.prototype.parseBinaryExpression = function(token, precedence) {
5602 $assert(precedence >= 4, "precedence >= 4", "parser.dart", 469, 12); 5593 $assert(precedence >= 4, "precedence >= 4", "parser.dart", 459, 12);
5603 token = this.parsePrimary(token); 5594 token = this.parsePrimary(token);
5604 var tokenLevel = this.getPrecedence(token); 5595 var tokenLevel = this.getPrecedence(token);
5605 for (var level = tokenLevel; 5596 for (var level = tokenLevel;
5606 $notnull_bool(level >= precedence); --level) { 5597 $notnull_bool(level >= precedence); --level) {
5607 while ($notnull_bool(tokenLevel === level)) { 5598 while ($notnull_bool(tokenLevel === level)) {
5608 var operator = token; 5599 var operator = token;
5609 token = this.parseBinaryExpression(this.next(token), level + 1); 5600 token = this.parseBinaryExpression(this.next(token), level + 1);
5610 this.listener.handleBinaryExpression(operator); 5601 this.listener.handleBinaryExpression(operator);
5611 tokenLevel = this.getPrecedence(token); 5602 tokenLevel = this.getPrecedence(token);
5612 } 5603 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
5857 this.listener.handleNoArguments(token); 5848 this.listener.handleNoArguments(token);
5858 return token; 5849 return token;
5859 } 5850 }
5860 else { 5851 else {
5861 return this.parseArguments(token); 5852 return this.parseArguments(token);
5862 } 5853 }
5863 } 5854 }
5864 BodyParser.prototype.parseArguments = function(token) { 5855 BodyParser.prototype.parseArguments = function(token) {
5865 var begin = token; 5856 var begin = token;
5866 this.listener.beginArguments(begin); 5857 this.listener.beginArguments(begin);
5867 $assert('(' === token.get$stringValue(), "'(' === token.stringValue", "parser. dart", 602, 12); 5858 $assert('(' === token.get$stringValue(), "'(' === token.stringValue", "parser. dart", 592, 12);
5868 var argumentCount = 0; 5859 var argumentCount = 0;
5869 if ($notnull_bool(this.optional(')', token.next))) { 5860 if ($notnull_bool(this.optional(')', token.next))) {
5870 this.listener.endArguments(argumentCount, begin, token.next); 5861 this.listener.endArguments(argumentCount, begin, token.next);
5871 return token.next.next; 5862 return token.next.next;
5872 } 5863 }
5873 do { 5864 do {
5874 token = this.parseExpression(this.next(token)); 5865 token = this.parseExpression(this.next(token));
5875 ++argumentCount; 5866 ++argumentCount;
5876 } 5867 }
5877 while ($notnull_bool(this.optional(',', token))) 5868 while ($notnull_bool(this.optional(',', token)))
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
5978 } 5969 }
5979 Listener.prototype.endClass = function(token) { 5970 Listener.prototype.endClass = function(token) {
5980 5971
5981 } 5972 }
5982 Listener.prototype.beginExpressionStatement = function(token) { 5973 Listener.prototype.beginExpressionStatement = function(token) {
5983 5974
5984 } 5975 }
5985 Listener.prototype.endExpressionStatement = function(token) { 5976 Listener.prototype.endExpressionStatement = function(token) {
5986 5977
5987 } 5978 }
5979 Listener.prototype.beginFormalParameter = function(token) {
5980
5981 }
5982 Listener.prototype.endFormalParameter = function(token) {
5983
5984 }
5988 Listener.prototype.beginFormalParameters = function(token) { 5985 Listener.prototype.beginFormalParameters = function(token) {
5989 5986
5990 } 5987 }
5991 Listener.prototype.endFormalParameters = function(count, beginToken, endToken) { 5988 Listener.prototype.endFormalParameters = function(count, beginToken, endToken) {
5992 5989
5993 } 5990 }
5994 Listener.prototype.beginFunction = function(token) { 5991 Listener.prototype.beginFunction = function(token) {
5995 5992
5996 } 5993 }
5997 Listener.prototype.beginFunctionBody = function(token) { 5994 Listener.prototype.beginFunctionBody = function(token) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
6098 } 6095 }
6099 Listener.prototype.handleLiteralInt = function(token) { 6096 Listener.prototype.handleLiteralInt = function(token) {
6100 6097
6101 } 6098 }
6102 Listener.prototype.handleLiteralString = function(token) { 6099 Listener.prototype.handleLiteralString = function(token) {
6103 6100
6104 } 6101 }
6105 Listener.prototype.handleNoArguments = function(token) { 6102 Listener.prototype.handleNoArguments = function(token) {
6106 6103
6107 } 6104 }
6105 Listener.prototype.handleNoType = function(token) {
6106
6107 }
6108 Listener.prototype.handleNoTypeVariables = function(token) { 6108 Listener.prototype.handleNoTypeVariables = function(token) {
6109 6109
6110 } 6110 }
6111 Listener.prototype.handleVarKeyword = function(token) { 6111 Listener.prototype.handleVarKeyword = function(token) {
6112 6112
6113 } 6113 }
6114 Listener.prototype.identifier = function(token) { 6114 Listener.prototype.identifier = function(token) {
6115 6115
6116 } 6116 }
6117 Listener.prototype.topLevelField = function(token) { 6117 Listener.prototype.topLevelField = function(token) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
6276 } 6276 }
6277 // ********** Code for BodyListener ************** 6277 // ********** Code for BodyListener **************
6278 function BodyListener(canceler, logger) { 6278 function BodyListener(canceler, logger) {
6279 this.nodes = const$228/*const EmptyLink<DeclarationBuilder>()*/ 6279 this.nodes = const$228/*const EmptyLink<DeclarationBuilder>()*/
6280 this.logger = logger; 6280 this.logger = logger;
6281 ElementListener.call(this, canceler); 6281 ElementListener.call(this, canceler);
6282 // Initializers done 6282 // Initializers done
6283 this.onError = this.get$handleOnError(); 6283 this.onError = this.get$handleOnError();
6284 } 6284 }
6285 $inherits(BodyListener, ElementListener); 6285 $inherits(BodyListener, ElementListener);
6286 BodyListener.prototype.endFormalParameter = function(token) {
6287 var name = new NodeList.singleton$ctor(this.popNode());
6288 var type = this.popNode();
6289 this.pushNode(new VariableDefinitions(type, null, name, token));
6290 }
6286 BodyListener.prototype.endFormalParameters = function(count, beginToken, endToke n) { 6291 BodyListener.prototype.endFormalParameters = function(count, beginToken, endToke n) {
6287 this.pushNode(this.makeNodeList(count, beginToken, endToken, ",")); 6292 this.pushNode(this.makeNodeList(count, beginToken, endToken, ","));
6288 } 6293 }
6289 BodyListener.prototype.endArguments = function(count, beginToken, endToken) { 6294 BodyListener.prototype.endArguments = function(count, beginToken, endToken) {
6290 this.pushNode(this.makeNodeList(count, beginToken, endToken, ",")); 6295 this.pushNode(this.makeNodeList(count, beginToken, endToken, ","));
6291 } 6296 }
6292 BodyListener.prototype.handleNoArguments = function(token) { 6297 BodyListener.prototype.handleNoArguments = function(token) {
6293 this.pushNode(null); 6298 this.pushNode(null);
6294 } 6299 }
6295 BodyListener.prototype.endReturnStatement = function(hasExpression, beginToken, endToken) { 6300 BodyListener.prototype.endReturnStatement = function(hasExpression, beginToken, endToken) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
6384 var $0; 6389 var $0;
6385 this.pushNode(new TypeAnnotation((($0 = this.popNode()) && $0.is$Identifier()) )); 6390 this.pushNode(new TypeAnnotation((($0 = this.popNode()) && $0.is$Identifier()) ));
6386 } 6391 }
6387 BodyListener.prototype.pushNode = function(node) { 6392 BodyListener.prototype.pushNode = function(node) {
6388 var $0; 6393 var $0;
6389 this.nodes = (($0 = this.nodes.prepend(node)) && $0.is$Link$Node()); 6394 this.nodes = (($0 = this.nodes.prepend(node)) && $0.is$Link$Node());
6390 this.logger.log(("push " + this.nodes + "")); 6395 this.logger.log(("push " + this.nodes + ""));
6391 } 6396 }
6392 BodyListener.prototype.popNode = function() { 6397 BodyListener.prototype.popNode = function() {
6393 var $0; 6398 var $0;
6394 $assert(!$notnull_bool(this.nodes.isEmpty()), "!nodes.isEmpty()", "listener.da rt", 510, 12); 6399 $assert(!$notnull_bool(this.nodes.isEmpty()), "!nodes.isEmpty()", "listener.da rt", 525, 12);
6395 var node = this.nodes.get$head(); 6400 var node = this.nodes.get$head();
6396 this.nodes = (($0 = this.nodes.get$tail()) && $0.is$Link$Node()); 6401 this.nodes = (($0 = this.nodes.get$tail()) && $0.is$Link$Node());
6397 this.logger.log(("pop " + this.nodes + "")); 6402 this.logger.log(("pop " + this.nodes + ""));
6398 return node; 6403 return node;
6399 } 6404 }
6400 BodyListener.prototype.makeNodeList = function(count, beginToken, endToken, deli miter) { 6405 BodyListener.prototype.makeNodeList = function(count, beginToken, endToken, deli miter) {
6401 var $0; 6406 var $0;
6402 var nodes = const$228/*const EmptyLink<DeclarationBuilder>()*/; 6407 var nodes = const$228/*const EmptyLink<DeclarationBuilder>()*/;
6403 for (; $notnull_bool(count > 0); --count) { 6408 for (; $notnull_bool(count > 0); --count) {
6404 nodes = (($0 = nodes.prepend(this.popNode())) && $0.is$Link$Node()); 6409 nodes = (($0 = nodes.prepend(this.popNode())) && $0.is$Link$Node());
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
6998 } 7003 }
6999 // ********** Code for Operator ************** 7004 // ********** Code for Operator **************
7000 function Operator(token) { 7005 function Operator(token) {
7001 Identifier.call(this, token); 7006 Identifier.call(this, token);
7002 // Initializers done 7007 // Initializers done
7003 } 7008 }
7004 $inherits(Operator, Identifier); 7009 $inherits(Operator, Identifier);
7005 Operator.prototype.accept = function(visitor) { 7010 Operator.prototype.accept = function(visitor) {
7006 return visitor.visitOperator(this); 7011 return visitor.visitOperator(this);
7007 } 7012 }
7008 // ********** Code for Parameter **************
7009 function Parameter() {}
7010 $inherits(Parameter, Node);
7011 Parameter.prototype.get$name = function() { return this.name; };
7012 Parameter.prototype.accept = function(visitor) {
7013 return visitor.visitParameter(this);
7014 }
7015 Parameter.prototype.getBeginToken = function() {
7016 return firstBeginToken(this.typeAnnotation, this.name);
7017 }
7018 Parameter.prototype.getEndToken = function() {
7019 return this.name.getEndToken();
7020 }
7021 // ********** Code for Return ************** 7013 // ********** Code for Return **************
7022 function Return(beginToken, endToken, expression) { 7014 function Return(beginToken, endToken, expression) {
7023 this.beginToken = beginToken; 7015 this.beginToken = beginToken;
7024 this.endToken = endToken; 7016 this.endToken = endToken;
7025 this.expression = expression; 7017 this.expression = expression;
7026 // Initializers done 7018 // Initializers done
7027 } 7019 }
7028 $inherits(Return, Statement); 7020 $inherits(Return, Statement);
7029 Return.prototype.get$hasExpression = function() { 7021 Return.prototype.get$hasExpression = function() {
7030 return this.expression != null; 7022 return this.expression != null;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
7154 if ($notnull_bool(!$notnull_bool(first))) delimiter.printOn(this.sb); 7146 if ($notnull_bool(!$notnull_bool(first))) delimiter.printOn(this.sb);
7155 first = false; 7147 first = false;
7156 this.visit(element); 7148 this.visit(element);
7157 } 7149 }
7158 } 7150 }
7159 if ($notnull_bool(node.endToken != null)) this.sb.add(node.endToken); 7151 if ($notnull_bool(node.endToken != null)) this.sb.add(node.endToken);
7160 } 7152 }
7161 DebugUnparser.prototype.visitOperator = function(node) { 7153 DebugUnparser.prototype.visitOperator = function(node) {
7162 this.visitIdentifier(node); 7154 this.visitIdentifier(node);
7163 } 7155 }
7164 DebugUnparser.prototype.visitParameter = function(node) {
7165 if ($notnull_bool(node.typeAnnotation != null)) {
7166 this.visit(node.typeAnnotation);
7167 this.sb.add(' ');
7168 }
7169 this.visit(node.name);
7170 }
7171 DebugUnparser.prototype.visitReturn = function(node) { 7156 DebugUnparser.prototype.visitReturn = function(node) {
7172 node.beginToken.get$value().printOn$1(this.sb); 7157 node.beginToken.get$value().printOn$1(this.sb);
7173 if ($notnull_bool(node.get$hasExpression())) { 7158 if ($notnull_bool(node.get$hasExpression())) {
7174 this.sb.add(' '); 7159 this.sb.add(' ');
7175 this.visit(node.expression); 7160 this.visit(node.expression);
7176 } 7161 }
7177 node.endToken.get$value().printOn$1(this.sb); 7162 node.endToken.get$value().printOn$1(this.sb);
7178 } 7163 }
7179 DebugUnparser.prototype.visitSend = function(node) { 7164 DebugUnparser.prototype.visitSend = function(node) {
7180 if ($notnull_bool(node.receiver != null)) { 7165 if ($notnull_bool(node.receiver != null)) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
7230 var $0; 7215 var $0;
7231 if ($notnull_bool(this.type != null)) return this.type; 7216 if ($notnull_bool(this.type != null)) return this.type;
7232 var node = this.parseNode(compiler, compiler); 7217 var node = this.parseNode(compiler, compiler);
7233 var returnType = getType(node.returnType, types); 7218 var returnType = getType(node.returnType, types);
7234 if ($notnull_bool(returnType == null)) compiler.cancel(('unknown type ' + retu rnType + '')); 7219 if ($notnull_bool(returnType == null)) compiler.cancel(('unknown type ' + retu rnType + ''));
7235 var parameterTypes = new LinkBuilderImplementation$Type(); 7220 var parameterTypes = new LinkBuilderImplementation$Type();
7236 for (var link = node.parameters.nodes; 7221 for (var link = node.parameters.nodes;
7237 $notnull_bool(!$notnull_bool(link.isEmpty())); link = link.get$tail()) { 7222 $notnull_bool(!$notnull_bool(link.isEmpty())); link = link.get$tail()) {
7238 compiler.cancel('parameters not supported.'); 7223 compiler.cancel('parameters not supported.');
7239 var parameter = link.get$head(); 7224 var parameter = link.get$head();
7240 parameterTypes.addLast(getType(parameter.typeAnnotation, types)); 7225 parameterTypes.addLast(getType(parameter.type, types));
7241 } 7226 }
7242 this.type = new FunctionType(returnType, (($0 = parameterTypes.toLink()) && $0 .is$Link$Type())); 7227 this.type = new FunctionType(returnType, (($0 = parameterTypes.toLink()) && $0 .is$Link$Type()));
7243 return this.type; 7228 return this.type;
7244 } 7229 }
7245 // ********** Code for top level ************** 7230 // ********** Code for top level **************
7246 function getType(annotation, types) { 7231 function getType(annotation, types) {
7247 if ($notnull_bool(annotation == null || annotation.typeName == null)) { 7232 if ($notnull_bool(annotation == null || annotation.typeName == null)) {
7248 return types.get$dynamic(); 7233 return types.get$dynamic();
7249 } 7234 }
7250 return types.lookup(annotation.typeName.get$source()); 7235 return types.lookup(annotation.typeName.get$source());
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
7393 SsaBuilder.prototype.visitNodeList = function(node) { 7378 SsaBuilder.prototype.visitNodeList = function(node) {
7394 var $0; 7379 var $0;
7395 for (var link = node.nodes; 7380 for (var link = node.nodes;
7396 $notnull_bool(!$notnull_bool(link.isEmpty())); link = (($0 = link.get$tail()) && $0.is$Link$Node())) { 7381 $notnull_bool(!$notnull_bool(link.isEmpty())); link = (($0 = link.get$tail()) && $0.is$Link$Node())) {
7397 this.visit((($0 = link.get$head()) && $0.is$Node())); 7382 this.visit((($0 = link.get$head()) && $0.is$Node()));
7398 } 7383 }
7399 } 7384 }
7400 SsaBuilder.prototype.visitOperator = function(node) { 7385 SsaBuilder.prototype.visitOperator = function(node) {
7401 this.compiler.unimplemented("SsaBuilder.visitOperator"); 7386 this.compiler.unimplemented("SsaBuilder.visitOperator");
7402 } 7387 }
7403 SsaBuilder.prototype.visitParameter = function(node) {
7404 this.compiler.unimplemented("SsaBuilder.visitParameter");
7405 }
7406 SsaBuilder.prototype.visitReturn = function(node) { 7388 SsaBuilder.prototype.visitReturn = function(node) {
7407 this.visit(node.expression); 7389 this.visit(node.expression);
7408 var value = this.pop(); 7390 var value = this.pop();
7409 this.add(new HReturn(value)); 7391 this.add(new HReturn(value));
7410 this.graph.setSuccessors(this.block, [this.graph.exit]); 7392 this.graph.setSuccessors(this.block, [this.graph.exit]);
7411 } 7393 }
7412 SsaBuilder.prototype.visitTypeAnnotation = function(node) { 7394 SsaBuilder.prototype.visitTypeAnnotation = function(node) {
7413 7395
7414 } 7396 }
7415 SsaBuilder.prototype.updateDefinition = function(node) { 7397 SsaBuilder.prototype.updateDefinition = function(node) {
7416 var $0; 7398 var $0;
7417 if ($notnull_bool(node.receiver != null)) { 7399 if ($notnull_bool(node.receiver != null)) {
7418 this.compiler.unimplemented("SsaBuilder: property access"); 7400 this.compiler.unimplemented("SsaBuilder: property access");
7419 } 7401 }
7420 var link = node.get$arguments(); 7402 var link = node.get$arguments();
7421 $assert(!$notnull_bool(link.isEmpty()) && link.get$tail().isEmpty(), "!link.is Empty() && link.tail.isEmpty()", "builder.dart", 197, 12); 7403 $assert(!$notnull_bool(link.isEmpty()) && link.get$tail().isEmpty(), "!link.is Empty() && link.tail.isEmpty()", "builder.dart", 193, 12);
7422 this.visit((($0 = link.get$head()) && $0.is$Node())); 7404 this.visit((($0 = link.get$head()) && $0.is$Node()));
7423 var value = this.pop(); 7405 var value = this.pop();
7424 return this.definitions.$setindex(this.elements.$index(node), value); 7406 return this.definitions.$setindex(this.elements.$index(node), value);
7425 } 7407 }
7426 SsaBuilder.prototype.visitVariableDefinitions = function(node) { 7408 SsaBuilder.prototype.visitVariableDefinitions = function(node) {
7427 var $0; 7409 var $0;
7428 for (var link = node.definitions.nodes; 7410 for (var link = node.definitions.nodes;
7429 $notnull_bool(!$notnull_bool(link.isEmpty())); link = (($0 = link.get$tail()) && $0.is$Link$Node())) { 7411 $notnull_bool(!$notnull_bool(link.isEmpty())); link = (($0 = link.get$tail()) && $0.is$Link$Node())) {
7430 var definition = link.get$head(); 7412 var definition = link.get$head();
7431 if ($notnull_bool((definition instanceof Identifier))) { 7413 if ($notnull_bool((definition instanceof Identifier))) {
7432 this.compiler.unimplemented("SsaBuilder.visitVariableDefinitions without i nitial value"); 7414 this.compiler.unimplemented("SsaBuilder.visitVariableDefinitions without i nitial value");
7433 } 7415 }
7434 else { 7416 else {
7435 $assert((definition instanceof SendSet), "definition is SendSet", "builder .dart", 212, 16); 7417 $assert((definition instanceof SendSet), "definition is SendSet", "builder .dart", 208, 16);
7436 this.updateDefinition((definition && definition.is$SendSet())); 7418 this.updateDefinition((definition && definition.is$SendSet()));
7437 } 7419 }
7438 } 7420 }
7439 } 7421 }
7440 // ********** Code for SsaCodeGeneratorTask ************** 7422 // ********** Code for SsaCodeGeneratorTask **************
7441 function SsaCodeGeneratorTask(compiler) { 7423 function SsaCodeGeneratorTask(compiler) {
7442 CompilerTask.call(this, compiler); 7424 CompilerTask.call(this, compiler);
7443 // Initializers done 7425 // Initializers done
7444 } 7426 }
7445 $inherits(SsaCodeGeneratorTask, CompilerTask); 7427 $inherits(SsaCodeGeneratorTask, CompilerTask);
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after
9088 TypeCheckerVisitor.prototype.visitNodeList = function(node) { 9070 TypeCheckerVisitor.prototype.visitNodeList = function(node) {
9089 var $0; 9071 var $0;
9090 for (var link = node.nodes; 9072 for (var link = node.nodes;
9091 $notnull_bool(!$notnull_bool(link.isEmpty())); link = (($0 = link.get$tail()) && $0.is$Link$Node())) { 9073 $notnull_bool(!$notnull_bool(link.isEmpty())); link = (($0 = link.get$tail()) && $0.is$Link$Node())) {
9092 this.type((($0 = link.get$head()) && $0.is$Node())); 9074 this.type((($0 = link.get$head()) && $0.is$Node()));
9093 } 9075 }
9094 } 9076 }
9095 TypeCheckerVisitor.prototype.visitOperator = function(node) { 9077 TypeCheckerVisitor.prototype.visitOperator = function(node) {
9096 return this.types.dynamicType; 9078 return this.types.dynamicType;
9097 } 9079 }
9098 TypeCheckerVisitor.prototype.visitParameter = function(node) {
9099 return null;
9100 }
9101 TypeCheckerVisitor.prototype.checkAssignable = function(node, s, t) { 9080 TypeCheckerVisitor.prototype.checkAssignable = function(node, s, t) {
9102 if ($notnull_bool(!$notnull_bool(this.types.isAssignable(s, t)))) { 9081 if ($notnull_bool(!$notnull_bool(this.types.isAssignable(s, t)))) {
9103 var error = CompilerError.notAssignable(s, t); 9082 var error = CompilerError.notAssignable(s, t);
9104 this.compiler.reportWarning(node, error); 9083 this.compiler.reportWarning(node, error);
9105 } 9084 }
9106 } 9085 }
9107 TypeCheckerVisitor.prototype.visitReturn = function(node) { 9086 TypeCheckerVisitor.prototype.visitReturn = function(node) {
9108 var expressionType = this.type(node.expression); 9087 var expressionType = this.type(node.expression);
9109 this.checkAssignable(node, this.expectedReturnType, expressionType); 9088 this.checkAssignable(node, this.expectedReturnType, expressionType);
9110 return this.types.voidType; 9089 return this.types.voidType;
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
9956 } 9935 }
9957 if ($notnull_bool(!$notnull_bool(field.get$isField()))) { 9936 if ($notnull_bool(!$notnull_bool(field.get$isField()))) {
9958 world.error(('"this.' + p.get$name() + '" does not refer to a field'), p .get$definition().get$span()); 9937 world.error(('"this.' + p.get$name() + '" does not refer to a field'), p .get$definition().get$span());
9959 } 9938 }
9960 var paramValue = new Value(field.get$returnType(), p.get$name(), false, fa lse, false); 9939 var paramValue = new Value(field.get$returnType(), p.get$name(), false, fa lse, false);
9961 this._paramCode.add(paramValue.code); 9940 this._paramCode.add(paramValue.code);
9962 initializers.add(('this.' + field.get$jsname() + ' = ' + paramValue.code + ';')); 9941 initializers.add(('this.' + field.get$jsname() + ' = ' + paramValue.code + ';'));
9963 initializedFields.add(p.get$name()); 9942 initializedFields.add(p.get$name());
9964 } 9943 }
9965 else { 9944 else {
9966 var paramValue = this._scope.declareParameter((p && p.is$lang_Parameter()) ); 9945 var paramValue = this._scope.declareParameter((p && p.is$Parameter()));
9967 this._paramCode.add(paramValue.code); 9946 this._paramCode.add(paramValue.code);
9968 } 9947 }
9969 } 9948 }
9970 var body = this.method.get$definition().body; 9949 var body = this.method.get$definition().body;
9971 if ($notnull_bool(body == null && !$notnull_bool(this.method.get$isConstructor ()))) { 9950 if ($notnull_bool(body == null && !$notnull_bool(this.method.get$isConstructor ()))) {
9972 world.error(('unexpected empty body for ' + this.method.name + ''), this.met hod.get$definition().get$span()); 9951 world.error(('unexpected empty body for ' + this.method.name + ''), this.met hod.get$definition().get$span());
9973 } 9952 }
9974 if ($notnull_bool($ne(initializers, null))) { 9953 if ($notnull_bool($ne(initializers, null))) {
9975 for (var $i = initializers.iterator(); $i.hasNext(); ) { 9954 for (var $i = initializers.iterator(); $i.hasNext(); ) {
9976 var i = $i.next(); 9955 var i = $i.next();
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
11529 _LibraryVisitor.prototype.visitVariableDefinition = function(node) { 11508 _LibraryVisitor.prototype.visitVariableDefinition = function(node) {
11530 this.currentType.addField(node); 11509 this.currentType.addField(node);
11531 } 11510 }
11532 _LibraryVisitor.prototype.visitFunctionDefinition = function(node) { 11511 _LibraryVisitor.prototype.visitFunctionDefinition = function(node) {
11533 this.currentType.addMethod(node.name.name, node); 11512 this.currentType.addMethod(node.name.name, node);
11534 } 11513 }
11535 _LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) { 11514 _LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) {
11536 var type = this.library.addType(node.func.name.name, node, false); 11515 var type = this.library.addType(node.func.name.name, node, false);
11537 type.addMethod('\$call', node.func); 11516 type.addMethod('\$call', node.func);
11538 } 11517 }
11539 // ********** Code for lang_Parameter ************** 11518 // ********** Code for Parameter **************
11540 function lang_Parameter(definition) { 11519 function Parameter(definition) {
11541 this.isInitializer = false 11520 this.isInitializer = false
11542 this.definition = definition; 11521 this.definition = definition;
11543 // Initializers done 11522 // Initializers done
11544 } 11523 }
11545 lang_Parameter.prototype.is$lang_Parameter = function(){return this;}; 11524 Parameter.prototype.is$Parameter = function(){return this;};
11546 lang_Parameter.prototype.get$definition = function() { return this.definition; } ; 11525 Parameter.prototype.get$definition = function() { return this.definition; };
11547 lang_Parameter.prototype.set$definition = function(value) { return this.definiti on = value; }; 11526 Parameter.prototype.set$definition = function(value) { return this.definition = value; };
11548 lang_Parameter.prototype.get$name = function() { return this.name; }; 11527 Parameter.prototype.get$name = function() { return this.name; };
11549 lang_Parameter.prototype.set$name = function(value) { return this.name = value; }; 11528 Parameter.prototype.set$name = function(value) { return this.name = value; };
11550 lang_Parameter.prototype.get$value = function() { return this.value; }; 11529 Parameter.prototype.get$value = function() { return this.value; };
11551 lang_Parameter.prototype.set$value = function(value) { return this.value = value ; }; 11530 Parameter.prototype.set$value = function(value) { return this.value = value; };
11552 lang_Parameter.prototype.resolve = function(method, inType) { 11531 Parameter.prototype.resolve = function(method, inType) {
11553 this.name = this.definition.name.name; 11532 this.name = this.definition.name.name;
11554 if ($notnull_bool(this.name.startsWith('this.'))) { 11533 if ($notnull_bool(this.name.startsWith('this.'))) {
11555 this.name = this.name.substring(5); 11534 this.name = this.name.substring(5);
11556 this.isInitializer = true; 11535 this.isInitializer = true;
11557 } 11536 }
11558 this.type = inType.resolveType(this.definition.type, false); 11537 this.type = inType.resolveType(this.definition.type, false);
11559 if ($notnull_bool(method.get$isStatic() && this.type.get$hasTypeParams())) { 11538 if ($notnull_bool(method.get$isStatic() && this.type.get$hasTypeParams())) {
11560 world.error('using type parameter in static context', this.definition.span); 11539 world.error('using type parameter in static context', this.definition.span);
11561 } 11540 }
11562 if ($notnull_bool(this.definition.value != null)) { 11541 if ($notnull_bool(this.definition.value != null)) {
11563 if ($notnull_bool((this.definition.value instanceof NullExpression) && this. definition.value.span.start == this.definition.span.start)) { 11542 if ($notnull_bool((this.definition.value instanceof NullExpression) && this. definition.value.span.start == this.definition.span.start)) {
11564 return; 11543 return;
11565 } 11544 }
11566 if ($notnull_bool(method.get$isAbstract())) { 11545 if ($notnull_bool(method.get$isAbstract())) {
11567 world.error('default value not allowed on abstract methods', this.definiti on.span); 11546 world.error('default value not allowed on abstract methods', this.definiti on.span);
11568 } 11547 }
11569 else if ($notnull_bool(method.name == '\$call' && method.get$definition().bo dy == null)) { 11548 else if ($notnull_bool(method.name == '\$call' && method.get$definition().bo dy == null)) {
11570 world.error('default value not allowed on function type', this.definition. span); 11549 world.error('default value not allowed on function type', this.definition. span);
11571 } 11550 }
11572 } 11551 }
11573 else if ($notnull_bool(this.isInitializer && !$notnull_bool(method.get$isConst ructor()))) { 11552 else if ($notnull_bool(this.isInitializer && !$notnull_bool(method.get$isConst ructor()))) {
11574 world.error('initializer parameters only allowed on constructors', this.defi nition.span); 11553 world.error('initializer parameters only allowed on constructors', this.defi nition.span);
11575 } 11554 }
11576 } 11555 }
11577 lang_Parameter.prototype.genValue = function(method, context) { 11556 Parameter.prototype.genValue = function(method, context) {
11578 var $0; 11557 var $0;
11579 if ($notnull_bool(this.definition.value == null || this.value != null)) return ; 11558 if ($notnull_bool(this.definition.value == null || this.value != null)) return ;
11580 if ($notnull_bool(context == null)) { 11559 if ($notnull_bool(context == null)) {
11581 context = new MethodGenerator(method, null); 11560 context = new MethodGenerator(method, null);
11582 } 11561 }
11583 this.value = (($0 = this.definition.value.visit(context)) && $0.is$Value()); 11562 this.value = (($0 = this.definition.value.visit(context)) && $0.is$Value());
11584 this.value = this.value.convertTo(context, this.type, this.definition.value, f alse); 11563 this.value = this.value.convertTo(context, this.type, this.definition.value, f alse);
11585 } 11564 }
11586 lang_Parameter.prototype.copyWithNewType = function(newType) { 11565 Parameter.prototype.copyWithNewType = function(newType) {
11587 var ret = new lang_Parameter(this.definition); 11566 var ret = new Parameter(this.definition);
11588 ret.type = newType; 11567 ret.type = newType;
11589 ret.name = this.name; 11568 ret.name = this.name;
11590 ret.isInitializer = this.isInitializer; 11569 ret.isInitializer = this.isInitializer;
11591 return ret; 11570 return ret;
11592 } 11571 }
11593 lang_Parameter.prototype.get$isOptional = function() { 11572 Parameter.prototype.get$isOptional = function() {
11594 return this.definition != null && this.definition.value != null; 11573 return this.definition != null && this.definition.value != null;
11595 } 11574 }
11596 // ********** Code for Member ************** 11575 // ********** Code for Member **************
11597 function Member(name, declaringType) { 11576 function Member(name, declaringType) {
11598 this.name = name; 11577 this.name = name;
11599 this.declaringType = declaringType; 11578 this.declaringType = declaringType;
11600 this.isGenerated = false; 11579 this.isGenerated = false;
11601 // Initializers done 11580 // Initializers done
11602 } 11581 }
11603 Member.prototype.is$Member = function(){return this;}; 11582 Member.prototype.is$Member = function(){return this;};
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
12777 else { 12756 else {
12778 this.returnType = inType.resolveType(this.definition.returnType, false); 12757 this.returnType = inType.resolveType(this.definition.returnType, false);
12779 if ($notnull_bool(this.isStatic && this.returnType.get$hasTypeParams())) { 12758 if ($notnull_bool(this.isStatic && this.returnType.get$hasTypeParams())) {
12780 world.error('using type parameter in static context', this.definition.retu rnType.span); 12759 world.error('using type parameter in static context', this.definition.retu rnType.span);
12781 } 12760 }
12782 } 12761 }
12783 this.parameters = []; 12762 this.parameters = [];
12784 var $list = this.definition.formals; 12763 var $list = this.definition.formals;
12785 for (var $i = 0;$i < $list.length; $i++) { 12764 for (var $i = 0;$i < $list.length; $i++) {
12786 var formal = $list.$index($i); 12765 var formal = $list.$index($i);
12787 var param = new lang_Parameter(formal); 12766 var param = new Parameter(formal);
12788 param.resolve(this, inType); 12767 param.resolve(this, inType);
12789 this.parameters.add(param); 12768 this.parameters.add(param);
12790 } 12769 }
12791 if ($notnull_bool(!$notnull_bool(this.isLambda))) { 12770 if ($notnull_bool(!$notnull_bool(this.isLambda))) {
12792 this.get$library()._addMember(this); 12771 this.get$library()._addMember(this);
12793 } 12772 }
12794 } 12773 }
12795 MethodMember.prototype.get_$3 = function($0, $1, $2) { 12774 MethodMember.prototype.get_$3 = function($0, $1, $2) {
12796 return this.get_(($0 && $0.is$MethodGenerator()), ($1 && $1.is$lang_Node()), ( $2 && $2.is$Value()), false); 12775 return this.get_(($0 && $0.is$MethodGenerator()), ($1 && $1.is$lang_Node()), ( $2 && $2.is$Value()), false);
12797 } 12776 }
(...skipping 6625 matching lines...) Expand 10 before | Expand all | Expand 10 after
19423 INTERFACE, 19402 INTERFACE,
19424 LIBRARY, 19403 LIBRARY,
19425 NATIVE, 19404 NATIVE,
19426 NEGATE, 19405 NEGATE,
19427 OPERATOR, 19406 OPERATOR,
19428 SET, 19407 SET,
19429 SOURCE, 19408 SOURCE,
19430 STATIC, 19409 STATIC,
19431 TYPEDEF ]*/; 19410 TYPEDEF ]*/;
19432 RunEntry(function () {main();}, []); 19411 RunEntry(function () {main();}, []);
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698