v8  3.14.5(node0.10.28)
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 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 >
VariableProxyNewUnresolved (AstNodeFactory< Visitor > *factory, Handle< String > name, Interface *interface=Interface::NewValue(), int position=RelocInfo::kNoPosition)
 
void RemoveUnresolved (VariableProxy *var)
 
VariableNewTemporary (Handle< String > name)
 
void AddDeclaration (Declaration *declaration)
 
void SetIllegalRedeclaration (Expression *expression)
 
void VisitIllegalRedeclaration (AstVisitor *visitor)
 
bool HasIllegalRedeclaration () const
 
DeclarationCheckConflictingVarDeclarations ()
 
VariableProxyCheckAssignmentToConst ()
 
void RecordWithStatement ()
 
void RecordEvalCall ()
 
void SetLanguageMode (LanguageMode language_mode)
 
int start_position () const
 
void set_start_position (int statement_pos)
 
int end_position () const
 
void set_end_position (int statement_pos)
 
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_classic_mode () const
 
bool is_extended_mode () const
 
bool is_strict_or_extended_eval_scope () const
 
bool calls_eval () const
 
bool calls_non_strict_eval ()
 
bool outer_scope_calls_non_strict_eval () const
 
bool inside_with () const
 
bool contains_with () const
 
ScopeType type () const
 
LanguageMode language_mode () const
 
Variablereceiver ()
 
VariableDeclarationfunction () 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
 
void ForceEagerCompilation ()
 
bool AllowsLazyCompilation () const
 
bool AllowsLazyCompilationWithoutContext () const
 
bool HasTrivialOuterContext () const
 
bool HasLazyCompilableOuterContext () const
 
int ContextChainLength (Scope *scope)
 
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_non_strict_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 ()
 
