OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 #include "vm/ast_transformer.h" | 5 #include "vm/ast_transformer.h" |
6 | 6 |
7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
8 #include "vm/parser.h" | 8 #include "vm/parser.h" |
| 9 #include "vm/thread.h" |
9 | 10 |
10 namespace dart { | 11 namespace dart { |
11 | 12 |
12 // Quick access to the locally defined isolate() method. | 13 // Quick access to the current isolate and zone. |
13 #define I (isolate()) | 14 #define I (thread()->isolate()) |
| 15 #define Z (thread()->zone()) |
14 | 16 |
15 // Nodes that are unreachable from already parsed expressions. | 17 // Nodes that are unreachable from already parsed expressions. |
16 #define FOR_EACH_UNREACHABLE_NODE(V) \ | 18 #define FOR_EACH_UNREACHABLE_NODE(V) \ |
17 V(AwaitMarker) \ | 19 V(AwaitMarker) \ |
18 V(Case) \ | 20 V(Case) \ |
19 V(CatchClause) \ | 21 V(CatchClause) \ |
20 V(CloneContext) \ | 22 V(CloneContext) \ |
21 V(ClosureCall) \ | 23 V(ClosureCall) \ |
22 V(DoWhile) \ | 24 V(DoWhile) \ |
23 V(If) \ | 25 V(If) \ |
(...skipping 19 matching lines...) Expand all Loading... |
43 FOR_EACH_UNREACHABLE_NODE(DEFINE_UNREACHABLE) | 45 FOR_EACH_UNREACHABLE_NODE(DEFINE_UNREACHABLE) |
44 #undef DEFINE_UNREACHABLE | 46 #undef DEFINE_UNREACHABLE |
45 | 47 |
46 AwaitTransformer::AwaitTransformer(SequenceNode* preamble, | 48 AwaitTransformer::AwaitTransformer(SequenceNode* preamble, |
47 ParsedFunction* const parsed_function, | 49 ParsedFunction* const parsed_function, |
48 LocalScope* function_top) | 50 LocalScope* function_top) |
49 : preamble_(preamble), | 51 : preamble_(preamble), |
50 temp_cnt_(0), | 52 temp_cnt_(0), |
51 parsed_function_(parsed_function), | 53 parsed_function_(parsed_function), |
52 function_top_(function_top), | 54 function_top_(function_top), |
53 isolate_(Isolate::Current()) { | 55 thread_(Thread::Current()) { |
54 ASSERT(function_top_ != NULL); | 56 ASSERT(function_top_ != NULL); |
55 } | 57 } |
56 | 58 |
57 | 59 |
58 AstNode* AwaitTransformer::Transform(AstNode* expr) { | 60 AstNode* AwaitTransformer::Transform(AstNode* expr) { |
59 expr->Visit(this); | 61 expr->Visit(this); |
60 return result_; | 62 return result_; |
61 } | 63 } |
62 | 64 |
63 | 65 |
64 LocalVariable* AwaitTransformer::EnsureCurrentTempVar() { | 66 LocalVariable* AwaitTransformer::EnsureCurrentTempVar() { |
65 const char* await_temp_prefix = ":await_temp_var_"; | 67 const char* await_temp_prefix = ":await_temp_var_"; |
66 const String& cnt_str = String::ZoneHandle( | 68 const String& cnt_str = String::ZoneHandle( |
67 I, String::NewFormatted("%s%d", await_temp_prefix, temp_cnt_)); | 69 I, String::NewFormatted("%s%d", await_temp_prefix, temp_cnt_)); |
68 const String& symbol = String::ZoneHandle(I, Symbols::New(cnt_str)); | 70 const String& symbol = String::ZoneHandle(I, Symbols::New(cnt_str)); |
69 ASSERT(!symbol.IsNull()); | 71 ASSERT(!symbol.IsNull()); |
70 // Look up the variable through the preamble scope. | 72 // Look up the variable through the preamble scope. |
71 LocalVariable* await_tmp = preamble_->scope()->LookupVariable(symbol, false); | 73 LocalVariable* await_tmp = preamble_->scope()->LookupVariable(symbol, false); |
72 if (await_tmp == NULL) { | 74 if (await_tmp == NULL) { |
73 // If we need a new temp variable, we add it to the function's top scope. | 75 // If we need a new temp variable, we add it to the function's top scope. |
74 await_tmp = new (I) LocalVariable( | 76 await_tmp = new (Z) LocalVariable( |
75 Scanner::kNoSourcePos, symbol, Type::ZoneHandle(Type::DynamicType())); | 77 Scanner::kNoSourcePos, symbol, Type::ZoneHandle(Type::DynamicType())); |
76 function_top_->AddVariable(await_tmp); | 78 function_top_->AddVariable(await_tmp); |
77 // After adding it to the top scope, we can look it up from the preamble. | 79 // After adding it to the top scope, we can look it up from the preamble. |
78 // The following call includes an ASSERT check. | 80 // The following call includes an ASSERT check. |
79 await_tmp = GetVariableInScope(preamble_->scope(), symbol); | 81 await_tmp = GetVariableInScope(preamble_->scope(), symbol); |
80 } | 82 } |
81 return await_tmp; | 83 return await_tmp; |
82 } | 84 } |
83 | 85 |
84 | 86 |
85 LocalVariable* AwaitTransformer::GetVariableInScope(LocalScope* scope, | 87 LocalVariable* AwaitTransformer::GetVariableInScope(LocalScope* scope, |
86 const String& symbol) { | 88 const String& symbol) { |
87 LocalVariable* var = scope->LookupVariable(symbol, false); | 89 LocalVariable* var = scope->LookupVariable(symbol, false); |
88 ASSERT(var != NULL); | 90 ASSERT(var != NULL); |
89 return var; | 91 return var; |
90 } | 92 } |
91 | 93 |
92 | 94 |
93 LocalVariable* AwaitTransformer::AddToPreambleNewTempVar(AstNode* node) { | 95 LocalVariable* AwaitTransformer::AddToPreambleNewTempVar(AstNode* node) { |
94 LocalVariable* tmp_var = EnsureCurrentTempVar(); | 96 LocalVariable* tmp_var = EnsureCurrentTempVar(); |
95 preamble_->Add(new(I) StoreLocalNode(Scanner::kNoSourcePos, tmp_var, node)); | 97 preamble_->Add(new(Z) StoreLocalNode(Scanner::kNoSourcePos, tmp_var, node)); |
96 NextTempVar(); | 98 NextTempVar(); |
97 return tmp_var; | 99 return tmp_var; |
98 } | 100 } |
99 | 101 |
100 | 102 |
101 void AwaitTransformer::VisitLiteralNode(LiteralNode* node) { | 103 void AwaitTransformer::VisitLiteralNode(LiteralNode* node) { |
102 result_ = node; | 104 result_ = node; |
103 } | 105 } |
104 | 106 |
105 | 107 |
106 void AwaitTransformer::VisitTypeNode(TypeNode* node) { | 108 void AwaitTransformer::VisitTypeNode(TypeNode* node) { |
107 result_ = new(I) TypeNode(node->token_pos(), node->type()); | 109 result_ = new(Z) TypeNode(node->token_pos(), node->type()); |
108 } | 110 } |
109 | 111 |
110 | 112 |
111 void AwaitTransformer::VisitAwaitNode(AwaitNode* node) { | 113 void AwaitTransformer::VisitAwaitNode(AwaitNode* node) { |
112 // Await transformation: | 114 // Await transformation: |
113 // | 115 // |
114 // :await_temp_var_X = <expr>; | 116 // :await_temp_var_X = <expr>; |
115 // :result_param = :await_temp_var_X; | 117 // :result_param = :await_temp_var_X; |
116 // if (:result_param is !Future) { | 118 // if (:result_param is !Future) { |
117 // :result_param = Future.value(:result_param); | 119 // :result_param = Future.value(:result_param); |
118 // } | 120 // } |
119 // AwaitMarker(kNewContinuationState); | 121 // AwaitMarker(kNewContinuationState); |
120 // :result_param = :result_param.then(:async_op); | 122 // :result_param = :result_param.then(:async_op); |
121 // _asyncCatchHelper(:result_param.catchError, :async_op); | 123 // _asyncCatchHelper(:result_param.catchError, :async_op); |
122 // return; // (return_type() == kContinuationTarget) | 124 // return; // (return_type() == kContinuationTarget) |
123 // | 125 // |
124 // :saved_try_ctx_var = :await_saved_try_ctx_var_y; | 126 // :saved_try_ctx_var = :await_saved_try_ctx_var_y; |
125 // :await_temp_var_(X+1) = :result_param; | 127 // :await_temp_var_(X+1) = :result_param; |
126 | 128 |
127 LocalVariable* async_op = GetVariableInScope( | 129 LocalVariable* async_op = GetVariableInScope( |
128 preamble_->scope(), Symbols::AsyncOperation()); | 130 preamble_->scope(), Symbols::AsyncOperation()); |
129 LocalVariable* result_param = GetVariableInScope( | 131 LocalVariable* result_param = GetVariableInScope( |
130 preamble_->scope(), Symbols::AsyncOperationParam()); | 132 preamble_->scope(), Symbols::AsyncOperationParam()); |
131 LocalVariable* error_param = GetVariableInScope( | 133 LocalVariable* error_param = GetVariableInScope( |
132 preamble_->scope(), Symbols::AsyncOperationErrorParam()); | 134 preamble_->scope(), Symbols::AsyncOperationErrorParam()); |
133 | 135 |
134 AstNode* transformed_expr = Transform(node->expr()); | 136 AstNode* transformed_expr = Transform(node->expr()); |
135 preamble_->Add(new(I) StoreLocalNode( | 137 preamble_->Add(new(Z) StoreLocalNode( |
136 Scanner::kNoSourcePos, result_param, transformed_expr)); | 138 Scanner::kNoSourcePos, result_param, transformed_expr)); |
137 | 139 |
138 LoadLocalNode* load_result_param = new(I) LoadLocalNode( | 140 LoadLocalNode* load_result_param = new(Z) LoadLocalNode( |
139 Scanner::kNoSourcePos, result_param); | 141 Scanner::kNoSourcePos, result_param); |
140 | 142 |
141 const Class& future_cls = | 143 const Class& future_cls = |
142 Class::ZoneHandle(I, I->object_store()->future_class()); | 144 Class::ZoneHandle(I, I->object_store()->future_class()); |
143 ASSERT(!future_cls.IsNull()); | 145 ASSERT(!future_cls.IsNull()); |
144 const AbstractType& future_type = | 146 const AbstractType& future_type = |
145 AbstractType::ZoneHandle(I, future_cls.RareType()); | 147 AbstractType::ZoneHandle(I, future_cls.RareType()); |
146 ASSERT(!future_type.IsNull()); | 148 ASSERT(!future_type.IsNull()); |
147 | 149 |
148 LocalScope* is_not_future_scope = ChainNewScope(preamble_->scope()); | 150 LocalScope* is_not_future_scope = ChainNewScope(preamble_->scope()); |
149 SequenceNode* is_not_future_branch = | 151 SequenceNode* is_not_future_branch = |
150 new (I) SequenceNode(Scanner::kNoSourcePos, is_not_future_scope); | 152 new (Z) SequenceNode(Scanner::kNoSourcePos, is_not_future_scope); |
151 | 153 |
152 // if (:result_param is !Future) { | 154 // if (:result_param is !Future) { |
153 // :result_param = Future.value(:result_param); | 155 // :result_param = Future.value(:result_param); |
154 // } | 156 // } |
155 const Function& value_ctor = Function::ZoneHandle( | 157 const Function& value_ctor = Function::ZoneHandle( |
156 I, future_cls.LookupFunction(Symbols::FutureValue())); | 158 I, future_cls.LookupFunction(Symbols::FutureValue())); |
157 ASSERT(!value_ctor.IsNull()); | 159 ASSERT(!value_ctor.IsNull()); |
158 ArgumentListNode* ctor_args = new (I) ArgumentListNode(Scanner::kNoSourcePos); | 160 ArgumentListNode* ctor_args = new (Z) ArgumentListNode(Scanner::kNoSourcePos); |
159 ctor_args->Add(new (I) LoadLocalNode(Scanner::kNoSourcePos, result_param)); | 161 ctor_args->Add(new (Z) LoadLocalNode(Scanner::kNoSourcePos, result_param)); |
160 ConstructorCallNode* ctor_call = | 162 ConstructorCallNode* ctor_call = |
161 new (I) ConstructorCallNode(Scanner::kNoSourcePos, | 163 new (Z) ConstructorCallNode(Scanner::kNoSourcePos, |
162 TypeArguments::ZoneHandle(I), | 164 TypeArguments::ZoneHandle(I), |
163 value_ctor, | 165 value_ctor, |
164 ctor_args); | 166 ctor_args); |
165 is_not_future_branch->Add(new (I) StoreLocalNode( | 167 is_not_future_branch->Add(new (Z) StoreLocalNode( |
166 Scanner::kNoSourcePos, result_param, ctor_call)); | 168 Scanner::kNoSourcePos, result_param, ctor_call)); |
167 AstNode* is_not_future_test = new (I) ComparisonNode( | 169 AstNode* is_not_future_test = new (Z) ComparisonNode( |
168 Scanner::kNoSourcePos, | 170 Scanner::kNoSourcePos, |
169 Token::kISNOT, | 171 Token::kISNOT, |
170 load_result_param, | 172 load_result_param, |
171 new (I) TypeNode(Scanner::kNoSourcePos, future_type)); | 173 new (Z) TypeNode(Scanner::kNoSourcePos, future_type)); |
172 preamble_->Add(new(I) IfNode(Scanner::kNoSourcePos, | 174 preamble_->Add(new(Z) IfNode(Scanner::kNoSourcePos, |
173 is_not_future_test, | 175 is_not_future_test, |
174 is_not_future_branch, | 176 is_not_future_branch, |
175 NULL)); | 177 NULL)); |
176 | 178 |
177 AwaitMarkerNode* await_marker = new (I) AwaitMarkerNode(); | 179 AwaitMarkerNode* await_marker = new (Z) AwaitMarkerNode(); |
178 await_marker->set_scope(preamble_->scope()); | 180 await_marker->set_scope(preamble_->scope()); |
179 preamble_->Add(await_marker); | 181 preamble_->Add(await_marker); |
180 ArgumentListNode* args = new(I) ArgumentListNode(Scanner::kNoSourcePos); | 182 ArgumentListNode* args = new(Z) ArgumentListNode(Scanner::kNoSourcePos); |
181 | 183 |
182 args->Add(new(I) LoadLocalNode(Scanner::kNoSourcePos, async_op)); | 184 args->Add(new(Z) LoadLocalNode(Scanner::kNoSourcePos, async_op)); |
183 preamble_->Add(new (I) StoreLocalNode( | 185 preamble_->Add(new (Z) StoreLocalNode( |
184 Scanner::kNoSourcePos, | 186 Scanner::kNoSourcePos, |
185 result_param, | 187 result_param, |
186 new(I) InstanceCallNode(Scanner::kNoSourcePos, | 188 new(Z) InstanceCallNode(Scanner::kNoSourcePos, |
187 load_result_param, | 189 load_result_param, |
188 Symbols::FutureThen(), | 190 Symbols::FutureThen(), |
189 args))); | 191 args))); |
190 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 192 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
191 const Function& async_catch_helper = Function::ZoneHandle( | 193 const Function& async_catch_helper = Function::ZoneHandle( |
192 I, core_lib.LookupFunctionAllowPrivate(Symbols::AsyncCatchHelper())); | 194 I, core_lib.LookupFunctionAllowPrivate(Symbols::AsyncCatchHelper())); |
193 ASSERT(!async_catch_helper.IsNull()); | 195 ASSERT(!async_catch_helper.IsNull()); |
194 ArgumentListNode* catch_helper_args = new (I) ArgumentListNode( | 196 ArgumentListNode* catch_helper_args = new (Z) ArgumentListNode( |
195 Scanner::kNoSourcePos); | 197 Scanner::kNoSourcePos); |
196 InstanceGetterNode* catch_error_getter = new (I) InstanceGetterNode( | 198 InstanceGetterNode* catch_error_getter = new (Z) InstanceGetterNode( |
197 Scanner::kNoSourcePos, | 199 Scanner::kNoSourcePos, |
198 load_result_param, | 200 load_result_param, |
199 Symbols::FutureCatchError()); | 201 Symbols::FutureCatchError()); |
200 catch_helper_args->Add(catch_error_getter); | 202 catch_helper_args->Add(catch_error_getter); |
201 catch_helper_args->Add(new (I) LoadLocalNode( | 203 catch_helper_args->Add(new (Z) LoadLocalNode( |
202 Scanner::kNoSourcePos, async_op)); | 204 Scanner::kNoSourcePos, async_op)); |
203 preamble_->Add(new (I) StaticCallNode( | 205 preamble_->Add(new (Z) StaticCallNode( |
204 Scanner::kNoSourcePos, | 206 Scanner::kNoSourcePos, |
205 async_catch_helper, | 207 async_catch_helper, |
206 catch_helper_args)); | 208 catch_helper_args)); |
207 ReturnNode* continuation_return = new(I) ReturnNode(Scanner::kNoSourcePos); | 209 ReturnNode* continuation_return = new(Z) ReturnNode(Scanner::kNoSourcePos); |
208 continuation_return->set_return_type(ReturnNode::kContinuationTarget); | 210 continuation_return->set_return_type(ReturnNode::kContinuationTarget); |
209 preamble_->Add(continuation_return); | 211 preamble_->Add(continuation_return); |
210 | 212 |
211 // If this expression is part of a try block, also append the code for | 213 // If this expression is part of a try block, also append the code for |
212 // restoring the saved try context that lives on the stack. | 214 // restoring the saved try context that lives on the stack. |
213 const String& async_saved_try_ctx_name = | 215 const String& async_saved_try_ctx_name = |
214 String::Handle(I, parsed_function_->async_saved_try_ctx_name()); | 216 String::Handle(I, parsed_function_->async_saved_try_ctx_name()); |
215 if (!async_saved_try_ctx_name.IsNull()) { | 217 if (!async_saved_try_ctx_name.IsNull()) { |
216 LocalVariable* async_saved_try_ctx = | 218 LocalVariable* async_saved_try_ctx = |
217 GetVariableInScope(preamble_->scope(), async_saved_try_ctx_name); | 219 GetVariableInScope(preamble_->scope(), async_saved_try_ctx_name); |
218 preamble_->Add(new (I) StoreLocalNode( | 220 preamble_->Add(new (Z) StoreLocalNode( |
219 Scanner::kNoSourcePos, | 221 Scanner::kNoSourcePos, |
220 parsed_function_->saved_try_ctx(), | 222 parsed_function_->saved_try_ctx(), |
221 new (I) LoadLocalNode(Scanner::kNoSourcePos, async_saved_try_ctx))); | 223 new (Z) LoadLocalNode(Scanner::kNoSourcePos, async_saved_try_ctx))); |
222 } | 224 } |
223 | 225 |
224 LoadLocalNode* load_error_param = new (I) LoadLocalNode( | 226 LoadLocalNode* load_error_param = new (Z) LoadLocalNode( |
225 Scanner::kNoSourcePos, error_param); | 227 Scanner::kNoSourcePos, error_param); |
226 SequenceNode* error_ne_null_branch = new (I) SequenceNode( | 228 SequenceNode* error_ne_null_branch = new (Z) SequenceNode( |
227 Scanner::kNoSourcePos, ChainNewScope(preamble_->scope())); | 229 Scanner::kNoSourcePos, ChainNewScope(preamble_->scope())); |
228 error_ne_null_branch->Add(new (I) ThrowNode( | 230 error_ne_null_branch->Add(new (Z) ThrowNode( |
229 Scanner::kNoSourcePos, | 231 Scanner::kNoSourcePos, |
230 load_error_param, | 232 load_error_param, |
231 NULL)); | 233 NULL)); |
232 preamble_->Add(new (I) IfNode( | 234 preamble_->Add(new (Z) IfNode( |
233 Scanner::kNoSourcePos, | 235 Scanner::kNoSourcePos, |
234 new (I) ComparisonNode( | 236 new (Z) ComparisonNode( |
235 Scanner::kNoSourcePos, | 237 Scanner::kNoSourcePos, |
236 Token::kNE, | 238 Token::kNE, |
237 load_error_param, | 239 load_error_param, |
238 new (I) LiteralNode(Scanner::kNoSourcePos, | 240 new (Z) LiteralNode(Scanner::kNoSourcePos, |
239 Object::null_instance())), | 241 Object::null_instance())), |
240 error_ne_null_branch, | 242 error_ne_null_branch, |
241 NULL)); | 243 NULL)); |
242 | 244 |
243 LocalVariable* result = AddToPreambleNewTempVar(new(I) LoadLocalNode( | 245 LocalVariable* result = AddToPreambleNewTempVar(new(Z) LoadLocalNode( |
244 Scanner::kNoSourcePos, result_param)); | 246 Scanner::kNoSourcePos, result_param)); |
245 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 247 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
246 } | 248 } |
247 | 249 |
248 | 250 |
249 // Transforms boolean expressions into a sequence of evaluatons that only lazily | 251 // Transforms boolean expressions into a sequence of evaluatons that only lazily |
250 // evaluate subexpressions. | 252 // evaluate subexpressions. |
251 // | 253 // |
252 // Example: | 254 // Example: |
253 // | 255 // |
254 // (a || b) only evaluates b if a is false | 256 // (a || b) only evaluates b if a is false |
255 // | 257 // |
256 // Transformation (roughly): | 258 // Transformation (roughly): |
257 // | 259 // |
258 // t_1 = a; | 260 // t_1 = a; |
259 // if (!t_1) { | 261 // if (!t_1) { |
260 // t_2 = b; | 262 // t_2 = b; |
261 // } | 263 // } |
262 // t_3 = t_1 || t_2; // Compiler takes care that lazy evaluation takes place | 264 // t_3 = t_1 || t_2; // Compiler takes care that lazy evaluation takes place |
263 // on this level. | 265 // on this level. |
264 AstNode* AwaitTransformer::LazyTransform(const Token::Kind logical_op, | 266 AstNode* AwaitTransformer::LazyTransform(const Token::Kind logical_op, |
265 AstNode* new_left, | 267 AstNode* new_left, |
266 AstNode* right) { | 268 AstNode* right) { |
267 ASSERT(logical_op == Token::kAND || logical_op == Token::kOR); | 269 ASSERT(logical_op == Token::kAND || logical_op == Token::kOR); |
268 AstNode* result = NULL; | 270 AstNode* result = NULL; |
269 const Token::Kind compare_logical_op = (logical_op == Token::kAND) ? | 271 const Token::Kind compare_logical_op = (logical_op == Token::kAND) ? |
270 Token::kEQ : Token::kNE; | 272 Token::kEQ : Token::kNE; |
271 SequenceNode* eval = new (I) SequenceNode( | 273 SequenceNode* eval = new (Z) SequenceNode( |
272 Scanner::kNoSourcePos, ChainNewScope(preamble_->scope())); | 274 Scanner::kNoSourcePos, ChainNewScope(preamble_->scope())); |
273 SequenceNode* saved_preamble = preamble_; | 275 SequenceNode* saved_preamble = preamble_; |
274 preamble_ = eval; | 276 preamble_ = eval; |
275 result = Transform(right); | 277 result = Transform(right); |
276 preamble_ = saved_preamble; | 278 preamble_ = saved_preamble; |
277 IfNode* right_body = new(I) IfNode( | 279 IfNode* right_body = new(Z) IfNode( |
278 Scanner::kNoSourcePos, | 280 Scanner::kNoSourcePos, |
279 new(I) ComparisonNode( | 281 new(Z) ComparisonNode( |
280 Scanner::kNoSourcePos, | 282 Scanner::kNoSourcePos, |
281 compare_logical_op, | 283 compare_logical_op, |
282 new_left, | 284 new_left, |
283 new(I) LiteralNode(Scanner::kNoSourcePos, Bool::True())), | 285 new(Z) LiteralNode(Scanner::kNoSourcePos, Bool::True())), |
284 eval, | 286 eval, |
285 NULL); | 287 NULL); |
286 preamble_->Add(right_body); | 288 preamble_->Add(right_body); |
287 return result; | 289 return result; |
288 } | 290 } |
289 | 291 |
290 | 292 |
291 LocalScope* AwaitTransformer::ChainNewScope(LocalScope* parent) { | 293 LocalScope* AwaitTransformer::ChainNewScope(LocalScope* parent) { |
292 return new (I) LocalScope( | 294 return new (Z) LocalScope( |
293 parent, parent->function_level(), parent->loop_level()); | 295 parent, parent->function_level(), parent->loop_level()); |
294 } | 296 } |
295 | 297 |
296 | 298 |
297 void AwaitTransformer::VisitBinaryOpNode(BinaryOpNode* node) { | 299 void AwaitTransformer::VisitBinaryOpNode(BinaryOpNode* node) { |
298 AstNode* new_left = Transform(node->left()); | 300 AstNode* new_left = Transform(node->left()); |
299 AstNode* new_right = NULL; | 301 AstNode* new_right = NULL; |
300 // Preserve lazy evaluaton. | 302 // Preserve lazy evaluaton. |
301 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { | 303 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { |
302 new_right = LazyTransform(node->kind(), new_left, node->right()); | 304 new_right = LazyTransform(node->kind(), new_left, node->right()); |
303 } else { | 305 } else { |
304 new_right = Transform(node->right()); | 306 new_right = Transform(node->right()); |
305 } | 307 } |
306 LocalVariable* result = AddToPreambleNewTempVar( | 308 LocalVariable* result = AddToPreambleNewTempVar( |
307 new(I) BinaryOpNode(node->token_pos(), | 309 new(Z) BinaryOpNode(node->token_pos(), |
308 node->kind(), | 310 node->kind(), |
309 new_left, | 311 new_left, |
310 new_right)); | 312 new_right)); |
311 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 313 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
312 } | 314 } |
313 | 315 |
314 | 316 |
315 void AwaitTransformer::VisitBinaryOpWithMask32Node( | 317 void AwaitTransformer::VisitBinaryOpWithMask32Node( |
316 BinaryOpWithMask32Node* node) { | 318 BinaryOpWithMask32Node* node) { |
317 ASSERT((node->kind() != Token::kAND) && (node->kind() != Token::kOR)); | 319 ASSERT((node->kind() != Token::kAND) && (node->kind() != Token::kOR)); |
318 AstNode* new_left = Transform(node->left()); | 320 AstNode* new_left = Transform(node->left()); |
319 AstNode* new_right = Transform(node->right()); | 321 AstNode* new_right = Transform(node->right()); |
320 LocalVariable* result = AddToPreambleNewTempVar( | 322 LocalVariable* result = AddToPreambleNewTempVar( |
321 new(I) BinaryOpWithMask32Node(node->token_pos(), | 323 new(Z) BinaryOpWithMask32Node(node->token_pos(), |
322 node->kind(), | 324 node->kind(), |
323 new_left, | 325 new_left, |
324 new_right, | 326 new_right, |
325 node->mask32())); | 327 node->mask32())); |
326 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 328 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
327 } | 329 } |
328 | 330 |
329 | 331 |
330 void AwaitTransformer::VisitComparisonNode(ComparisonNode* node) { | 332 void AwaitTransformer::VisitComparisonNode(ComparisonNode* node) { |
331 AstNode* new_left = Transform(node->left()); | 333 AstNode* new_left = Transform(node->left()); |
332 AstNode* new_right = Transform(node->right()); | 334 AstNode* new_right = Transform(node->right()); |
333 LocalVariable* result = AddToPreambleNewTempVar( | 335 LocalVariable* result = AddToPreambleNewTempVar( |
334 new(I) ComparisonNode(node->token_pos(), | 336 new(Z) ComparisonNode(node->token_pos(), |
335 node->kind(), | 337 node->kind(), |
336 new_left, | 338 new_left, |
337 new_right)); | 339 new_right)); |
338 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 340 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
339 } | 341 } |
340 | 342 |
341 | 343 |
342 void AwaitTransformer::VisitUnaryOpNode(UnaryOpNode* node) { | 344 void AwaitTransformer::VisitUnaryOpNode(UnaryOpNode* node) { |
343 AstNode* new_operand = Transform(node->operand()); | 345 AstNode* new_operand = Transform(node->operand()); |
344 LocalVariable* result = AddToPreambleNewTempVar( | 346 LocalVariable* result = AddToPreambleNewTempVar( |
345 new(I) UnaryOpNode(node->token_pos(), node->kind(), new_operand)); | 347 new(Z) UnaryOpNode(node->token_pos(), node->kind(), new_operand)); |
346 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 348 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
347 } | 349 } |
348 | 350 |
349 | 351 |
350 // ::= (<condition>) ? <true-branch> : <false-branch> | 352 // ::= (<condition>) ? <true-branch> : <false-branch> |
351 // | 353 // |
352 void AwaitTransformer::VisitConditionalExprNode(ConditionalExprNode* node) { | 354 void AwaitTransformer::VisitConditionalExprNode(ConditionalExprNode* node) { |
353 AstNode* new_condition = Transform(node->condition()); | 355 AstNode* new_condition = Transform(node->condition()); |
354 SequenceNode* new_true = new (I) SequenceNode( | 356 SequenceNode* new_true = new (Z) SequenceNode( |
355 Scanner::kNoSourcePos, ChainNewScope(preamble_->scope())); | 357 Scanner::kNoSourcePos, ChainNewScope(preamble_->scope())); |
356 SequenceNode* saved_preamble = preamble_; | 358 SequenceNode* saved_preamble = preamble_; |
357 preamble_ = new_true; | 359 preamble_ = new_true; |
358 AstNode* new_true_result = Transform(node->true_expr()); | 360 AstNode* new_true_result = Transform(node->true_expr()); |
359 SequenceNode* new_false = new (I) SequenceNode( | 361 SequenceNode* new_false = new (Z) SequenceNode( |
360 Scanner::kNoSourcePos, ChainNewScope(preamble_->scope())); | 362 Scanner::kNoSourcePos, ChainNewScope(preamble_->scope())); |
361 preamble_ = new_false; | 363 preamble_ = new_false; |
362 AstNode* new_false_result = Transform(node->false_expr()); | 364 AstNode* new_false_result = Transform(node->false_expr()); |
363 preamble_ = saved_preamble; | 365 preamble_ = saved_preamble; |
364 IfNode* new_if = new(I) IfNode(Scanner::kNoSourcePos, | 366 IfNode* new_if = new(Z) IfNode(Scanner::kNoSourcePos, |
365 new_condition, | 367 new_condition, |
366 new_true, | 368 new_true, |
367 new_false); | 369 new_false); |
368 preamble_->Add(new_if); | 370 preamble_->Add(new_if); |
369 LocalVariable* result = AddToPreambleNewTempVar( | 371 LocalVariable* result = AddToPreambleNewTempVar( |
370 new(I) ConditionalExprNode(Scanner::kNoSourcePos, | 372 new(Z) ConditionalExprNode(Scanner::kNoSourcePos, |
371 new_condition, | 373 new_condition, |
372 new_true_result, | 374 new_true_result, |
373 new_false_result)); | 375 new_false_result)); |
374 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 376 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
375 } | 377 } |
376 | 378 |
377 | 379 |
378 void AwaitTransformer::VisitArgumentListNode(ArgumentListNode* node) { | 380 void AwaitTransformer::VisitArgumentListNode(ArgumentListNode* node) { |
379 ArgumentListNode* new_args = new(I) ArgumentListNode(node->token_pos()); | 381 ArgumentListNode* new_args = new(Z) ArgumentListNode(node->token_pos()); |
380 for (intptr_t i = 0; i < node->length(); i++) { | 382 for (intptr_t i = 0; i < node->length(); i++) { |
381 new_args->Add(Transform(node->NodeAt(i))); | 383 new_args->Add(Transform(node->NodeAt(i))); |
382 } | 384 } |
383 new_args->set_names(node->names()); | 385 new_args->set_names(node->names()); |
384 result_ = new_args; | 386 result_ = new_args; |
385 } | 387 } |
386 | 388 |
387 | 389 |
388 void AwaitTransformer::VisitArrayNode(ArrayNode* node) { | 390 void AwaitTransformer::VisitArrayNode(ArrayNode* node) { |
389 GrowableArray<AstNode*> new_elements; | 391 GrowableArray<AstNode*> new_elements; |
390 for (intptr_t i = 0; i < node->length(); i++) { | 392 for (intptr_t i = 0; i < node->length(); i++) { |
391 new_elements.Add(Transform(node->ElementAt(i))); | 393 new_elements.Add(Transform(node->ElementAt(i))); |
392 } | 394 } |
393 result_ = new(I) ArrayNode(node->token_pos(), node->type(), new_elements); | 395 result_ = new(Z) ArrayNode(node->token_pos(), node->type(), new_elements); |
394 } | 396 } |
395 | 397 |
396 | 398 |
397 void AwaitTransformer::VisitStringInterpolateNode(StringInterpolateNode* node) { | 399 void AwaitTransformer::VisitStringInterpolateNode(StringInterpolateNode* node) { |
398 ArrayNode* new_value = Transform(node->value())->AsArrayNode(); | 400 ArrayNode* new_value = Transform(node->value())->AsArrayNode(); |
399 LocalVariable* result = AddToPreambleNewTempVar( | 401 LocalVariable* result = AddToPreambleNewTempVar( |
400 new(I) StringInterpolateNode(node->token_pos(), | 402 new(Z) StringInterpolateNode(node->token_pos(), |
401 new_value)); | 403 new_value)); |
402 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 404 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
403 } | 405 } |
404 | 406 |
405 | 407 |
406 void AwaitTransformer::VisitClosureNode(ClosureNode* node) { | 408 void AwaitTransformer::VisitClosureNode(ClosureNode* node) { |
407 AstNode* new_receiver = node->receiver(); | 409 AstNode* new_receiver = node->receiver(); |
408 if (new_receiver != NULL) { | 410 if (new_receiver != NULL) { |
409 new_receiver = Transform(new_receiver); | 411 new_receiver = Transform(new_receiver); |
410 } | 412 } |
411 LocalVariable* result = AddToPreambleNewTempVar( | 413 LocalVariable* result = AddToPreambleNewTempVar( |
412 new(I) ClosureNode(node->token_pos(), | 414 new(Z) ClosureNode(node->token_pos(), |
413 node->function(), | 415 node->function(), |
414 new_receiver, | 416 new_receiver, |
415 node->scope())); | 417 node->scope())); |
416 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 418 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
417 } | 419 } |
418 | 420 |
419 | 421 |
420 void AwaitTransformer::VisitInstanceCallNode(InstanceCallNode* node) { | 422 void AwaitTransformer::VisitInstanceCallNode(InstanceCallNode* node) { |
421 AstNode* new_receiver = Transform(node->receiver()); | 423 AstNode* new_receiver = Transform(node->receiver()); |
422 ArgumentListNode* new_args = | 424 ArgumentListNode* new_args = |
423 Transform(node->arguments())->AsArgumentListNode(); | 425 Transform(node->arguments())->AsArgumentListNode(); |
424 LocalVariable* result = AddToPreambleNewTempVar( | 426 LocalVariable* result = AddToPreambleNewTempVar( |
425 new(I) InstanceCallNode(node->token_pos(), | 427 new(Z) InstanceCallNode(node->token_pos(), |
426 new_receiver, | 428 new_receiver, |
427 node->function_name(), | 429 node->function_name(), |
428 new_args)); | 430 new_args)); |
429 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 431 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
430 } | 432 } |
431 | 433 |
432 | 434 |
433 void AwaitTransformer::VisitStaticCallNode(StaticCallNode* node) { | 435 void AwaitTransformer::VisitStaticCallNode(StaticCallNode* node) { |
434 ArgumentListNode* new_args = | 436 ArgumentListNode* new_args = |
435 Transform(node->arguments())->AsArgumentListNode(); | 437 Transform(node->arguments())->AsArgumentListNode(); |
436 LocalVariable* result = AddToPreambleNewTempVar( | 438 LocalVariable* result = AddToPreambleNewTempVar( |
437 new(I) StaticCallNode(node->token_pos(), | 439 new(Z) StaticCallNode(node->token_pos(), |
438 node->function(), | 440 node->function(), |
439 new_args)); | 441 new_args)); |
440 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 442 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
441 } | 443 } |
442 | 444 |
443 | 445 |
444 void AwaitTransformer::VisitConstructorCallNode(ConstructorCallNode* node) { | 446 void AwaitTransformer::VisitConstructorCallNode(ConstructorCallNode* node) { |
445 ArgumentListNode* new_args = | 447 ArgumentListNode* new_args = |
446 Transform(node->arguments())->AsArgumentListNode(); | 448 Transform(node->arguments())->AsArgumentListNode(); |
447 LocalVariable* result = AddToPreambleNewTempVar( | 449 LocalVariable* result = AddToPreambleNewTempVar( |
448 new(I) ConstructorCallNode(node->token_pos(), | 450 new(Z) ConstructorCallNode(node->token_pos(), |
449 node->type_arguments(), | 451 node->type_arguments(), |
450 node->constructor(), | 452 node->constructor(), |
451 new_args)); | 453 new_args)); |
452 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 454 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
453 } | 455 } |
454 | 456 |
455 | 457 |
456 void AwaitTransformer::VisitInstanceGetterNode(InstanceGetterNode* node) { | 458 void AwaitTransformer::VisitInstanceGetterNode(InstanceGetterNode* node) { |
457 AstNode* new_receiver = Transform(node->receiver()); | 459 AstNode* new_receiver = Transform(node->receiver()); |
458 LocalVariable* result = AddToPreambleNewTempVar( | 460 LocalVariable* result = AddToPreambleNewTempVar( |
459 new(I) InstanceGetterNode(node->token_pos(), | 461 new(Z) InstanceGetterNode(node->token_pos(), |
460 new_receiver, | 462 new_receiver, |
461 node->field_name())); | 463 node->field_name())); |
462 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 464 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
463 } | 465 } |
464 | 466 |
465 | 467 |
466 void AwaitTransformer::VisitInstanceSetterNode(InstanceSetterNode* node) { | 468 void AwaitTransformer::VisitInstanceSetterNode(InstanceSetterNode* node) { |
467 AstNode* new_receiver = node->receiver(); | 469 AstNode* new_receiver = node->receiver(); |
468 if (new_receiver != NULL) { | 470 if (new_receiver != NULL) { |
469 new_receiver = Transform(new_receiver); | 471 new_receiver = Transform(new_receiver); |
470 } | 472 } |
471 AstNode* new_value = Transform(node->value()); | 473 AstNode* new_value = Transform(node->value()); |
472 LocalVariable* result = AddToPreambleNewTempVar( | 474 LocalVariable* result = AddToPreambleNewTempVar( |
473 new(I) InstanceSetterNode(node->token_pos(), | 475 new(Z) InstanceSetterNode(node->token_pos(), |
474 new_receiver, | 476 new_receiver, |
475 node->field_name(), | 477 node->field_name(), |
476 new_value)); | 478 new_value)); |
477 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 479 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
478 } | 480 } |
479 | 481 |
480 | 482 |
481 void AwaitTransformer::VisitStaticGetterNode(StaticGetterNode* node) { | 483 void AwaitTransformer::VisitStaticGetterNode(StaticGetterNode* node) { |
482 AstNode* new_receiver = node->receiver(); | 484 AstNode* new_receiver = node->receiver(); |
483 if (new_receiver != NULL) { | 485 if (new_receiver != NULL) { |
484 new_receiver = Transform(new_receiver); | 486 new_receiver = Transform(new_receiver); |
485 } | 487 } |
486 LocalVariable* result = AddToPreambleNewTempVar( | 488 LocalVariable* result = AddToPreambleNewTempVar( |
487 new(I) StaticGetterNode(node->token_pos(), | 489 new(Z) StaticGetterNode(node->token_pos(), |
488 new_receiver, | 490 new_receiver, |
489 node->is_super_getter(), | 491 node->is_super_getter(), |
490 node->cls(), | 492 node->cls(), |
491 node->field_name())); | 493 node->field_name())); |
492 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 494 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
493 } | 495 } |
494 | 496 |
495 | 497 |
496 void AwaitTransformer::VisitStaticSetterNode(StaticSetterNode* node) { | 498 void AwaitTransformer::VisitStaticSetterNode(StaticSetterNode* node) { |
497 AstNode* new_receiver = node->receiver(); | 499 AstNode* new_receiver = node->receiver(); |
498 if (new_receiver != NULL) { | 500 if (new_receiver != NULL) { |
499 new_receiver = Transform(new_receiver); | 501 new_receiver = Transform(new_receiver); |
500 } | 502 } |
501 AstNode* new_value = Transform(node->value()); | 503 AstNode* new_value = Transform(node->value()); |
502 LocalVariable* result = AddToPreambleNewTempVar( | 504 LocalVariable* result = AddToPreambleNewTempVar( |
503 new(I) StaticSetterNode(node->token_pos(), | 505 new(Z) StaticSetterNode(node->token_pos(), |
504 new_receiver, | 506 new_receiver, |
505 node->cls(), | 507 node->cls(), |
506 node->field_name(), | 508 node->field_name(), |
507 new_value)); | 509 new_value)); |
508 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 510 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
509 } | 511 } |
510 | 512 |
511 | 513 |
512 void AwaitTransformer::VisitLoadLocalNode(LoadLocalNode* node) { | 514 void AwaitTransformer::VisitLoadLocalNode(LoadLocalNode* node) { |
513 LocalVariable* result = AddToPreambleNewTempVar( | 515 LocalVariable* result = AddToPreambleNewTempVar( |
514 new(I) LoadLocalNode(node->token_pos(), &node->local())); | 516 new(Z) LoadLocalNode(node->token_pos(), &node->local())); |
515 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 517 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
516 } | 518 } |
517 | 519 |
518 | 520 |
519 void AwaitTransformer::VisitStoreLocalNode(StoreLocalNode* node) { | 521 void AwaitTransformer::VisitStoreLocalNode(StoreLocalNode* node) { |
520 AstNode* new_value = Transform(node->value()); | 522 AstNode* new_value = Transform(node->value()); |
521 LocalVariable* result = AddToPreambleNewTempVar( | 523 LocalVariable* result = AddToPreambleNewTempVar( |
522 new(I) StoreLocalNode(node->token_pos(), | 524 new(Z) StoreLocalNode(node->token_pos(), |
523 &node->local(), | 525 &node->local(), |
524 new_value)); | 526 new_value)); |
525 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 527 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
526 } | 528 } |
527 | 529 |
528 | 530 |
529 void AwaitTransformer::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) { | 531 void AwaitTransformer::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) { |
530 LocalVariable* result = AddToPreambleNewTempVar( | 532 LocalVariable* result = AddToPreambleNewTempVar( |
531 new(I) LoadStaticFieldNode(node->token_pos(), | 533 new(Z) LoadStaticFieldNode(node->token_pos(), |
532 node->field())); | 534 node->field())); |
533 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 535 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
534 } | 536 } |
535 | 537 |
536 | 538 |
537 void AwaitTransformer::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { | 539 void AwaitTransformer::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { |
538 AstNode* new_value = Transform(node->value()); | 540 AstNode* new_value = Transform(node->value()); |
539 LocalVariable* result = AddToPreambleNewTempVar( | 541 LocalVariable* result = AddToPreambleNewTempVar( |
540 new(I) StoreStaticFieldNode(node->token_pos(), | 542 new(Z) StoreStaticFieldNode(node->token_pos(), |
541 node->field(), | 543 node->field(), |
542 new_value)); | 544 new_value)); |
543 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 545 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
544 } | 546 } |
545 | 547 |
546 | 548 |
547 void AwaitTransformer::VisitLoadIndexedNode(LoadIndexedNode* node) { | 549 void AwaitTransformer::VisitLoadIndexedNode(LoadIndexedNode* node) { |
548 AstNode* new_array = Transform(node->array()); | 550 AstNode* new_array = Transform(node->array()); |
549 AstNode* new_index = Transform(node->index_expr()); | 551 AstNode* new_index = Transform(node->index_expr()); |
550 LocalVariable* result = AddToPreambleNewTempVar( | 552 LocalVariable* result = AddToPreambleNewTempVar( |
551 new(I) LoadIndexedNode(node->token_pos(), | 553 new(Z) LoadIndexedNode(node->token_pos(), |
552 new_array, | 554 new_array, |
553 new_index, | 555 new_index, |
554 node->super_class())); | 556 node->super_class())); |
555 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 557 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
556 } | 558 } |
557 | 559 |
558 | 560 |
559 void AwaitTransformer::VisitStoreIndexedNode(StoreIndexedNode* node) { | 561 void AwaitTransformer::VisitStoreIndexedNode(StoreIndexedNode* node) { |
560 AstNode* new_array = Transform(node->array()); | 562 AstNode* new_array = Transform(node->array()); |
561 AstNode* new_index = Transform(node->index_expr()); | 563 AstNode* new_index = Transform(node->index_expr()); |
562 AstNode* new_value = Transform(node->value()); | 564 AstNode* new_value = Transform(node->value()); |
563 LocalVariable* result = AddToPreambleNewTempVar( | 565 LocalVariable* result = AddToPreambleNewTempVar( |
564 new(I) StoreIndexedNode(node->token_pos(), | 566 new(Z) StoreIndexedNode(node->token_pos(), |
565 new_array, | 567 new_array, |
566 new_index, | 568 new_index, |
567 new_value, | 569 new_value, |
568 node->super_class())); | 570 node->super_class())); |
569 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 571 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
570 } | 572 } |
571 | 573 |
572 | 574 |
573 void AwaitTransformer::VisitAssignableNode(AssignableNode* node) { | 575 void AwaitTransformer::VisitAssignableNode(AssignableNode* node) { |
574 AstNode* new_expr = Transform(node->expr()); | 576 AstNode* new_expr = Transform(node->expr()); |
575 LocalVariable* result = AddToPreambleNewTempVar( | 577 LocalVariable* result = AddToPreambleNewTempVar( |
576 new(I) AssignableNode(node->token_pos(), | 578 new(Z) AssignableNode(node->token_pos(), |
577 new_expr, | 579 new_expr, |
578 node->type(), | 580 node->type(), |
579 node->dst_name())); | 581 node->dst_name())); |
580 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); | 582 result_ = new(Z) LoadLocalNode(Scanner::kNoSourcePos, result); |
581 } | 583 } |
582 | 584 |
583 | 585 |
584 void AwaitTransformer::VisitLetNode(LetNode* node) { | 586 void AwaitTransformer::VisitLetNode(LetNode* node) { |
585 // TODO(mlippautz): Check initializers and their temps. | 587 // TODO(mlippautz): Check initializers and their temps. |
586 LetNode* result = new(I) LetNode(node->token_pos()); | 588 LetNode* result = new(Z) LetNode(node->token_pos()); |
587 for (intptr_t i = 0; i < node->nodes().length(); i++) { | 589 for (intptr_t i = 0; i < node->nodes().length(); i++) { |
588 result->AddNode(Transform(node->nodes()[i])); | 590 result->AddNode(Transform(node->nodes()[i])); |
589 } | 591 } |
590 result_ = result; | 592 result_ = result; |
591 } | 593 } |
592 | 594 |
593 | 595 |
594 void AwaitTransformer::VisitThrowNode(ThrowNode* node) { | 596 void AwaitTransformer::VisitThrowNode(ThrowNode* node) { |
595 // TODO(mlippautz): Check if relevant. | 597 // TODO(mlippautz): Check if relevant. |
596 AstNode* new_exception = Transform(node->exception()); | 598 AstNode* new_exception = Transform(node->exception()); |
597 AstNode* new_stacktrace = Transform(node->stacktrace()); | 599 AstNode* new_stacktrace = Transform(node->stacktrace()); |
598 result_ = new(I) ThrowNode(node->token_pos(), | 600 result_ = new(Z) ThrowNode(node->token_pos(), |
599 new_exception, | 601 new_exception, |
600 new_stacktrace); | 602 new_stacktrace); |
601 } | 603 } |
602 | 604 |
603 } // namespace dart | 605 } // namespace dart |
OLD | NEW |