Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: src/contexts.cc

Issue 7549008: Preliminary code for block scopes and block contexts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Small fix: set harmony flag properly Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/contexts.h ('k') | src/d8.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/contexts.cc
diff --git a/src/contexts.cc b/src/contexts.cc
index d066d347692931b887a1f767828293a0c2ab5d19..72a5ae4d6077fab4a067c57553f7348eeeb8bfa4 100644
--- a/src/contexts.cc
+++ b/src/contexts.cc
@@ -109,7 +109,7 @@ Handle<Object> Context::Lookup(Handle<String> name,
}
// Check extension/with/global object.
- if (context->has_extension()) {
+ if (!context->IsBlockContext() && context->has_extension()) {
if (context->IsCatchContext()) {
// Catch contexts have the variable name in the extension slot.
if (name->Equals(String::cast(context->extension()))) {
@@ -121,6 +121,9 @@ Handle<Object> Context::Lookup(Handle<String> name,
return context;
}
} else {
+ ASSERT(context->IsGlobalContext() ||
+ context->IsFunctionContext() ||
+ context->IsWithContext());
// Global, function, and with contexts may have an object in the
// extension slot.
Handle<JSObject> extension(JSObject::cast(context->extension()),
@@ -145,11 +148,20 @@ Handle<Object> Context::Lookup(Handle<String> name,
}
}
- // Only functions can have locals, parameters, and a function name.
- if (context->IsFunctionContext()) {
+ // Check serialized scope information of functions and blocks. Only
+ // functions can have parameters, and a function name.
+ if (context->IsFunctionContext() || context->IsBlockContext()) {
// We may have context-local slots. Check locals in the context.
- Handle<SerializedScopeInfo> scope_info(
- context->closure()->shared()->scope_info(), isolate);
+ Handle<SerializedScopeInfo> scope_info;
+ if (context->IsFunctionContext()) {
+ scope_info = Handle<SerializedScopeInfo>(
+ context->closure()->shared()->scope_info(), isolate);
+ } else {
+ ASSERT(context->IsBlockContext());
+ scope_info = Handle<SerializedScopeInfo>(
+ SerializedScopeInfo::cast(context->extension()), isolate);
+ }
+
Variable::Mode mode;
int index = scope_info->ContextSlotIndex(*name, &mode);
ASSERT(index < 0 || index >= MIN_CONTEXT_SLOTS);
« no previous file with comments | « src/contexts.h ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698