| Index: src/contexts.cc
|
| ===================================================================
|
| --- src/contexts.cc (revision 1344)
|
| +++ src/contexts.cc (working copy)
|
| @@ -198,6 +198,42 @@
|
| }
|
|
|
|
|
| +bool Context::GlobalIfNotShadowedByEval(Handle<String> name) {
|
| + Context* context = this;
|
| +
|
| + // Check that there is no local with the given name in contexts
|
| + // before the global context and check that there are no context
|
| + // extension objects (conservative check for with statements).
|
| + while (!context->IsGlobalContext()) {
|
| + // Check if the context is a potentially a with context.
|
| + if (context->has_extension()) return false;
|
| +
|
| + // Not a with context so it must be a function context.
|
| + ASSERT(context->is_function_context());
|
| +
|
| + // Check non-parameter locals.
|
| + Handle<Code> code(context->closure()->code());
|
| + Variable::Mode mode;
|
| + int index = ScopeInfo<>::ContextSlotIndex(*code, *name, &mode);
|
| + ASSERT(index < 0 || index >= MIN_CONTEXT_SLOTS);
|
| + if (index >= 0) return false;
|
| +
|
| + // Check parameter locals.
|
| + int param_index = ScopeInfo<>::ParameterIndex(*code, *name);
|
| + if (param_index >= 0) return false;
|
| +
|
| + // Check context only holding the function name variable.
|
| + index = ScopeInfo<>::FunctionContextSlotIndex(*code, *name);
|
| + if (index >= 0) return false;
|
| + context = Context::cast(context->closure()->context());
|
| + }
|
| +
|
| + // No local or potential with statement found so the variable is
|
| + // global unless it is shadowed by an eval-introduced variable.
|
| + return true;
|
| +}
|
| +
|
| +
|
| #ifdef DEBUG
|
| bool Context::IsBootstrappingOrContext(Object* object) {
|
| // During bootstrapping we allow all objects to pass as
|
|
|