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

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

Issue 2819423004: Simplify shadow class hierarchy. (Closed)
Patch Set: 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_shadow_ast.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /// This file declares mixins which can be used to create a shadow hierarchy
6 /// of either the kernel or the analyzer AST representations.
7 ///
8 /// These classes are intended to be used by [BodyBuilder] as a form of
9 /// indirection so that it can manipulate either kernel or analyzer ASTs.
10 ///
11 /// All methods, getters, and setters defined in this file start with the prefix
12 /// "shadow" in order to avoid naming conflicts with code in kernel or analyzer.
13 ///
14 /// Note that the analyzer AST representation closely parallels Dart syntax,
15 /// whereas the kernel AST representation is desugared. The classes in the
16 /// shadow hierarchy represent the full language (prior to desugaring).
17 import 'package:kernel/ast.dart' show DartType;
18
19 /// Shadow mixin representing a statement block.
20 abstract class ShadowBlock implements ShadowStatement {
21 /// Iterates through the statements contained in the block.
22 Iterable<ShadowStatement> get shadowStatements;
23 }
24
25 /// Common interface for shadow mixins representing expressions.
26 ///
27 /// TODO(paulberry): add an abstract `shadowInfer` method here to do type
28 /// inference.
29 abstract class ShadowExpression {}
30
31 /// Shadow mixin representing a function expression.
32 abstract class ShadowFunctionExpression implements ShadowExpression {
33 /// Gets the body of the function expression.
34 ShadowStatement get shadowBody;
35
36 /// Creates a [DartType] representing the type of the function expression.
37 ///
38 /// If type inference has already been performed, returns the inferred type.
39 /// Otherwise returns the declared type.
40 DartType get shadowFunctionType;
41
42 /// Indicates whether the function is asynchronous (`async` or `async*`)
43 bool get shadowIsAsync;
44
45 /// Indicates whether the function was declared using `=>` syntax.
46 bool get shadowIsExpressionFunction;
47
48 /// Indicates whether the function is a generator (`sync*` or `async*`)
49 bool get shadowIsGenerator;
50
51 /// Sets the return type of the function expression.
52 ///
53 /// Intended for use by type inference.
54 void set shadowReturnType(DartType type);
55 }
56
57 /// Shadow mixin representing an integer literal.
58 abstract class ShadowIntLiteral implements ShadowExpression {}
59
60 /// Shadow mixin representing a list literal.
61 abstract class ShadowListLiteral implements ShadowExpression {
62 /// Iterates through the expressions contained in the list literal.
63 Iterable<ShadowExpression> get shadowExpressions;
64
65 /// Gets the type argument of the list literal. If type inference has not
66 /// been performed and no explicit type argument was specified, returns
67 /// `null`.
68 DartType get shadowTypeArgument;
69
70 /// Sets the type argument of the list literal.
71 ///
72 /// Intended for use by type inference.
73 void set shadowTypeArgument(DartType type);
74 }
75
76 /// Shadow mixin representing a null literal.
77 abstract class ShadowNullLiteral implements ShadowExpression {}
78
79 /// Shadow mixin representing a return statement.
80 abstract class ShadowReturnStatement implements ShadowStatement {
81 /// Gets the expression being returned, or `null` if this is a bare "return"
82 /// statement.
83 ShadowExpression get shadowExpression;
84 }
85
86 /// Common interface for shadow mixins representing statements.
87 ///
88 /// TODO(paulberry): add an abstract `shadowInfer` method here to do type
89 /// inference.
90 abstract class ShadowStatement {}
91
92 /// Shadow mixin representing a declaration of a single variable.
93 abstract class ShadowVariableDeclaration implements ShadowStatement {
94 /// Gets the initializer expression for the variable, or `null` if the
95 /// variable has no initializer.
96 ShadowExpression get shadowInitializer;
97
98 /// Gets the type of the variable. If type inference has not been performed
99 /// and no explicit type was specified, returns `null`.
100 DartType get shadowType;
101
102 /// Sets the type of the variable.
103 ///
104 /// Intended for use by type inference.
105 void set shadowType(DartType type);
106 }
107
108 /// Shadow mixin representing a "read" reference to a variable.
109 abstract class ShadowVariableGet implements ShadowExpression {
110 /// Gets the variable declaration which is being referenced.
111 ShadowVariableDeclaration get shadowDeclaration;
112 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698