| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 142 } |
| 142 | 143 |
| 143 | 144 |
| 144 void ParsedFunction::SetNodeSequence(SequenceNode* node_sequence) { | 145 void ParsedFunction::SetNodeSequence(SequenceNode* node_sequence) { |
| 145 ASSERT(node_sequence_ == NULL); | 146 ASSERT(node_sequence_ == NULL); |
| 146 ASSERT(node_sequence != NULL); | 147 ASSERT(node_sequence != NULL); |
| 147 node_sequence_ = node_sequence; | 148 node_sequence_ = node_sequence; |
| 148 } | 149 } |
| 149 | 150 |
| 150 | 151 |
| 152 void ParsedFunction::SetRegExpCompileData( |
| 153 RegExpCompileData* regexp_compile_data) { |
| 154 ASSERT(regexp_compile_data_ == NULL); |
| 155 ASSERT(regexp_compile_data != NULL); |
| 156 regexp_compile_data_ = regexp_compile_data; |
| 157 } |
| 158 |
| 159 |
| 151 void ParsedFunction::AddDeferredPrefix(const LibraryPrefix& prefix) { | 160 void ParsedFunction::AddDeferredPrefix(const LibraryPrefix& prefix) { |
| 152 ASSERT(prefix.is_deferred_load()); | 161 ASSERT(prefix.is_deferred_load()); |
| 153 ASSERT(!prefix.is_loaded()); | 162 ASSERT(!prefix.is_loaded()); |
| 154 for (intptr_t i = 0; i < deferred_prefixes_->length(); i++) { | 163 for (intptr_t i = 0; i < deferred_prefixes_->length(); i++) { |
| 155 if ((*deferred_prefixes_)[i]->raw() == prefix.raw()) { | 164 if ((*deferred_prefixes_)[i]->raw() == prefix.raw()) { |
| 156 return; | 165 return; |
| 157 } | 166 } |
| 158 } | 167 } |
| 159 deferred_prefixes_->Add(&LibraryPrefix::ZoneHandle(I, prefix.raw())); | 168 deferred_prefixes_->Add(&LibraryPrefix::ZoneHandle(I, prefix.raw())); |
| 160 } | 169 } |
| 161 | 170 |
| 162 | 171 |
| 163 void ParsedFunction::AllocateVariables() { | 172 void ParsedFunction::AllocateVariables() { |
| 173 ASSERT(!function().IsIrregexpFunction()); |
| 164 LocalScope* scope = node_sequence()->scope(); | 174 LocalScope* scope = node_sequence()->scope(); |
| 165 const intptr_t num_fixed_params = function().num_fixed_parameters(); | 175 const intptr_t num_fixed_params = function().num_fixed_parameters(); |
| 166 const intptr_t num_opt_params = function().NumOptionalParameters(); | 176 const intptr_t num_opt_params = function().NumOptionalParameters(); |
| 167 const intptr_t num_params = num_fixed_params + num_opt_params; | 177 const intptr_t num_params = num_fixed_params + num_opt_params; |
| 168 // Compute start indices to parameters and locals, and the number of | 178 // Compute start indices to parameters and locals, and the number of |
| 169 // parameters to copy. | 179 // parameters to copy. |
| 170 if (num_opt_params == 0) { | 180 if (num_opt_params == 0) { |
| 171 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and | 181 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and |
| 172 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. | 182 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. |
| 173 first_parameter_index_ = kParamEndSlotFromFp + num_params; | 183 first_parameter_index_ = kParamEndSlotFromFp + num_params; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 202 struct CatchParamDesc { | 212 struct CatchParamDesc { |
| 203 CatchParamDesc() | 213 CatchParamDesc() |
| 204 : token_pos(0), type(NULL), name(NULL), var(NULL) { } | 214 : token_pos(0), type(NULL), name(NULL), var(NULL) { } |
| 205 intptr_t token_pos; | 215 intptr_t token_pos; |
| 206 const AbstractType* type; | 216 const AbstractType* type; |
| 207 const String* name; | 217 const String* name; |
| 208 LocalVariable* var; | 218 LocalVariable* var; |
| 209 }; | 219 }; |
| 210 | 220 |
| 211 | 221 |
| 222 void ParsedFunction::AllocateIrregexpVariables(intptr_t num_stack_locals) { |
| 223 ASSERT(function().IsIrregexpFunction()); |
| 224 ASSERT(function().NumOptionalParameters() == 0); |
| 225 const intptr_t num_params = function().num_fixed_parameters(); |
| 226 ASSERT(num_params == RegExpMacroAssembler::kParamCount); |
| 227 // Compute start indices to parameters and locals, and the number of |
| 228 // parameters to copy. |
| 229 // Parameter i will be at fp[kParamEndSlotFromFp + num_params - i] and |
| 230 // local variable j will be at fp[kFirstLocalSlotFromFp - j]. |
| 231 first_parameter_index_ = kParamEndSlotFromFp + num_params; |
| 232 first_stack_local_index_ = kFirstLocalSlotFromFp; |
| 233 num_copied_params_ = 0; |
| 234 |
| 235 // Frame indices are relative to the frame pointer and are decreasing. |
| 236 num_stack_locals_ = num_stack_locals; |
| 237 } |
| 238 |
| 239 |
| 212 struct Parser::Block : public ZoneAllocated { | 240 struct Parser::Block : public ZoneAllocated { |
| 213 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) | 241 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) |
| 214 : parent(outer_block), scope(local_scope), statements(seq) { | 242 : parent(outer_block), scope(local_scope), statements(seq) { |
| 215 ASSERT(scope != NULL); | 243 ASSERT(scope != NULL); |
| 216 ASSERT(statements != NULL); | 244 ASSERT(statements != NULL); |
| 217 } | 245 } |
| 218 Block* parent; // Enclosing block, or NULL if outermost. | 246 Block* parent; // Enclosing block, or NULL if outermost. |
| 219 LocalScope* scope; | 247 LocalScope* scope; |
| 220 SequenceNode* statements; | 248 SequenceNode* statements; |
| 221 }; | 249 }; |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 node_sequence = parser.ParseMethodExtractor(func); | 850 node_sequence = parser.ParseMethodExtractor(func); |
| 823 break; | 851 break; |
| 824 case RawFunction::kNoSuchMethodDispatcher: | 852 case RawFunction::kNoSuchMethodDispatcher: |
| 825 node_sequence = | 853 node_sequence = |
| 826 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values); | 854 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values); |
| 827 break; | 855 break; |
| 828 case RawFunction::kInvokeFieldDispatcher: | 856 case RawFunction::kInvokeFieldDispatcher: |
| 829 node_sequence = | 857 node_sequence = |
| 830 parser.ParseInvokeFieldDispatcher(func, &default_parameter_values); | 858 parser.ParseInvokeFieldDispatcher(func, &default_parameter_values); |
| 831 break; | 859 break; |
| 860 case RawFunction::kIrregexpFunction: |
| 861 UNREACHABLE(); // Irregexp functions have their own parser. |
| 832 default: | 862 default: |
| 833 UNREACHABLE(); | 863 UNREACHABLE(); |
| 834 } | 864 } |
| 835 | 865 |
| 836 if (!HasReturnNode(node_sequence)) { | 866 if (!HasReturnNode(node_sequence)) { |
| 837 // Add implicit return node. | 867 // Add implicit return node. |
| 838 node_sequence->Add(new ReturnNode(func.end_token_pos())); | 868 node_sequence->Add(new ReturnNode(func.end_token_pos())); |
| 839 } | 869 } |
| 840 if (parsed_function->has_expression_temp_var()) { | 870 if (parsed_function->has_expression_temp_var()) { |
| 841 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); | 871 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); |
| (...skipping 11062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11904 void Parser::SkipQualIdent() { | 11934 void Parser::SkipQualIdent() { |
| 11905 ASSERT(IsIdentifier()); | 11935 ASSERT(IsIdentifier()); |
| 11906 ConsumeToken(); | 11936 ConsumeToken(); |
| 11907 if (CurrentToken() == Token::kPERIOD) { | 11937 if (CurrentToken() == Token::kPERIOD) { |
| 11908 ConsumeToken(); // Consume the kPERIOD token. | 11938 ConsumeToken(); // Consume the kPERIOD token. |
| 11909 ExpectIdentifier("identifier expected after '.'"); | 11939 ExpectIdentifier("identifier expected after '.'"); |
| 11910 } | 11940 } |
| 11911 } | 11941 } |
| 11912 | 11942 |
| 11913 } // namespace dart | 11943 } // namespace dart |
| OLD | NEW |