OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
ahe
2017/03/24 12:00:40
This comment is so last year ;-)
Paul Berry
2017/03/24 14:55:23
Done.
| |
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. | |
ahe
2017/03/24 12:00:40
It would probably help debugging if we also add Sh
Paul Berry
2017/03/24 14:55:23
Fair enough. Done.
| |
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 Block implements Statement { | |
21 /// Iterates through the statements contained in the block. | |
22 Iterable<Statement> 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 Expression {} | |
30 | |
31 /// Shadow mixin representing a function expression. | |
32 abstract class FunctionExpression implements Expression { | |
33 /// Gets the body of the function expression. | |
34 Statement get shadowBody; | |
35 | |
36 /// Indicates whether the function is asynchronous (`async` or `async*`) | |
37 bool get shadowIsAsync; | |
38 | |
39 /// Indicates whether the function was declared using `=>` syntax. | |
40 bool get shadowIsExpressionFunction; | |
41 | |
42 /// Indicates whether the function is a generator (`sync*` or `async*`) | |
43 bool get shadowIsGenerator; | |
44 | |
45 /// Sets the return type of the function expression. | |
46 /// | |
47 /// Intended for use by type inference. | |
48 void set shadowReturnType(DartType type); | |
49 | |
50 /// Creates a [DartType] representing the type of the function expression. | |
51 /// | |
52 /// If type inference has already been performed, returns the inferred type. | |
53 /// Otherwise returns the declared type. | |
54 DartType shadowMakeFunctionType(); | |
scheglov
2017/03/24 03:19:17
Why not getter?
Paul Berry
2017/03/24 14:55:23
Done.
| |
55 } | |
56 | |
57 /// Shadow mixin representing an integer literal. | |
58 abstract class IntLiteral implements Expression {} | |
59 | |
60 /// Shadow mixin representing a list literal. | |
61 abstract class ListLiteral implements Expression { | |
62 /// Iterates through the expressions contained in the list literal. | |
63 Iterable<Expression> 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 NullLiteral implements Expression {} | |
78 | |
79 /// Shadow mixin representing a return statement. | |
80 abstract class ReturnStatement implements Statement { | |
81 /// Gets the expression being returned, or `null` if this is a bare "return" | |
82 /// statement. | |
83 Expression 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 Statement {} | |
91 | |
92 /// Shadow mixin representing a declaration of a single variable. | |
93 abstract class VariableDeclaration implements Statement { | |
94 /// Gets the initializer expression for the variable, or `null` if the | |
95 /// variable has no initializer. | |
96 Expression 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. | |
scheglov
2017/03/24 03:19:16
I don't understand this yet.
Is it a node or eleme
Paul Berry
2017/03/24 14:55:23
I haven't prototyped this yet, but here's my curre
| |
109 abstract class VariableGet implements Expression { | |
110 /// Gets the variable declaration which is being referenced. | |
111 VariableDeclaration get shadowDeclaration; | |
112 } | |
OLD | NEW |