OLD | NEW |
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 Loading... |
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), |
| 57 have_seen_await_expr_(false), |
56 isolate_(isolate) { | 58 isolate_(isolate) { |
57 ASSERT(function.IsZoneHandle()); | 59 ASSERT(function.IsZoneHandle()); |
58 } | 60 } |
59 | 61 |
60 const Function& function() const { return function_; } | 62 const Function& function() const { return function_; } |
61 const Code& code() const { return code_; } | 63 const Code& code() const { return code_; } |
62 | 64 |
63 SequenceNode* node_sequence() const { return node_sequence_; } | 65 SequenceNode* node_sequence() const { return node_sequence_; } |
64 void SetNodeSequence(SequenceNode* node_sequence); | 66 void SetNodeSequence(SequenceNode* node_sequence); |
65 | 67 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 133 } |
132 void AddDeferredPrefix(const LibraryPrefix& prefix); | 134 void AddDeferredPrefix(const LibraryPrefix& prefix); |
133 | 135 |
134 int first_parameter_index() const { return first_parameter_index_; } | 136 int first_parameter_index() const { return first_parameter_index_; } |
135 int first_stack_local_index() const { return first_stack_local_index_; } | 137 int first_stack_local_index() const { return first_stack_local_index_; } |
136 int num_copied_params() const { return num_copied_params_; } | 138 int num_copied_params() const { return num_copied_params_; } |
137 int num_stack_locals() const { return num_stack_locals_; } | 139 int num_stack_locals() const { return num_stack_locals_; } |
138 | 140 |
139 void AllocateVariables(); | 141 void AllocateVariables(); |
140 | 142 |
| 143 void set_await_temps_scope(LocalScope* scope) { |
| 144 ASSERT(await_temps_scope_ == NULL); |
| 145 await_temps_scope_ = scope; |
| 146 } |
| 147 LocalScope* await_temps_scope() const { |
| 148 ASSERT(await_temps_scope_ != NULL); |
| 149 return await_temps_scope_; |
| 150 } |
| 151 |
| 152 void record_await() { |
| 153 have_seen_await_expr_ = true; |
| 154 } |
| 155 void reset_have_seen_await() { have_seen_await_expr_ = false; } |
| 156 bool have_seen_await() const { return have_seen_await_expr_; } |
| 157 |
141 Isolate* isolate() const { return isolate_; } | 158 Isolate* isolate() const { return isolate_; } |
142 | 159 |
143 private: | 160 private: |
144 const Function& function_; | 161 const Function& function_; |
145 Code& code_; | 162 Code& code_; |
146 SequenceNode* node_sequence_; | 163 SequenceNode* node_sequence_; |
147 LocalVariable* instantiator_; | 164 LocalVariable* instantiator_; |
148 Array& default_parameter_values_; | 165 Array& default_parameter_values_; |
149 LocalVariable* saved_current_context_var_; | 166 LocalVariable* saved_current_context_var_; |
150 LocalVariable* saved_entry_context_var_; | 167 LocalVariable* saved_entry_context_var_; |
151 LocalVariable* expression_temp_var_; | 168 LocalVariable* expression_temp_var_; |
152 LocalVariable* finally_return_temp_var_; | 169 LocalVariable* finally_return_temp_var_; |
| 170 LocalScope* await_temps_scope_; |
153 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; | 171 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
154 | 172 |
155 int first_parameter_index_; | 173 int first_parameter_index_; |
156 int first_stack_local_index_; | 174 int first_stack_local_index_; |
157 int num_copied_params_; | 175 int num_copied_params_; |
158 int num_stack_locals_; | 176 int num_stack_locals_; |
| 177 bool have_seen_await_expr_; |
159 | 178 |
160 Isolate* isolate_; | 179 Isolate* isolate_; |
161 | 180 |
162 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); | 181 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); |
163 }; | 182 }; |
164 | 183 |
165 | 184 |
166 class Parser : public ValueObject { | 185 class Parser : public ValueObject { |
167 public: | 186 public: |
168 // Parse the top level of a whole script file and register declared classes | 187 // 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 Loading... |
495 SequenceNode* ParseInvokeFieldDispatcher(const Function& func, | 514 SequenceNode* ParseInvokeFieldDispatcher(const Function& func, |
496 Array* default_values); | 515 Array* default_values); |
497 void BuildDispatcherScope(const Function& func, | 516 void BuildDispatcherScope(const Function& func, |
498 const ArgumentsDescriptor& desc, | 517 const ArgumentsDescriptor& desc, |
499 Array* default_values); | 518 Array* default_values); |
500 | 519 |
501 void ChainNewBlock(LocalScope* outer_scope); | 520 void ChainNewBlock(LocalScope* outer_scope); |
502 void OpenBlock(); | 521 void OpenBlock(); |
503 void OpenLoopBlock(); | 522 void OpenLoopBlock(); |
504 void OpenFunctionBlock(const Function& func); | 523 void OpenFunctionBlock(const Function& func); |
| 524 void OpenAsyncClosure(); |
505 RawFunction* OpenAsyncFunction(intptr_t formal_param_pos); | 525 RawFunction* OpenAsyncFunction(intptr_t formal_param_pos); |
506 SequenceNode* CloseBlock(); | 526 SequenceNode* CloseBlock(); |
507 SequenceNode* CloseAsyncFunction(const Function& closure, | 527 SequenceNode* CloseAsyncFunction(const Function& closure, |
508 SequenceNode* closure_node); | 528 SequenceNode* closure_node); |
509 void CloseAsyncClosure(SequenceNode* body); | 529 void CloseAsyncClosure(SequenceNode* body); |
510 | 530 |
511 | 531 |
512 LocalVariable* LookupPhaseParameter(); | 532 LocalVariable* LookupPhaseParameter(); |
513 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only); | 533 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only); |
514 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope, | 534 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 bool IsFunctionLiteral(); | 599 bool IsFunctionLiteral(); |
580 bool IsForInStatement(); | 600 bool IsForInStatement(); |
581 bool IsTopLevelAccessor(); | 601 bool IsTopLevelAccessor(); |
582 | 602 |
583 AstNode* ParseBinaryExpr(int min_preced); | 603 AstNode* ParseBinaryExpr(int min_preced); |
584 LiteralNode* ParseConstExpr(); | 604 LiteralNode* ParseConstExpr(); |
585 static const bool kRequireConst = true; | 605 static const bool kRequireConst = true; |
586 static const bool kAllowConst = false; | 606 static const bool kAllowConst = false; |
587 static const bool kConsumeCascades = true; | 607 static const bool kConsumeCascades = true; |
588 static const bool kNoCascades = false; | 608 static const bool kNoCascades = false; |
| 609 AstNode* ParseAwaitableExpr(bool require_compiletime_const, |
| 610 bool consume_cascades); |
589 AstNode* ParseExpr(bool require_compiletime_const, bool consume_cascades); | 611 AstNode* ParseExpr(bool require_compiletime_const, bool consume_cascades); |
590 AstNode* ParseExprList(); | 612 AstNode* ParseExprList(); |
591 AstNode* ParseConditionalExpr(); | 613 AstNode* ParseConditionalExpr(); |
592 AstNode* ParseUnaryExpr(); | 614 AstNode* ParseUnaryExpr(); |
593 AstNode* ParsePostfixExpr(); | 615 AstNode* ParsePostfixExpr(); |
594 AstNode* ParseSelectors(AstNode* primary, bool is_cascade); | 616 AstNode* ParseSelectors(AstNode* primary, bool is_cascade); |
595 AstNode* ParseCascades(AstNode* expr); | 617 AstNode* ParseCascades(AstNode* expr); |
596 AstNode* ParsePrimary(); | 618 AstNode* ParsePrimary(); |
597 AstNode* ParseStringLiteral(bool allow_interpolation); | 619 AstNode* ParseStringLiteral(bool allow_interpolation); |
598 String* ParseImportStringLiteral(); | 620 String* ParseImportStringLiteral(); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 int16_t last_used_try_index_; | 778 int16_t last_used_try_index_; |
757 | 779 |
758 bool unregister_pending_function_; | 780 bool unregister_pending_function_; |
759 | 781 |
760 DISALLOW_COPY_AND_ASSIGN(Parser); | 782 DISALLOW_COPY_AND_ASSIGN(Parser); |
761 }; | 783 }; |
762 | 784 |
763 } // namespace dart | 785 } // namespace dart |
764 | 786 |
765 #endif // VM_PARSER_H_ | 787 #endif // VM_PARSER_H_ |
OLD | NEW |