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

Side by Side Diff: pkg/front_end/lib/src/fasta/builder/ast_factory.dart

Issue 2861523003: Add KernelXyzExpression stubs and factory methods. (Closed)
Patch Set: Created 3 years, 7 months 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/body_builder.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 // 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 17 matching lines...) Expand all
28 /// that's what analyzer ASTs need. Note that analyzer needs multiple tokens 28 /// that's what analyzer ASTs need. Note that analyzer needs multiple tokens
29 /// for many AST constructs, not just one. Note also that for kernel codegen 29 /// for many AST constructs, not just one. Note also that for kernel codegen
30 /// we want to be very careful not to keep tokens around too long, so consider 30 /// we want to be very careful not to keep tokens around too long, so consider
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 an `as` expression.
39 AsExpression asExpression(Expression operand, Token operator, DartType type);
40
41 /// Creates an `await` expression.
42 AwaitExpression awaitExpression(Token keyword, Expression operand);
43
38 /// Creates a statement block. 44 /// Creates a statement block.
39 Block block(List<Statement> statements, Token beginToken); 45 Block block(List<Statement> statements, Token beginToken);
40 46
41 /// Creates a boolean literal. 47 /// Creates a boolean literal.
42 BoolLiteral boolLiteral(bool value, Token token); 48 BoolLiteral boolLiteral(bool value, Token token);
43 49
50 /// Creates a constructor invocation.
51 ConstructorInvocation constructorInvocation(
52 Constructor target, Arguments arguments,
53 {bool isConst: false});
54
55 /// Creates a direct method invocation.
56 DirectMethodInvocation directMethodInvocation(
57 Expression receiver, Procedure target, Arguments arguments);
58
59 /// Creates a direct property get.
60 DirectPropertyGet directPropertyGet(Expression receiver, Member target);
61
62 /// Creates a direct property get.
63 DirectPropertySet directPropertySet(
64 Expression receiver, Member target, Expression value);
65
44 /// Creates a double literal. 66 /// Creates a double literal.
45 DoubleLiteral doubleLiteral(double value, Token token); 67 DoubleLiteral doubleLiteral(double value, Token token);
46 68
47 /// Creates an expression statement. 69 /// Creates an expression statement.
48 ExpressionStatement expressionStatement(Expression expression); 70 ExpressionStatement expressionStatement(Expression expression);
49 71
50 /// Creates a function expression. 72 /// Creates a function expression.
51 FunctionExpression functionExpression(FunctionNode function, Token token); 73 FunctionExpression functionExpression(FunctionNode function, Token token);
52 74
53 /// Creates an `if` statement. 75 /// Creates an `if` statement.
54 Statement ifStatement( 76 Statement ifStatement(
55 Expression condition, Statement thenPart, Statement elsePart); 77 Expression condition, Statement thenPart, Statement elsePart);
56 78
57 /// Creates an integer literal. 79 /// Creates an integer literal.
58 IntLiteral intLiteral(int value, Token token); 80 IntLiteral intLiteral(int value, Token token);
59 81
60 /// Creates an `is` expression. 82 /// Creates an `is` expression.
61 Expression isExpression( 83 Expression isExpression(
62 Expression expression, DartType type, Token token, bool isInverted); 84 Expression expression, DartType type, Token token, bool isInverted);
63 85
64 /// Creates a list literal expression. 86 /// Creates a list literal expression.
65 /// 87 ///
66 /// If the list literal did not have an explicitly declared type argument, 88 /// If the list literal did not have an explicitly declared type argument,
67 /// [typeArgument] should be `null`. 89 /// [typeArgument] should be `null`.
68 ListLiteral listLiteral(List<Expression> expressions, DartType typeArgument, 90 ListLiteral listLiteral(List<Expression> expressions, DartType typeArgument,
69 bool isConst, Token token); 91 bool isConst, Token token);
70 92
93 /// Creates a logical expression in for of `x && y` or `x || y`.
94 LogicalExpression logicalExpression(
95 Expression left, String operator, Expression right);
96
97 /// Creates a map literal expression.
98 ///
99 /// If the map literal did not have an explicitly declared type argument,
100 /// [keyType] and [valueType] should be `null`.
101 MapLiteral mapLiteral(
102 Token beginToken, Token constKeyword, List<MapEntry> entries,
103 {DartType keyType: const DynamicType(),
104 DartType valueType: const DynamicType()});
105
106 /// Create an expression of form `!x`.
107 Not not(Token token, Expression operand);
108
71 /// Creates a null literal expression. 109 /// Creates a null literal expression.
72 NullLiteral nullLiteral(Token token); 110 NullLiteral nullLiteral(Token token);
73 111
112 /// Create a `rethrow` expression.
113 Rethrow rethrowExpression(Token keyword);
114
74 /// Creates a return statement. 115 /// Creates a return statement.
75 Statement returnStatement(Expression expression, Token token); 116 Statement returnStatement(Expression expression, Token token);
76 117
77 /// Creates a read of a static variable. 118 /// Creates a read of a static variable.
78 StaticGet staticGet(Member readTarget, Token token); 119 StaticGet staticGet(Member readTarget, Token token);
79 120
121 /// Creates a static invocation.
122 StaticInvocation staticInvocation(Procedure target, Arguments arguments,
123 {bool isConst: false});
124
80 /// Creates a string concatenation. 125 /// Creates a string concatenation.
81 StringConcatenation stringConcatenation( 126 StringConcatenation stringConcatenation(
82 List<Expression> expressions, Token token); 127 List<Expression> expressions, Token token);
83 128
84 /// Creates a string literal. 129 /// Creates a string literal.
85 StringLiteral stringLiteral(String value, Token token); 130 StringLiteral stringLiteral(String value, Token token);
86 131
132 /// Creates a super method invocation.
133 SuperMethodInvocation superMethodInvocation(
134 Token beginToken, Name name, Arguments arguments,
135 [Procedure interfaceTarget]);
136
137 /// Create an expression of form `super.field`.
138 SuperPropertyGet superPropertyGet(Name name, [Member interfaceTarget]);
139
140 /// Create an expression of form `#foo.bar`.
141 SymbolLiteral symbolLiteral(Token hashToken, String value);
142
143 /// Create an expression of form `this`.
144 ThisExpression thisExpression(Token keyword);
145
146 /// Create a `throw` expression.
147 Throw throwExpression(Token keyword, Expression expression);
148
149 /// Create a type literal expression.
150 TypeLiteral typeLiteral(DartType type);
151
87 /// Creates a variable declaration statement declaring one variable. 152 /// Creates a variable declaration statement declaring one variable.
88 /// 153 ///
89 /// TODO(paulberry): analyzer makes a distinction between a single variable 154 /// TODO(paulberry): analyzer makes a distinction between a single variable
90 /// declaration and a variable declaration statement (which can contain 155 /// declaration and a variable declaration statement (which can contain
91 /// multiple variable declarations). Currently this API only makes sense for 156 /// multiple variable declarations). Currently this API only makes sense for
92 /// kernel, which desugars each variable declaration to its own statement. 157 /// kernel, which desugars each variable declaration to its own statement.
93 /// 158 ///
94 /// If the variable declaration did not have an explicitly declared type, 159 /// If the variable declaration did not have an explicitly declared type,
95 /// [type] should be `null`. 160 /// [type] should be `null`.
96 VariableDeclaration variableDeclaration( 161 VariableDeclaration variableDeclaration(
97 String name, Token token, int functionNestingLevel, 162 String name, Token token, int functionNestingLevel,
98 {DartType type, 163 {DartType type,
99 Expression initializer, 164 Expression initializer,
100 Token equalsToken, 165 Token equalsToken,
101 bool isFinal: false, 166 bool isFinal: false,
102 bool isConst: false}); 167 bool isConst: false});
103 168
104 /// Creates a read of a local variable. 169 /// Creates a read of a local variable.
105 variableGet(VariableDeclaration variable, TypePromotionFact<V> fact, 170 VariableGet variableGet(VariableDeclaration variable,
106 TypePromotionScope scope, Token token); 171 TypePromotionFact<V> fact, TypePromotionScope scope, Token token);
107 } 172 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/body_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698