v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Scope Class Reference

#include <scopes.h>

Inheritance diagram for Scope:
Collaboration diagram for Scope:

Public Member Functions

 Scope (Scope *outer_scope, ScopeType scope_type, Zone *zone)
 
void SetScopeName (Handle< String > scope_name)
 
void Initialize ()
 
ScopeFinalizeBlockScope ()
 
Zonezone () const
 
VariableLocalLookup (Handle< String > name)
 
VariableLookupFunctionVar (Handle< String > name, AstNodeFactory< AstNullVisitor > *factory)
 
VariableLookup (Handle< String > name)
 
void DeclareFunctionVar (VariableDeclaration *declaration)
 
void DeclareParameter (Handle< String > name, VariableMode mode)
 
VariableDeclareLocal (Handle< String > name, VariableMode mode, InitializationFlag init_flag, Interface *interface=Interface::NewValue())
 
VariableDeclareDynamicGlobal (Handle< String > name)
 
template<class Visitor >
VariableProxy * NewUnresolved (AstNodeFactory< Visitor > *factory, Handle< String > name, Interface *interface=Interface::NewValue(), int position=RelocInfo::kNoPosition)
 
void RemoveUnresolved (VariableProxy *var)
 
VariableNewInternal (Handle< String > name)
 
VariableNewTemporary (Handle< String > name)
 
void AddDeclaration (Declaration *declaration)
 
void SetIllegalRedeclaration (Expression *expression)
 
void VisitIllegalRedeclaration (AstVisitor *visitor)
 
bool HasIllegalRedeclaration () const
 
DeclarationCheckConflictingVarDeclarations ()
 
void RecordWithStatement ()
 
void RecordEvalCall ()
 
void SetStrictMode (StrictMode strict_mode)
 
int start_position () const
 
void set_start_position (int statement_pos)
 
int end_position () const
 
void set_end_position (int statement_pos)
 
void ForceContextAllocation ()
 
bool has_forced_context_allocation () const
 
bool is_eval_scope () const
 
bool is_function_scope () const
 
bool is_module_scope () const
 
bool is_global_scope () const
 
bool is_catch_scope () const
 
bool is_block_scope () const
 
bool is_with_scope () const
 
bool is_declaration_scope () const
 
bool is_strict_eval_scope () const
 
bool calls_eval () const
 
bool calls_sloppy_eval ()
 
bool outer_scope_calls_sloppy_eval () const
 
bool inside_with () const
 
bool contains_with () const
 
ScopeType scope_type () const
 
StrictMode strict_mode () const
 
Variablereceiver ()
 
VariableDeclaration * function () const
 
Variableparameter (int index) const
 
int num_parameters () const
 
Variablearguments () const
 
ZoneList< Declaration * > * declarations ()
 
ZoneList< Scope * > * inner_scopes ()
 
Scopeouter_scope () const
 
Interfaceinterface () const
 
void CollectStackAndContextLocals (ZoneList< Variable * > *stack_locals, ZoneList< Variable * > *context_locals)
 
int num_var_or_const ()
 
int num_stack_slots () const
 
int num_heap_slots () const
 
int StackLocalCount () const
 
int ContextLocalCount () const
 
int num_modules () const
 
Variablemodule_var () const
 
void ForceEagerCompilation ()
 
bool AllowsLazyCompilation () const
 
bool AllowsLazyCompilationWithoutContext () const
 
bool HasTrivialOuterContext () const
 
bool HasLazyCompilableOuterContext () const
 
int ContextChainLength (Scope *scope)
 
ScopeGlobalScope ()
 
ScopeDeclarationScope ()
 
Handle< ScopeInfoGetScopeInfo ()
 
void GetNestedScopeChain (List< Handle< ScopeInfo > > *chain, int statement_position)
 
bool IsDeclared (Handle< String > name)
 
- Public Member Functions inherited from ZoneObject
 INLINE (void *operator new(size_t size, Zone *zone))
 
void operator delete (void *, size_t)
 
void operator delete (void *pointer, Zone *zone)
 

Static Public Member Functions

static bool Analyze (CompilationInfo *info)
 
static ScopeDeserializeScopeChain (Context *context, Scope *global_scope, Zone *zone)
 

Protected Types

enum  BindingKind {
  BOUND, BOUND_EVAL_SHADOWED, UNBOUND, UNBOUND_EVAL_SHADOWED,
  DYNAMIC_LOOKUP
}
 

