| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 Scope(Scope* outer_scope, Type type); | 98 Scope(Scope* outer_scope, Type type); |
| 99 | 99 |
| 100 virtual ~Scope() { } | 100 virtual ~Scope() { } |
| 101 | 101 |
| 102 // Compute top scope and allocate variables. For lazy compilation the top | 102 // Compute top scope and allocate variables. For lazy compilation the top |
| 103 // scope only contains the single lazily compiled function, so this | 103 // scope only contains the single lazily compiled function, so this |
| 104 // doesn't re-allocate variables repeatedly. | 104 // doesn't re-allocate variables repeatedly. |
| 105 static bool Analyze(CompilationInfo* info); | 105 static bool Analyze(CompilationInfo* info); |
| 106 | 106 |
| 107 static Scope* DeserializeScopeChain(CompilationInfo* info, |
| 108 Scope* innermost_scope); |
| 109 |
| 107 // The scope name is only used for printing/debugging. | 110 // The scope name is only used for printing/debugging. |
| 108 void SetScopeName(Handle<String> scope_name) { scope_name_ = scope_name; } | 111 void SetScopeName(Handle<String> scope_name) { scope_name_ = scope_name; } |
| 109 | 112 |
| 110 virtual void Initialize(bool inside_with); | 113 virtual void Initialize(bool inside_with); |
| 111 | 114 |
| 112 // Called just before leaving a scope. | 115 // Called just before leaving a scope. |
| 113 virtual void Leave() { | 116 virtual void Leave() { |
| 114 // No cleanup or fixup necessary. | 117 // No cleanup or fixup necessary. |
| 115 } | 118 } |
| 116 | 119 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 void Print(int n = 0); // n = indentation; n < 0 => don't print recursively | 309 void Print(int n = 0); // n = indentation; n < 0 => don't print recursively |
| 307 #endif | 310 #endif |
| 308 | 311 |
| 309 // --------------------------------------------------------------------------- | 312 // --------------------------------------------------------------------------- |
| 310 // Implementation. | 313 // Implementation. |
| 311 protected: | 314 protected: |
| 312 friend class ParserFactory; | 315 friend class ParserFactory; |
| 313 | 316 |
| 314 explicit Scope(Type type); | 317 explicit Scope(Type type); |
| 315 | 318 |
| 316 void InsertAfterScope(Scope* scope) { | |
| 317 inner_scopes_.Add(scope); | |
| 318 outer_scope_ = scope->outer_scope_; | |
| 319 outer_scope_->inner_scopes_.RemoveElement(scope); | |
| 320 outer_scope_->inner_scopes_.Add(this); | |
| 321 scope->outer_scope_ = this; | |
| 322 } | |
| 323 | |
| 324 // Scope tree. | 319 // Scope tree. |
| 325 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL | 320 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL |
| 326 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes | 321 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes |
| 327 | 322 |
| 328 // The scope type. | 323 // The scope type. |
| 329 Type type_; | 324 Type type_; |
| 330 | 325 |
| 331 // Debugging support. | 326 // Debugging support. |
| 332 Handle<String> scope_name_; | 327 Handle<String> scope_name_; |
| 333 | 328 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 void AllocateStackSlot(Variable* var); | 401 void AllocateStackSlot(Variable* var); |
| 407 void AllocateHeapSlot(Variable* var); | 402 void AllocateHeapSlot(Variable* var); |
| 408 void AllocateParameterLocals(); | 403 void AllocateParameterLocals(); |
| 409 void AllocateNonParameterLocal(Variable* var); | 404 void AllocateNonParameterLocal(Variable* var); |
| 410 void AllocateNonParameterLocals(); | 405 void AllocateNonParameterLocals(); |
| 411 void AllocateVariablesRecursively(); | 406 void AllocateVariablesRecursively(); |
| 412 | 407 |
| 413 private: | 408 private: |
| 414 Scope(Scope* inner_scope, SerializedScopeInfo* scope_info); | 409 Scope(Scope* inner_scope, SerializedScopeInfo* scope_info); |
| 415 | 410 |
| 411 void AddInnerScope(Scope* inner_scope) { |
| 412 if (inner_scope != NULL) { |
| 413 inner_scopes_.Add(inner_scope); |
| 414 inner_scope->outer_scope_ = this; |
| 415 } |
| 416 } |
| 417 |
| 416 void SetDefaults(Type type, | 418 void SetDefaults(Type type, |
| 417 Scope* outer_scope, | 419 Scope* outer_scope, |
| 418 SerializedScopeInfo* scope_info) { | 420 SerializedScopeInfo* scope_info) { |
| 419 outer_scope_ = outer_scope; | 421 outer_scope_ = outer_scope; |
| 420 type_ = type; | 422 type_ = type; |
| 421 scope_name_ = Factory::empty_symbol(); | 423 scope_name_ = Factory::empty_symbol(); |
| 422 dynamics_ = NULL; | 424 dynamics_ = NULL; |
| 423 receiver_ = NULL; | 425 receiver_ = NULL; |
| 424 function_ = NULL; | 426 function_ = NULL; |
| 425 arguments_ = NULL; | 427 arguments_ = NULL; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 int nesting_level_; | 487 int nesting_level_; |
| 486 // Nesting level of outermost scope that is contained in a with statement, | 488 // Nesting level of outermost scope that is contained in a with statement, |
| 487 // or kNotInsideWith if there are no with's around the current scope. | 489 // or kNotInsideWith if there are no with's around the current scope. |
| 488 int inside_with_level_; | 490 int inside_with_level_; |
| 489 }; | 491 }; |
| 490 | 492 |
| 491 | 493 |
| 492 } } // namespace v8::internal | 494 } } // namespace v8::internal |
| 493 | 495 |
| 494 #endif // V8_SCOPES_H_ | 496 #endif // V8_SCOPES_H_ |
| OLD | NEW |