| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef V8_SCOPES_H_ | 5 #ifndef V8_SCOPES_H_ | 
| 6 #define V8_SCOPES_H_ | 6 #define V8_SCOPES_H_ | 
| 7 | 7 | 
| 8 #include "src/ast.h" | 8 #include "src/ast.h" | 
| 9 #include "src/zone.h" | 9 #include "src/zone.h" | 
| 10 | 10 | 
| 11 namespace v8 { | 11 namespace v8 { | 
| 12 namespace internal { | 12 namespace internal { | 
| 13 | 13 | 
| 14 class CompilationInfo; | 14 class CompilationInfo; | 
| 15 | 15 | 
| 16 | 16 | 
| 17 // A hash map to support fast variable declaration and lookup. | 17 // A hash map to support fast variable declaration and lookup. | 
| 18 class VariableMap: public ZoneHashMap { | 18 class VariableMap: public ZoneHashMap { | 
| 19  public: | 19  public: | 
| 20   explicit VariableMap(Zone* zone); | 20   explicit VariableMap(Zone* zone); | 
| 21 | 21 | 
| 22   virtual ~VariableMap(); | 22   virtual ~VariableMap(); | 
| 23 | 23 | 
| 24   Variable* Declare(Scope* scope, | 24   Variable* Declare(Scope* scope, const AstRawString* name, VariableMode mode, | 
| 25                     const AstRawString* name, | 25                     bool is_valid_lhs, Variable::Kind kind, | 
| 26                     VariableMode mode, |  | 
| 27                     bool is_valid_lhs, |  | 
| 28                     Variable::Kind kind, |  | 
| 29                     InitializationFlag initialization_flag, | 26                     InitializationFlag initialization_flag, | 
|  | 27                     MaybeAssignedFlag maybe_assigned_flag = kNotAssigned, | 
| 30                     Interface* interface = Interface::NewValue()); | 28                     Interface* interface = Interface::NewValue()); | 
| 31 | 29 | 
| 32   Variable* Lookup(const AstRawString* name); | 30   Variable* Lookup(const AstRawString* name); | 
| 33 | 31 | 
| 34   Zone* zone() const { return zone_; } | 32   Zone* zone() const { return zone_; } | 
| 35 | 33 | 
| 36  private: | 34  private: | 
| 37   Zone* zone_; | 35   Zone* zone_; | 
| 38 }; | 36 }; | 
| 39 | 37 | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 120   // is in an intermediate scope between this function scope and the the | 118   // is in an intermediate scope between this function scope and the the | 
| 121   // outer scope. Only possible for function scopes; at most one variable. | 119   // outer scope. Only possible for function scopes; at most one variable. | 
| 122   void DeclareFunctionVar(VariableDeclaration* declaration) { | 120   void DeclareFunctionVar(VariableDeclaration* declaration) { | 
| 123     ASSERT(is_function_scope()); | 121     ASSERT(is_function_scope()); | 
| 124     function_ = declaration; | 122     function_ = declaration; | 
| 125   } | 123   } | 
| 126 | 124 | 
| 127   // Declare a parameter in this scope.  When there are duplicated | 125   // Declare a parameter in this scope.  When there are duplicated | 
| 128   // parameters the rightmost one 'wins'.  However, the implementation | 126   // parameters the rightmost one 'wins'.  However, the implementation | 
| 129   // expects all parameters to be declared and from left to right. | 127   // expects all parameters to be declared and from left to right. | 
| 130   void DeclareParameter(const AstRawString* name, VariableMode mode); | 128   Variable* DeclareParameter(const AstRawString* name, VariableMode mode); | 
| 131 | 129 | 
| 132   // Declare a local variable in this scope. If the variable has been | 130   // Declare a local variable in this scope. If the variable has been | 
| 133   // declared before, the previously declared variable is returned. | 131   // declared before, the previously declared variable is returned. | 
| 134   Variable* DeclareLocal(const AstRawString* name, | 132   Variable* DeclareLocal(const AstRawString* name, VariableMode mode, | 
| 135                          VariableMode mode, |  | 
| 136                          InitializationFlag init_flag, | 133                          InitializationFlag init_flag, | 
|  | 134                          MaybeAssignedFlag maybe_assigned_flag = kNotAssigned, | 
| 137                          Interface* interface = Interface::NewValue()); | 135                          Interface* interface = Interface::NewValue()); | 
| 138 | 136 | 
| 139   // Declare an implicit global variable in this scope which must be a | 137   // Declare an implicit global variable in this scope which must be a | 
| 140   // global scope.  The variable was introduced (possibly from an inner | 138   // global scope.  The variable was introduced (possibly from an inner | 
| 141   // scope) by a reference to an unresolved variable with no intervening | 139   // scope) by a reference to an unresolved variable with no intervening | 
| 142   // with statements or eval calls. | 140   // with statements or eval calls. | 
| 143   Variable* DeclareDynamicGlobal(const AstRawString* name); | 141   Variable* DeclareDynamicGlobal(const AstRawString* name); | 
| 144 | 142 | 
| 145   // Create a new unresolved variable. | 143   // Create a new unresolved variable. | 
| 146   template<class Visitor> | 144   template<class Visitor> | 
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 613                    Scope* outer_scope, | 611                    Scope* outer_scope, | 
| 614                    Handle<ScopeInfo> scope_info); | 612                    Handle<ScopeInfo> scope_info); | 
| 615 | 613 | 
| 616   AstValueFactory* ast_value_factory_; | 614   AstValueFactory* ast_value_factory_; | 
| 617   Zone* zone_; | 615   Zone* zone_; | 
| 618 }; | 616 }; | 
| 619 | 617 | 
| 620 } }  // namespace v8::internal | 618 } }  // namespace v8::internal | 
| 621 | 619 | 
| 622 #endif  // V8_SCOPES_H_ | 620 #endif  // V8_SCOPES_H_ | 
| OLD | NEW | 
|---|