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

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

Issue 2802433003: Make the AstFactory API refer to kernel types rather than "shadow" types. (Closed)
Patch Set: dartfmt Created 3 years, 8 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/kernel_ast_factory.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:kernel/ast.dart' show DartType, TreeNode; 5 import 'package:kernel/ast.dart';
6
7 import 'shadow_ast.dart';
8 6
9 /// An abstract class containing factory methods that create AST objects. 7 /// An abstract class containing factory methods that create AST objects.
10 /// 8 ///
11 /// 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
12 /// kernel ASTs depending on which concrete factory it is connected to. 10 /// kernel ASTs depending on which concrete factory it is connected to.
13 /// 11 ///
14 /// This class is defined in terms of the builder's shadow AST mixins (which are 12 /// This class is defined in terms of the builder's shadow AST mixins (which are
15 /// shared between kernel and analyzer shadow AST representations). 13 /// shared between kernel and analyzer shadow AST representations).
16 /// 14 ///
17 /// Note that the analyzer AST representation closely parallels Dart syntax, 15 /// Note that the analyzer AST representation closely parallels Dart syntax,
(...skipping 11 matching lines...) Expand all
29 /// for many AST constructs, not just one. Note also that for kernel codegen 27 /// 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 28 /// 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 29 /// having a `toLocation` method on AstFactory that changes tokens to an
32 /// abstract type (`int` for kernel, `Token` for analyzer). 30 /// abstract type (`int` for kernel, `Token` for analyzer).
33 /// 31 ///
34 /// 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
35 /// 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
36 /// exact tokens that were used to specify a type. 34 /// exact tokens that were used to specify a type.
37 abstract class AstFactory { 35 abstract class AstFactory {
38 /// Creates a statement block. 36 /// Creates a statement block.
39 ShadowBlock block(List<ShadowStatement> statements, int charOffset); 37 Block block(List<Statement> statements, int charOffset);
40 38
41 /// Creates an integer literal. 39 /// Creates an integer literal.
42 ShadowIntLiteral intLiteral(value, int charOffset); 40 IntLiteral intLiteral(value, int charOffset);
43 41
44 /// Creates a list literal expression. 42 /// Creates a list literal expression.
45 /// 43 ///
46 /// If the list literal did not have an explicitly declared type argument, 44 /// If the list literal did not have an explicitly declared type argument,
47 /// [typeArgument] should be `null`. 45 /// [typeArgument] should be `null`.
48 ShadowListLiteral listLiteral(List<ShadowExpression> expressions, 46 ListLiteral listLiteral(List<Expression> expressions, DartType typeArgument,
49 DartType typeArgument, bool isConst, int charOffset); 47 bool isConst, int charOffset);
50 48
51 /// Creates a null literal expression. 49 /// Creates a null literal expression.
52 ShadowNullLiteral nullLiteral(int charOffset); 50 NullLiteral nullLiteral(int charOffset);
53 51
54 /// Creates a return statement. 52 /// Creates a return statement.
55 ShadowStatement returnStatement(ShadowExpression expression, int charOffset); 53 Statement returnStatement(Expression expression, int charOffset);
56 54
57 /// Creates a variable declaration statement declaring one variable. 55 /// Creates a variable declaration statement declaring one variable.
58 /// 56 ///
59 /// TODO(paulberry): analyzer makes a distinction between a single variable 57 /// TODO(paulberry): analyzer makes a distinction between a single variable
60 /// declaration and a variable declaration statement (which can contain 58 /// declaration and a variable declaration statement (which can contain
61 /// multiple variable declarations). Currently this API only makes sense for 59 /// multiple variable declarations). Currently this API only makes sense for
62 /// kernel, which desugars each variable declaration to its own statement. 60 /// kernel, which desugars each variable declaration to its own statement.
63 /// 61 ///
64 /// If the variable declaration did not have an explicitly declared type, 62 /// If the variable declaration did not have an explicitly declared type,
65 /// [type] should be `null`. 63 /// [type] should be `null`.
66 ShadowVariableDeclaration variableDeclaration(String name, 64 VariableDeclaration variableDeclaration(String name,
67 {DartType type, 65 {DartType type,
68 ShadowExpression initializer, 66 Expression initializer,
69 int charOffset: TreeNode.noOffset, 67 int charOffset: TreeNode.noOffset,
70 bool isFinal: false, 68 bool isFinal: false,
71 bool isConst: false}); 69 bool isConst: false});
72 } 70 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698