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

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

Issue 447003003: Introduce await (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
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 29 matching lines...) Expand all
40 public: 40 public:
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 await_temps_scope_(NULL),
50 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), 51 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()),
51 first_parameter_index_(0), 52 first_parameter_index_(0),
52 first_stack_local_index_(0), 53 first_stack_local_index_(0),
53 num_copied_params_(0), 54 num_copied_params_(0),
54 num_stack_locals_(0), 55 num_stack_locals_(0),
56 num_awaits_(0),
57 seen_await_expr_(false),
55 isolate_(isolate) { 58 isolate_(isolate) {
56 ASSERT(function.IsZoneHandle()); 59 ASSERT(function.IsZoneHandle());
57 } 60 }
58 61
59 const Function& function() const { return function_; } 62 const Function& function() const { return function_; }
60 const Code& code() const { return code_; } 63 const Code& code() const { return code_; }
61 64
62 SequenceNode* node_sequence() const { return node_sequence_; } 65 SequenceNode* node_sequence() const { return node_sequence_; }
63 void SetNodeSequence(SequenceNode* node_sequence); 66 void SetNodeSequence(SequenceNode* node_sequence);
64 67
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 119 }
117 void AddDeferredPrefix(const LibraryPrefix& prefix); 120 void AddDeferredPrefix(const LibraryPrefix& prefix);
118 121
119 int first_parameter_index() const { return first_parameter_index_; } 122 int first_parameter_index() const { return first_parameter_index_; }
120 int first_stack_local_index() const { return first_stack_local_index_; } 123 int first_stack_local_index() const { return first_stack_local_index_; }
121 int num_copied_params() const { return num_copied_params_; } 124 int num_copied_params() const { return num_copied_params_; }
122 int num_stack_locals() const { return num_stack_locals_; } 125 int num_stack_locals() const { return num_stack_locals_; }
123 126
124 void AllocateVariables(); 127 void AllocateVariables();
125 128
129 void set_await_temps_scope(LocalScope* scope) {
130 ASSERT(await_temps_scope_ == NULL);
131 await_temps_scope_ = scope;
132 }
133 LocalScope* await_temps_scope() const {
134 ASSERT(await_temps_scope_ != NULL);
135 return await_temps_scope_;
136 }
137
138 int num_awaits() const { return num_awaits_; }
139 void record_await() {
140 num_awaits_++;
141 seen_await_expr_ = true;
142 }
143 void reset_seen_await() { seen_await_expr_ = false; }
144 bool seen_await() const { return seen_await_expr_; }
145
126 Isolate* isolate() const { return isolate_; } 146 Isolate* isolate() const { return isolate_; }
127 147
128 private: 148 private:
129 const Function& function_; 149 const Function& function_;
130 Code& code_; 150 Code& code_;
131 SequenceNode* node_sequence_; 151 SequenceNode* node_sequence_;
132 LocalVariable* instantiator_; 152 LocalVariable* instantiator_;
133 Array& default_parameter_values_; 153 Array& default_parameter_values_;
134 LocalVariable* saved_current_context_var_; 154 LocalVariable* saved_current_context_var_;
135 LocalVariable* saved_entry_context_var_; 155 LocalVariable* saved_entry_context_var_;
136 LocalVariable* expression_temp_var_; 156 LocalVariable* expression_temp_var_;
157 LocalScope* await_temps_scope_;
137 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; 158 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_;
138 159
139 int first_parameter_index_; 160 int first_parameter_index_;
140 int first_stack_local_index_; 161 int first_stack_local_index_;
141 int num_copied_params_; 162 int num_copied_params_;
142 int num_stack_locals_; 163 int num_stack_locals_;
164 int num_awaits_;
165 bool seen_await_expr_;
143 166
144 Isolate* isolate_; 167 Isolate* isolate_;
145 168
146 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); 169 DISALLOW_COPY_AND_ASSIGN(ParsedFunction);
147 }; 170 };
148 171
149 172
150 class Parser : public ValueObject { 173 class Parser : public ValueObject {
151 public: 174 public:
152 // Parse the top level of a whole script file and register declared classes 175 // Parse the top level of a whole script file and register declared classes
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 SequenceNode* ParseInvokeFieldDispatcher(const Function& func, 502 SequenceNode* ParseInvokeFieldDispatcher(const Function& func,
480 Array* default_values); 503 Array* default_values);
481 void BuildDispatcherScope(const Function& func, 504 void BuildDispatcherScope(const Function& func,
482 const ArgumentsDescriptor& desc, 505 const ArgumentsDescriptor& desc,
483 Array* default_values); 506 Array* default_values);
484 507
485 void ChainNewBlock(LocalScope* outer_scope); 508 void ChainNewBlock(LocalScope* outer_scope);
486 void OpenBlock(); 509 void OpenBlock();
487 void OpenLoopBlock(); 510 void OpenLoopBlock();
488 void OpenFunctionBlock(const Function& func); 511 void OpenFunctionBlock(const Function& func);
512 void OpenAsyncClosure();
489 RawFunction* OpenAsyncFunction(intptr_t formal_param_pos); 513 RawFunction* OpenAsyncFunction(intptr_t formal_param_pos);
490 SequenceNode* CloseBlock(); 514 SequenceNode* CloseBlock();
491 SequenceNode* CloseAsyncFunction(const Function& closure, 515 SequenceNode* CloseAsyncFunction(const Function& closure,
492 SequenceNode* closure_node); 516 SequenceNode* closure_node);
493 void CloseAsyncClosure(SequenceNode* body); 517 void CloseAsyncClosure(SequenceNode* body);
494 518
495 519
496 LocalVariable* LookupPhaseParameter(); 520 LocalVariable* LookupPhaseParameter();
497 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only); 521 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only);
498 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope, 522 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 bool IsFunctionLiteral(); 587 bool IsFunctionLiteral();
564 bool IsForInStatement(); 588 bool IsForInStatement();
565 bool IsTopLevelAccessor(); 589 bool IsTopLevelAccessor();
566 590
567 AstNode* ParseBinaryExpr(int min_preced); 591 AstNode* ParseBinaryExpr(int min_preced);
568 LiteralNode* ParseConstExpr(); 592 LiteralNode* ParseConstExpr();
569 static const bool kRequireConst = true; 593 static const bool kRequireConst = true;
570 static const bool kAllowConst = false; 594 static const bool kAllowConst = false;
571 static const bool kConsumeCascades = true; 595 static const bool kConsumeCascades = true;
572 static const bool kNoCascades = false; 596 static const bool kNoCascades = false;
597 AstNode* ParseAwaitableExpr(bool require_compiletime_const,
598 bool consume_cascades);
599 AstNode* ParseAwaitExpr();
573 AstNode* ParseExpr(bool require_compiletime_const, bool consume_cascades); 600 AstNode* ParseExpr(bool require_compiletime_const, bool consume_cascades);
574 AstNode* ParseExprList(); 601 AstNode* ParseExprList();
575 AstNode* ParseConditionalExpr(); 602 AstNode* ParseConditionalExpr();
576 AstNode* ParseUnaryExpr(); 603 AstNode* ParseUnaryExpr();
577 AstNode* ParsePostfixExpr(); 604 AstNode* ParsePostfixExpr();
578 AstNode* ParseSelectors(AstNode* primary, bool is_cascade); 605 AstNode* ParseSelectors(AstNode* primary, bool is_cascade);
579 AstNode* ParseCascades(AstNode* expr); 606 AstNode* ParseCascades(AstNode* expr);
580 AstNode* ParsePrimary(); 607 AstNode* ParsePrimary();
581 AstNode* ParseStringLiteral(bool allow_interpolation); 608 AstNode* ParseStringLiteral(bool allow_interpolation);
582 String* ParseImportStringLiteral(); 609 String* ParseImportStringLiteral();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 int16_t last_used_try_index_; 767 int16_t last_used_try_index_;
741 768
742 bool unregister_pending_function_; 769 bool unregister_pending_function_;
743 770
744 DISALLOW_COPY_AND_ASSIGN(Parser); 771 DISALLOW_COPY_AND_ASSIGN(Parser);
745 }; 772 };
746 773
747 } // namespace dart 774 } // namespace dart
748 775
749 #endif // VM_PARSER_H_ 776 #endif // VM_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698