| 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" |
| 11 #include "platform/globals.h" | 11 #include "platform/globals.h" |
| 12 #include "lib/invocation_mirror.h" | 12 #include "lib/invocation_mirror.h" |
| 13 #include "vm/allocation.h" | 13 #include "vm/allocation.h" |
| 14 #include "vm/ast.h" | 14 #include "vm/ast.h" |
| 15 #include "vm/class_finalizer.h" | 15 #include "vm/class_finalizer.h" |
| 16 #include "vm/compiler_stats.h" | 16 #include "vm/compiler_stats.h" |
| 17 #include "vm/object.h" | 17 #include "vm/object.h" |
| 18 #include "vm/raw_object.h" | 18 #include "vm/raw_object.h" |
| 19 #include "vm/token.h" | 19 #include "vm/token.h" |
| 20 | 20 |
| 21 namespace dart { | 21 namespace dart { |
| 22 | 22 |
| 23 // Forward declarations. | 23 // Forward declarations. |
| 24 class ArgumentsDescriptor; | 24 class ArgumentsDescriptor; |
| 25 class Isolate; | 25 class Isolate; |
| 26 class LocalScope; | 26 class LocalScope; |
| 27 class LocalVariable; | 27 class LocalVariable; |
| 28 class RegExpCompileData; |
| 28 class SourceLabel; | 29 class SourceLabel; |
| 29 template <typename T> class GrowableArray; | 30 template <typename T> class GrowableArray; |
| 30 | 31 |
| 31 struct CatchParamDesc; | 32 struct CatchParamDesc; |
| 32 class ClassDesc; | 33 class ClassDesc; |
| 33 struct MemberDesc; | 34 struct MemberDesc; |
| 34 struct ParamList; | 35 struct ParamList; |
| 35 struct QualIdent; | 36 struct QualIdent; |
| 36 struct TopLevel; | 37 struct TopLevel; |
| 37 | 38 |
| 38 // The class ParsedFunction holds the result of parsing a function. | 39 // The class ParsedFunction holds the result of parsing a function. |
| 39 class ParsedFunction : public ZoneAllocated { | 40 class ParsedFunction : public ZoneAllocated { |
| 40 public: | 41 public: |
| 41 ParsedFunction(Isolate* isolate, const Function& function) | 42 ParsedFunction(Isolate* isolate, const Function& function) |
| 42 : function_(function), | 43 : function_(function), |
| 43 code_(Code::Handle(isolate, function.unoptimized_code())), | 44 code_(Code::Handle(isolate, function.unoptimized_code())), |
| 44 node_sequence_(NULL), | 45 node_sequence_(NULL), |
| 46 regexp_compile_data_(NULL), |
| 45 instantiator_(NULL), | 47 instantiator_(NULL), |
| 46 default_parameter_values_(Array::ZoneHandle(isolate, Array::null())), | 48 default_parameter_values_(Array::ZoneHandle(isolate, Array::null())), |
| 47 saved_current_context_var_(NULL), | 49 saved_current_context_var_(NULL), |
| 48 saved_entry_context_var_(NULL), | 50 saved_entry_context_var_(NULL), |
| 49 expression_temp_var_(NULL), | 51 expression_temp_var_(NULL), |
| 50 finally_return_temp_var_(NULL), | 52 finally_return_temp_var_(NULL), |
| 51 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), | 53 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), |
| 52 first_parameter_index_(0), | 54 first_parameter_index_(0), |
| 53 first_stack_local_index_(0), | 55 first_stack_local_index_(0), |
| 54 num_copied_params_(0), | 56 num_copied_params_(0), |
| 55 num_stack_locals_(0), | 57 num_stack_locals_(0), |
| 56 have_seen_await_expr_(false), | 58 have_seen_await_expr_(false), |
| 57 saved_try_ctx_(NULL), | 59 saved_try_ctx_(NULL), |
| 58 async_saved_try_ctx_name_(String::ZoneHandle(isolate, String::null())), | 60 async_saved_try_ctx_name_(String::ZoneHandle(isolate, String::null())), |
| 59 isolate_(isolate) { | 61 isolate_(isolate) { |
| 60 ASSERT(function.IsZoneHandle()); | 62 ASSERT(function.IsZoneHandle()); |
| 61 } | 63 } |
| 62 | 64 |
| 63 const Function& function() const { return function_; } | 65 const Function& function() const { return function_; } |
| 64 const Code& code() const { return code_; } | 66 const Code& code() const { return code_; } |
| 65 | 67 |
| 66 SequenceNode* node_sequence() const { return node_sequence_; } | 68 SequenceNode* node_sequence() const { return node_sequence_; } |
| 67 void SetNodeSequence(SequenceNode* node_sequence); | 69 void SetNodeSequence(SequenceNode* node_sequence); |
| 68 | 70 |
| 71 RegExpCompileData* regexp_compile_data() const { |
| 72 return regexp_compile_data_; |
| 73 } |
| 74 void SetRegExpCompileData(RegExpCompileData* regexp_compile_data); |
| 75 |
| 69 LocalVariable* instantiator() const { return instantiator_; } | 76 LocalVariable* instantiator() const { return instantiator_; } |
| 70 void set_instantiator(LocalVariable* instantiator) { | 77 void set_instantiator(LocalVariable* instantiator) { |
| 71 // May be NULL. | 78 // May be NULL. |
| 72 instantiator_ = instantiator; | 79 instantiator_ = instantiator; |
| 73 } | 80 } |
| 74 | 81 |
| 75 const Array& default_parameter_values() const { | 82 const Array& default_parameter_values() const { |
| 76 return default_parameter_values_; | 83 return default_parameter_values_; |
| 77 } | 84 } |
| 78 void set_default_parameter_values(const Array& default_parameter_values) { | 85 void set_default_parameter_values(const Array& default_parameter_values) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return deferred_prefixes_; | 140 return deferred_prefixes_; |
| 134 } | 141 } |
| 135 void AddDeferredPrefix(const LibraryPrefix& prefix); | 142 void AddDeferredPrefix(const LibraryPrefix& prefix); |
| 136 | 143 |
| 137 int first_parameter_index() const { return first_parameter_index_; } | 144 int first_parameter_index() const { return first_parameter_index_; } |
| 138 int first_stack_local_index() const { return first_stack_local_index_; } | 145 int first_stack_local_index() const { return first_stack_local_index_; } |
| 139 int num_copied_params() const { return num_copied_params_; } | 146 int num_copied_params() const { return num_copied_params_; } |
| 140 int num_stack_locals() const { return num_stack_locals_; } | 147 int num_stack_locals() const { return num_stack_locals_; } |
| 141 | 148 |
| 142 void AllocateVariables(); | 149 void AllocateVariables(); |
| 150 void AllocateIrregexpVariables(intptr_t num_stack_locals); |
| 143 | 151 |
| 144 void record_await() { | 152 void record_await() { |
| 145 have_seen_await_expr_ = true; | 153 have_seen_await_expr_ = true; |
| 146 } | 154 } |
| 147 void reset_have_seen_await() { have_seen_await_expr_ = false; } | 155 void reset_have_seen_await() { have_seen_await_expr_ = false; } |
| 148 bool have_seen_await() const { return have_seen_await_expr_; } | 156 bool have_seen_await() const { return have_seen_await_expr_; } |
| 149 | 157 |
| 150 void set_saved_try_ctx(LocalVariable* saved_try_ctx) { | 158 void set_saved_try_ctx(LocalVariable* saved_try_ctx) { |
| 151 ASSERT((saved_try_ctx == NULL) || !saved_try_ctx->is_captured()); | 159 ASSERT((saved_try_ctx == NULL) || !saved_try_ctx->is_captured()); |
| 152 saved_try_ctx_ = saved_try_ctx; | 160 saved_try_ctx_ = saved_try_ctx; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 164 saved_try_ctx_ = NULL; | 172 saved_try_ctx_ = NULL; |
| 165 async_saved_try_ctx_name_ = String::null(); | 173 async_saved_try_ctx_name_ = String::null(); |
| 166 } | 174 } |
| 167 | 175 |
| 168 Isolate* isolate() const { return isolate_; } | 176 Isolate* isolate() const { return isolate_; } |
| 169 | 177 |
| 170 private: | 178 private: |
| 171 const Function& function_; | 179 const Function& function_; |
| 172 Code& code_; | 180 Code& code_; |
| 173 SequenceNode* node_sequence_; | 181 SequenceNode* node_sequence_; |
| 182 RegExpCompileData* regexp_compile_data_; |
| 174 LocalVariable* instantiator_; | 183 LocalVariable* instantiator_; |
| 175 Array& default_parameter_values_; | 184 Array& default_parameter_values_; |
| 176 LocalVariable* saved_current_context_var_; | 185 LocalVariable* saved_current_context_var_; |
| 177 LocalVariable* saved_entry_context_var_; | 186 LocalVariable* saved_entry_context_var_; |
| 178 LocalVariable* expression_temp_var_; | 187 LocalVariable* expression_temp_var_; |
| 179 LocalVariable* finally_return_temp_var_; | 188 LocalVariable* finally_return_temp_var_; |
| 180 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; | 189 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
| 181 | 190 |
| 182 int first_parameter_index_; | 191 int first_parameter_index_; |
| 183 int first_stack_local_index_; | 192 int first_stack_local_index_; |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 bool unregister_pending_function_; | 823 bool unregister_pending_function_; |
| 815 | 824 |
| 816 LocalScope* async_temp_scope_; | 825 LocalScope* async_temp_scope_; |
| 817 | 826 |
| 818 DISALLOW_COPY_AND_ASSIGN(Parser); | 827 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 819 }; | 828 }; |
| 820 | 829 |
| 821 } // namespace dart | 830 } // namespace dart |
| 822 | 831 |
| 823 #endif // VM_PARSER_H_ | 832 #endif // VM_PARSER_H_ |
| OLD | NEW |