| Index: src/scopes.cc
|
| diff --git a/src/scopes.cc b/src/scopes.cc
|
| index d0ee8ec7f21af11758a2cb3c49dcf9f8a2aa6b18..9760550671139290a8b7a2f9444600f97bed9da6 100644
|
| --- a/src/scopes.cc
|
| +++ b/src/scopes.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2011 the V8 project authors. All rights reserved.
|
| +// Copyright 2012 the V8 project authors. All rights reserved.
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| // met:
|
| @@ -274,8 +274,11 @@ bool Scope::Analyze(CompilationInfo* info) {
|
| top = top->outer_scope();
|
| }
|
|
|
| - // Allocated the variables.
|
| - top->AllocateVariables(info->global_scope());
|
| + // Allocate the variables.
|
| + {
|
| + AstNodeFactory ast_node_factory(info->isolate());
|
| + top->AllocateVariables(info->global_scope(), &ast_node_factory);
|
| + }
|
|
|
| #ifdef DEBUG
|
| if (info->isolate()->bootstrapper()->IsActive()
|
| @@ -417,7 +420,8 @@ Variable* Scope::LocalLookup(Handle<String> name) {
|
| }
|
|
|
|
|
| -Variable* Scope::LookupFunctionVar(Handle<String> name) {
|
| +Variable* Scope::LookupFunctionVar(Handle<String> name,
|
| + AstNodeFactory* factory) {
|
| if (function_ != NULL && function_->name().is_identical_to(name)) {
|
| return function_->var();
|
| } else if (!scope_info_.is_null()) {
|
| @@ -425,7 +429,7 @@ Variable* Scope::LookupFunctionVar(Handle<String> name) {
|
| VariableMode mode;
|
| int index = scope_info_->FunctionContextSlotIndex(*name, &mode);
|
| if (index < 0) return NULL;
|
| - Variable* var = DeclareFunctionVar(name, mode);
|
| + Variable* var = DeclareFunctionVar(name, mode, factory);
|
| var->AllocateTo(Variable::CONTEXT, index);
|
| return var;
|
| } else {
|
| @@ -445,11 +449,13 @@ Variable* Scope::Lookup(Handle<String> name) {
|
| }
|
|
|
|
|
| -Variable* Scope::DeclareFunctionVar(Handle<String> name, VariableMode mode) {
|
| +Variable* Scope::DeclareFunctionVar(Handle<String> name,
|
| + VariableMode mode,
|
| + AstNodeFactory* factory) {
|
| ASSERT(is_function_scope() && function_ == NULL);
|
| Variable* function_var = new Variable(
|
| this, name, mode, true, Variable::NORMAL, kCreatedInitialized);
|
| - function_ = new(isolate_->zone()) VariableProxy(isolate_, function_var);
|
| + function_ = factory->NewVariableProxy(function_var);
|
| return function_var;
|
| }
|
|
|
| @@ -491,13 +497,14 @@ Variable* Scope::DeclareGlobal(Handle<String> name) {
|
| }
|
|
|
|
|
| -VariableProxy* Scope::NewUnresolved(Handle<String> name, int position) {
|
| +VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory,
|
| + Handle<String> name,
|
| + int position) {
|
| // Note that we must not share the unresolved variables with
|
| // the same name because they may be removed selectively via
|
| // RemoveUnresolved().
|
| ASSERT(!already_resolved());
|
| - VariableProxy* proxy = new(isolate_->zone()) VariableProxy(
|
| - isolate_, name, false, position);
|
| + VariableProxy* proxy = factory->NewVariableProxy(name, false, position);
|
| unresolved_.Add(proxy);
|
| return proxy;
|
| }
|
| @@ -625,7 +632,7 @@ void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
|
| }
|
|
|
|
|
| -void Scope::AllocateVariables(Scope* global_scope) {
|
| +void Scope::AllocateVariables(Scope* global_scope, AstNodeFactory* factory) {
|
| // 1) Propagate scope information.
|
| bool outer_scope_calls_non_strict_eval = false;
|
| if (outer_scope_ != NULL) {
|
| @@ -636,7 +643,7 @@ void Scope::AllocateVariables(Scope* global_scope) {
|
| PropagateScopeInfo(outer_scope_calls_non_strict_eval);
|
|
|
| // 2) Resolve variables.
|
| - ResolveVariablesRecursively(global_scope);
|
| + ResolveVariablesRecursively(global_scope, factory);
|
|
|
| // 3) Allocate variables.
|
| AllocateVariablesRecursively();
|
| @@ -899,7 +906,8 @@ Variable* Scope::NonLocal(Handle<String> name, VariableMode mode) {
|
|
|
|
|
| Variable* Scope::LookupRecursive(Handle<String> name,
|
| - BindingKind* binding_kind) {
|
| + BindingKind* binding_kind,
|
| + AstNodeFactory* factory) {
|
| ASSERT(binding_kind != NULL);
|
| // Try to find the variable in this scope.
|
| Variable* var = LocalLookup(name);
|
| @@ -916,11 +924,11 @@ Variable* Scope::LookupRecursive(Handle<String> name,
|
| // if any. We can do this for all scopes, since the function variable is
|
| // only present - if at all - for function scopes.
|
| *binding_kind = UNBOUND;
|
| - var = LookupFunctionVar(name);
|
| + var = LookupFunctionVar(name, factory);
|
| if (var != NULL) {
|
| *binding_kind = BOUND;
|
| } else if (outer_scope_ != NULL) {
|
| - var = outer_scope_->LookupRecursive(name, binding_kind);
|
| + var = outer_scope_->LookupRecursive(name, binding_kind, factory);
|
| if (*binding_kind == BOUND && (is_function_scope() || is_with_scope())) {
|
| var->ForceContextAllocation();
|
| }
|
| @@ -953,7 +961,8 @@ Variable* Scope::LookupRecursive(Handle<String> name,
|
|
|
|
|
| void Scope::ResolveVariable(Scope* global_scope,
|
| - VariableProxy* proxy) {
|
| + VariableProxy* proxy,
|
| + AstNodeFactory* factory) {
|
| ASSERT(global_scope == NULL || global_scope->is_global_scope());
|
|
|
| // If the proxy is already resolved there's nothing to do
|
| @@ -962,7 +971,7 @@ void Scope::ResolveVariable(Scope* global_scope,
|
|
|
| // Otherwise, try to resolve the variable.
|
| BindingKind binding_kind;
|
| - Variable* var = LookupRecursive(proxy->name(), &binding_kind);
|
| + Variable* var = LookupRecursive(proxy->name(), &binding_kind, factory);
|
| switch (binding_kind) {
|
| case BOUND:
|
| // We found a variable binding.
|
| @@ -1003,17 +1012,18 @@ void Scope::ResolveVariable(Scope* global_scope,
|
| }
|
|
|
|
|
| -void Scope::ResolveVariablesRecursively(Scope* global_scope) {
|
| +void Scope::ResolveVariablesRecursively(Scope* global_scope,
|
| + AstNodeFactory* factory) {
|
| ASSERT(global_scope == NULL || global_scope->is_global_scope());
|
|
|
| // Resolve unresolved variables for this scope.
|
| for (int i = 0; i < unresolved_.length(); i++) {
|
| - ResolveVariable(global_scope, unresolved_[i]);
|
| + ResolveVariable(global_scope, unresolved_[i], factory);
|
| }
|
|
|
| // Resolve unresolved variables for inner scopes.
|
| for (int i = 0; i < inner_scopes_.length(); i++) {
|
| - inner_scopes_[i]->ResolveVariablesRecursively(global_scope);
|
| + inner_scopes_[i]->ResolveVariablesRecursively(global_scope, factory);
|
| }
|
| }
|
|
|
|
|