Lines Matching defs:Scope
66 Scope* scope,
78 p->value = new(zone()) Variable(scope,
103 // Implementation of Scope
105 Scope::Scope(Scope* outer_scope, ScopeType scope_type, Zone* zone)
120 // The outermost scope must be a global scope.
126 Scope::Scope(Scope* inner_scope,
152 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone)
178 void Scope::SetDefaults(ScopeType scope_type,
179 Scope* outer_scope,
192 // Inherit the strict mode from the parent scope.
215 Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope,
217 // Reconstruct the outer scope chain from a closure's context chain.
218 Scope* current_scope = NULL;
219 Scope* innermost_scope = NULL;
223 Scope* with_scope = new(zone) Scope(current_scope,
230 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) {
235 current_scope = new(zone) Scope(current_scope,
241 current_scope = new(zone) Scope(current_scope,
247 current_scope = new(zone) Scope(current_scope,
253 current_scope = new(zone) Scope(current_scope,
260 current_scope = new(zone) Scope(
279 bool Scope::Analyze(CompilationInfo* info) {
281 Scope* scope = info->function()->scope();
282 Scope* top = scope;
284 // Traverse the scope tree up to the first unresolved scope or the global
285 // scope and start scope resolution and variable allocation from that scope.
302 scope->Print();
311 info->SetScope(scope);
316 void Scope::Initialize() {
319 // Add this scope as a new inner scope of the outer scope.
328 // Declare and allocate receiver (even for the global scope, and even
330 // NOTE: When loading parameters in the global scope, we must take
364 Scope* Scope::FinalizeBlockScope() {
372 // Remove this scope from outer scope.
394 Variable* Scope::LocalLookup(Handle<String> name) {
399 // If we have a serialized scope info, we might find the variable there.
425 Variable* Scope::LookupFunctionVar(Handle<String> name,
430 // If we are backed by a scope info, try to lookup the variable there.
449 Variable* Scope::Lookup(Handle<String> name) {
450 for (Scope* scope = this;
451 scope != NULL;
452 scope = scope->outer_scope()) {
453 Variable* var = scope->LocalLookup(name);
460 void Scope::DeclareParameter(Handle<String> name, VariableMode mode) {
469 Variable* Scope::DeclareLocal(Handle<String> name,
484 Variable* Scope::DeclareDynamicGlobal(Handle<String> name) {
495 void Scope::RemoveUnresolved(VariableProxy* var) {
507 Variable* Scope::NewInternal(Handle<String> name) {
520 Variable* Scope::NewTemporary(Handle<String> name) {
533 void Scope::AddDeclaration(Declaration* declaration) {
538 void Scope::SetIllegalRedeclaration(Expression* expression) {
547 void Scope::VisitIllegalRedeclaration(AstVisitor* visitor) {
553 Declaration* Scope::CheckConflictingVarDeclarations() {
560 // Iterate through all scopes until and including the declaration scope.
561 Scope* previous = NULL;
562 Scope* current = decl->scope();
592 void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
644 bool Scope::AllocateVariables(CompilationInfo* info,
646 // 1) Propagate scope information.
671 bool Scope::HasTrivialContext() const {
672 // A function scope has a trivial context if it always is the global
674 // there is anything that makes this scope non-trivial; otherwise we
676 for (const Scope* scope = this; scope != NULL; scope = scope->outer_scope_) {
677 if (scope->is_eval_scope()) return false;
678 if (scope->scope_inside_with_) return false;
679 if (scope->num_heap_slots_ > 0) return false;
685 bool Scope::HasTrivialOuterContext() const {
686 Scope* outer = outer_scope_;
689 // scope may be inside a 'with' statement in which case the outer context
690 // for this scope is not trivial.
695 bool Scope::HasLazyCompilableOuterContext() const {
696 Scope* outer = outer_scope_;
698 // We have to prevent lazy compilation if this scope is inside a with scope
700 // declaration scopes may become invisible during scope info deserialization.
703 for (const Scope* scope = outer; scope != NULL; scope = scope->outer_scope_) {
704 if (scope->is_with_scope() && !found_non_trivial_declarations) return false;
705 if (scope->is_declaration_scope() && scope->num_heap_slots() > 0) {
713 bool Scope::AllowsLazyCompilation() const {
718 bool Scope::AllowsLazyCompilationWithoutContext() const {
723 int Scope::ContextChainLength(Scope* scope) {
725 for (Scope* s = this; s != scope; s = s->outer_scope_) {
726 ASSERT(s != NULL); // scope must be in the scope chain
736 Scope* Scope::GlobalScope() {
737 Scope* scope = this;
738 while (!scope->is_global_scope()) {
739 scope = scope->outer_scope();
741 return scope;
745 Scope* Scope::DeclarationScope() {
746 Scope* scope = this;
747 while (!scope->is_declaration_scope()) {
748 scope = scope->outer_scope();
750 return scope;
754 Handle<ScopeInfo> Scope::GetScopeInfo() {
762 void Scope::GetNestedScopeChain(
768 Scope* scope = inner_scopes_[i];
769 int beg_pos = scope->start_position();
770 int end_pos = scope->end_position();
773 scope->GetNestedScopeChain(chain, position);
851 void Scope::Print(int n) {
881 // Scope info.
883 Indent(n1, "// scope has trivial outer context\n");
889 Indent(n1, "// strict mode scope\n");
892 Indent(n1, "// extended mode scope\n");
895 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
896 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
897 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
899 Indent(n1, "// outer scope calls 'eval' in non-strict context\n");
901 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
952 Variable* Scope::NonLocal(Handle<String> name, VariableMode mode) {
973 Variable* Scope::LookupRecursive(Handle<String> name,
978 // Short-cut: if the scope is deserialized from a scope info, variable
984 // Try to find the variable in this scope.
988 // this scope which introduces the same variable again, the resulting
1013 // The current scope is a with scope, so the variable binding can not be
1015 // in the outer scope anyway, because if a binding exists in an outer scope,
1017 // from inside of an inner with scope (the property may not be in the 'with'
1022 // A variable binding may have been found in an outer scope, but the current
1023 // scope makes a non-strict 'eval' call, so the found variable may not be
1036 bool Scope::ResolveVariable(CompilationInfo* info,
1056 // scope which was not promoted to a context, this can happen if we use
1075 // No binding has been found. But some scope makes a
1141 bool Scope::ResolveVariablesRecursively(
1146 // Resolve unresolved variables for this scope.
1161 bool Scope::PropagateScopeInfo(bool outer_scope_calls_non_strict_eval ) {
1169 Scope* inner_scope = inner_scopes_[i];
1182 bool Scope::MustAllocate(Variable* var) {
1202 bool Scope::MustAllocateInContext(Variable* var) {
1203 // If var is accessed from an inner scope, or if there is a possibility
1204 // that it might be accessed from the current or an inner scope (through
1208 // Exceptions: If the scope as a whole has forced context allocation, all
1224 bool Scope::HasArgumentsParameter() {
1235 void Scope::AllocateStackSlot(Variable* var) {
1240 void Scope::AllocateHeapSlot(Variable* var) {
1245 void Scope::AllocateParameterLocals() {
1278 ASSERT(var->scope() == this);
1301 void Scope::AllocateNonParameterLocal(Variable* var) {
1302 ASSERT(var->scope() == this);
1315 void Scope::AllocateNonParameterLocals() {
1341 // ScopeInfo::ScopeInfo(FunctionScope* scope) constructor).
1348 void Scope::AllocateVariablesRecursively() {
1354 // If scope is already resolved, we still need to allocate
1361 // Allocate variables for this scope.
1366 // Force allocation of a context for this scope if necessary. For a 'with'
1367 // scope and for a function scope that makes an 'eval' call we need a context,
1368 // even if no local variables were statically allocated in the scope.
1384 void Scope::AllocateModulesRecursively(Scope* host_scope) {
1396 Scope* inner_scope = inner_scopes_.at(i);
1402 int Scope::StackLocalCount() const {
1408 int Scope::ContextLocalCount() const {