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 #include "vm/parser.h" | 5 #include "vm/parser.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 void ParsedFunction::SetNodeSequence(SequenceNode* node_sequence) { | 144 void ParsedFunction::SetNodeSequence(SequenceNode* node_sequence) { |
145 ASSERT(node_sequence_ == NULL); | 145 ASSERT(node_sequence_ == NULL); |
146 ASSERT(node_sequence != NULL); | 146 ASSERT(node_sequence != NULL); |
147 node_sequence_ = node_sequence; | 147 node_sequence_ = node_sequence; |
148 } | 148 } |
149 | 149 |
150 | 150 |
| 151 void ParsedFunction::SetRegExpCompileData( |
| 152 RegExpCompileData* regexp_compile_data) { |
| 153 ASSERT(regexp_compile_data_ == NULL); |
| 154 ASSERT(regexp_compile_data != NULL); |
| 155 regexp_compile_data_ = regexp_compile_data; |
| 156 } |
| 157 |
| 158 |
151 void ParsedFunction::AddDeferredPrefix(const LibraryPrefix& prefix) { | 159 void ParsedFunction::AddDeferredPrefix(const LibraryPrefix& prefix) { |
152 ASSERT(prefix.is_deferred_load()); | 160 ASSERT(prefix.is_deferred_load()); |
153 ASSERT(!prefix.is_loaded()); | 161 ASSERT(!prefix.is_loaded()); |
154 for (intptr_t i = 0; i < deferred_prefixes_->length(); i++) { | 162 for (intptr_t i = 0; i < deferred_prefixes_->length(); i++) { |
155 if ((*deferred_prefixes_)[i]->raw() == prefix.raw()) { | 163 if ((*deferred_prefixes_)[i]->raw() == prefix.raw()) { |
156 return; | 164 return; |
157 } | 165 } |
158 } | 166 } |
159 deferred_prefixes_->Add(&LibraryPrefix::ZoneHandle(I, prefix.raw())); | 167 deferred_prefixes_->Add(&LibraryPrefix::ZoneHandle(I, prefix.raw())); |
160 } | 168 } |
161 | 169 |
162 | 170 |
163 void ParsedFunction::AllocateVariables() { | 171 void ParsedFunction::AllocateVariables() { |
| 172 ASSERT(!function().IsIrregexpFunction()); |
164 LocalScope* scope = node_sequence()->scope(); | 173 LocalScope* scope = node_sequence()->scope(); |
165 const intptr_t num_fixed_params = function().num_fixed_parameters(); | 174 const intptr_t num_fixed_params = function().num_fixed_parameters(); |
166 const intptr_t num_opt_params = function().NumOptionalParameters(); | 175 const intptr_t num_opt_params = function().NumOptionalParameters(); |
167 const intptr_t num_params = num_fixed_params + num_opt_params; | 176 const intptr_t num_params = num_fixed_params + num_opt_params; |
168 // Compute start indices to parameters and locals, and the number of | 177 // Compute start indices to parameters and locals, and the number of |
169 // parameters to copy. | 178 // parameters to copy. |
170 if (num_opt_params == 0) { | 179 if (num_opt_params == 0) { |
171 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and | 180 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and |
172 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. | 181 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. |
173 first_parameter_index_ = kParamEndSlotFromFp + num_params; | 182 first_parameter_index_ = kParamEndSlotFromFp + num_params; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 struct CatchParamDesc { | 235 struct CatchParamDesc { |
227 CatchParamDesc() | 236 CatchParamDesc() |
228 : token_pos(0), type(NULL), name(NULL), var(NULL) { } | 237 : token_pos(0), type(NULL), name(NULL), var(NULL) { } |
229 intptr_t token_pos; | 238 intptr_t token_pos; |
230 const AbstractType* type; | 239 const AbstractType* type; |
231 const String* name; | 240 const String* name; |
232 LocalVariable* var; | 241 LocalVariable* var; |
233 }; | 242 }; |
234 | 243 |
235 | 244 |
| 245 void ParsedFunction::AllocateIrregexpVariables(intptr_t num_stack_locals) { |
| 246 ASSERT(function().IsIrregexpFunction()); |
| 247 ASSERT(function().NumOptionalParameters() == 0); |
| 248 const intptr_t num_params = function().num_fixed_parameters();; |
| 249 // Compute start indices to parameters and locals, and the number of |
| 250 // parameters to copy. |
| 251 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and |
| 252 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. |
| 253 first_parameter_index_ = kParamEndSlotFromFp + num_params; |
| 254 first_stack_local_index_ = kFirstLocalSlotFromFp; |
| 255 num_copied_params_ = 0; |
| 256 |
| 257 // Frame indices are relative to the frame pointer and are decreasing. |
| 258 num_stack_locals_ = num_stack_locals; |
| 259 } |
| 260 |
| 261 |
236 struct Parser::Block : public ZoneAllocated { | 262 struct Parser::Block : public ZoneAllocated { |
237 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) | 263 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) |
238 : parent(outer_block), scope(local_scope), statements(seq) { | 264 : parent(outer_block), scope(local_scope), statements(seq) { |
239 ASSERT(scope != NULL); | 265 ASSERT(scope != NULL); |
240 ASSERT(statements != NULL); | 266 ASSERT(statements != NULL); |
241 } | 267 } |
242 Block* parent; // Enclosing block, or NULL if outermost. | 268 Block* parent; // Enclosing block, or NULL if outermost. |
243 LocalScope* scope; | 269 LocalScope* scope; |
244 SequenceNode* statements; | 270 SequenceNode* statements; |
245 }; | 271 }; |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 node_sequence = parser.ParseMethodExtractor(func); | 872 node_sequence = parser.ParseMethodExtractor(func); |
847 break; | 873 break; |
848 case RawFunction::kNoSuchMethodDispatcher: | 874 case RawFunction::kNoSuchMethodDispatcher: |
849 node_sequence = | 875 node_sequence = |
850 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values); | 876 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values); |
851 break; | 877 break; |
852 case RawFunction::kInvokeFieldDispatcher: | 878 case RawFunction::kInvokeFieldDispatcher: |
853 node_sequence = | 879 node_sequence = |
854 parser.ParseInvokeFieldDispatcher(func, &default_parameter_values); | 880 parser.ParseInvokeFieldDispatcher(func, &default_parameter_values); |
855 break; | 881 break; |
| 882 case RawFunction::kIrregexpFunction: |
| 883 UNREACHABLE(); // Irregexp functions have their own parser. |
856 default: | 884 default: |
857 UNREACHABLE(); | 885 UNREACHABLE(); |
858 } | 886 } |
859 | 887 |
860 if (!HasReturnNode(node_sequence)) { | 888 if (!HasReturnNode(node_sequence)) { |
861 // Add implicit return node. | 889 // Add implicit return node. |
862 node_sequence->Add(new ReturnNode(func.end_token_pos())); | 890 node_sequence->Add(new ReturnNode(func.end_token_pos())); |
863 } | 891 } |
864 if (parsed_function->has_expression_temp_var()) { | 892 if (parsed_function->has_expression_temp_var()) { |
865 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); | 893 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); |
(...skipping 10917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11783 void Parser::SkipQualIdent() { | 11811 void Parser::SkipQualIdent() { |
11784 ASSERT(IsIdentifier()); | 11812 ASSERT(IsIdentifier()); |
11785 ConsumeToken(); | 11813 ConsumeToken(); |
11786 if (CurrentToken() == Token::kPERIOD) { | 11814 if (CurrentToken() == Token::kPERIOD) { |
11787 ConsumeToken(); // Consume the kPERIOD token. | 11815 ConsumeToken(); // Consume the kPERIOD token. |
11788 ExpectIdentifier("identifier expected after '.'"); | 11816 ExpectIdentifier("identifier expected after '.'"); |
11789 } | 11817 } |
11790 } | 11818 } |
11791 | 11819 |
11792 } // namespace dart | 11820 } // namespace dart |
OLD | NEW |