| 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 29 matching lines...) Expand all Loading... |
| 40 // The class ParsedFunction holds the result of parsing a function. | 40 // The class ParsedFunction holds the result of parsing a function. |
| 41 class ParsedFunction : public ZoneAllocated { | 41 class ParsedFunction : public ZoneAllocated { |
| 42 public: | 42 public: |
| 43 ParsedFunction(Thread* thread, const Function& function) | 43 ParsedFunction(Thread* thread, const Function& function) |
| 44 : thread_(thread), | 44 : thread_(thread), |
| 45 function_(function), | 45 function_(function), |
| 46 code_(Code::Handle(zone(), function.unoptimized_code())), | 46 code_(Code::Handle(zone(), function.unoptimized_code())), |
| 47 node_sequence_(NULL), | 47 node_sequence_(NULL), |
| 48 regexp_compile_data_(NULL), | 48 regexp_compile_data_(NULL), |
| 49 instantiator_(NULL), | 49 instantiator_(NULL), |
| 50 default_parameter_values_(Array::ZoneHandle(zone(), Array::null())), | |
| 51 current_context_var_(NULL), | 50 current_context_var_(NULL), |
| 52 expression_temp_var_(NULL), | 51 expression_temp_var_(NULL), |
| 53 finally_return_temp_var_(NULL), | 52 finally_return_temp_var_(NULL), |
| 54 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), | 53 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), |
| 55 guarded_fields_(new ZoneGrowableArray<const Field*>()), | 54 guarded_fields_(new ZoneGrowableArray<const Field*>()), |
| 55 default_parameter_values_(NULL), |
| 56 first_parameter_index_(0), | 56 first_parameter_index_(0), |
| 57 first_stack_local_index_(0), | 57 first_stack_local_index_(0), |
| 58 num_copied_params_(0), | 58 num_copied_params_(0), |
| 59 num_stack_locals_(0), | 59 num_stack_locals_(0), |
| 60 have_seen_await_expr_(false) { | 60 have_seen_await_expr_(false) { |
| 61 ASSERT(function.IsZoneHandle()); | 61 ASSERT(function.IsZoneHandle()); |
| 62 // Every function has a local variable for the current context. | 62 // Every function has a local variable for the current context. |
| 63 LocalVariable* temp = new(zone()) LocalVariable( | 63 LocalVariable* temp = new(zone()) LocalVariable( |
| 64 function.token_pos(), | 64 function.token_pos(), |
| 65 Symbols::CurrentContextVar(), | 65 Symbols::CurrentContextVar(), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 return regexp_compile_data_; | 78 return regexp_compile_data_; |
| 79 } | 79 } |
| 80 void SetRegExpCompileData(RegExpCompileData* regexp_compile_data); | 80 void SetRegExpCompileData(RegExpCompileData* regexp_compile_data); |
| 81 | 81 |
| 82 LocalVariable* instantiator() const { return instantiator_; } | 82 LocalVariable* instantiator() const { return instantiator_; } |
| 83 void set_instantiator(LocalVariable* instantiator) { | 83 void set_instantiator(LocalVariable* instantiator) { |
| 84 // May be NULL. | 84 // May be NULL. |
| 85 instantiator_ = instantiator; | 85 instantiator_ = instantiator; |
| 86 } | 86 } |
| 87 | 87 |
| 88 const Array& default_parameter_values() const { | 88 void set_default_parameter_values(ZoneGrowableArray<const Instance*>* list) { |
| 89 return default_parameter_values_; | 89 default_parameter_values_ = list; |
| 90 #if defined(DEBUG) |
| 91 for (intptr_t i = 0; i < list->length(); i++) { |
| 92 ASSERT(list->At(i)->IsZoneHandle() || list->At(i)->InVMHeap()); |
| 93 } |
| 94 #endif |
| 90 } | 95 } |
| 91 void set_default_parameter_values(const Array& default_parameter_values) { | 96 |
| 92 ASSERT(default_parameter_values.IsZoneHandle() || | 97 |
| 93 default_parameter_values.InVMHeap()); | 98 const Instance& DefaultParameterValueAt(intptr_t i) const { |
| 94 default_parameter_values_ = default_parameter_values.raw(); | 99 ASSERT(default_parameter_values_ != NULL); |
| 100 return *default_parameter_values_->At(i); |
| 95 } | 101 } |
| 96 | 102 |
| 97 LocalVariable* current_context_var() const { | 103 LocalVariable* current_context_var() const { |
| 98 return current_context_var_; | 104 return current_context_var_; |
| 99 } | 105 } |
| 100 | 106 |
| 101 LocalVariable* expression_temp_var() const { | 107 LocalVariable* expression_temp_var() const { |
| 102 ASSERT(has_expression_temp_var()); | 108 ASSERT(has_expression_temp_var()); |
| 103 return expression_temp_var_; | 109 return expression_temp_var_; |
| 104 } | 110 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 Isolate* isolate() const { return thread_->isolate(); } | 160 Isolate* isolate() const { return thread_->isolate(); } |
| 155 Zone* zone() const { return thread_->zone(); } | 161 Zone* zone() const { return thread_->zone(); } |
| 156 | 162 |
| 157 private: | 163 private: |
| 158 Thread* thread_; | 164 Thread* thread_; |
| 159 const Function& function_; | 165 const Function& function_; |
| 160 Code& code_; | 166 Code& code_; |
| 161 SequenceNode* node_sequence_; | 167 SequenceNode* node_sequence_; |
| 162 RegExpCompileData* regexp_compile_data_; | 168 RegExpCompileData* regexp_compile_data_; |
| 163 LocalVariable* instantiator_; | 169 LocalVariable* instantiator_; |
| 164 Array& default_parameter_values_; | |
| 165 LocalVariable* current_context_var_; | 170 LocalVariable* current_context_var_; |
| 166 LocalVariable* expression_temp_var_; | 171 LocalVariable* expression_temp_var_; |
| 167 LocalVariable* finally_return_temp_var_; | 172 LocalVariable* finally_return_temp_var_; |
| 168 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; | 173 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
| 169 ZoneGrowableArray<const Field*>* guarded_fields_; | 174 ZoneGrowableArray<const Field*>* guarded_fields_; |
| 175 ZoneGrowableArray<const Instance*>* default_parameter_values_; |
| 170 | 176 |
| 171 int first_parameter_index_; | 177 int first_parameter_index_; |
| 172 int first_stack_local_index_; | 178 int first_stack_local_index_; |
| 173 int num_copied_params_; | 179 int num_copied_params_; |
| 174 int num_stack_locals_; | 180 int num_stack_locals_; |
| 175 bool have_seen_await_expr_; | 181 bool have_seen_await_expr_; |
| 176 | 182 |
| 177 friend class Parser; | 183 friend class Parser; |
| 178 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); | 184 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); |
| 179 }; | 185 }; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 ArgumentListNode* arguments, | 511 ArgumentListNode* arguments, |
| 506 bool resolve_getter, | 512 bool resolve_getter, |
| 507 bool* is_no_such_method); | 513 bool* is_no_such_method); |
| 508 AstNode* ParseSuperCall(const String& function_name); | 514 AstNode* ParseSuperCall(const String& function_name); |
| 509 AstNode* ParseSuperFieldAccess(const String& field_name, intptr_t field_pos); | 515 AstNode* ParseSuperFieldAccess(const String& field_name, intptr_t field_pos); |
| 510 AstNode* ParseSuperOperator(); | 516 AstNode* ParseSuperOperator(); |
| 511 AstNode* BuildUnarySuperOperator(Token::Kind op, PrimaryNode* super); | 517 AstNode* BuildUnarySuperOperator(Token::Kind op, PrimaryNode* super); |
| 512 | 518 |
| 513 static bool ParseFormalParameters(const Function& func, ParamList* params); | 519 static bool ParseFormalParameters(const Function& func, ParamList* params); |
| 514 | 520 |
| 515 static void SetupDefaultsForOptionalParams(const ParamList& params, | 521 static void SetupDefaultsForOptionalParams( |
| 516 Array* default_values); | 522 const ParamList& params, |
| 523 ZoneGrowableArray<const Instance*>* default_values); |
| 517 ClosureNode* CreateImplicitClosureNode(const Function& func, | 524 ClosureNode* CreateImplicitClosureNode(const Function& func, |
| 518 intptr_t token_pos, | 525 intptr_t token_pos, |
| 519 AstNode* receiver); | 526 AstNode* receiver); |
| 520 static void AddFormalParamsToFunction(const ParamList* params, | 527 static void AddFormalParamsToFunction(const ParamList* params, |
| 521 const Function& func); | 528 const Function& func); |
| 522 void AddFormalParamsToScope(const ParamList* params, LocalScope* scope); | 529 void AddFormalParamsToScope(const ParamList* params, LocalScope* scope); |
| 523 | 530 |
| 524 SequenceNode* ParseConstructor(const Function& func, | 531 SequenceNode* ParseConstructor( |
| 525 Array* default_parameter_values); | 532 const Function& func, ZoneGrowableArray<const Instance*>* default_values); |
| 526 SequenceNode* ParseFunc(const Function& func, | 533 SequenceNode* ParseFunc( |
| 527 Array* default_parameter_values); | 534 const Function& func, ZoneGrowableArray<const Instance*>* default_values); |
| 528 | 535 |
| 529 void ParseNativeFunctionBlock(const ParamList* params, const Function& func); | 536 void ParseNativeFunctionBlock(const ParamList* params, const Function& func); |
| 530 | 537 |
| 531 SequenceNode* ParseInstanceGetter(const Function& func); | 538 SequenceNode* ParseInstanceGetter(const Function& func); |
| 532 SequenceNode* ParseInstanceSetter(const Function& func); | 539 SequenceNode* ParseInstanceSetter(const Function& func); |
| 533 SequenceNode* ParseStaticFinalGetter(const Function& func); | 540 SequenceNode* ParseStaticFinalGetter(const Function& func); |
| 534 SequenceNode* ParseStaticInitializer(); | 541 SequenceNode* ParseStaticInitializer(); |
| 535 SequenceNode* ParseMethodExtractor(const Function& func); | 542 SequenceNode* ParseMethodExtractor(const Function& func); |
| 536 SequenceNode* ParseNoSuchMethodDispatcher(const Function& func, | 543 SequenceNode* ParseNoSuchMethodDispatcher( |
| 537 Array* default_values); | 544 const Function& func, ZoneGrowableArray<const Instance*>* default_values); |
| 538 SequenceNode* ParseInvokeFieldDispatcher(const Function& func, | 545 SequenceNode* ParseInvokeFieldDispatcher( |
| 539 Array* default_values); | 546 const Function& func, ZoneGrowableArray<const Instance*>* default_values); |
| 540 SequenceNode* ParseImplicitClosure(const Function& func, | 547 SequenceNode* ParseImplicitClosure( |
| 541 Array* default_values); | 548 const Function& func, ZoneGrowableArray<const Instance*>* default_values); |
| 542 SequenceNode* ParseConstructorClosure(const Function& func, | 549 SequenceNode* ParseConstructorClosure( |
| 543 Array* default_values); | 550 const Function& func, ZoneGrowableArray<const Instance*>* default_values); |
| 544 | 551 |
| 545 void BuildDispatcherScope(const Function& func, | 552 void BuildDispatcherScope(const Function& func, |
| 546 const ArgumentsDescriptor& desc, | 553 const ArgumentsDescriptor& desc, |
| 547 Array* default_values); | 554 ZoneGrowableArray<const Instance*>* default_values); |
| 548 | 555 |
| 549 void EnsureHasReturnStatement(SequenceNode* seq, intptr_t return_pos); | 556 void EnsureHasReturnStatement(SequenceNode* seq, intptr_t return_pos); |
| 550 void ChainNewBlock(LocalScope* outer_scope); | 557 void ChainNewBlock(LocalScope* outer_scope); |
| 551 void OpenBlock(); | 558 void OpenBlock(); |
| 552 void OpenLoopBlock(); | 559 void OpenLoopBlock(); |
| 553 void OpenFunctionBlock(const Function& func); | 560 void OpenFunctionBlock(const Function& func); |
| 554 void OpenAsyncClosure(); | 561 void OpenAsyncClosure(); |
| 555 RawFunction* OpenAsyncFunction(intptr_t formal_param_pos); | 562 RawFunction* OpenAsyncFunction(intptr_t formal_param_pos); |
| 556 RawFunction* OpenSyncGeneratorFunction(intptr_t func_pos); | 563 RawFunction* OpenSyncGeneratorFunction(intptr_t func_pos); |
| 557 SequenceNode* CloseSyncGenFunction(const Function& closure, | 564 SequenceNode* CloseSyncGenFunction(const Function& closure, |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 | 890 |
| 884 // Indentation of parser trace. | 891 // Indentation of parser trace. |
| 885 intptr_t trace_indent_; | 892 intptr_t trace_indent_; |
| 886 | 893 |
| 887 DISALLOW_COPY_AND_ASSIGN(Parser); | 894 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 888 }; | 895 }; |
| 889 | 896 |
| 890 } // namespace dart | 897 } // namespace dart |
| 891 | 898 |
| 892 #endif // VM_PARSER_H_ | 899 #endif // VM_PARSER_H_ |
| OLD | NEW |