Chromium Code Reviews| Index: src/contexts.cc |
| diff --git a/src/contexts.cc b/src/contexts.cc |
| index 0c356c1c71139a50a2f1bc2df5a981ef5b6b635c..c590d02267d9b8ed8ebeef94f452e53834a3e852 100644 |
| --- a/src/contexts.cc |
| +++ b/src/contexts.cc |
| @@ -98,24 +98,38 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags, |
| // Check extension/with/global object. |
| if (context->has_extension()) { |
| - Handle<JSObject> extension = Handle<JSObject>(context->extension(), |
| - isolate); |
| - // Context extension objects needs to behave as if they have no |
| - // prototype. So even if we want to follow prototype chains, we |
| - // need to only do a local lookup for context extension objects. |
| - if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || |
| - extension->IsJSContextExtensionObject()) { |
| - *attributes = extension->GetLocalPropertyAttribute(*name); |
| + if (context->IsCatchContext()) { |
| + // Catch contexts have the variable name in the extension slot. |
| + if (name->Equals(String::cast(context->extension()))) { |
|
Søren Thygesen Gjesse
2011/06/14 12:23:31
Dbc. Should context perhaps have a method GetCatch
|
| + if (FLAG_trace_contexts) { |
| + PrintF("=> found in catch context\n"); |
| + } |
| + *index_ = Context::THROWN_OBJECT_INDEX; |
| + *attributes = NONE; |
| + return context; |
| + } |
| } else { |
| - *attributes = extension->GetPropertyAttribute(*name); |
| - } |
| - if (*attributes != ABSENT) { |
| - // property found |
| - if (FLAG_trace_contexts) { |
| - PrintF("=> found property in context object %p\n", |
| - reinterpret_cast<void*>(*extension)); |
| + // Global, function, and with contexts may have an object in the |
| + // extension slot. |
| + Handle<JSObject> extension(JSObject::cast(context->extension()), |
| + isolate); |
| + // Context extension objects needs to behave as if they have no |
| + // prototype. So even if we want to follow prototype chains, we |
| + // need to only do a local lookup for context extension objects. |
| + if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || |
| + extension->IsJSContextExtensionObject()) { |
| + *attributes = extension->GetLocalPropertyAttribute(*name); |
| + } else { |
| + *attributes = extension->GetPropertyAttribute(*name); |
| + } |
| + if (*attributes != ABSENT) { |
| + // property found |
| + if (FLAG_trace_contexts) { |
| + PrintF("=> found property in context object %p\n", |
| + reinterpret_cast<void*>(*extension)); |
| + } |
| + return extension; |
| } |
| - return extension; |
| } |
| } |