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

Side by Side Diff: runtime/vm/parser.h

Issue 536543002: Revert "Fix scoping async functions." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/ast_transformer.cc ('k') | runtime/vm/parser.cc » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #ifndef VM_PARSER_H_ 5 #ifndef VM_PARSER_H_
6 #define VM_PARSER_H_ 6 #define VM_PARSER_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 30 matching lines...) Expand all
41 ParsedFunction(Isolate* isolate, const Function& function) 41 ParsedFunction(Isolate* isolate, const Function& function)
42 : function_(function), 42 : function_(function),
43 code_(Code::Handle(isolate, function.unoptimized_code())), 43 code_(Code::Handle(isolate, function.unoptimized_code())),
44 node_sequence_(NULL), 44 node_sequence_(NULL),
45 instantiator_(NULL), 45 instantiator_(NULL),
46 default_parameter_values_(Array::ZoneHandle(isolate, Array::null())), 46 default_parameter_values_(Array::ZoneHandle(isolate, Array::null())),
47 saved_current_context_var_(NULL), 47 saved_current_context_var_(NULL),
48 saved_entry_context_var_(NULL), 48 saved_entry_context_var_(NULL),
49 expression_temp_var_(NULL), 49 expression_temp_var_(NULL),
50 finally_return_temp_var_(NULL), 50 finally_return_temp_var_(NULL),
51 await_temps_scope_(NULL),
51 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), 52 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()),
52 first_parameter_index_(0), 53 first_parameter_index_(0),
53 first_stack_local_index_(0), 54 first_stack_local_index_(0),
54 num_copied_params_(0), 55 num_copied_params_(0),
55 num_stack_locals_(0), 56 num_stack_locals_(0),
56 have_seen_await_expr_(false), 57 have_seen_await_expr_(false),
57 saved_try_ctx_(NULL), 58 saved_try_ctx_(NULL),
58 async_saved_try_ctx_name_(String::ZoneHandle(isolate, String::null())), 59 async_saved_try_ctx_(NULL),
59 isolate_(isolate) { 60 isolate_(isolate) {
60 ASSERT(function.IsZoneHandle()); 61 ASSERT(function.IsZoneHandle());
61 } 62 }
62 63
63 const Function& function() const { return function_; } 64 const Function& function() const { return function_; }
64 const Code& code() const { return code_; } 65 const Code& code() const { return code_; }
65 66
66 SequenceNode* node_sequence() const { return node_sequence_; } 67 SequenceNode* node_sequence() const { return node_sequence_; }
67 void SetNodeSequence(SequenceNode* node_sequence); 68 void SetNodeSequence(SequenceNode* node_sequence);
68 69
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 135 }
135 void AddDeferredPrefix(const LibraryPrefix& prefix); 136 void AddDeferredPrefix(const LibraryPrefix& prefix);
136 137
137 int first_parameter_index() const { return first_parameter_index_; } 138 int first_parameter_index() const { return first_parameter_index_; }
138 int first_stack_local_index() const { return first_stack_local_index_; } 139 int first_stack_local_index() const { return first_stack_local_index_; }
139 int num_copied_params() const { return num_copied_params_; } 140 int num_copied_params() const { return num_copied_params_; }
140 int num_stack_locals() const { return num_stack_locals_; } 141 int num_stack_locals() const { return num_stack_locals_; }
141 142
142 void AllocateVariables(); 143 void AllocateVariables();
143 144
145 void set_await_temps_scope(LocalScope* scope) {
146 ASSERT(await_temps_scope_ == NULL);
147 await_temps_scope_ = scope;
148 }
149 LocalScope* await_temps_scope() const {
150 ASSERT(await_temps_scope_ != NULL);
151 return await_temps_scope_;
152 }
153
144 void record_await() { 154 void record_await() {
145 have_seen_await_expr_ = true; 155 have_seen_await_expr_ = true;
146 } 156 }
147 void reset_have_seen_await() { have_seen_await_expr_ = false; } 157 void reset_have_seen_await() { have_seen_await_expr_ = false; }
148 bool have_seen_await() const { return have_seen_await_expr_; } 158 bool have_seen_await() const { return have_seen_await_expr_; }
149 159
150 void set_saved_try_ctx(LocalVariable* saved_try_ctx) { 160 void set_saved_try_ctx(LocalVariable* saved_try_ctx) {
151 ASSERT((saved_try_ctx == NULL) || !saved_try_ctx->is_captured()); 161 ASSERT((saved_try_ctx != NULL) && !saved_try_ctx->is_captured());
152 saved_try_ctx_ = saved_try_ctx; 162 saved_try_ctx_ = saved_try_ctx;
153 } 163 }
154 LocalVariable* saved_try_ctx() const { return saved_try_ctx_; } 164 LocalVariable* saved_try_ctx() const { return saved_try_ctx_; }
155 165
156 void set_async_saved_try_ctx_name(const String& async_saved_try_ctx_name) { 166 void set_async_saved_try_ctx(LocalVariable* async_saved_try_ctx) {
157 async_saved_try_ctx_name_ = async_saved_try_ctx_name.raw(); 167 ASSERT((async_saved_try_ctx != NULL) && async_saved_try_ctx->is_captured());
168 async_saved_try_ctx_ = async_saved_try_ctx;
158 } 169 }
159 RawString* async_saved_try_ctx_name() const { 170 LocalVariable* async_saved_try_ctx() const { return async_saved_try_ctx_; }
160 return async_saved_try_ctx_name_.raw();
161 }
162 171
163 void reset_saved_try_ctx_vars() { 172 void reset_saved_try_ctx_vars() {
164 saved_try_ctx_ = NULL; 173 saved_try_ctx_ = NULL;
165 async_saved_try_ctx_name_ = String::null(); 174 async_saved_try_ctx_ = NULL;
166 } 175 }
167 176
168 Isolate* isolate() const { return isolate_; } 177 Isolate* isolate() const { return isolate_; }
169 178
170 private: 179 private:
171 const Function& function_; 180 const Function& function_;
172 Code& code_; 181 Code& code_;
173 SequenceNode* node_sequence_; 182 SequenceNode* node_sequence_;
174 LocalVariable* instantiator_; 183 LocalVariable* instantiator_;
175 Array& default_parameter_values_; 184 Array& default_parameter_values_;
176 LocalVariable* saved_current_context_var_; 185 LocalVariable* saved_current_context_var_;
177 LocalVariable* saved_entry_context_var_; 186 LocalVariable* saved_entry_context_var_;
178 LocalVariable* expression_temp_var_; 187 LocalVariable* expression_temp_var_;
179 LocalVariable* finally_return_temp_var_; 188 LocalVariable* finally_return_temp_var_;
189 LocalScope* await_temps_scope_;
180 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; 190 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_;
181 191
182 int first_parameter_index_; 192 int first_parameter_index_;
183 int first_stack_local_index_; 193 int first_stack_local_index_;
184 int num_copied_params_; 194 int num_copied_params_;
185 int num_stack_locals_; 195 int num_stack_locals_;
186 bool have_seen_await_expr_; 196 bool have_seen_await_expr_;
187 LocalVariable* saved_try_ctx_; 197 LocalVariable* saved_try_ctx_;
188 String& async_saved_try_ctx_name_; 198 LocalVariable* async_saved_try_ctx_;
189 199
190 Isolate* isolate_; 200 Isolate* isolate_;
191 201
192 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); 202 DISALLOW_COPY_AND_ASSIGN(ParsedFunction);
193 }; 203 };
194 204
195 205
196 class Parser : public ValueObject { 206 class Parser : public ValueObject {
197 public: 207 public:
198 // Parse the top level of a whole script file and register declared classes 208 // Parse the top level of a whole script file and register declared classes
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 void ChainNewBlock(LocalScope* outer_scope); 550 void ChainNewBlock(LocalScope* outer_scope);
541 void OpenBlock(); 551 void OpenBlock();
542 void OpenLoopBlock(); 552 void OpenLoopBlock();
543 void OpenFunctionBlock(const Function& func); 553 void OpenFunctionBlock(const Function& func);
544 void OpenAsyncClosure(); 554 void OpenAsyncClosure();
545 RawFunction* OpenAsyncFunction(intptr_t formal_param_pos); 555 RawFunction* OpenAsyncFunction(intptr_t formal_param_pos);
546 SequenceNode* CloseBlock(); 556 SequenceNode* CloseBlock();
547 SequenceNode* CloseAsyncFunction(const Function& closure, 557 SequenceNode* CloseAsyncFunction(const Function& closure,
548 SequenceNode* closure_node); 558 SequenceNode* closure_node);
549 void CloseAsyncClosure(SequenceNode* body); 559 void CloseAsyncClosure(SequenceNode* body);
550 void AddAsyncClosureVariables();
551 560
552 561
553 LocalVariable* LookupPhaseParameter(); 562 LocalVariable* LookupPhaseParameter();
554 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only); 563 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only);
555 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope, 564 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope,
556 bool test_only); 565 bool test_only);
557 void CaptureInstantiator(); 566 void CaptureInstantiator();
558 AstNode* LoadReceiver(intptr_t token_pos); 567 AstNode* LoadReceiver(intptr_t token_pos);
559 AstNode* LoadTypeArgumentsParameter(intptr_t token_pos); 568 AstNode* LoadTypeArgumentsParameter(intptr_t token_pos);
560 AstNode* LoadFieldIfUnresolved(AstNode* node); 569 AstNode* LoadFieldIfUnresolved(AstNode* node);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 AstNode* MakeAssertCall(intptr_t begin, intptr_t end); 724 AstNode* MakeAssertCall(intptr_t begin, intptr_t end);
716 AstNode* ThrowTypeError(intptr_t type_pos, const AbstractType& type); 725 AstNode* ThrowTypeError(intptr_t type_pos, const AbstractType& type);
717 AstNode* ThrowNoSuchMethodError(intptr_t call_pos, 726 AstNode* ThrowNoSuchMethodError(intptr_t call_pos,
718 const Class& cls, 727 const Class& cls,
719 const String& function_name, 728 const String& function_name,
720 ArgumentListNode* function_arguments, 729 ArgumentListNode* function_arguments,
721 InvocationMirror::Call call, 730 InvocationMirror::Call call,
722 InvocationMirror::Type type, 731 InvocationMirror::Type type,
723 const Function* func); 732 const Function* func);
724 733
725 void SetupSavedTryContext(LocalVariable* saved_try_context); 734 void SetupSavedTryContext(LocalScope* saved_try_context_scope,
726 void RestoreSavedTryContext(LocalScope* saved_try_context_scope, 735 int16_t try_index,
727 int16_t try_index, 736 SequenceNode* target);
728 SequenceNode* target);
729 737
730 void CheckOperatorArity(const MemberDesc& member); 738 void CheckOperatorArity(const MemberDesc& member);
731 739
732 void EnsureExpressionTemp(); 740 void EnsureExpressionTemp();
733 void EnsureSavedCurrentContext(); 741 void EnsureSavedCurrentContext();
734 bool IsLegalAssignableSyntax(AstNode* expr, intptr_t end_pos); 742 bool IsLegalAssignableSyntax(AstNode* expr, intptr_t end_pos);
735 AstNode* CreateAssignmentNode(AstNode* original, 743 AstNode* CreateAssignmentNode(AstNode* original,
736 AstNode* rhs, 744 AstNode* rhs,
737 const String* left_ident, 745 const String* left_ident,
738 intptr_t left_pos); 746 intptr_t left_pos);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 // done using 'return', 'break' or 'continue' statements. 810 // done using 'return', 'break' or 'continue' statements.
803 TryBlocks* try_blocks_list_; 811 TryBlocks* try_blocks_list_;
804 812
805 // Each try in this function gets its own try index. 813 // Each try in this function gets its own try index.
806 int16_t AllocateTryIndex(); 814 int16_t AllocateTryIndex();
807 815
808 int16_t last_used_try_index_; 816 int16_t last_used_try_index_;
809 817
810 bool unregister_pending_function_; 818 bool unregister_pending_function_;
811 819
812 LocalScope* async_temp_scope_;
813
814 DISALLOW_COPY_AND_ASSIGN(Parser); 820 DISALLOW_COPY_AND_ASSIGN(Parser);
815 }; 821 };
816 822
817 } // namespace dart 823 } // namespace dart
818 824
819 #endif // VM_PARSER_H_ 825 #endif // VM_PARSER_H_
OLDNEW
« no previous file with comments | « runtime/vm/ast_transformer.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698