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" |
11 #include "vm/class_finalizer.h" | 11 #include "vm/class_finalizer.h" |
12 #include "vm/compiler.h" | 12 #include "vm/compiler.h" |
13 #include "vm/compiler_stats.h" | 13 #include "vm/compiler_stats.h" |
14 #include "vm/dart_api_impl.h" | 14 #include "vm/dart_api_impl.h" |
15 #include "vm/dart_entry.h" | 15 #include "vm/dart_entry.h" |
16 #include "vm/flags.h" | 16 #include "vm/flags.h" |
17 #include "vm/growable_array.h" | 17 #include "vm/growable_array.h" |
18 #include "vm/handles.h" | 18 #include "vm/handles.h" |
19 #include "vm/heap.h" | 19 #include "vm/heap.h" |
20 #include "vm/isolate.h" | 20 #include "vm/isolate.h" |
21 #include "vm/longjump.h" | 21 #include "vm/longjump.h" |
22 #include "vm/native_arguments.h" | 22 #include "vm/native_arguments.h" |
23 #include "vm/native_entry.h" | 23 #include "vm/native_entry.h" |
24 #include "vm/object.h" | 24 #include "vm/object.h" |
25 #include "vm/object_store.h" | 25 #include "vm/object_store.h" |
26 #include "vm/os.h" | 26 #include "vm/os.h" |
| 27 #include "vm/regexp_assembler.h" |
27 #include "vm/report.h" | 28 #include "vm/report.h" |
28 #include "vm/resolver.h" | 29 #include "vm/resolver.h" |
29 #include "vm/scanner.h" | 30 #include "vm/scanner.h" |
30 #include "vm/scopes.h" | 31 #include "vm/scopes.h" |
31 #include "vm/stack_frame.h" | 32 #include "vm/stack_frame.h" |
32 #include "vm/symbols.h" | 33 #include "vm/symbols.h" |
33 #include "vm/tags.h" | 34 #include "vm/tags.h" |
34 #include "vm/timer.h" | 35 #include "vm/timer.h" |
35 #include "vm/zone.h" | 36 #include "vm/zone.h" |
36 | 37 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 157 } |
157 | 158 |
158 | 159 |
159 void ParsedFunction::SetNodeSequence(SequenceNode* node_sequence) { | 160 void ParsedFunction::SetNodeSequence(SequenceNode* node_sequence) { |
160 ASSERT(node_sequence_ == NULL); | 161 ASSERT(node_sequence_ == NULL); |
161 ASSERT(node_sequence != NULL); | 162 ASSERT(node_sequence != NULL); |
162 node_sequence_ = node_sequence; | 163 node_sequence_ = node_sequence; |
163 } | 164 } |
164 | 165 |
165 | 166 |
| 167 void ParsedFunction::SetRegExpCompileData( |
| 168 RegExpCompileData* regexp_compile_data) { |
| 169 ASSERT(regexp_compile_data_ == NULL); |
| 170 ASSERT(regexp_compile_data != NULL); |
| 171 regexp_compile_data_ = regexp_compile_data; |
| 172 } |
| 173 |
| 174 |
166 void ParsedFunction::AddDeferredPrefix(const LibraryPrefix& prefix) { | 175 void ParsedFunction::AddDeferredPrefix(const LibraryPrefix& prefix) { |
167 ASSERT(prefix.is_deferred_load()); | 176 ASSERT(prefix.is_deferred_load()); |
168 ASSERT(!prefix.is_loaded()); | 177 ASSERT(!prefix.is_loaded()); |
169 for (intptr_t i = 0; i < deferred_prefixes_->length(); i++) { | 178 for (intptr_t i = 0; i < deferred_prefixes_->length(); i++) { |
170 if ((*deferred_prefixes_)[i]->raw() == prefix.raw()) { | 179 if ((*deferred_prefixes_)[i]->raw() == prefix.raw()) { |
171 return; | 180 return; |
172 } | 181 } |
173 } | 182 } |
174 deferred_prefixes_->Add(&LibraryPrefix::ZoneHandle(I, prefix.raw())); | 183 deferred_prefixes_->Add(&LibraryPrefix::ZoneHandle(I, prefix.raw())); |
175 } | 184 } |
176 | 185 |
177 | 186 |
178 void ParsedFunction::AllocateVariables() { | 187 void ParsedFunction::AllocateVariables() { |
| 188 ASSERT(!function().IsIrregexpFunction()); |
179 LocalScope* scope = node_sequence()->scope(); | 189 LocalScope* scope = node_sequence()->scope(); |
180 const intptr_t num_fixed_params = function().num_fixed_parameters(); | 190 const intptr_t num_fixed_params = function().num_fixed_parameters(); |
181 const intptr_t num_opt_params = function().NumOptionalParameters(); | 191 const intptr_t num_opt_params = function().NumOptionalParameters(); |
182 const intptr_t num_params = num_fixed_params + num_opt_params; | 192 const intptr_t num_params = num_fixed_params + num_opt_params; |
183 // Compute start indices to parameters and locals, and the number of | 193 // Compute start indices to parameters and locals, and the number of |
184 // parameters to copy. | 194 // parameters to copy. |
185 if (num_opt_params == 0) { | 195 if (num_opt_params == 0) { |
186 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and | 196 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and |
187 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. | 197 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. |
188 first_parameter_index_ = kParamEndSlotFromFp + num_params; | 198 first_parameter_index_ = kParamEndSlotFromFp + num_params; |
(...skipping 28 matching lines...) Expand all Loading... |
217 struct CatchParamDesc { | 227 struct CatchParamDesc { |
218 CatchParamDesc() | 228 CatchParamDesc() |
219 : token_pos(0), type(NULL), name(NULL), var(NULL) { } | 229 : token_pos(0), type(NULL), name(NULL), var(NULL) { } |
220 intptr_t token_pos; | 230 intptr_t token_pos; |
221 const AbstractType* type; | 231 const AbstractType* type; |
222 const String* name; | 232 const String* name; |
223 LocalVariable* var; | 233 LocalVariable* var; |
224 }; | 234 }; |
225 | 235 |
226 | 236 |
| 237 void ParsedFunction::AllocateIrregexpVariables(intptr_t num_stack_locals) { |
| 238 ASSERT(function().IsIrregexpFunction()); |
| 239 ASSERT(function().NumOptionalParameters() == 0); |
| 240 const intptr_t num_params = function().num_fixed_parameters(); |
| 241 ASSERT(num_params == RegExpMacroAssembler::kParamCount); |
| 242 // Compute start indices to parameters and locals, and the number of |
| 243 // parameters to copy. |
| 244 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and |
| 245 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. |
| 246 first_parameter_index_ = kParamEndSlotFromFp + num_params; |
| 247 first_stack_local_index_ = kFirstLocalSlotFromFp; |
| 248 num_copied_params_ = 0; |
| 249 |
| 250 // Frame indices are relative to the frame pointer and are decreasing. |
| 251 num_stack_locals_ = num_stack_locals; |
| 252 } |
| 253 |
| 254 |
227 struct Parser::Block : public ZoneAllocated { | 255 struct Parser::Block : public ZoneAllocated { |
228 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) | 256 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) |
229 : parent(outer_block), scope(local_scope), statements(seq) { | 257 : parent(outer_block), scope(local_scope), statements(seq) { |
230 ASSERT(scope != NULL); | 258 ASSERT(scope != NULL); |
231 ASSERT(statements != NULL); | 259 ASSERT(statements != NULL); |
232 } | 260 } |
233 Block* parent; // Enclosing block, or NULL if outermost. | 261 Block* parent; // Enclosing block, or NULL if outermost. |
234 LocalScope* scope; | 262 LocalScope* scope; |
235 SequenceNode* statements; | 263 SequenceNode* statements; |
236 }; | 264 }; |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 node_sequence = parser.ParseMethodExtractor(func); | 873 node_sequence = parser.ParseMethodExtractor(func); |
846 break; | 874 break; |
847 case RawFunction::kNoSuchMethodDispatcher: | 875 case RawFunction::kNoSuchMethodDispatcher: |
848 node_sequence = | 876 node_sequence = |
849 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values); | 877 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values); |
850 break; | 878 break; |
851 case RawFunction::kInvokeFieldDispatcher: | 879 case RawFunction::kInvokeFieldDispatcher: |
852 node_sequence = | 880 node_sequence = |
853 parser.ParseInvokeFieldDispatcher(func, &default_parameter_values); | 881 parser.ParseInvokeFieldDispatcher(func, &default_parameter_values); |
854 break; | 882 break; |
| 883 case RawFunction::kIrregexpFunction: |
| 884 UNREACHABLE(); // Irregexp functions have their own parser. |
855 default: | 885 default: |
856 UNREACHABLE(); | 886 UNREACHABLE(); |
857 } | 887 } |
858 | 888 |
859 if (!HasReturnNode(node_sequence)) { | 889 if (!HasReturnNode(node_sequence)) { |
860 // Add implicit return node. | 890 // Add implicit return node. |
861 node_sequence->Add(new ReturnNode(func.end_token_pos())); | 891 node_sequence->Add(new ReturnNode(func.end_token_pos())); |
862 } | 892 } |
863 if (parsed_function->has_expression_temp_var()) { | 893 if (parsed_function->has_expression_temp_var()) { |
864 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); | 894 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); |
(...skipping 11272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12137 void Parser::SkipQualIdent() { | 12167 void Parser::SkipQualIdent() { |
12138 ASSERT(IsIdentifier()); | 12168 ASSERT(IsIdentifier()); |
12139 ConsumeToken(); | 12169 ConsumeToken(); |
12140 if (CurrentToken() == Token::kPERIOD) { | 12170 if (CurrentToken() == Token::kPERIOD) { |
12141 ConsumeToken(); // Consume the kPERIOD token. | 12171 ConsumeToken(); // Consume the kPERIOD token. |
12142 ExpectIdentifier("identifier expected after '.'"); | 12172 ExpectIdentifier("identifier expected after '.'"); |
12143 } | 12173 } |
12144 } | 12174 } |
12145 | 12175 |
12146 } // namespace dart | 12176 } // namespace dart |
OLD | NEW |