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 function_type_arguments_(NULL), |
| 100 parent_type_arguments_(NULL), |
100 current_context_var_(NULL), | 101 current_context_var_(NULL), |
101 expression_temp_var_(NULL), | 102 expression_temp_var_(NULL), |
102 finally_return_temp_var_(NULL), | 103 finally_return_temp_var_(NULL), |
103 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), | 104 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), |
104 guarded_fields_(new ZoneGrowableArray<const Field*>()), | 105 guarded_fields_(new ZoneGrowableArray<const Field*>()), |
105 default_parameter_values_(NULL), | 106 default_parameter_values_(NULL), |
106 first_parameter_index_(0), | 107 first_parameter_index_(0), |
107 first_stack_local_index_(0), | 108 first_stack_local_index_(0), |
108 num_copied_params_(0), | 109 num_copied_params_(0), |
109 num_stack_locals_(0), | 110 num_stack_locals_(0), |
(...skipping 17 matching lines...) Expand all Loading... |
127 RegExpCompileData* regexp_compile_data() const { | 128 RegExpCompileData* regexp_compile_data() const { |
128 return regexp_compile_data_; | 129 return regexp_compile_data_; |
129 } | 130 } |
130 void SetRegExpCompileData(RegExpCompileData* regexp_compile_data); | 131 void SetRegExpCompileData(RegExpCompileData* regexp_compile_data); |
131 | 132 |
132 LocalVariable* instantiator() const { return instantiator_; } | 133 LocalVariable* instantiator() const { return instantiator_; } |
133 void set_instantiator(LocalVariable* instantiator) { | 134 void set_instantiator(LocalVariable* instantiator) { |
134 ASSERT(instantiator != NULL); | 135 ASSERT(instantiator != NULL); |
135 instantiator_ = instantiator; | 136 instantiator_ = instantiator; |
136 } | 137 } |
137 LocalVariable* function_instantiator() const { | 138 LocalVariable* function_type_arguments() const { |
138 return function_instantiator_; | 139 return function_type_arguments_; |
139 } | 140 } |
140 void set_function_instantiator(LocalVariable* function_instantiator) { | 141 void set_function_type_arguments(LocalVariable* function_type_arguments) { |
141 ASSERT(function_instantiator != NULL); | 142 ASSERT(function_type_arguments != NULL); |
142 function_instantiator_ = function_instantiator; | 143 function_type_arguments_ = function_type_arguments; |
| 144 } |
| 145 LocalVariable* parent_type_arguments() const { |
| 146 return parent_type_arguments_; |
| 147 } |
| 148 void set_parent_type_arguments(LocalVariable* parent_type_arguments) { |
| 149 ASSERT(parent_type_arguments != NULL); |
| 150 parent_type_arguments_ = parent_type_arguments; |
143 } | 151 } |
144 | 152 |
145 void set_default_parameter_values(ZoneGrowableArray<const Instance*>* list) { | 153 void set_default_parameter_values(ZoneGrowableArray<const Instance*>* list) { |
146 default_parameter_values_ = list; | 154 default_parameter_values_ = list; |
147 #if defined(DEBUG) | 155 #if defined(DEBUG) |
148 if (list == NULL) return; | 156 if (list == NULL) return; |
149 for (intptr_t i = 0; i < list->length(); i++) { | 157 for (intptr_t i = 0; i < list->length(); i++) { |
150 ASSERT(list->At(i)->IsZoneHandle() || list->At(i)->InVMHeap()); | 158 ASSERT(list->At(i)->IsZoneHandle() || list->At(i)->InVMHeap()); |
151 } | 159 } |
152 #endif | 160 #endif |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 233 |
226 kernel::ScopeBuildingResult* EnsureKernelScopes(); | 234 kernel::ScopeBuildingResult* EnsureKernelScopes(); |
227 | 235 |
228 private: | 236 private: |
229 Thread* thread_; | 237 Thread* thread_; |
230 const Function& function_; | 238 const Function& function_; |
231 Code& code_; | 239 Code& code_; |
232 SequenceNode* node_sequence_; | 240 SequenceNode* node_sequence_; |
233 RegExpCompileData* regexp_compile_data_; | 241 RegExpCompileData* regexp_compile_data_; |
234 LocalVariable* instantiator_; | 242 LocalVariable* instantiator_; |
235 LocalVariable* function_instantiator_; | 243 LocalVariable* function_type_arguments_; |
| 244 LocalVariable* parent_type_arguments_; |
236 LocalVariable* current_context_var_; | 245 LocalVariable* current_context_var_; |
237 LocalVariable* expression_temp_var_; | 246 LocalVariable* expression_temp_var_; |
238 LocalVariable* finally_return_temp_var_; | 247 LocalVariable* finally_return_temp_var_; |
239 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; | 248 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
240 ZoneGrowableArray<const Field*>* guarded_fields_; | 249 ZoneGrowableArray<const Field*>* guarded_fields_; |
241 ZoneGrowableArray<const Instance*>* default_parameter_values_; | 250 ZoneGrowableArray<const Instance*>* default_parameter_values_; |
242 | 251 |
243 int first_parameter_index_; | 252 int first_parameter_index_; |
244 int first_stack_local_index_; | 253 int first_stack_local_index_; |
245 int num_copied_params_; | 254 int num_copied_params_; |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 | 683 |
675 void AddAsyncClosureParameters(ParamList* params); | 684 void AddAsyncClosureParameters(ParamList* params); |
676 void AddContinuationVariables(); | 685 void AddContinuationVariables(); |
677 void AddAsyncClosureVariables(); | 686 void AddAsyncClosureVariables(); |
678 void AddAsyncGeneratorVariables(); | 687 void AddAsyncGeneratorVariables(); |
679 | 688 |
680 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only); | 689 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only); |
681 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope, | 690 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope, |
682 bool test_only); | 691 bool test_only); |
683 void CaptureInstantiator(); | 692 void CaptureInstantiator(); |
684 void CaptureFunctionInstantiators(); | 693 void CaptureFunctionTypeArguments(); |
685 void CaptureAllInstantiators(); | 694 void CaptureAllInstantiators(); |
686 AstNode* LoadReceiver(TokenPosition token_pos); | 695 AstNode* LoadReceiver(TokenPosition token_pos); |
687 AstNode* LoadFieldIfUnresolved(AstNode* node); | 696 AstNode* LoadFieldIfUnresolved(AstNode* node); |
688 AstNode* LoadClosure(PrimaryNode* primary); | 697 AstNode* LoadClosure(PrimaryNode* primary); |
689 AstNode* LoadTypeParameter(PrimaryNode* primary); | 698 AstNode* LoadTypeParameter(PrimaryNode* primary); |
690 InstanceGetterNode* CallGetter(TokenPosition token_pos, | 699 InstanceGetterNode* CallGetter(TokenPosition token_pos, |
691 AstNode* object, | 700 AstNode* object, |
692 const String& name); | 701 const String& name); |
693 | 702 |
694 AstNode* ParseAssertStatement(bool is_const = false); | 703 AstNode* ParseAssertStatement(bool is_const = false); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 AstNode* GenerateStaticFieldAccess(const Class& cls, | 848 AstNode* GenerateStaticFieldAccess(const Class& cls, |
840 const String& field_name, | 849 const String& field_name, |
841 TokenPosition ident_pos); | 850 TokenPosition ident_pos); |
842 | 851 |
843 LocalVariable* LookupLocalScope(const String& ident); | 852 LocalVariable* LookupLocalScope(const String& ident); |
844 void CheckInstanceFieldAccess(TokenPosition field_pos, | 853 void CheckInstanceFieldAccess(TokenPosition field_pos, |
845 const String& field_name); | 854 const String& field_name); |
846 bool ParsingStaticMember() const; | 855 bool ParsingStaticMember() const; |
847 const AbstractType* ReceiverType(const Class& cls); | 856 const AbstractType* ReceiverType(const Class& cls); |
848 bool IsInstantiatorRequired() const; | 857 bool IsInstantiatorRequired() const; |
849 bool AreFunctionInstantiatorsRequired() const; | |
850 bool InGenericFunctionScope() const; | 858 bool InGenericFunctionScope() const; |
851 bool ResolveIdentInLocalScope(TokenPosition ident_pos, | 859 bool ResolveIdentInLocalScope(TokenPosition ident_pos, |
852 const String& ident, | 860 const String& ident, |
853 AstNode** node, | 861 AstNode** node, |
854 intptr_t* function_level); | 862 intptr_t* function_level); |
855 static const bool kResolveLocally = true; | 863 static const bool kResolveLocally = true; |
856 static const bool kResolveIncludingImports = false; | 864 static const bool kResolveIncludingImports = false; |
857 | 865 |
858 // Resolve a primary identifier in the library or prefix scope and | 866 // Resolve a primary identifier in the library or prefix scope and |
859 // generate the corresponding AstNode. | 867 // generate the corresponding AstNode. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 | 1006 |
999 intptr_t recursion_counter_; | 1007 intptr_t recursion_counter_; |
1000 friend class RecursionChecker; | 1008 friend class RecursionChecker; |
1001 | 1009 |
1002 DISALLOW_COPY_AND_ASSIGN(Parser); | 1010 DISALLOW_COPY_AND_ASSIGN(Parser); |
1003 }; | 1011 }; |
1004 | 1012 |
1005 } // namespace dart | 1013 } // namespace dart |
1006 | 1014 |
1007 #endif // RUNTIME_VM_PARSER_H_ | 1015 #endif // RUNTIME_VM_PARSER_H_ |
OLD | NEW |