libraries/v8/runtime.cc
// Create a plain JSObject which materializes the closure content for the
// context.
Create a plain JSObject which materializes the closure content for the
context.
Create a plain JSObject which materializes the closure content for the context .
static Handle<JSObject> MaterializeClosure(Isolate* isolate,
                                           Handle<Context> context) {
  ASSERT(context->IsFunctionContext());
  Handle<SharedFunctionInfo> shared(context->closure()->shared());
  Handle<ScopeInfo> scope_info(shared->scope_info());
  Handle<JSObject> closure_scope =
      isolate->factory()->NewJSObject(isolate->object_function());
  if (!ScopeInfo::CopyContextLocalsToScopeObject(
          scope_info, context, closure_scope)) {
    return Handle<JSObject>();
  }
  if (context->has_extension()) {
    Handle<JSObject> ext(JSObject::cast(context->extension()));
    bool threw = false;
    Handle<FixedArray> keys =
        GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw);
    if (threw) return Handle<JSObject>();
    for (int i = 0; i < keys->length(); i++) {
      ASSERT(keys->get(i)->IsString());
      Handle<String> key(String::cast(keys->get(i)));
       RETURN_IF_EMPTY_HANDLE_VALUE(
          isolate,
          SetProperty(isolate,
                      closure_scope,
                      key,
                      GetProperty(isolate, ext, key),
                      NONE,
                      kNonStrictMode),
          Handle<JSObject>());
    }
  }
  return closure_scope;
}
static Handle < JSObject > MaterializeClosure ( Isolate * isolate , Handle < Context > context ) { ASSERT ( context -> IsFunctionContext ( ) ) ; Handle < SharedFunctionInfo > shared ( context -> closure ( ) -> shared ( ) ) ; Handle < ScopeInfo > scope_info ( shared -> scope_info ( ) ) ; Handle < JSObject > closure_scope = isolate -> factory ( ) -> NewJSObject ( isolate -> object_function ( ) ) ; if ( ! ScopeInfo :: CopyContextLocalsToScopeObject ( scope_info , context , closure_scope ) ) { return Handle < JSObject > ( ) ; } if ( context -> has_extension ( ) ) { Handle < JSObject > ext ( JSObject :: cast ( context -> extension ( ) ) ) ; bool threw = false ; Handle < FixedArray > keys = GetKeysInFixedArrayFor ( ext , INCLUDE_PROTOS , & threw ) ; if ( threw ) return Handle < JSObject > ( ) ; for ( int i = 0 ; i < keys -> length ( ) ; i ++ ) { ASSERT ( keys -> get ( i ) -> IsString ( ) ) ; Handle < String > key ( String :: cast ( keys -> get ( i ) ) ) ; RETURN_IF_EMPTY_HANDLE_VALUE ( isolate , SetProperty ( isolate , closure_scope , key , GetProperty ( isolate , ext , key ) , NONE , kNonStrictMode ) , Handle < JSObject > ( ) ) ; } } return closure_scope ; }
Create a plain JSObject which materializes the closure content for the
context.
Create a plain JSObject which materializes the closure content for the context .
// Allocate and initialize a JSObject with all the content of this function // closure. // Fill all context locals to the context extension. // Finally copy any properties from the function context extension. This will // be variables introduced by eval. // Names of variables introduced by eval are strings.