| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:front_end/src/fasta/scanner.dart' show Token; | 5 import 'package:front_end/src/fasta/scanner.dart' show Token; |
| 6 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; | 6 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; |
| 7 import 'package:kernel/ast.dart'; | 7 import 'package:kernel/ast.dart'; |
| 8 | 8 |
| 9 /// An abstract class containing factory methods that create AST objects. | 9 /// An abstract class containing factory methods that create AST objects. |
| 10 /// | 10 /// |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 /// having a `toLocation` method on AstFactory that changes tokens to an | 31 /// having a `toLocation` method on AstFactory that changes tokens to an |
| 32 /// abstract type (`int` for kernel, `Token` for analyzer). | 32 /// abstract type (`int` for kernel, `Token` for analyzer). |
| 33 /// | 33 /// |
| 34 /// TODO(paulberry): in order to interface with analyzer, we'll need to | 34 /// TODO(paulberry): in order to interface with analyzer, we'll need to |
| 35 /// shadow-ify [DartType], since analyzer ASTs need to be able to record the | 35 /// shadow-ify [DartType], since analyzer ASTs need to be able to record the |
| 36 /// exact tokens that were used to specify a type. | 36 /// exact tokens that were used to specify a type. |
| 37 abstract class AstFactory<V> { | 37 abstract class AstFactory<V> { |
| 38 /// Creates a statement block. | 38 /// Creates a statement block. |
| 39 Block block(List<Statement> statements, Token beginToken); | 39 Block block(List<Statement> statements, Token beginToken); |
| 40 | 40 |
| 41 /// Creates a boolean literal. |
| 42 BoolLiteral boolLiteral(bool value, Token token); |
| 43 |
| 41 /// Creates a double literal. | 44 /// Creates a double literal. |
| 42 DoubleLiteral doubleLiteral(double value, Token token); | 45 DoubleLiteral doubleLiteral(double value, Token token); |
| 43 | 46 |
| 44 /// Creates an expression statement. | 47 /// Creates an expression statement. |
| 45 ExpressionStatement expressionStatement(Expression expression); | 48 ExpressionStatement expressionStatement(Expression expression); |
| 46 | 49 |
| 47 /// Creates a function expression. | 50 /// Creates a function expression. |
| 48 FunctionExpression functionExpression(FunctionNode function, Token token); | 51 FunctionExpression functionExpression(FunctionNode function, Token token); |
| 49 | 52 |
| 50 /// Creates an `if` statement. | 53 /// Creates an `if` statement. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 67 | 70 |
| 68 /// Creates a null literal expression. | 71 /// Creates a null literal expression. |
| 69 NullLiteral nullLiteral(Token token); | 72 NullLiteral nullLiteral(Token token); |
| 70 | 73 |
| 71 /// Creates a return statement. | 74 /// Creates a return statement. |
| 72 Statement returnStatement(Expression expression, Token token); | 75 Statement returnStatement(Expression expression, Token token); |
| 73 | 76 |
| 74 /// Creates a read of a static variable. | 77 /// Creates a read of a static variable. |
| 75 StaticGet staticGet(Member readTarget, Token token); | 78 StaticGet staticGet(Member readTarget, Token token); |
| 76 | 79 |
| 80 /// Creates a string concatenation. |
| 81 StringConcatenation stringConcatenation( |
| 82 List<Expression> expressions, Token token); |
| 83 |
| 84 /// Creates a string literal. |
| 85 StringLiteral stringLiteral(String value, Token token); |
| 86 |
| 77 /// Creates a variable declaration statement declaring one variable. | 87 /// Creates a variable declaration statement declaring one variable. |
| 78 /// | 88 /// |
| 79 /// TODO(paulberry): analyzer makes a distinction between a single variable | 89 /// TODO(paulberry): analyzer makes a distinction between a single variable |
| 80 /// declaration and a variable declaration statement (which can contain | 90 /// declaration and a variable declaration statement (which can contain |
| 81 /// multiple variable declarations). Currently this API only makes sense for | 91 /// multiple variable declarations). Currently this API only makes sense for |
| 82 /// kernel, which desugars each variable declaration to its own statement. | 92 /// kernel, which desugars each variable declaration to its own statement. |
| 83 /// | 93 /// |
| 84 /// If the variable declaration did not have an explicitly declared type, | 94 /// If the variable declaration did not have an explicitly declared type, |
| 85 /// [type] should be `null`. | 95 /// [type] should be `null`. |
| 86 VariableDeclaration variableDeclaration( | 96 VariableDeclaration variableDeclaration( |
| 87 String name, Token token, int functionNestingLevel, | 97 String name, Token token, int functionNestingLevel, |
| 88 {DartType type, | 98 {DartType type, |
| 89 Expression initializer, | 99 Expression initializer, |
| 90 Token equalsToken, | 100 Token equalsToken, |
| 91 bool isFinal: false, | 101 bool isFinal: false, |
| 92 bool isConst: false}); | 102 bool isConst: false}); |
| 93 | 103 |
| 94 /// Creates a read of a local variable. | 104 /// Creates a read of a local variable. |
| 95 variableGet(VariableDeclaration variable, TypePromotionFact<V> fact, | 105 variableGet(VariableDeclaration variable, TypePromotionFact<V> fact, |
| 96 TypePromotionScope scope, Token token); | 106 TypePromotionScope scope, Token token); |
| 97 } | 107 } |
| OLD | NEW |