Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index d0947ae81d8d632854096acb99ffa261697ac2c6..54bcf8a752ecb1d215b36e82990e2a1267b06d5c 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -1998,35 +1998,40 @@ MaybeLocal<Script> ScriptCompiler::CompileModule(Local<Context> context, |
| Source* source, |
| CompileOptions options) { |
| auto isolate = context->GetIsolate(); |
| + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| + |
| auto maybe = CompileUnboundInternal(isolate, source, options, true); |
| Local<UnboundScript> generic; |
| if (!maybe.ToLocal(&generic)) return MaybeLocal<Script>(); |
| v8::Context::Scope scope(context); |
| auto result = generic->BindToCurrentContext(); |
| - i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| - i::Handle<i::JSModule> module = i_isolate->factory()->NewJSModule(); |
| - // TODO(neis): Storing the module into the native context is a temporary hack |
| - // to pass it to the Script::Run function. This will be removed once we |
| - // support modules in the API. |
| - i_isolate->native_context()->set_current_module(*module); |
| - |
| i::Handle<i::SharedFunctionInfo> shared = |
| i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*generic)); |
|
adamk
2016/09/15 21:44:02
You shouldn't need this ::cast(), OpenHandle is su
neis
2016/09/15 23:22:58
Done.
|
| i::Handle<i::FixedArray> regular_exports = |
| i::handle(shared->scope_info()->ModuleDescriptorInfo()->regular_exports(), |
| i_isolate); |
| + int regular_exports_length = regular_exports->length(); |
| + |
| + i::Handle<i::Module> module = |
| + i_isolate->factory()->NewModule(regular_exports_length); |
| + |
| + // TODO(neis): Storing the module into the native context is a temporary hack |
| + // to pass it to the Script::Run function. This will be removed once we |
| + // support modules in the API. |
| + i_isolate->native_context()->set_current_module(*module); |
| + |
| // TODO(neis): This will create multiple cells for the same local variable if |
| // exported under multiple names, which is wrong but cannot be observed at the |
| // moment. This will be fixed by doing the full-fledged linking here once we |
| // get there. |
| - for (int i = 0; i < regular_exports->length(); ++i) { |
| + for (int i = 0; i < regular_exports_length; ++i) { |
| i::Handle<i::ModuleInfoEntry> entry = |
| i::handle(i::ModuleInfoEntry::cast(regular_exports->get(i)), i_isolate); |
| DCHECK(entry->import_name()->IsUndefined(i_isolate)); |
| i::Handle<i::String> export_name = |
| handle(i::String::cast(entry->export_name()), i_isolate); |
| - i::JSModule::CreateExport(module, export_name); |
| + i::Module::CreateExport(module, export_name); |
| } |
| return result; |