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:kernel/ast.dart'; | 5 import 'package:kernel/ast.dart'; |
6 | 6 |
7 /// An abstract class containing factory methods that create AST objects. | 7 /// An abstract class containing factory methods that create AST objects. |
8 /// | 8 /// |
9 /// Itended for use by [BodyBuilder] so that it can create either analyzer or | 9 /// Itended for use by [BodyBuilder] so that it can create either analyzer or |
10 /// kernel ASTs depending on which concrete factory it is connected to. | 10 /// kernel ASTs depending on which concrete factory it is connected to. |
(...skipping 18 matching lines...) Expand all Loading... |
29 /// having a `toLocation` method on AstFactory that changes tokens to an | 29 /// having a `toLocation` method on AstFactory that changes tokens to an |
30 /// abstract type (`int` for kernel, `Token` for analyzer). | 30 /// abstract type (`int` for kernel, `Token` for analyzer). |
31 /// | 31 /// |
32 /// TODO(paulberry): in order to interface with analyzer, we'll need to | 32 /// TODO(paulberry): in order to interface with analyzer, we'll need to |
33 /// shadow-ify [DartType], since analyzer ASTs need to be able to record the | 33 /// shadow-ify [DartType], since analyzer ASTs need to be able to record the |
34 /// exact tokens that were used to specify a type. | 34 /// exact tokens that were used to specify a type. |
35 abstract class AstFactory { | 35 abstract class AstFactory { |
36 /// Creates a statement block. | 36 /// Creates a statement block. |
37 Block block(List<Statement> statements, int charOffset); | 37 Block block(List<Statement> statements, int charOffset); |
38 | 38 |
| 39 /// Creates a field. |
| 40 Field field(Name name, int charOffset, {String fileUri}); |
| 41 |
39 /// Creates an integer literal. | 42 /// Creates an integer literal. |
40 IntLiteral intLiteral(value, int charOffset); | 43 IntLiteral intLiteral(value, int charOffset); |
41 | 44 |
42 /// Creates a list literal expression. | 45 /// Creates a list literal expression. |
43 /// | 46 /// |
44 /// If the list literal did not have an explicitly declared type argument, | 47 /// If the list literal did not have an explicitly declared type argument, |
45 /// [typeArgument] should be `null`. | 48 /// [typeArgument] should be `null`. |
46 ListLiteral listLiteral(List<Expression> expressions, DartType typeArgument, | 49 ListLiteral listLiteral(List<Expression> expressions, DartType typeArgument, |
47 bool isConst, int charOffset); | 50 bool isConst, int charOffset); |
48 | 51 |
49 /// Creates a null literal expression. | 52 /// Creates a null literal expression. |
50 NullLiteral nullLiteral(int charOffset); | 53 NullLiteral nullLiteral(int charOffset); |
51 | 54 |
52 /// Creates a return statement. | 55 /// Creates a return statement. |
53 Statement returnStatement(Expression expression, int charOffset); | 56 Statement returnStatement(Expression expression, int charOffset); |
54 | 57 |
| 58 /// Creates a read of a static variable. |
| 59 StaticGet staticGet(Member readTarget, int offset); |
| 60 |
55 /// Creates a variable declaration statement declaring one variable. | 61 /// Creates a variable declaration statement declaring one variable. |
56 /// | 62 /// |
57 /// TODO(paulberry): analyzer makes a distinction between a single variable | 63 /// TODO(paulberry): analyzer makes a distinction between a single variable |
58 /// declaration and a variable declaration statement (which can contain | 64 /// declaration and a variable declaration statement (which can contain |
59 /// multiple variable declarations). Currently this API only makes sense for | 65 /// multiple variable declarations). Currently this API only makes sense for |
60 /// kernel, which desugars each variable declaration to its own statement. | 66 /// kernel, which desugars each variable declaration to its own statement. |
61 /// | 67 /// |
62 /// If the variable declaration did not have an explicitly declared type, | 68 /// If the variable declaration did not have an explicitly declared type, |
63 /// [type] should be `null`. | 69 /// [type] should be `null`. |
64 VariableDeclaration variableDeclaration(String name, | 70 VariableDeclaration variableDeclaration(String name, |
65 {DartType type, | 71 {DartType type, |
66 Expression initializer, | 72 Expression initializer, |
67 int charOffset = TreeNode.noOffset, | 73 int charOffset = TreeNode.noOffset, |
68 int equalsCharOffset = TreeNode.noOffset, | 74 int equalsCharOffset = TreeNode.noOffset, |
69 bool isFinal: false, | 75 bool isFinal: false, |
70 bool isConst: false}); | 76 bool isConst: false}); |
71 } | 77 } |
OLD | NEW |