}
-// Copy all the context locals into an object used to materialize a scope.
-static bool CopyContextLocalsToScopeObject(
- Isolate* isolate,
- Handle<ScopeInfo> scope_info,
- Handle<Context> context,
- Handle<JSObject> scope_object) {
- // Fill all context locals to the context extension.
- for (int i = 0; i < scope_info->ContextLocalCount(); i++) {
- VariableMode mode;
- InitializationFlag init_flag;
- int context_index = scope_info->ContextSlotIndex(
- scope_info->ContextLocalName(i), &mode, &init_flag);
-
- RETURN_IF_EMPTY_HANDLE_VALUE(
- isolate,
- SetProperty(isolate,
- scope_object,
- Handle<String>(scope_info->ContextLocalName(i)),
- Handle<Object>(context->get(context_index), isolate),
- NONE,
- kNonStrictMode),
- false);
- }
-
- return true;
-}
-
-
// Create a plain JSObject which materializes the local scope for the specified
// frame.
static Handle<JSObject> MaterializeLocalScopeWithFrameInspector(
// Third fill all context locals.
Handle<Context> frame_context(Context::cast(frame->context()));
Handle<Context> function_context(frame_context->declaration_context());
- if (!CopyContextLocalsToScopeObject(
- isolate, scope_info, function_context, local_scope)) {
+ if (!scope_info->CopyContextLocalsToScopeObject(
+ isolate, function_context, local_scope)) {
return Handle<JSObject>();
}
isolate->factory()->NewJSObject(isolate->object_function());
// Fill all context locals to the context extension.
- if (!CopyContextLocalsToScopeObject(
- isolate, scope_info, context, closure_scope)) {
+ if (!scope_info->CopyContextLocalsToScopeObject(
+ isolate, context, closure_scope)) {
return Handle<JSObject>();
}
isolate->factory()->NewJSObject(isolate->object_function());
// Fill all context locals.
- if (!CopyContextLocalsToScopeObject(
- isolate, scope_info, context, block_scope)) {
+ if (!scope_info->CopyContextLocalsToScopeObject(
+ isolate, context, block_scope)) {
return Handle<JSObject>();
}
isolate->factory()->NewJSObject(isolate->object_function());
// Fill all context locals.
- if (!CopyContextLocalsToScopeObject(
- isolate, scope_info, context, module_scope)) {
+ if (!scope_info->CopyContextLocalsToScopeObject(
+ isolate, context, module_scope)) {
return Handle<JSObject>();
}
}
+bool ScopeInfo::CopyContextLocalsToScopeObject(
+ Isolate* isolate,
+ Handle<Context> context,
+ Handle<JSObject> scope_object) {
+ // Fill all context locals to the context extension.
+ int start = ContextLocalNameEntriesIndex();
+ int end = start + ContextLocalCount();
+ for (int i = start; i < end; ++i) {
+ int context_index = Context::MIN_CONTEXT_SLOTS + i - start;
+ RETURN_IF_EMPTY_HANDLE_VALUE(
+ isolate,
+ SetProperty(isolate,
+ scope_object,
+ Handle<String>(String::cast(get(i))),
+ Handle<Object>(context->get(context_index), isolate),
+ ::NONE,
+ kNonStrictMode),
+ false);
+ }
+ return true;
+}
+
+
int ScopeInfo::ParameterEntriesIndex() {
ASSERT(length() > 0);
return kVariablePartIndex;