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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // The class ParsedFunction holds the result of parsing a function. | 38 // The class ParsedFunction holds the result of parsing a function. |
39 class ParsedFunction : public ZoneAllocated { | 39 class ParsedFunction : public ZoneAllocated { |
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 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 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), | 51 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), |
52 first_parameter_index_(0), | 52 first_parameter_index_(0), |
53 first_stack_local_index_(0), | 53 first_stack_local_index_(0), |
54 num_copied_params_(0), | 54 num_copied_params_(0), |
55 num_stack_locals_(0), | 55 num_stack_locals_(0), |
56 have_seen_await_expr_(false), | 56 have_seen_await_expr_(false), |
57 saved_try_ctx_(NULL), | 57 saved_try_ctx_(NULL), |
(...skipping 16 matching lines...) Expand all Loading... |
74 | 74 |
75 const Array& default_parameter_values() const { | 75 const Array& default_parameter_values() const { |
76 return default_parameter_values_; | 76 return default_parameter_values_; |
77 } | 77 } |
78 void set_default_parameter_values(const Array& default_parameter_values) { | 78 void set_default_parameter_values(const Array& default_parameter_values) { |
79 ASSERT(default_parameter_values.IsZoneHandle() || | 79 ASSERT(default_parameter_values.IsZoneHandle() || |
80 default_parameter_values.InVMHeap()); | 80 default_parameter_values.InVMHeap()); |
81 default_parameter_values_ = default_parameter_values.raw(); | 81 default_parameter_values_ = default_parameter_values.raw(); |
82 } | 82 } |
83 | 83 |
84 LocalVariable* saved_current_context_var() const { | 84 LocalVariable* current_context_var() const { |
85 return saved_current_context_var_; | 85 return current_context_var_; |
86 } | 86 } |
87 void set_saved_current_context_var(LocalVariable* saved_current_context_var) { | 87 void set_current_context_var(LocalVariable* current_context_var) { |
88 ASSERT(saved_current_context_var != NULL); | 88 ASSERT(current_context_var != NULL); |
89 saved_current_context_var_ = saved_current_context_var; | 89 current_context_var_ = current_context_var; |
90 } | 90 } |
91 bool has_saved_current_context_var() const { | 91 bool has_current_context_var() const { |
92 return saved_current_context_var_ != NULL; | 92 return current_context_var_ != NULL; |
93 } | 93 } |
94 | 94 |
95 LocalVariable* saved_entry_context_var() const { | 95 LocalVariable* saved_entry_context_var() const { |
96 return saved_entry_context_var_; | 96 return saved_entry_context_var_; |
97 } | 97 } |
98 void set_saved_entry_context_var(LocalVariable* saved_entry_context_var) { | 98 void set_saved_entry_context_var(LocalVariable* saved_entry_context_var) { |
99 ASSERT(saved_entry_context_var != NULL); | 99 ASSERT(saved_entry_context_var != NULL); |
100 saved_entry_context_var_ = saved_entry_context_var; | 100 saved_entry_context_var_ = saved_entry_context_var; |
101 } | 101 } |
102 | 102 |
(...skipping 15 matching lines...) Expand all Loading... |
118 } | 118 } |
119 void set_finally_return_temp_var(LocalVariable* value) { | 119 void set_finally_return_temp_var(LocalVariable* value) { |
120 ASSERT(!has_finally_return_temp_var()); | 120 ASSERT(!has_finally_return_temp_var()); |
121 finally_return_temp_var_ = value; | 121 finally_return_temp_var_ = value; |
122 } | 122 } |
123 bool has_finally_return_temp_var() const { | 123 bool has_finally_return_temp_var() const { |
124 return finally_return_temp_var_ != NULL; | 124 return finally_return_temp_var_ != NULL; |
125 } | 125 } |
126 void EnsureFinallyReturnTemp(); | 126 void EnsureFinallyReturnTemp(); |
127 | 127 |
128 static LocalVariable* CreateExpressionTempVar(intptr_t token_pos); | |
129 LocalVariable* EnsureExpressionTemp(); | 128 LocalVariable* EnsureExpressionTemp(); |
| 129 LocalVariable* EnsureSavedCurrentContext(); |
130 | 130 |
131 bool HasDeferredPrefixes() const { return deferred_prefixes_->length() != 0; } | 131 bool HasDeferredPrefixes() const { return deferred_prefixes_->length() != 0; } |
132 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes() const { | 132 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes() const { |
133 return deferred_prefixes_; | 133 return deferred_prefixes_; |
134 } | 134 } |
135 void AddDeferredPrefix(const LibraryPrefix& prefix); | 135 void AddDeferredPrefix(const LibraryPrefix& prefix); |
136 | 136 |
137 int first_parameter_index() const { return first_parameter_index_; } | 137 int first_parameter_index() const { return first_parameter_index_; } |
138 int first_stack_local_index() const { return first_stack_local_index_; } | 138 int first_stack_local_index() const { return first_stack_local_index_; } |
139 int num_copied_params() const { return num_copied_params_; } | 139 int num_copied_params() const { return num_copied_params_; } |
(...skipping 26 matching lines...) Expand all Loading... |
166 } | 166 } |
167 | 167 |
168 Isolate* isolate() const { return isolate_; } | 168 Isolate* isolate() const { return isolate_; } |
169 | 169 |
170 private: | 170 private: |
171 const Function& function_; | 171 const Function& function_; |
172 Code& code_; | 172 Code& code_; |
173 SequenceNode* node_sequence_; | 173 SequenceNode* node_sequence_; |
174 LocalVariable* instantiator_; | 174 LocalVariable* instantiator_; |
175 Array& default_parameter_values_; | 175 Array& default_parameter_values_; |
176 LocalVariable* saved_current_context_var_; | 176 LocalVariable* current_context_var_; |
177 LocalVariable* saved_entry_context_var_; | 177 LocalVariable* saved_entry_context_var_; |
178 LocalVariable* expression_temp_var_; | 178 LocalVariable* expression_temp_var_; |
179 LocalVariable* finally_return_temp_var_; | 179 LocalVariable* finally_return_temp_var_; |
180 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; | 180 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
181 | 181 |
182 int first_parameter_index_; | 182 int first_parameter_index_; |
183 int first_stack_local_index_; | 183 int first_stack_local_index_; |
184 int num_copied_params_; | 184 int num_copied_params_; |
185 int num_stack_locals_; | 185 int num_stack_locals_; |
186 bool have_seen_await_expr_; | 186 bool have_seen_await_expr_; |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 const Function* func); | 727 const Function* func); |
728 | 728 |
729 void SetupSavedTryContext(LocalVariable* saved_try_context); | 729 void SetupSavedTryContext(LocalVariable* saved_try_context); |
730 void RestoreSavedTryContext(LocalScope* saved_try_context_scope, | 730 void RestoreSavedTryContext(LocalScope* saved_try_context_scope, |
731 int16_t try_index, | 731 int16_t try_index, |
732 SequenceNode* target); | 732 SequenceNode* target); |
733 | 733 |
734 void CheckOperatorArity(const MemberDesc& member); | 734 void CheckOperatorArity(const MemberDesc& member); |
735 | 735 |
736 void EnsureExpressionTemp(); | 736 void EnsureExpressionTemp(); |
| 737 void EnsureContextVar(); |
737 void EnsureSavedCurrentContext(); | 738 void EnsureSavedCurrentContext(); |
738 bool IsLegalAssignableSyntax(AstNode* expr, intptr_t end_pos); | 739 bool IsLegalAssignableSyntax(AstNode* expr, intptr_t end_pos); |
739 AstNode* CreateAssignmentNode(AstNode* original, | 740 AstNode* CreateAssignmentNode(AstNode* original, |
740 AstNode* rhs, | 741 AstNode* rhs, |
741 const String* left_ident, | 742 const String* left_ident, |
742 intptr_t left_pos); | 743 intptr_t left_pos); |
743 AstNode* InsertClosureCallNodes(AstNode* condition); | 744 AstNode* InsertClosureCallNodes(AstNode* condition); |
744 | 745 |
745 ConstructorCallNode* CreateConstructorCallNode( | 746 ConstructorCallNode* CreateConstructorCallNode( |
746 intptr_t token_pos, | 747 intptr_t token_pos, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 bool unregister_pending_function_; | 815 bool unregister_pending_function_; |
815 | 816 |
816 LocalScope* async_temp_scope_; | 817 LocalScope* async_temp_scope_; |
817 | 818 |
818 DISALLOW_COPY_AND_ASSIGN(Parser); | 819 DISALLOW_COPY_AND_ASSIGN(Parser); |
819 }; | 820 }; |
820 | 821 |
821 } // namespace dart | 822 } // namespace dart |
822 | 823 |
823 #endif // VM_PARSER_H_ | 824 #endif // VM_PARSER_H_ |
OLD | NEW |