MUST_USE_RESULT bool AllocateVariables (CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
 
void AllocateModules (CompilationInfo *info)
 
void LinkModules (CompilationInfo *info)
 

Protected Attributes

Isolate *const isolate_
 
Scopeouter_scope_
 
ZoneList< Scope * > inner_scopes_
 
ScopeType type_
 
Handle< Stringscope_name_
 
VariableMap variables_
 
ZoneList< Variable * > temps_
 
ZoneList< Variable * > params_
 
DynamicScopePartdynamics_
 
ZoneList< VariableProxy * > unresolved_
 
ZoneList< Declaration * > decls_
 
Variablereceiver_
 
VariableDeclarationfunction_
 
Variablearguments_
 
Interfaceinterface_
 
Expressionillegal_redecl_
 
bool scope_inside_with_
 
bool scope_contains_with_
 
bool scope_calls_eval_
 
LanguageMode language_mode_
 
int start_position_
 
int end_position_
 
bool outer_scope_calls_non_strict_eval_
 
bool inner_scope_calls_eval_
 
bool force_eager_compilation_
 
bool already_resolved_
 
int num_var_or_const_
 
int num_stack_slots_
 
int num_heap_slots_
 
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 509 of file scopes.h.

Constructor & Destructor Documentation

Scope ( Scope outer_scope,
ScopeType  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 AllowsLazyCompilationWithoutContext ( ) const
Variable* arguments ( ) const
inline

Definition at line 339 of file scopes.h.

References Scope::arguments_.

Referenced by Scope::AllocateParameterLocals(), and Compiler::SetFunctionInfo().

bool calls_eval ( ) const
inline
bool calls_non_strict_eval ( )
inline
VariableProxy * CheckAssignmentToConst ( )
bool contains_with ( ) const
inline

Definition at line 308 of file scopes.h.

References Scope::scope_contains_with_.

Referenced by Scope::DeserializeScopeChain().

int ContextChainLength ( Scope scope)

Definition at line 735 of file scopes.cc.

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

ZoneList<Declaration*>* declarations ( )
inline

Definition at line 342 of file scopes.h.

References Scope::decls_.

Referenced by HGraphBuilder::CreateGraph().

Scope * DeclarationScope ( )

Definition at line 745 of file scopes.cc.

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

Referenced by Scope::HasLazyCompilableOuterContext().

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 266 of file scopes.h.

References Scope::end_position_.

Referenced by FunctionLiteral::end_position(), Scope::GetNestedScopeChain(), and TEST().

void ForceEagerCompilation ( )
inline

Definition at line 373 of file scopes.h.

References Scope::force_eager_compilation_.

VariableDeclaration* function ( ) const
inline

Definition at line 324 of file scopes.h.

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

Referenced by ScopeInfo::Create(), and HGraphBuilder::CreateGraph().

void GetNestedScopeChain ( List< Handle< ScopeInfo > > *  chain,
int  statement_position 
)
Handle< ScopeInfo > GetScopeInfo ( )
bool HasArgumentsParameter ( )
protected

Definition at line 1187 of file scopes.cc.

References Isolate::factory(), Scope::isolate_, and Scope::params_.

Referenced by Scope::AllocateParameterLocals().

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

Definition at line 678 of file scopes.cc.

References v8::internal::NULL.

Referenced by Scope::HasTrivialOuterContext().

ZoneList<Scope*>* inner_scopes ( )
inline

Definition at line 345 of file scopes.h.

References Scope::inner_scopes_.

Referenced by TEST().

bool inside_with ( ) const
inline

Definition at line 306 of file scopes.h.

References Scope::scope_inside_with_.

Referenced by CompilationInfo::DisableOptimization().

Interface* interface ( ) const
inline

Definition at line 351 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 279 of file scopes.h.

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

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

bool is_classic_mode ( ) const
inline
bool is_eval_scope ( ) const
inline
bool is_extended_mode ( ) const
inline

Definition at line 289 of file scopes.h.

References v8::internal::EXTENDED_MODE, and Scope::language_mode().

Referenced by Scope::CheckAssignmentToConst().

bool is_strict_or_extended_eval_scope ( ) const
inline

Definition at line 292 of file scopes.h.

References Scope::is_classic_mode(), and Scope::is_eval_scope().

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

Definition at line 405 of file scopes.h.

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

Variable * Lookup ( Handle< String name)

Definition at line 460 of file scopes.cc.

References v8::internal::NULL.

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

Definition at line 167 of file scopes.h.

References Scope::already_resolved(), ASSERT, Scope::interface(), and Scope::unresolved_.

int num_heap_slots ( ) const
inline

Definition at line 367 of file scopes.h.

References Scope::num_heap_slots_.

Referenced by Scope::ContextLocalCount(), and ScopeInfo::Create().

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

Definition at line 363 of file scopes.h.

References Scope::num_var_or_const_.

Referenced by Scope::FinalizeBlockScope().

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

Definition at line 331 of file scopes.h.

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

Referenced by ScopeInfo::Create().

Variable* receiver ( )
inline

Definition at line 320 of file scopes.h.

References Scope::receiver_.

Referenced by Scope::Initialize().

void RecordEvalCall ( )
inline

Definition at line 233 of file scopes.h.

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

void RecordWithStatement ( )
inline

Definition at line 230 of file scopes.h.

References Scope::scope_contains_with_.

Referenced by Scope::DeserializeScopeChain().

void RemoveUnresolved ( VariableProxy var)

Definition at line 506 of file scopes.cc.

References Scope::unresolved_.

bool ResolveVariablesRecursively ( CompilationInfo info,
AstNodeFactory< AstNullVisitor > *  factory 
)
protected
void set_end_position ( int  statement_pos)
inline

Definition at line 267 of file scopes.h.

References Scope::end_position_.

void set_start_position ( int  statement_pos)
inline

Definition at line 263 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 SetLanguageMode ( LanguageMode  language_mode)
inline

Definition at line 236 of file scopes.h.

References Scope::language_mode(), and Scope::language_mode_.

void SetScopeName ( Handle< String scope_name)
inline

Definition at line 111 of file scopes.h.

References Scope::scope_name_.

int StackLocalCount ( ) const
int start_position ( ) const
inline

Definition at line 262 of file scopes.h.

References Scope::start_position_.

Referenced by Scope::GetNestedScopeChain(), FunctionLiteral::start_position(), and TEST().

ScopeType type ( ) const
inline

Definition at line 314 of file scopes.h.

References Scope::type_.

Referenced by ScopeInfo::Create().

void VisitIllegalRedeclaration ( AstVisitor *  visitor)

Friends And Related Function Documentation

friend class ParserFactory
friend

Definition at line 424 of file scopes.h.

Field Documentation

bool already_resolved_
protected

Definition at line 488 of file scopes.h.

Referenced by Scope::already_resolved().

Variable* arguments_
protected

Definition at line 459 of file scopes.h.

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

ZoneList<Declaration*> decls_
protected
DynamicScopePart* dynamics_
protected

Definition at line 449 of file scopes.h.

Referenced by Scope::NonLocal().

int end_position_
protected

Definition at line 479 of file scopes.h.

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

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

Definition at line 461 of file scopes.h.

Referenced by Scope::AllocateModules(), Scope::interface(), and Scope::LinkModules().

LanguageMode language_mode_
protected

Definition at line 476 of file scopes.h.

Referenced by Scope::language_mode(), and Scope::SetLanguageMode().

int num_heap_slots_
protected
int num_stack_slots_
protected
int num_var_or_const_
protected

Definition at line 491 of file scopes.h.

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

bool outer_scope_calls_non_strict_eval_
protected
Variable* receiver_
protected

Definition at line 455 of file scopes.h.

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

bool scope_contains_with_
protected
Handle<ScopeInfo> scope_info_
protected
bool scope_inside_with_
protected
Handle<String> scope_name_
protected

Definition at line 436 of file scopes.h.

Referenced by Scope::SetScopeName().

int start_position_
protected

Definition at line 478 of file scopes.h.

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


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