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 #include "vm/thread.h" |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 return result_; | 59 return result_; |
60 } | 60 } |
61 | 61 |
62 | 62 |
63 LocalVariable* AwaitTransformer::EnsureCurrentTempVar() { | 63 LocalVariable* AwaitTransformer::EnsureCurrentTempVar() { |
64 const char* await_temp_prefix = ":await_temp_var_"; | 64 const char* await_temp_prefix = ":await_temp_var_"; |
65 const String& cnt_str = String::ZoneHandle( | 65 const String& cnt_str = String::ZoneHandle( |
66 Z, String::NewFormatted("%s%d", await_temp_prefix, temp_cnt_)); | 66 Z, String::NewFormatted("%s%d", await_temp_prefix, temp_cnt_)); |
67 const String& symbol = String::ZoneHandle(Z, Symbols::New(cnt_str)); | 67 const String& symbol = String::ZoneHandle(Z, Symbols::New(cnt_str)); |
68 ASSERT(!symbol.IsNull()); | 68 ASSERT(!symbol.IsNull()); |
69 // Look up the variable through the preamble scope. | 69 // Look up the variable in the scope used for async temp variables. |
70 LocalVariable* await_tmp = preamble_->scope()->LookupVariable(symbol, false); | 70 LocalVariable* await_tmp = function_top_->LocalLookupVariable(symbol); |
71 if (await_tmp == NULL) { | 71 if (await_tmp == NULL) { |
72 // If we need a new temp variable, we add it to the function's top scope. | 72 // We need a new temp variable; add it to the function's top scope. |
73 await_tmp = new (Z) LocalVariable( | 73 await_tmp = new (Z) LocalVariable( |
74 Scanner::kNoSourcePos, symbol, Type::ZoneHandle(Type::DynamicType())); | 74 Scanner::kNoSourcePos, symbol, Type::ZoneHandle(Type::DynamicType())); |
75 function_top_->AddVariable(await_tmp); | 75 function_top_->AddVariable(await_tmp); |
76 // After adding it to the top scope, we can look it up from the preamble. | 76 // After adding it to the top scope, we can look it up from the preamble. |
77 // The following call includes an ASSERT check. | 77 // The following call includes an ASSERT check. |
78 await_tmp = GetVariableInScope(preamble_->scope(), symbol); | 78 await_tmp = GetVariableInScope(preamble_->scope(), symbol); |
79 } | 79 } |
80 return await_tmp; | 80 return await_tmp; |
81 } | 81 } |
82 | 82 |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 622 |
623 | 623 |
624 void AwaitTransformer::VisitThrowNode(ThrowNode* node) { | 624 void AwaitTransformer::VisitThrowNode(ThrowNode* node) { |
625 AstNode* new_exception = Transform(node->exception()); | 625 AstNode* new_exception = Transform(node->exception()); |
626 result_ = new(Z) ThrowNode(node->token_pos(), | 626 result_ = new(Z) ThrowNode(node->token_pos(), |
627 new_exception, | 627 new_exception, |
628 node->stacktrace()); | 628 node->stacktrace()); |
629 } | 629 } |
630 | 630 |
631 } // namespace dart | 631 } // namespace dart |
OLD | NEW |