Chromium Code Reviews| Index: src/scopes.h |
| diff --git a/src/scopes.h b/src/scopes.h |
| index 23a10f19c8d8245e757b2f90d5200791cf883a7d..6392a5e0fe993df5ee6108fedaadee8bac65f718 100644 |
| --- a/src/scopes.h |
| +++ b/src/scopes.h |
| @@ -22,14 +22,16 @@ class VariableMap: public ZoneHashMap { |
| virtual ~VariableMap(); |
| Variable* Declare(Scope* scope, |
| - Handle<String> name, |
| + ParserSymbolTable::Symbol* name, |
| VariableMode mode, |
| bool is_valid_lhs, |
| Variable::Kind kind, |
| InitializationFlag initialization_flag, |
| Interface* interface = Interface::NewValue()); |
| - Variable* Lookup(Handle<String> name); |
| + Variable* Lookup(ParserSymbolTable::Symbol* name); |
| + |
| + void Add(ParserSymbolTable::Symbol* name, Variable* variable); |
| Zone* zone() const { return zone_; } |
| @@ -71,10 +73,17 @@ class DynamicScopePart : public ZoneObject { |
| class Scope: public ZoneObject { |
| public: |
| + enum HeapMode { |
|
rossberg
2014/05/08 12:52:08
Where is this used?
marja
2014/06/03 08:48:20
Nowhere :) -> removed
|
| + DONT_USE_HEAP, |
| + USE_HEAP |
| + }; |
| + |
| + |
| // --------------------------------------------------------------------------- |
| // Construction |
| - Scope(Scope* outer_scope, ScopeType scope_type, Zone* zone); |
| + Scope(Scope* outer_scope, ScopeType scope_type, |
| + ParserSymbolTable* symbol_table, Zone* zone); |
| // Compute top scope and allocate variables. For lazy compilation the top |
| // scope only contains the single lazily compiled function, so this |
| @@ -85,7 +94,9 @@ class Scope: public ZoneObject { |
| Zone* zone); |
| // The scope name is only used for printing/debugging. |
| - void SetScopeName(Handle<String> scope_name) { scope_name_ = scope_name; } |
| + void SetScopeName(ParserSymbolTable::Symbol* scope_name) { |
| + scope_name_ = scope_name; |
| + } |
| void Initialize(); |
| @@ -100,18 +111,18 @@ class Scope: public ZoneObject { |
| // Declarations |
| // Lookup a variable in this scope. Returns the variable or NULL if not found. |
| - Variable* LocalLookup(Handle<String> name); |
| + Variable* LocalLookup(ParserSymbolTable::Symbol* name); |
| // This lookup corresponds to a lookup in the "intermediate" scope sitting |
| // between this scope and the outer scope. (ECMA-262, 3rd., requires that |
| // the name of named function literal is kept in an intermediate scope |
| // in between this scope and the next outer scope.) |
| - Variable* LookupFunctionVar(Handle<String> name, |
| + Variable* LookupFunctionVar(ParserSymbolTable::Symbol* name, |
| AstNodeFactory<AstNullVisitor>* factory); |
| // Lookup a variable in this scope or outer scopes. |
| // Returns the variable or NULL if not found. |
| - Variable* Lookup(Handle<String> name); |
| + Variable* Lookup(ParserSymbolTable::Symbol* name); |
| // Declare the function variable for a function literal. This variable |
| // is in an intermediate scope between this function scope and the the |
| @@ -124,7 +135,7 @@ class Scope: public ZoneObject { |
| // Declare a parameter in this scope. When there are duplicated |
| // parameters the rightmost one 'wins'. However, the implementation |
| // expects all parameters to be declared and from left to right. |
| - void DeclareParameter(Handle<String> name, VariableMode mode); |
| + void DeclareParameter(ParserSymbolTable::Symbol* name, VariableMode mode); |
| // Declare a local variable in this scope. If the variable has been |
| // declared before, the previously declared variable is returned. |
| @@ -133,16 +144,21 @@ class Scope: public ZoneObject { |
| InitializationFlag init_flag, |
| Interface* interface = Interface::NewValue()); |
| + Variable* DeclareLocal(ParserSymbolTable::Symbol* name, |
| + VariableMode mode, |
| + InitializationFlag init_flag, |
| + Interface* interface = Interface::NewValue()); |
| + |
| // Declare an implicit global variable in this scope which must be a |
| // global scope. The variable was introduced (possibly from an inner |
| // scope) by a reference to an unresolved variable with no intervening |
| // with statements or eval calls. |
| - Variable* DeclareDynamicGlobal(Handle<String> name); |
| + Variable* DeclareDynamicGlobal(ParserSymbolTable::Symbol* name); |
| // Create a new unresolved variable. |
| template<class Visitor> |
| VariableProxy* NewUnresolved(AstNodeFactory<Visitor>* factory, |
| - Handle<String> name, |
| + ParserSymbolTable::Symbol* name, |
| Interface* interface = Interface::NewValue(), |
| int position = RelocInfo::kNoPosition) { |
| // Note that we must not share the unresolved variables with |
| @@ -167,13 +183,13 @@ class Scope: public ZoneObject { |
| // for printing and cannot be used to find the variable. In particular, |
| // the only way to get hold of the temporary is by keeping the Variable* |
| // around. |
| - Variable* NewInternal(Handle<String> name); |
| + Variable* NewInternal(ParserSymbolTable::Symbol* name); |
| // Creates a new temporary variable in this scope. The name is only used |
| // for printing and cannot be used to find the variable. In particular, |
| // the only way to get hold of the temporary is by keeping the Variable* |
| // around. The name should not clash with a legitimate variable names. |
| - Variable* NewTemporary(Handle<String> name); |
| + Variable* NewTemporary(ParserSymbolTable::Symbol* name); |
| // Adds the specific declaration node to the list of declarations in |
| // this scope. The declarations are processed as part of entering |
| @@ -390,7 +406,7 @@ class Scope: public ZoneObject { |
| // --------------------------------------------------------------------------- |
| // Strict mode support. |
| - bool IsDeclared(Handle<String> name) { |
| + bool IsDeclared(ParserSymbolTable::Symbol* name) { |
| // During formal parameter list parsing the scope only contains |
| // two variables inserted at initialization: "this" and "arguments". |
| // "this" is an invalid parameter name and "arguments" is invalid parameter |
| @@ -399,6 +415,8 @@ class Scope: public ZoneObject { |
| return variables_.Lookup(name) != NULL; |
| } |
| + Isolate* isolate() const { return isolate_; } |
| + |
| // --------------------------------------------------------------------------- |
| // Debugging. |
| @@ -421,7 +439,7 @@ class Scope: public ZoneObject { |
| ScopeType scope_type_; |
| // Debugging support. |
| - Handle<String> scope_name_; |
| + ParserSymbolTable::Symbol* scope_name_; |
| // The variables declared in this scope: |
| // |
| @@ -497,7 +515,7 @@ class Scope: public ZoneObject { |
| // Create a non-local variable with a given name. |
| // These variables are looked up dynamically at runtime. |
| - Variable* NonLocal(Handle<String> name, VariableMode mode); |
| + Variable* NonLocal(ParserSymbolTable::Symbol* name, VariableMode mode); |
| // Variable resolution. |
| // Possible results of a recursive variable lookup telling if and how a |
| @@ -548,7 +566,7 @@ class Scope: public ZoneObject { |
| // Lookup a variable reference given by name recursively starting with this |
| // scope. If the code is executed because of a call to 'eval', the context |
| // parameter should be set to the calling context of 'eval'. |
| - Variable* LookupRecursive(Handle<String> name, |
| + Variable* LookupRecursive(ParserSymbolTable::Symbol* name, |
| BindingKind* binding_kind, |
| AstNodeFactory<AstNullVisitor>* factory); |
| MUST_USE_RESULT |
| @@ -592,10 +610,11 @@ class Scope: public ZoneObject { |
| private: |
| // Construct a scope based on the scope info. |
| Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info, |
| - Zone* zone); |
| + ParserSymbolTable* symbol_table, Zone* zone); |
| // Construct a catch scope with a binding for the name. |
| - Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone); |
| + Scope(Scope* inner_scope, ParserSymbolTable::Symbol* catch_variable_name, |
| + ParserSymbolTable* symbol_table, Zone* zone); |
| void AddInnerScope(Scope* inner_scope) { |
| if (inner_scope != NULL) { |
| @@ -608,6 +627,7 @@ class Scope: public ZoneObject { |
| Scope* outer_scope, |
| Handle<ScopeInfo> scope_info); |
| + ParserSymbolTable* symbol_table_; |
| Zone* zone_; |
| }; |