| Index: src/ast/scopes.cc
|
| diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
|
| index 1eb5b66a9377df597dca77325581b715479281c1..5817b13e763307dce041f172ecfdee4b322ccfed 100644
|
| --- a/src/ast/scopes.cc
|
| +++ b/src/ast/scopes.cc
|
| @@ -308,14 +308,10 @@ bool Scope::Analyze(ParseInfo* info) {
|
| }
|
|
|
| #ifdef DEBUG
|
| - bool native = info->isolate()->bootstrapper()->IsActive();
|
| - if (!info->shared_info().is_null()) {
|
| - Object* script = info->shared_info()->script();
|
| - native = script->IsScript() &&
|
| - Script::cast(script)->type() == Script::TYPE_NATIVE;
|
| + if (info->script_is_native() ? FLAG_print_builtin_scopes
|
| + : FLAG_print_scopes) {
|
| + scope->Print();
|
| }
|
| -
|
| - if (native ? FLAG_print_builtin_scopes : FLAG_print_scopes) scope->Print();
|
| #endif
|
|
|
| info->set_scope(scope);
|
| @@ -1161,6 +1157,22 @@ bool Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy,
|
| // Otherwise, try to resolve the variable.
|
| BindingKind binding_kind;
|
| Variable* var = LookupRecursive(proxy, &binding_kind, factory);
|
| +
|
| +#ifdef DEBUG
|
| + if (info->script_is_native()) {
|
| + // To avoid polluting the global object in native scripts
|
| + // - Variables must not be allocated to the global scope.
|
| + CHECK_NOT_NULL(outer_scope());
|
| + // - Variables must be bound locally or unallocated.
|
| + CHECK_EQ(BOUND, binding_kind);
|
| + VariableLocation location = var->location();
|
| + CHECK(location == VariableLocation::LOCAL ||
|
| + location == VariableLocation::CONTEXT ||
|
| + location == VariableLocation::PARAMETER ||
|
| + location == VariableLocation::UNALLOCATED);
|
| + }
|
| +#endif
|
| +
|
| switch (binding_kind) {
|
| case BOUND:
|
| // We found a variable binding.
|
|
|