| 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/kernel.h" |
| 17 #include "vm/hash_table.h" | 18 #include "vm/hash_table.h" |
| 18 #include "vm/object.h" | 19 #include "vm/object.h" |
| 19 #include "vm/raw_object.h" | 20 #include "vm/raw_object.h" |
| 20 #include "vm/token.h" | 21 #include "vm/token.h" |
| 21 | 22 |
| 22 namespace dart { | 23 namespace dart { |
| 23 | 24 |
| 24 // Forward declarations. | 25 // Forward declarations. |
| 26 |
| 27 namespace kernel { |
| 28 |
| 29 class ScopeBuildingResult; |
| 30 |
| 31 } // kernel |
| 32 |
| 25 class ArgumentsDescriptor; | 33 class ArgumentsDescriptor; |
| 26 class Isolate; | 34 class Isolate; |
| 27 class LocalScope; | 35 class LocalScope; |
| 28 class LocalVariable; | 36 class LocalVariable; |
| 29 struct RegExpCompileData; | 37 struct RegExpCompileData; |
| 30 class SourceLabel; | 38 class SourceLabel; |
| 31 template <typename T> class GrowableArray; | 39 template <typename T> class GrowableArray; |
| 32 class Parser; | 40 class Parser; |
| 33 | 41 |
| 34 struct CatchParamDesc; | 42 struct CatchParamDesc; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 current_context_var_(NULL), | 102 current_context_var_(NULL), |
| 95 expression_temp_var_(NULL), | 103 expression_temp_var_(NULL), |
| 96 finally_return_temp_var_(NULL), | 104 finally_return_temp_var_(NULL), |
| 97 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), | 105 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), |
| 98 guarded_fields_(new ZoneGrowableArray<const Field*>()), | 106 guarded_fields_(new ZoneGrowableArray<const Field*>()), |
| 99 default_parameter_values_(NULL), | 107 default_parameter_values_(NULL), |
| 100 first_parameter_index_(0), | 108 first_parameter_index_(0), |
| 101 first_stack_local_index_(0), | 109 first_stack_local_index_(0), |
| 102 num_copied_params_(0), | 110 num_copied_params_(0), |
| 103 num_stack_locals_(0), | 111 num_stack_locals_(0), |
| 104 have_seen_await_expr_(false) { | 112 have_seen_await_expr_(false), |
| 113 kernel_scopes_(NULL) { |
| 105 ASSERT(function.IsZoneHandle()); | 114 ASSERT(function.IsZoneHandle()); |
| 106 // Every function has a local variable for the current context. | 115 // Every function has a local variable for the current context. |
| 107 LocalVariable* temp = new(zone()) LocalVariable( | 116 LocalVariable* temp = new(zone()) LocalVariable( |
| 108 function.token_pos(), | 117 function.token_pos(), |
| 109 Symbols::CurrentContextVar(), | 118 Symbols::CurrentContextVar(), |
| 110 Object::dynamic_type()); | 119 Object::dynamic_type()); |
| 111 ASSERT(temp != NULL); | 120 ASSERT(temp != NULL); |
| 112 current_context_var_ = temp; | 121 current_context_var_ = temp; |
| 113 } | 122 } |
| 114 | 123 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 Thread* thread() const { return thread_; } | 217 Thread* thread() const { return thread_; } |
| 209 Isolate* isolate() const { return thread_->isolate(); } | 218 Isolate* isolate() const { return thread_->isolate(); } |
| 210 Zone* zone() const { return thread_->zone(); } | 219 Zone* zone() const { return thread_->zone(); } |
| 211 | 220 |
| 212 // Adds only relevant fields: field must be unique and its guarded_cid() | 221 // Adds only relevant fields: field must be unique and its guarded_cid() |
| 213 // relevant. | 222 // relevant. |
| 214 void AddToGuardedFields(const Field* field) const; | 223 void AddToGuardedFields(const Field* field) const; |
| 215 | 224 |
| 216 void Bailout(const char* origin, const char* reason) const; | 225 void Bailout(const char* origin, const char* reason) const; |
| 217 | 226 |
| 227 kernel::ScopeBuildingResult* EnsureKernelScopes(); |
| 228 |
| 218 private: | 229 private: |
| 219 Thread* thread_; | 230 Thread* thread_; |
| 220 const Function& function_; | 231 const Function& function_; |
| 221 Code& code_; | 232 Code& code_; |
| 222 SequenceNode* node_sequence_; | 233 SequenceNode* node_sequence_; |
| 223 RegExpCompileData* regexp_compile_data_; | 234 RegExpCompileData* regexp_compile_data_; |
| 224 LocalVariable* instantiator_; | 235 LocalVariable* instantiator_; |
| 225 LocalVariable* current_context_var_; | 236 LocalVariable* current_context_var_; |
| 226 LocalVariable* expression_temp_var_; | 237 LocalVariable* expression_temp_var_; |
| 227 LocalVariable* finally_return_temp_var_; | 238 LocalVariable* finally_return_temp_var_; |
| 228 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; | 239 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
| 229 ZoneGrowableArray<const Field*>* guarded_fields_; | 240 ZoneGrowableArray<const Field*>* guarded_fields_; |
| 230 ZoneGrowableArray<const Instance*>* default_parameter_values_; | 241 ZoneGrowableArray<const Instance*>* default_parameter_values_; |
| 231 | 242 |
| 232 int first_parameter_index_; | 243 int first_parameter_index_; |
| 233 int first_stack_local_index_; | 244 int first_stack_local_index_; |
| 234 int num_copied_params_; | 245 int num_copied_params_; |
| 235 int num_stack_locals_; | 246 int num_stack_locals_; |
| 236 bool have_seen_await_expr_; | 247 bool have_seen_await_expr_; |
| 237 | 248 |
| 249 kernel::ScopeBuildingResult* kernel_scopes_; |
| 250 |
| 238 friend class Parser; | 251 friend class Parser; |
| 239 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); | 252 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); |
| 240 }; | 253 }; |
| 241 | 254 |
| 242 | 255 |
| 243 class Parser : public ValueObject { | 256 class Parser : public ValueObject { |
| 244 public: | 257 public: |
| 245 // Parse the top level of a whole script file and register declared classes | 258 // Parse the top level of a whole script file and register declared classes |
| 246 // in the given library. | 259 // in the given library. |
| 247 static void ParseCompilationUnit(const Library& library, | 260 static void ParseCompilationUnit(const Library& library, |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 | 988 |
| 976 intptr_t recursion_counter_; | 989 intptr_t recursion_counter_; |
| 977 friend class RecursionChecker; | 990 friend class RecursionChecker; |
| 978 | 991 |
| 979 DISALLOW_COPY_AND_ASSIGN(Parser); | 992 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 980 }; | 993 }; |
| 981 | 994 |
| 982 } // namespace dart | 995 } // namespace dart |
| 983 | 996 |
| 984 #endif // VM_PARSER_H_ | 997 #endif // VM_PARSER_H_ |
| OLD | NEW |