diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-06-29 17:26:51 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-06-29 17:26:51 +0200 |
commit | 33af2720f26c2b25bc7f75ce7eb454ff99db6d35 (patch) | |
tree | 9a38f0c96420edf503eebd6325dd8d2d8249f653 /deps/v8/src/scopes.h | |
parent | 6afdca885adeeeed9eef8cbb01c3d97af0bc084d (diff) | |
download | node-new-33af2720f26c2b25bc7f75ce7eb454ff99db6d35.tar.gz |
Upgrade V8 to 3.4.8
Diffstat (limited to 'deps/v8/src/scopes.h')
-rw-r--r-- | deps/v8/src/scopes.h | 117 |
1 files changed, 36 insertions, 81 deletions
diff --git a/deps/v8/src/scopes.h b/deps/v8/src/scopes.h index 4a48a4c453..d4e8e2bd91 100644 --- a/deps/v8/src/scopes.h +++ b/deps/v8/src/scopes.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -97,8 +97,6 @@ class Scope: public ZoneObject { Scope(Scope* outer_scope, Type type); - virtual ~Scope() { } - // Compute top scope and allocate variables. For lazy compilation the top // scope only contains the single lazily compiled function, so this // doesn't re-allocate variables repeatedly. @@ -110,31 +108,31 @@ class Scope: public ZoneObject { // The scope name is only used for printing/debugging. void SetScopeName(Handle<String> scope_name) { scope_name_ = scope_name; } - virtual void Initialize(bool inside_with); - - // Called just before leaving a scope. - virtual void Leave() { - // No cleanup or fixup necessary. - } + void Initialize(bool inside_with); // --------------------------------------------------------------------------- // Declarations // Lookup a variable in this scope. Returns the variable or NULL if not found. - virtual Variable* LocalLookup(Handle<String> name); + Variable* LocalLookup(Handle<String> name); // Lookup a variable in this scope or outer scopes. // Returns the variable or NULL if not found. - virtual Variable* Lookup(Handle<String> name); + Variable* Lookup(Handle<String> name); // Declare the function variable for a function literal. This variable // is in an intermediate scope between this function scope and the the // outer scope. Only possible for function scopes; at most one variable. Variable* DeclareFunctionVar(Handle<String> name); + // 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); + // Declare a local variable in this scope. If the variable has been // declared before, the previously declared variable is returned. - virtual Variable* DeclareLocal(Handle<String> name, Variable::Mode mode); + Variable* DeclareLocal(Handle<String> name, Variable::Mode mode); // Declare an implicit global variable in this scope which must be a // global scope. The variable was introduced (possibly from an inner @@ -142,14 +140,10 @@ class Scope: public ZoneObject { // with statements or eval calls. Variable* DeclareGlobal(Handle<String> name); - // Add a parameter to the parameter list. The parameter must have been - // declared via Declare. The same parameter may occur more than once in - // the parameter list; they must be added in source order, from left to - // right. - void AddParameter(Variable* var); - // Create a new unresolved variable. - virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with); + VariableProxy* NewUnresolved(Handle<String> name, + bool inside_with, + int position = RelocInfo::kNoPosition); // Remove a unresolved variable. During parsing, an unresolved variable // may have been added optimistically, but then only the variable name @@ -163,7 +157,7 @@ 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. - virtual Variable* NewTemporary(Handle<String> name); + Variable* NewTemporary(Handle<String> name); // Adds the specific declaration node to the list of declarations in // this scope. The declarations are processed as part of entering @@ -196,6 +190,10 @@ class Scope: public ZoneObject { // Inform the scope that the corresponding code contains an eval call. void RecordEvalCall() { scope_calls_eval_ = true; } + // Enable strict mode for the scope (unless disabled by a global flag). + void EnableStrictMode() { + strict_mode_ = FLAG_strict_mode; + } // --------------------------------------------------------------------------- // Predicates. @@ -204,10 +202,17 @@ class Scope: public ZoneObject { bool is_eval_scope() const { return type_ == EVAL_SCOPE; } bool is_function_scope() const { return type_ == FUNCTION_SCOPE; } bool is_global_scope() const { return type_ == GLOBAL_SCOPE; } + bool is_strict_mode() const { return strict_mode_; } + bool is_strict_mode_eval_scope() const { + return is_eval_scope() && is_strict_mode(); + } // Information about which scopes calls eval. bool calls_eval() const { return scope_calls_eval_; } bool outer_scope_calls_eval() const { return outer_scope_calls_eval_; } + bool outer_scope_calls_non_strict_eval() const { + return outer_scope_calls_non_strict_eval_; + } // Is this scope inside a with statement. bool inside_with() const { return scope_inside_with_; } @@ -223,7 +228,7 @@ class Scope: public ZoneObject { // A new variable proxy corresponding to the (function) receiver. VariableProxy* receiver() const { VariableProxy* proxy = - new VariableProxy(Factory::this_symbol(), true, false); + new VariableProxy(FACTORY->this_symbol(), true, false); proxy->BindTo(receiver_); return proxy; } @@ -246,18 +251,12 @@ class Scope: public ZoneObject { int num_parameters() const { return params_.length(); } // The local variable 'arguments' if we need to allocate it; NULL otherwise. - // If arguments() exist, arguments_shadow() exists, too. Variable* arguments() const { return arguments_; } - // The '.arguments' shadow variable if we need to allocate it; NULL otherwise. - // If arguments_shadow() exist, arguments() exists, too. - Variable* arguments_shadow() const { return arguments_shadow_; } - // Declarations list. ZoneList<Declaration*>* declarations() { return &decls_; } - // --------------------------------------------------------------------------- // Variable allocation. @@ -275,6 +274,9 @@ class Scope: public ZoneObject { // cases the context parameter is an empty handle. void AllocateVariables(Handle<Context> context); + // Current number of var or const locals. + int num_var_or_const() { return num_var_or_const_; } + // Result of variable allocation. int num_stack_slots() const { return num_stack_slots_; } int num_heap_slots() const { return num_heap_slots_; } @@ -286,7 +288,7 @@ class Scope: public ZoneObject { bool AllowsLazyCompilation() const; // True if the outer context of this scope is always the global context. - virtual bool HasTrivialOuterContext() const; + bool HasTrivialOuterContext() const; // The number of contexts between this and scope; zero if this == scope. int ContextChainLength(Scope* scope); @@ -348,8 +350,6 @@ class Scope: public ZoneObject { Variable* function_; // Convenience variable; function scopes only. Variable* arguments_; - // Convenience variable; function scopes only. - Variable* arguments_shadow_; // Illegal redeclaration. Expression* illegal_redecl_; @@ -358,13 +358,18 @@ class Scope: public ZoneObject { bool scope_inside_with_; // this scope is inside a 'with' of some outer scope bool scope_contains_with_; // this scope contains a 'with' statement bool scope_calls_eval_; // this scope contains an 'eval' call + bool strict_mode_; // this scope is a strict mode scope // Computed via PropagateScopeInfo. bool outer_scope_calls_eval_; + bool outer_scope_calls_non_strict_eval_; bool inner_scope_calls_eval_; bool outer_scope_is_eval_scope_; bool force_eager_compilation_; + // Computed as variables are declared. + int num_var_or_const_; + // Computed via AllocateVariables; function scopes only. int num_stack_slots_; int num_heap_slots_; @@ -389,6 +394,7 @@ class Scope: public ZoneObject { // Scope analysis. bool PropagateScopeInfo(bool outer_scope_calls_eval, + bool outer_scope_calls_non_strict_eval, bool outer_scope_is_eval_scope); bool HasTrivialContext() const; @@ -420,57 +426,6 @@ class Scope: public ZoneObject { Handle<SerializedScopeInfo> scope_info); }; - -// Scope used during pre-parsing. -class DummyScope : public Scope { - public: - DummyScope() - : Scope(GLOBAL_SCOPE), - nesting_level_(1), // Allows us to Leave the initial scope. - inside_with_level_(kNotInsideWith) { - outer_scope_ = this; - scope_inside_with_ = false; - } - - virtual void Initialize(bool inside_with) { - nesting_level_++; - if (inside_with && inside_with_level_ == kNotInsideWith) { - inside_with_level_ = nesting_level_; - } - ASSERT(inside_with_level_ <= nesting_level_); - } - - virtual void Leave() { - nesting_level_--; - ASSERT(nesting_level_ >= 0); - if (nesting_level_ < inside_with_level_) { - inside_with_level_ = kNotInsideWith; - } - ASSERT(inside_with_level_ <= nesting_level_); - } - - virtual Variable* Lookup(Handle<String> name) { return NULL; } - - virtual VariableProxy* NewUnresolved(Handle<String> name, bool inside_with) { - return NULL; - } - - virtual Variable* NewTemporary(Handle<String> name) { return NULL; } - - virtual bool HasTrivialOuterContext() const { - return (nesting_level_ == 0 || inside_with_level_ <= 0); - } - - private: - static const int kNotInsideWith = -1; - // Number of surrounding scopes of the current scope. - int nesting_level_; - // Nesting level of outermost scope that is contained in a with statement, - // or kNotInsideWith if there are no with's around the current scope. - int inside_with_level_; -}; - - } } // namespace v8::internal #endif // V8_SCOPES_H_ |