Protected Member Functions

bool already_resolved ()
 
VariableNonLocal (Handle< String > name, VariableMode mode)
 
VariableLookupRecursive (Handle< String > name, BindingKind *binding_kind, AstNodeFactory< AstNullVisitor > *factory)
 
MUST_USE_RESULT bool ResolveVariable (CompilationInfo *info, VariableProxy *proxy, AstNodeFactory< AstNullVisitor > *factory)
 
MUST_USE_RESULT bool ResolveVariablesRecursively (CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
 
bool PropagateScopeInfo (bool outer_scope_calls_sloppy_eval)
 
bool HasTrivialContext () const
 
bool MustAllocate (Variable *var)
 
bool MustAllocateInContext (Variable *var)
 
bool HasArgumentsParameter ()
 
void AllocateStackSlot (Variable *var)
 
void AllocateHeapSlot (Variable *var)
 
void AllocateParameterLocals ()
 
void AllocateNonParameterLocal (Variable *var)
 
void AllocateNonParameterLocals ()
 
void AllocateVariablesRecursively ()
 
void AllocateModulesRecursively (Scope *host_scope)
 
MUST_USE_RESULT bool AllocateVariables (CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
 

Protected Attributes

Isolate *const isolate_
 
Scopeouter_scope_
 
ZoneList< Scope * > inner_scopes_
 
ScopeType scope_type_
 
Handle< Stringscope_name_
 
VariableMap variables_
 
ZoneList< Variable * > internals_
 
ZoneList< Variable * > temps_
 
ZoneList< Variable * > params_
 
DynamicScopePartdynamics_
 
ZoneList< VariableProxy * > unresolved_
 
ZoneList< Declaration * > decls_
 
Variablereceiver_
 
VariableDeclaration * function_
 
Variablearguments_
 
Interfaceinterface_
 
Expressionillegal_redecl_
 
bool scope_inside_with_
 
bool scope_contains_with_
 
bool scope_calls_eval_
 
StrictMode strict_mode_
 
int start_position_
 
int end_position_
 
bool outer_scope_calls_sloppy_eval_
 
bool inner_scope_calls_eval_
 
bool force_eager_compilation_
 
bool force_context_allocation_
 
bool already_resolved_
 
int num_var_or_const_
 
int num_stack_slots_
 
int num_heap_slots_
 
int num_modules_
 
Variablemodule_var_
 
Handle< ScopeInfoscope_info_
 

Friends

class ParserFactory
 

Detailed Description

Definition at line 95 of file scopes.h.

Member Enumeration Documentation

enum BindingKind
protected
Enumerator
BOUND 
BOUND_EVAL_SHADOWED 
UNBOUND 
UNBOUND_EVAL_SHADOWED 
DYNAMIC_LOOKUP 

Definition at line 529 of file scopes.h.

Constructor & Destructor Documentation

Scope ( Scope outer_scope,
ScopeType  scope_type,
Zone zone 
)

Member Function Documentation

void AddDeclaration ( Declaration declaration)

Definition at line 531 of file scopes.cc.

References Scope::decls_, and Scope::zone().

void AllocateHeapSlot ( Variable var)
protected
void AllocateStackSlot ( Variable var)
protected
bool AllowsLazyCompilation ( ) const
bool AllowsLazyCompilationWithoutContext ( ) const

Definition at line 716 of file scopes.cc.

References Scope::force_eager_compilation_, and Scope::HasTrivialOuterContext().

Variable* arguments ( ) const
inline

Definition at line 341 of file scopes.h.

References Scope::arguments_.

Referenced by Scope::AllocateParameterLocals(), and HOptimizedGraphBuilder::SetUpScope().

bool calls_eval ( ) const
inline
bool calls_sloppy_eval ( )
inline
bool contains_with ( ) const
inline

Definition at line 310 of file scopes.h.

References Scope::scope_contains_with_.

Referenced by Scope::DeserializeScopeChain().

int ContextChainLength ( Scope scope)

Definition at line 721 of file scopes.cc.

References ASSERT, v8::internal::NULL, and Scope::outer_scope_.

int ContextLocalCount ( ) const
ZoneList<Declaration*>* declarations ( )
inline

Definition at line 344 of file scopes.h.

References Scope::decls_.

Referenced by HOptimizedGraphBuilder::BuildGraph(), and AstTyper::Run().

void DeclareFunctionVar ( VariableDeclaration *  declaration)
inline

Definition at line 142 of file scopes.h.

References ASSERT, Scope::function_, and Scope::is_function_scope().

Referenced by Scope::LookupFunctionVar().

int end_position ( ) const
inline

Definition at line 265 of file scopes.h.

References Scope::end_position_.

Referenced by Scope::GetNestedScopeChain().

void ForceContextAllocation ( )
inline

Definition at line 271 of file scopes.h.

References Scope::already_resolved(), ASSERT, and Scope::force_context_allocation_.

void ForceEagerCompilation ( )
inline

Definition at line 381 of file scopes.h.

References Scope::force_eager_compilation_.

VariableDeclaration* function ( ) const
inline
void GetNestedScopeChain ( List< Handle< ScopeInfo > > *  chain,
int  statement_position 
)
Handle< ScopeInfo > GetScopeInfo ( )

Definition at line 752 of file scopes.cc.

References ScopeInfo::Create(), Scope::scope_info_, and Scope::zone().

Referenced by Scope::GetNestedScopeChain().

Scope * GlobalScope ( )

Definition at line 734 of file scopes.cc.

References Scope::is_global_scope(), and Scope::outer_scope().

bool has_forced_context_allocation ( ) const
inline
bool HasArgumentsParameter ( )
protected
bool HasIllegalRedeclaration ( ) const
inline
bool HasLazyCompilableOuterContext ( ) const
bool HasTrivialContext ( ) const
protected

Definition at line 669 of file scopes.cc.

References v8::internal::NULL.

Referenced by Scope::HasTrivialOuterContext().

ZoneList<Scope*>* inner_scopes ( )
inline

Definition at line 347 of file scopes.h.

References Scope::inner_scopes_.

Referenced by TEST().

bool inside_with ( ) const
inline

Definition at line 308 of file scopes.h.

References Scope::scope_inside_with_.

Referenced by CompilationInfo::DisableOptimization().

Interface* interface ( ) const
inline

Definition at line 353 of file scopes.h.

References Scope::interface_.

Referenced by Scope::Analyze(), and Scope::NewUnresolved().

bool is_block_scope ( ) const
inline
bool is_catch_scope ( ) const
inline

Definition at line 287 of file scopes.h.

References v8::internal::CATCH_SCOPE, and Scope::scope_type_.

Referenced by Scope::MustAllocate(), and Scope::MustAllocateInContext().

bool is_eval_scope ( ) const
inline
bool is_strict_eval_scope ( ) const
inline

Definition at line 294 of file scopes.h.

References Scope::is_eval_scope(), v8::internal::STRICT, and Scope::strict_mode_.

bool is_with_scope ( ) const
inline
bool IsDeclared ( Handle< String name)
inline

Definition at line 416 of file scopes.h.

References VariableMap::Lookup(), v8::internal::NULL, and Scope::variables_.

Variable * Lookup ( Handle< String name)

Definition at line 447 of file scopes.cc.

References v8::internal::NULL.

Variable* module_var ( ) const
inline

Definition at line 378 of file scopes.h.

References Scope::module_var_.

VariableProxy* NewUnresolved ( AstNodeFactory< Visitor > *  factory,
Handle< String name,
Interface interface = Interface::NewValue(),
int  position = RelocInfo::kNoPosition 
)
inline
int num_heap_slots ( ) const
inline
int num_modules ( ) const
inline

Definition at line 375 of file scopes.h.

References Scope::num_modules_.

int num_parameters ( ) const
inline
int num_stack_slots ( ) const
inline
int num_var_or_const ( )
inline

Definition at line 365 of file scopes.h.

References Scope::num_var_or_const_.

Referenced by Scope::FinalizeBlockScope().

Scope* outer_scope ( ) const
inline
bool outer_scope_calls_sloppy_eval ( ) const
inline
Variable* parameter ( int  index) const
inline

Definition at line 333 of file scopes.h.

References ASSERT, Scope::is_function_scope(), and Scope::params_.

Referenced by ScopeInfo::Create().

Variable* receiver ( )
inline

Definition at line 322 of file scopes.h.

References Scope::receiver_.

Referenced by Scope::Initialize(), and ParserTraits::ThisExpression().

void RecordEvalCall ( )
inline

Definition at line 234 of file scopes.h.

References Scope::is_global_scope(), and Scope::scope_calls_eval_.

Referenced by ParserTraits::CheckPossibleEvalCall().

void RecordWithStatement ( )
inline

Definition at line 231 of file scopes.h.

References Scope::scope_contains_with_.

Referenced by Scope::DeserializeScopeChain().

void RemoveUnresolved ( VariableProxy *  var)

Definition at line 493 of file scopes.cc.

References List< T, P >::Remove(), and Scope::unresolved_.

bool ResolveVariablesRecursively ( CompilationInfo info,
AstNodeFactory< AstNullVisitor > *  factory 
)
protected
ScopeType scope_type ( ) const
inline

Definition at line 316 of file scopes.h.

References Scope::scope_type_.

Referenced by ScopeInfo::Create().

void set_end_position ( int  statement_pos)
inline

Definition at line 266 of file scopes.h.

References Scope::end_position_.

void set_start_position ( int  statement_pos)
inline

Definition at line 262 of file scopes.h.

References Scope::start_position_.

void SetIllegalRedeclaration ( Expression expression)

Definition at line 536 of file scopes.cc.

References ASSERT, Scope::HasIllegalRedeclaration(), and Scope::illegal_redecl_.

void SetScopeName ( Handle< String scope_name)
inline

Definition at line 111 of file scopes.h.

References Scope::scope_name_.

void SetStrictMode ( StrictMode  strict_mode)
inline

Definition at line 237 of file scopes.h.

References Scope::strict_mode(), and Scope::strict_mode_.

int StackLocalCount ( ) const

Definition at line 1392 of file scopes.cc.

References Scope::function_, v8::internal::NULL, and Scope::num_stack_slots().

Referenced by ScopeInfo::Create().

int start_position ( ) const
inline

Definition at line 261 of file scopes.h.

References Scope::start_position_.

Referenced by Scope::GetNestedScopeChain().

StrictMode strict_mode ( ) const
inline
void VisitIllegalRedeclaration ( AstVisitor *  visitor)

Friends And Related Function Documentation

friend class ParserFactory
friend

Definition at line 435 of file scopes.h.

Field Documentation

bool already_resolved_
protected

Definition at line 502 of file scopes.h.

Referenced by Scope::already_resolved().

Variable* arguments_
protected

Definition at line 472 of file scopes.h.

Referenced by Scope::AllocateParameterLocals(), and Scope::arguments().

ZoneList<Declaration*> decls_
protected
DynamicScopePart* dynamics_
protected

Definition at line 462 of file scopes.h.

Referenced by Scope::NonLocal().

int end_position_
protected

Definition at line 492 of file scopes.h.

Referenced by Scope::end_position(), and Scope::set_end_position().

bool force_context_allocation_
protected
bool force_eager_compilation_
protected
Expression* illegal_redecl_
protected
bool inner_scope_calls_eval_
protected
Interface* interface_
protected

Definition at line 474 of file scopes.h.

Referenced by Scope::AllocateModulesRecursively(), and Scope::interface().

Variable* module_var_
protected

Definition at line 515 of file scopes.h.

Referenced by Scope::AllocateModulesRecursively(), and Scope::module_var().

int num_heap_slots_
protected
int num_modules_
protected
int num_stack_slots_
protected
int num_var_or_const_
protected

Definition at line 505 of file scopes.h.

Referenced by Scope::DeclareLocal(), and Scope::num_var_or_const().

bool outer_scope_calls_sloppy_eval_
protected

Definition at line 495 of file scopes.h.

Referenced by Scope::outer_scope_calls_sloppy_eval(), and Scope::PropagateScopeInfo().

Variable* receiver_
protected

Definition at line 468 of file scopes.h.

Referenced by Scope::Initialize(), and Scope::receiver().

bool scope_contains_with_
protected
Handle<ScopeInfo> scope_info_
protected

Definition at line 518 of file scopes.h.

Referenced by Scope::GetScopeInfo().

bool scope_inside_with_
protected
Handle<String> scope_name_
protected

Definition at line 447 of file scopes.h.

Referenced by Scope::SetScopeName().

int start_position_
protected

Definition at line 491 of file scopes.h.

Referenced by Scope::set_start_position(), and Scope::start_position().

StrictMode strict_mode_
protected
ZoneList<VariableProxy*> unresolved_
protected

The documentation for this class was generated from the following files: