Lines Matching refs:scope
43 Scope* scope,
55 p->value = new(zone()) Variable(scope,
80 // Implementation of Scope
82 Scope::Scope(Scope* outer_scope, ScopeType scope_type, Zone* zone)
97 // The outermost scope must be a global scope.
103 Scope::Scope(Scope* inner_scope,
129 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone)
155 void Scope::SetDefaults(ScopeType scope_type,
156 Scope* outer_scope,
169 // Inherit the strict mode from the parent scope.
191 Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope,
193 // Reconstruct the outer scope chain from a closure's context chain.
194 Scope* current_scope = NULL;
195 Scope* innermost_scope = NULL;
199 Scope* with_scope = new(zone) Scope(current_scope,
206 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) {
211 current_scope = new(zone) Scope(current_scope,
217 current_scope = new(zone) Scope(current_scope,
223 current_scope = new(zone) Scope(current_scope,
229 current_scope = new(zone) Scope(current_scope,
236 current_scope = new(zone) Scope(
255 bool Scope::Analyze(CompilationInfo* info) {
257 Scope* scope = info->function()->scope();
258 Scope* top = scope;
260 // Traverse the scope tree up to the first unresolved scope or the global
261 // scope and start scope resolution and variable allocation from that scope.
277 scope->Print();
286 info->PrepareForCompilation(scope);
291 void Scope::Initialize() {
294 // Add this scope as a new inner scope of the outer scope.
303 // Declare and allocate receiver (even for the global scope, and even
305 // NOTE: When loading parameters in the global scope, we must take
339 Scope* Scope::FinalizeBlockScope() {
347 // Remove this scope from outer scope.
369 Variable* Scope::LookupLocal(Handle<String> name) {
374 // If we have a serialized scope info, we might find the variable there.
400 Variable* Scope::LookupFunctionVar(Handle<String> name,
405 // If we are backed by a scope info, try to lookup the variable there.
424 Variable* Scope::Lookup(Handle<String> name) {
425 for (Scope* scope = this;
426 scope != NULL;
427 scope = scope->outer_scope()) {
428 Variable* var = scope->LookupLocal(name);
435 void Scope::DeclareParameter(Handle<String> name, VariableMode mode) {
444 Variable* Scope::DeclareLocal(Handle<String> name,
459 Variable* Scope::DeclareDynamicGlobal(Handle<String> name) {
470 void Scope::RemoveUnresolved(VariableProxy* var) {
482 Variable* Scope::NewInternal(Handle<String> name) {
495 Variable* Scope::NewTemporary(Handle<String> name) {
508 void Scope::AddDeclaration(Declaration* declaration) {
513 void Scope::SetIllegalRedeclaration(Expression* expression) {
522 void Scope::VisitIllegalRedeclaration(AstVisitor* visitor) {
528 Declaration* Scope::CheckConflictingVarDeclarations() {
535 // Iterate through all scopes until and including the declaration scope.
536 Scope* previous = NULL;
537 Scope* current = decl->scope();
567 void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
619 bool Scope::AllocateVariables(CompilationInfo* info,
621 // 1) Propagate scope information.
646 bool Scope::HasTrivialContext() const {
647 // A function scope has a trivial context if it always is the global
649 // there is anything that makes this scope non-trivial; otherwise we
651 for (const Scope* scope = this; scope != NULL; scope = scope->outer_scope_) {
652 if (scope->is_eval_scope()) return false;
653 if (scope->scope_inside_with_) return false;
654 if (scope->num_heap_slots_ > 0) return false;
660 bool Scope::HasTrivialOuterContext() const {
661 Scope* outer = outer_scope_;
664 // scope may be inside a 'with' statement in which case the outer context
665 // for this scope is not trivial.
670 bool Scope::HasLazyCompilableOuterContext() const {
671 Scope* outer = outer_scope_;
673 // We have to prevent lazy compilation if this scope is inside a with scope
675 // declaration scopes may become invisible during scope info deserialization.
678 for (const Scope* scope = outer; scope != NULL; scope = scope->outer_scope_) {
679 if (scope->is_with_scope() && !found_non_trivial_declarations) return false;
680 if (scope->is_declaration_scope() && scope->num_heap_slots() > 0) {
688 bool Scope::AllowsLazyCompilation() const {
693 bool Scope::AllowsLazyCompilationWithoutContext() const {
698 int Scope::ContextChainLength(Scope* scope) {
700 for (Scope* s = this; s != scope; s = s->outer_scope_) {
701 ASSERT(s != NULL); // scope must be in the scope chain
711 Scope* Scope::GlobalScope() {
712 Scope* scope = this;
713 while (!scope->is_global_scope()) {
714 scope = scope->outer_scope();
716 return scope;
720 Scope* Scope::DeclarationScope() {
721 Scope* scope = this;
722 while (!scope->is_declaration_scope()) {
723 scope = scope->outer_scope();
725 return scope;
729 Handle<ScopeInfo> Scope::GetScopeInfo() {
737 void Scope::GetNestedScopeChain(
743 Scope* scope = inner_scopes_[i];
744 int beg_pos = scope->start_position();
745 int end_pos = scope->end_position();
748 scope->GetNestedScopeChain(chain, position);
826 void Scope::Print(int n) {
856 // Scope info.
858 Indent(n1, "// scope has trivial outer context\n");
861 Indent(n1, "// strict mode scope\n");
863 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
864 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
865 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
867 Indent(n1, "// outer scope calls 'eval' in sloppy context\n");
869 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
920 Variable* Scope::NonLocal(Handle<String> name, VariableMode mode) {
941 Variable* Scope::LookupRecursive(Handle<String> name,
946 // Short-cut: if the scope is deserialized from a scope info, variable
952 // Try to find the variable in this scope.
956 // this scope which introduces the same variable again, the resulting
981 // The current scope is a with scope, so the variable binding can not be
983 // in the outer scope anyway, because if a binding exists in an outer scope,
985 // from inside of an inner with scope (the property may not be in the 'with'
990 // A variable binding may have been found in an outer scope, but the current
991 // scope makes a sloppy 'eval' call, so the found variable may not be
1004 bool Scope::ResolveVariable(CompilationInfo* info,
1024 // scope which was not promoted to a context, this can happen if we use
1043 // No binding has been found. But some scope makes a sloppy 'eval' call.
1108 bool Scope::ResolveVariablesRecursively(
1113 // Resolve unresolved variables for this scope.
1128 bool Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval ) {
1136 Scope* inner_scope = inner_scopes_[i];
1149 bool Scope::MustAllocate(Variable* var) {
1169 bool Scope::MustAllocateInContext(Variable* var) {
1170 // If var is accessed from an inner scope, or if there is a possibility
1171 // that it might be accessed from the current or an inner scope (through
1175 // Exceptions: If the scope as a whole has forced context allocation, all
1191 bool Scope::HasArgumentsParameter() {
1202 void Scope::AllocateStackSlot(Variable* var) {
1207 void Scope::AllocateHeapSlot(Variable* var) {
1212 void Scope::AllocateParameterLocals() {
1245 ASSERT(var->scope() == this);
1268 void Scope::AllocateNonParameterLocal(Variable* var) {
1269 ASSERT(var->scope() == this);
1282 void Scope::AllocateNonParameterLocals() {
1308 // ScopeInfo::ScopeInfo(FunctionScope* scope) constructor).
1315 void Scope::AllocateVariablesRecursively() {
1321 // If scope is already resolved, we still need to allocate
1328 // Allocate variables for this scope.
1333 // Force allocation of a context for this scope if necessary. For a 'with'
1334 // scope and for a function scope that makes an 'eval' call we need a context,
1335 // even if no local variables were statically allocated in the scope.
1351 void Scope::AllocateModulesRecursively(Scope* host_scope) {
1363 Scope* inner_scope = inner_scopes_.at(i);
1369 int Scope::StackLocalCount() const {
1375 int Scope::ContextLocalCount() const {