Home | History | Annotate | Download | only in src

Lines Matching refs:scope

85 Variable* VariableMap::Declare(Scope* scope,
94 p->value = new Variable(scope, name, mode, is_valid_lhs, kind);
112 // Implementation of Scope
116 Scope::Scope(Type type)
128 Scope::Scope(Scope* outer_scope, Type type)
137 // eval scopes (by walking the stack and reading the scope info).
145 Scope::Scope(Scope* inner_scope, Handle<SerializedScopeInfo> scope_info)
161 // This scope's arguments shadow (if present) is context-allocated if an inner
162 // scope accesses this one's parameters. Allocate the arguments_shadow_
184 void Scope::SetDefaults(Type type,
185 Scope* outer_scope,
199 // Inherit the strict mode from the parent scope.
212 Scope* Scope::DeserializeScopeChain(CompilationInfo* info,
213 Scope* global_scope) {
215 // If we have a serialized scope info, reuse it.
216 Scope* innermost_scope = NULL;
217 Scope* scope = NULL;
226 scope = new Scope(scope, scope_info);
227 if (innermost_scope == NULL) innermost_scope = scope;
234 global_scope->AddInnerScope(scope);
241 bool Scope::Analyze(CompilationInfo* info) {
243 Scope* top = info->function()->scope();
252 info->function()->scope()->Print();
256 info->SetScope(info->function()->scope());
261 void Scope::Initialize(bool inside_with) {
264 // Add this scope as a new inner scope of the outer scope.
273 // Declare and allocate receiver (even for the global scope, and even
275 // NOTE: When loading parameters in the global scope, we must take
296 Variable* Scope::LocalLookup(Handle<String> name) {
301 // If the scope is resolved, we can find a variable in serialized scope info.
303 // We should never lookup 'arguments' in this scope
304 // as it is implicitly present in any scope.
350 Variable* Scope::Lookup(Handle<String> name) {
351 for (Scope* scope = this;
352 scope != NULL;
353 scope = scope->outer_scope()) {
354 Variable* var = scope->LocalLookup(name);
361 Variable* Scope::DeclareFunctionVar(Handle<String> name) {
368 Variable* Scope::DeclareLocal(Handle<String> name,
383 Variable* Scope::DeclareGlobal(Handle<String> name) {
390 void Scope::AddParameter(Variable* var) {
397 VariableProxy* Scope::NewUnresolved(Handle<String> name,
410 void Scope::RemoveUnresolved(VariableProxy* var) {
422 Variable* Scope::NewTemporary(Handle<String> name) {
431 void Scope::AddDeclaration(Declaration* declaration) {
436 void Scope::SetIllegalRedeclaration(Expression* expression) {
445 void Scope::VisitIllegalRedeclaration(AstVisitor* visitor) {
452 void Scope::CollectUsedVariables(List<Variable*, Allocator>* locals) {
453 // Collect variables in this scope.
475 template void Scope::CollectUsedVariables(
477 template void Scope::CollectUsedVariables(
479 template void Scope::CollectUsedVariables(
483 void Scope::AllocateVariables(Handle<Context> context) {
486 // 1) Propagate scope information.
487 // If we are in an eval scope, we may have other outer scopes about
496 Scope* global_scope = NULL;
505 bool Scope::AllowsLazyCompilation() const {
510 bool Scope::HasTrivialContext() const {
511 // A function scope has a trivial context if it always is the global
513 // there is anything that makes this scope non-trivial; otherwise we
515 for (const Scope* scope = this; scope != NULL; scope = scope->outer_scope_) {
516 if (scope->is_eval_scope()) return false;
517 if (scope->scope_inside_with_) return false;
518 if (scope->num_heap_slots_ > 0) return false;
524 bool Scope::HasTrivialOuterContext() const {
525 Scope* outer = outer_scope_;
528 // scope may be inside a 'with' statement in which case the outer context
529 // for this scope is not trivial.
534 int Scope::ContextChainLength(Scope* scope) {
536 for (Scope* s = this; s != scope; s = s->outer_scope_) {
537 ASSERT(s != NULL); // scope must be in the scope chain
545 static const char* Header(Scope::Type type) {
547 case Scope::EVAL_SCOPE: return "eval";
548 case Scope::FUNCTION_SCOPE: return "function";
549 case Scope::GLOBAL_SCOPE: return "global";
577 if (var->is_accessed_from_inner_scope()) PrintF("inner scope access");
591 void Scope::Print(int n) {
621 // Scope info.
623 Indent(n1, "// scope has trivial outer context\n");
625 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
626 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
627 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
628 if (outer_scope_calls_eval_) Indent(n1, "// outer scope calls 'eval'\n");
629 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
631 Indent(n1, "// outer scope is 'eval' scope\n");
673 Variable* Scope::NonLocal(Handle<String> name, Variable::Mode mode) {
687 // Lookup a variable starting with this scope. The result is either
688 // the statically resolved variable belonging to an outer scope, or
693 Variable* Scope::LookupRecursive(Handle<String> name,
696 // If we find a variable, but the current scope calls 'eval', the found
702 // Try to find the variable in this scope.
707 // (Even if there is an 'eval' in this scope which introduces the
718 // This lookup corresponds to a lookup in the "intermediate" scope sitting
719 // between this scope and the outer scope. (ECMA-262, 3rd., requires that
720 // the name of named function literal is kept in an intermediate scope
721 // in between this scope and the next outer scope.)
727 // We may have found a variable in an outer scope. However, if
728 // the current scope is inside a 'with', the actual variable may
742 // If this is a lookup from an inner scope, mark the variable.
759 void Scope::ResolveVariable(Scope* global_scope,
778 // inner scope (the property may not be in the 'with' object).
786 // if we are in the global scope (we know already that we
790 // or we don't know about the outer scope (because we are
791 // in an eval scope).
814 // scope information that we can use to determine if the
838 void Scope::ResolveVariablesRecursively(Scope* global_scope,
842 // Resolve unresolved variables for this scope.
854 bool Scope::PropagateScopeInfo(bool outer_scope_calls_eval,
867 Scope* inner_scope = inner_scopes_[i];
880 bool Scope::MustAllocate(Variable* var) {
895 bool Scope::MustAllocateInContext(Variable* var) {
896 // If var is accessed from an inner scope, or if there is a
898 // scope (through an eval() call), it must be allocated in the
909 bool Scope::HasArgumentsParameter() {
918 void Scope::AllocateStackSlot(Variable* var) {
923 void Scope::AllocateHeapSlot(Variable* var) {
928 void Scope::AllocateParameterLocals() {
995 ASSERT(var->scope() == this);
1021 ASSERT(var->scope() == this);
1048 void Scope::AllocateNonParameterLocal(Variable* var) {
1049 ASSERT(var->scope() == this);
1063 void Scope::AllocateNonParameterLocals() {
1079 // ScopeInfo::ScopeInfo(FunctionScope* scope) constructor).
1086 void Scope::AllocateVariablesRecursively() {
1092 // If scope is already resolved, we still need to allocate
1099 // Allocate variables for this scope.
1107 // The context for the eval() call or 'with' statement in this scope.
1108 // Unless we are in the global or an eval scope, we need a local
1111 // not in an inner scope, the scope is provided from the outside.