| 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 RUNTIME_VM_PARSER_H_ | 5 #ifndef RUNTIME_VM_PARSER_H_ |
| 6 #define RUNTIME_VM_PARSER_H_ | 6 #define RUNTIME_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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // The class ParsedFunction holds the result of parsing a function. | 89 // The class ParsedFunction holds the result of parsing a function. |
| 90 class ParsedFunction : public ZoneAllocated { | 90 class ParsedFunction : public ZoneAllocated { |
| 91 public: | 91 public: |
| 92 ParsedFunction(Thread* thread, const Function& function) | 92 ParsedFunction(Thread* thread, const Function& function) |
| 93 : thread_(thread), | 93 : thread_(thread), |
| 94 function_(function), | 94 function_(function), |
| 95 code_(Code::Handle(zone(), function.unoptimized_code())), | 95 code_(Code::Handle(zone(), function.unoptimized_code())), |
| 96 node_sequence_(NULL), | 96 node_sequence_(NULL), |
| 97 regexp_compile_data_(NULL), | 97 regexp_compile_data_(NULL), |
| 98 instantiator_(NULL), | 98 instantiator_(NULL), |
| 99 function_instantiator_(NULL), |
| 99 current_context_var_(NULL), | 100 current_context_var_(NULL), |
| 100 expression_temp_var_(NULL), | 101 expression_temp_var_(NULL), |
| 101 finally_return_temp_var_(NULL), | 102 finally_return_temp_var_(NULL), |
| 102 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), | 103 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), |
| 103 guarded_fields_(new ZoneGrowableArray<const Field*>()), | 104 guarded_fields_(new ZoneGrowableArray<const Field*>()), |
| 104 default_parameter_values_(NULL), | 105 default_parameter_values_(NULL), |
| 105 first_parameter_index_(0), | 106 first_parameter_index_(0), |
| 106 first_stack_local_index_(0), | 107 first_stack_local_index_(0), |
| 107 num_copied_params_(0), | 108 num_copied_params_(0), |
| 108 num_stack_locals_(0), | 109 num_stack_locals_(0), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 123 SequenceNode* node_sequence() const { return node_sequence_; } | 124 SequenceNode* node_sequence() const { return node_sequence_; } |
| 124 void SetNodeSequence(SequenceNode* node_sequence); | 125 void SetNodeSequence(SequenceNode* node_sequence); |
| 125 | 126 |
| 126 RegExpCompileData* regexp_compile_data() const { | 127 RegExpCompileData* regexp_compile_data() const { |
| 127 return regexp_compile_data_; | 128 return regexp_compile_data_; |
| 128 } | 129 } |
| 129 void SetRegExpCompileData(RegExpCompileData* regexp_compile_data); | 130 void SetRegExpCompileData(RegExpCompileData* regexp_compile_data); |
| 130 | 131 |
| 131 LocalVariable* instantiator() const { return instantiator_; } | 132 LocalVariable* instantiator() const { return instantiator_; } |
| 132 void set_instantiator(LocalVariable* instantiator) { | 133 void set_instantiator(LocalVariable* instantiator) { |
| 133 // May be NULL. | 134 ASSERT(instantiator != NULL); |
| 134 instantiator_ = instantiator; | 135 instantiator_ = instantiator; |
| 135 } | 136 } |
| 137 LocalVariable* function_instantiator() const { |
| 138 return function_instantiator_; |
| 139 } |
| 140 void set_function_instantiator(LocalVariable* function_instantiator) { |
| 141 ASSERT(function_instantiator != NULL); |
| 142 function_instantiator_ = function_instantiator; |
| 143 } |
| 136 | 144 |
| 137 void set_default_parameter_values(ZoneGrowableArray<const Instance*>* list) { | 145 void set_default_parameter_values(ZoneGrowableArray<const Instance*>* list) { |
| 138 default_parameter_values_ = list; | 146 default_parameter_values_ = list; |
| 139 #if defined(DEBUG) | 147 #if defined(DEBUG) |
| 140 if (list == NULL) return; | 148 if (list == NULL) return; |
| 141 for (intptr_t i = 0; i < list->length(); i++) { | 149 for (intptr_t i = 0; i < list->length(); i++) { |
| 142 ASSERT(list->At(i)->IsZoneHandle() || list->At(i)->InVMHeap()); | 150 ASSERT(list->At(i)->IsZoneHandle() || list->At(i)->InVMHeap()); |
| 143 } | 151 } |
| 144 #endif | 152 #endif |
| 145 } | 153 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 225 |
| 218 kernel::ScopeBuildingResult* EnsureKernelScopes(); | 226 kernel::ScopeBuildingResult* EnsureKernelScopes(); |
| 219 | 227 |
| 220 private: | 228 private: |
| 221 Thread* thread_; | 229 Thread* thread_; |
| 222 const Function& function_; | 230 const Function& function_; |
| 223 Code& code_; | 231 Code& code_; |
| 224 SequenceNode* node_sequence_; | 232 SequenceNode* node_sequence_; |
| 225 RegExpCompileData* regexp_compile_data_; | 233 RegExpCompileData* regexp_compile_data_; |
| 226 LocalVariable* instantiator_; | 234 LocalVariable* instantiator_; |
| 235 LocalVariable* function_instantiator_; |
| 227 LocalVariable* current_context_var_; | 236 LocalVariable* current_context_var_; |
| 228 LocalVariable* expression_temp_var_; | 237 LocalVariable* expression_temp_var_; |
| 229 LocalVariable* finally_return_temp_var_; | 238 LocalVariable* finally_return_temp_var_; |
| 230 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; | 239 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
| 231 ZoneGrowableArray<const Field*>* guarded_fields_; | 240 ZoneGrowableArray<const Field*>* guarded_fields_; |
| 232 ZoneGrowableArray<const Instance*>* default_parameter_values_; | 241 ZoneGrowableArray<const Instance*>* default_parameter_values_; |
| 233 | 242 |
| 234 int first_parameter_index_; | 243 int first_parameter_index_; |
| 235 int first_stack_local_index_; | 244 int first_stack_local_index_; |
| 236 int num_copied_params_; | 245 int num_copied_params_; |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 | 672 |
| 664 void AddAsyncClosureParameters(ParamList* params); | 673 void AddAsyncClosureParameters(ParamList* params); |
| 665 void AddContinuationVariables(); | 674 void AddContinuationVariables(); |
| 666 void AddAsyncClosureVariables(); | 675 void AddAsyncClosureVariables(); |
| 667 void AddAsyncGeneratorVariables(); | 676 void AddAsyncGeneratorVariables(); |
| 668 | 677 |
| 669 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only); | 678 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only); |
| 670 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope, | 679 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope, |
| 671 bool test_only); | 680 bool test_only); |
| 672 void CaptureInstantiator(); | 681 void CaptureInstantiator(); |
| 673 void CaptureFunctionInstantiator(); | 682 void CaptureFunctionInstantiators(); |
| 683 void CaptureAllInstantiators(); |
| 674 AstNode* LoadReceiver(TokenPosition token_pos); | 684 AstNode* LoadReceiver(TokenPosition token_pos); |
| 675 AstNode* LoadFieldIfUnresolved(AstNode* node); | 685 AstNode* LoadFieldIfUnresolved(AstNode* node); |
| 676 AstNode* LoadClosure(PrimaryNode* primary); | 686 AstNode* LoadClosure(PrimaryNode* primary); |
| 677 AstNode* LoadTypeParameter(PrimaryNode* primary); | 687 AstNode* LoadTypeParameter(PrimaryNode* primary); |
| 678 InstanceGetterNode* CallGetter(TokenPosition token_pos, | 688 InstanceGetterNode* CallGetter(TokenPosition token_pos, |
| 679 AstNode* object, | 689 AstNode* object, |
| 680 const String& name); | 690 const String& name); |
| 681 | 691 |
| 682 AstNode* ParseAssertStatement(bool is_const = false); | 692 AstNode* ParseAssertStatement(bool is_const = false); |
| 683 AstNode* ParseJump(String* label_name); | 693 AstNode* ParseJump(String* label_name); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 AstNode* GenerateStaticFieldAccess(const Class& cls, | 837 AstNode* GenerateStaticFieldAccess(const Class& cls, |
| 828 const String& field_name, | 838 const String& field_name, |
| 829 TokenPosition ident_pos); | 839 TokenPosition ident_pos); |
| 830 | 840 |
| 831 LocalVariable* LookupLocalScope(const String& ident); | 841 LocalVariable* LookupLocalScope(const String& ident); |
| 832 void CheckInstanceFieldAccess(TokenPosition field_pos, | 842 void CheckInstanceFieldAccess(TokenPosition field_pos, |
| 833 const String& field_name); | 843 const String& field_name); |
| 834 bool ParsingStaticMember() const; | 844 bool ParsingStaticMember() const; |
| 835 const AbstractType* ReceiverType(const Class& cls); | 845 const AbstractType* ReceiverType(const Class& cls); |
| 836 bool IsInstantiatorRequired() const; | 846 bool IsInstantiatorRequired() const; |
| 847 bool AreFunctionInstantiatorsRequired() const; |
| 848 bool InGenericFunctionScope() const; |
| 837 bool ResolveIdentInLocalScope(TokenPosition ident_pos, | 849 bool ResolveIdentInLocalScope(TokenPosition ident_pos, |
| 838 const String& ident, | 850 const String& ident, |
| 839 AstNode** node, | 851 AstNode** node, |
| 840 intptr_t* function_level); | 852 intptr_t* function_level); |
| 841 static const bool kResolveLocally = true; | 853 static const bool kResolveLocally = true; |
| 842 static const bool kResolveIncludingImports = false; | 854 static const bool kResolveIncludingImports = false; |
| 843 | 855 |
| 844 // Resolve a primary identifier in the library or prefix scope and | 856 // Resolve a primary identifier in the library or prefix scope and |
| 845 // generate the corresponding AstNode. | 857 // generate the corresponding AstNode. |
| 846 AstNode* ResolveIdentInCurrentLibraryScope(TokenPosition ident_pos, | 858 AstNode* ResolveIdentInCurrentLibraryScope(TokenPosition ident_pos, |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 | 996 |
| 985 intptr_t recursion_counter_; | 997 intptr_t recursion_counter_; |
| 986 friend class RecursionChecker; | 998 friend class RecursionChecker; |
| 987 | 999 |
| 988 DISALLOW_COPY_AND_ASSIGN(Parser); | 1000 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 989 }; | 1001 }; |
| 990 | 1002 |
| 991 } // namespace dart | 1003 } // namespace dart |
| 992 | 1004 |
| 993 #endif // RUNTIME_VM_PARSER_H_ | 1005 #endif // RUNTIME_VM_PARSER_H_ |
| OLD | NEW |