Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dev_compiler.src.codegen.ast_builder; | 5 library dev_compiler.src.codegen.ast_builder; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/scanner.dart'; | 8 import 'package:analyzer/src/generated/scanner.dart'; |
| 9 import 'package:analyzer/src/generated/utilities_dart.dart'; | 9 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 10 import 'package:logging/logging.dart' as logger; | 10 import 'package:logging/logging.dart' as logger; |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 | 422 |
| 423 static ConditionalExpression conditionalExpression( | 423 static ConditionalExpression conditionalExpression( |
| 424 Expression cond, Expression tExp, Expression fExp) { | 424 Expression cond, Expression tExp, Expression fExp) { |
| 425 var q = new Token(TokenType.QUESTION, 0); | 425 var q = new Token(TokenType.QUESTION, 0); |
| 426 var c = new Token(TokenType.COLON, 0); | 426 var c = new Token(TokenType.COLON, 0); |
| 427 return new ConditionalExpression(cond, q, tExp, c, fExp); | 427 return new ConditionalExpression(cond, q, tExp, c, fExp); |
| 428 } | 428 } |
| 429 | 429 |
| 430 static Expression functionExpressionInvocation( | 430 static Expression functionExpressionInvocation( |
| 431 Expression function, ArgumentList es) { | 431 Expression function, ArgumentList es) { |
| 432 return new FunctionExpressionInvocation(function, es); | 432 return new FunctionExpressionInvocation(function, null, es); |
|
Jennifer Messerly
2015/07/09 17:03:29
the `null` is for generic type args \o/
| |
| 433 } | 433 } |
| 434 | 434 |
| 435 static FormalParameterList formalParameterList(List<FormalParameter> params) { | 435 static FormalParameterList formalParameterList(List<FormalParameter> params) { |
| 436 Token lp = new BeginToken(TokenType.OPEN_PAREN, 0); | 436 Token lp = new BeginToken(TokenType.OPEN_PAREN, 0); |
| 437 Token rp = new Token(TokenType.CLOSE_PAREN, 0); | 437 Token rp = new Token(TokenType.CLOSE_PAREN, 0); |
| 438 bool hasOptional = params.any((p) => p.kind == ParameterKind.POSITIONAL); | 438 bool hasOptional = params.any((p) => p.kind == ParameterKind.POSITIONAL); |
| 439 bool hasNamed = params.any((p) => p.kind == ParameterKind.NAMED); | 439 bool hasNamed = params.any((p) => p.kind == ParameterKind.NAMED); |
| 440 assert(!(hasOptional && hasNamed)); | 440 assert(!(hasOptional && hasNamed)); |
| 441 Token ld = null; | 441 Token ld = null; |
| 442 Token rd = null; | 442 Token rd = null; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 470 static FunctionDeclaration functionDeclaration( | 470 static FunctionDeclaration functionDeclaration( |
| 471 TypeName rt, Identifier f, FunctionExpression fexp) { | 471 TypeName rt, Identifier f, FunctionExpression fexp) { |
| 472 return new FunctionDeclaration(null, null, null, rt, null, f, fexp); | 472 return new FunctionDeclaration(null, null, null, rt, null, f, fexp); |
| 473 } | 473 } |
| 474 | 474 |
| 475 static MethodDeclaration methodDeclaration( | 475 static MethodDeclaration methodDeclaration( |
| 476 TypeName rt, Identifier m, FormalParameterList fl, FunctionBody body, | 476 TypeName rt, Identifier m, FormalParameterList fl, FunctionBody body, |
| 477 {bool isStatic: false}) { | 477 {bool isStatic: false}) { |
| 478 Token st = isStatic ? new KeywordToken(Keyword.STATIC, 0) : null; | 478 Token st = isStatic ? new KeywordToken(Keyword.STATIC, 0) : null; |
| 479 return new MethodDeclaration( | 479 return new MethodDeclaration( |
| 480 null, null, null, st, rt, null, null, m, fl, body); | 480 null, null, null, st, rt, null, null, m, null, fl, body); |
| 481 } | 481 } |
| 482 | 482 |
| 483 static FunctionExpression functionExpression( | 483 static FunctionExpression functionExpression( |
| 484 FormalParameterList fl, FunctionBody body) { | 484 FormalParameterList fl, FunctionBody body) { |
| 485 return new FunctionExpression(fl, body); | 485 return new FunctionExpression(null, fl, body); |
| 486 } | 486 } |
| 487 | 487 |
| 488 static FunctionDeclarationStatement functionDeclarationStatement( | 488 static FunctionDeclarationStatement functionDeclarationStatement( |
| 489 FunctionDeclaration fd) { | 489 FunctionDeclaration fd) { |
| 490 return new FunctionDeclarationStatement(fd); | 490 return new FunctionDeclarationStatement(fd); |
| 491 } | 491 } |
| 492 | 492 |
| 493 static Statement returnExpression([Expression e]) { | 493 static Statement returnExpression([Expression e]) { |
| 494 Token ret = new KeywordToken(Keyword.RETURN, 0); | 494 Token ret = new KeywordToken(Keyword.RETURN, 0); |
| 495 Token semi = new Token(TokenType.SEMICOLON, 0); | 495 Token semi = new Token(TokenType.SEMICOLON, 0); |
| 496 return new ReturnStatement(ret, e, semi); | 496 return new ReturnStatement(ret, e, semi); |
| 497 } | 497 } |
| 498 | 498 |
| 499 static SimpleFormalParameter simpleFormalParameter(Identifier v, TypeName t) { | 499 static SimpleFormalParameter simpleFormalParameter(Identifier v, TypeName t) { |
| 500 return new SimpleFormalParameter(null, <Annotation>[], null, t, v); | 500 return new SimpleFormalParameter(null, <Annotation>[], null, t, v); |
| 501 } | 501 } |
| 502 | 502 |
| 503 static FunctionTypedFormalParameter functionTypedFormalParameter( | 503 static FunctionTypedFormalParameter functionTypedFormalParameter( |
| 504 TypeName ret, Identifier v, FormalParameterList ps) { | 504 TypeName ret, Identifier v, FormalParameterList ps) { |
| 505 return new FunctionTypedFormalParameter(null, <Annotation>[], ret, v, ps); | 505 return new FunctionTypedFormalParameter( |
| 506 null, <Annotation>[], ret, v, null, ps); | |
| 506 } | 507 } |
| 507 | 508 |
| 508 static FormalParameter requiredFormalParameter(NormalFormalParameter fp) { | 509 static FormalParameter requiredFormalParameter(NormalFormalParameter fp) { |
| 509 return fp; | 510 return fp; |
| 510 } | 511 } |
| 511 | 512 |
| 512 static FormalParameter optionalFormalParameter(NormalFormalParameter fp) { | 513 static FormalParameter optionalFormalParameter(NormalFormalParameter fp) { |
| 513 return new DefaultFormalParameter(fp, ParameterKind.POSITIONAL, null, null); | 514 return new DefaultFormalParameter(fp, ParameterKind.POSITIONAL, null, null); |
| 514 } | 515 } |
| 515 | 516 |
| 516 static FormalParameter namedFormalParameter(NormalFormalParameter fp) { | 517 static FormalParameter namedFormalParameter(NormalFormalParameter fp) { |
| 517 return new DefaultFormalParameter(fp, ParameterKind.NAMED, null, null); | 518 return new DefaultFormalParameter(fp, ParameterKind.NAMED, null, null); |
| 518 } | 519 } |
| 519 | 520 |
| 520 static NamedExpression namedParameter(Identifier s, Expression e) { | 521 static NamedExpression namedParameter(Identifier s, Expression e) { |
| 521 return namedExpression(s, e); | 522 return namedExpression(s, e); |
| 522 } | 523 } |
| 523 | 524 |
| 524 static NamedExpression namedExpression(Identifier s, Expression e) { | 525 static NamedExpression namedExpression(Identifier s, Expression e) { |
| 525 Label l = new Label(s, new Token(TokenType.COLON, 0)); | 526 Label l = new Label(s, new Token(TokenType.COLON, 0)); |
| 526 return new NamedExpression(l, e); | 527 return new NamedExpression(l, e); |
| 527 } | 528 } |
| 528 } | 529 } |
| OLD | NEW |