| 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 22 matching lines...) Expand all Loading... |
| 33 struct CatchParamDesc; | 33 struct CatchParamDesc; |
| 34 class ClassDesc; | 34 class ClassDesc; |
| 35 struct MemberDesc; | 35 struct MemberDesc; |
| 36 struct ParamList; | 36 struct ParamList; |
| 37 struct QualIdent; | 37 struct QualIdent; |
| 38 struct TopLevel; | 38 struct TopLevel; |
| 39 | 39 |
| 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(Isolate* isolate, const Function& function) | 43 ParsedFunction(Thread* thread, const Function& function) |
| 44 : function_(function), | 44 : thread_(thread), |
| 45 code_(Code::Handle(isolate, function.unoptimized_code())), | 45 function_(function), |
| 46 code_(Code::Handle(zone(), function.unoptimized_code())), |
| 46 node_sequence_(NULL), | 47 node_sequence_(NULL), |
| 47 regexp_compile_data_(NULL), | 48 regexp_compile_data_(NULL), |
| 48 instantiator_(NULL), | 49 instantiator_(NULL), |
| 49 default_parameter_values_(Array::ZoneHandle(isolate, Array::null())), | 50 default_parameter_values_(Array::ZoneHandle(zone(), Array::null())), |
| 50 current_context_var_(NULL), | 51 current_context_var_(NULL), |
| 51 expression_temp_var_(NULL), | 52 expression_temp_var_(NULL), |
| 52 finally_return_temp_var_(NULL), | 53 finally_return_temp_var_(NULL), |
| 53 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), | 54 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), |
| 54 guarded_fields_(new ZoneGrowableArray<const Field*>()), | 55 guarded_fields_(new ZoneGrowableArray<const Field*>()), |
| 55 first_parameter_index_(0), | 56 first_parameter_index_(0), |
| 56 first_stack_local_index_(0), | 57 first_stack_local_index_(0), |
| 57 num_copied_params_(0), | 58 num_copied_params_(0), |
| 58 num_stack_locals_(0), | 59 num_stack_locals_(0), |
| 59 have_seen_await_expr_(false), | 60 have_seen_await_expr_(false), |
| 60 saved_try_ctx_(NULL), | 61 saved_try_ctx_(NULL), |
| 61 async_saved_try_ctx_name_(String::ZoneHandle(isolate, String::null())), | 62 async_saved_try_ctx_name_(String::ZoneHandle(zone(), String::null())) { |
| 62 isolate_(isolate) { | |
| 63 ASSERT(function.IsZoneHandle()); | 63 ASSERT(function.IsZoneHandle()); |
| 64 // Every function has a local variable for the current context. | 64 // Every function has a local variable for the current context. |
| 65 LocalVariable* temp = new(isolate) LocalVariable( | 65 LocalVariable* temp = new(zone()) LocalVariable( |
| 66 function.token_pos(), | 66 function.token_pos(), |
| 67 Symbols::CurrentContextVar(), | 67 Symbols::CurrentContextVar(), |
| 68 Type::ZoneHandle(isolate, Type::DynamicType())); | 68 Type::ZoneHandle(zone(), Type::DynamicType())); |
| 69 ASSERT(temp != NULL); | 69 ASSERT(temp != NULL); |
| 70 current_context_var_ = temp; | 70 current_context_var_ = temp; |
| 71 } | 71 } |
| 72 | 72 |
| 73 const Function& function() const { return function_; } | 73 const Function& function() const { return function_; } |
| 74 const Code& code() const { return code_; } | 74 const Code& code() const { return code_; } |
| 75 | 75 |
| 76 SequenceNode* node_sequence() const { return node_sequence_; } | 76 SequenceNode* node_sequence() const { return node_sequence_; } |
| 77 void SetNodeSequence(SequenceNode* node_sequence); | 77 void SetNodeSequence(SequenceNode* node_sequence); |
| 78 | 78 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 163 } |
| 164 RawString* async_saved_try_ctx_name() const { | 164 RawString* async_saved_try_ctx_name() const { |
| 165 return async_saved_try_ctx_name_.raw(); | 165 return async_saved_try_ctx_name_.raw(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void reset_saved_try_ctx_vars() { | 168 void reset_saved_try_ctx_vars() { |
| 169 saved_try_ctx_ = NULL; | 169 saved_try_ctx_ = NULL; |
| 170 async_saved_try_ctx_name_ = String::null(); | 170 async_saved_try_ctx_name_ = String::null(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 Isolate* isolate() const { return isolate_; } | 173 Thread* thread() const { return thread_; } |
| 174 Isolate* isolate() const { return thread()->isolate(); } |
| 175 Zone* zone() const { return thread()->zone(); } |
| 174 | 176 |
| 175 private: | 177 private: |
| 178 Thread* thread_; |
| 176 const Function& function_; | 179 const Function& function_; |
| 177 Code& code_; | 180 Code& code_; |
| 178 SequenceNode* node_sequence_; | 181 SequenceNode* node_sequence_; |
| 179 RegExpCompileData* regexp_compile_data_; | 182 RegExpCompileData* regexp_compile_data_; |
| 180 LocalVariable* instantiator_; | 183 LocalVariable* instantiator_; |
| 181 Array& default_parameter_values_; | 184 Array& default_parameter_values_; |
| 182 LocalVariable* current_context_var_; | 185 LocalVariable* current_context_var_; |
| 183 LocalVariable* expression_temp_var_; | 186 LocalVariable* expression_temp_var_; |
| 184 LocalVariable* finally_return_temp_var_; | 187 LocalVariable* finally_return_temp_var_; |
| 185 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; | 188 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
| 186 ZoneGrowableArray<const Field*>* guarded_fields_; | 189 ZoneGrowableArray<const Field*>* guarded_fields_; |
| 187 | 190 |
| 188 int first_parameter_index_; | 191 int first_parameter_index_; |
| 189 int first_stack_local_index_; | 192 int first_stack_local_index_; |
| 190 int num_copied_params_; | 193 int num_copied_params_; |
| 191 int num_stack_locals_; | 194 int num_stack_locals_; |
| 192 bool have_seen_await_expr_; | 195 bool have_seen_await_expr_; |
| 193 LocalVariable* saved_try_ctx_; | 196 LocalVariable* saved_try_ctx_; |
| 194 String& async_saved_try_ctx_name_; | 197 String& async_saved_try_ctx_name_; |
| 195 | 198 |
| 196 Isolate* isolate_; | |
| 197 | |
| 198 friend class Parser; | 199 friend class Parser; |
| 199 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); | 200 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); |
| 200 }; | 201 }; |
| 201 | 202 |
| 202 | 203 |
| 203 class Parser : public ValueObject { | 204 class Parser : public ValueObject { |
| 204 public: | 205 public: |
| 205 // Parse the top level of a whole script file and register declared classes | 206 // Parse the top level of a whole script file and register declared classes |
| 206 // in the given library. | 207 // in the given library. |
| 207 static void ParseCompilationUnit(const Library& library, | 208 static void ParseCompilationUnit(const Library& library, |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 ArgumentListNode* arguments); | 763 ArgumentListNode* arguments); |
| 763 | 764 |
| 764 void AddEqualityNullCheck(); | 765 void AddEqualityNullCheck(); |
| 765 | 766 |
| 766 AstNode* BuildClosureCall(intptr_t token_pos, | 767 AstNode* BuildClosureCall(intptr_t token_pos, |
| 767 AstNode* closure, | 768 AstNode* closure, |
| 768 ArgumentListNode* arguments); | 769 ArgumentListNode* arguments); |
| 769 | 770 |
| 770 RawInstance* TryCanonicalize(const Instance& instance, intptr_t token_pos); | 771 RawInstance* TryCanonicalize(const Instance& instance, intptr_t token_pos); |
| 771 | 772 |
| 772 Isolate* isolate() const { return isolate_; } | 773 Thread* thread() const { return thread_; } |
| 774 Isolate* isolate() const { return thread()->isolate(); } |
| 775 Zone* zone() const { return thread()->zone(); } |
| 773 | 776 |
| 774 Isolate* isolate_; // Cached current isolate. | 777 Thread* thread_; // Cached current thread. |
| 775 | 778 |
| 776 Script& script_; | 779 Script& script_; |
| 777 TokenStream::Iterator tokens_iterator_; | 780 TokenStream::Iterator tokens_iterator_; |
| 778 Token::Kind token_kind_; // Cached token kind for current token. | 781 Token::Kind token_kind_; // Cached token kind for current token. |
| 779 Block* current_block_; | 782 Block* current_block_; |
| 780 | 783 |
| 781 // is_top_level_ is true if parsing the "top level" of a compilation unit, | 784 // is_top_level_ is true if parsing the "top level" of a compilation unit, |
| 782 // that is class definitions, function type aliases, global functions, | 785 // that is class definitions, function type aliases, global functions, |
| 783 // global variables. | 786 // global variables. |
| 784 bool is_top_level_; | 787 bool is_top_level_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 bool unregister_pending_function_; | 830 bool unregister_pending_function_; |
| 828 | 831 |
| 829 LocalScope* async_temp_scope_; | 832 LocalScope* async_temp_scope_; |
| 830 | 833 |
| 831 DISALLOW_COPY_AND_ASSIGN(Parser); | 834 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 832 }; | 835 }; |
| 833 | 836 |
| 834 } // namespace dart | 837 } // namespace dart |
| 835 | 838 |
| 836 #endif // VM_PARSER_H_ | 839 #endif // VM_PARSER_H_ |
| OLD | NEW |