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

Unified Diff: src/objects.cc

Issue 2376693003: [modules] Move Evaluate from api.cc into internal Module implementation (Closed)
Patch Set: Created 4 years, 3 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/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 828fcd896a0607ecd52aacfa7f9a0e49080c15bd..17007029f059b070da1e4f79c90cd4c92e06997b 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -19900,5 +19900,27 @@ bool Module::Instantiate(Handle<Module> module, v8::Local<v8::Context> context,
return true;
}
+MaybeHandle<Object> Module::Evaluate(Handle<Module> module) {
+ DCHECK(module->code()->IsJSFunction());
+
+ Isolate* isolate = module->GetIsolate();
+
+ // Each module can only be evaluated once.
+ if (module->evaluated()) return isolate->factory()->undefined_value();
+ module->set_evaluated(true);
+
+ Handle<FixedArray> requested_modules(module->requested_modules(), isolate);
+ for (int i = 0, length = requested_modules->length(); i < length; ++i) {
+ Handle<Module> import(Module::cast(requested_modules->get(i)), isolate);
+ RETURN_ON_EXCEPTION(isolate, Evaluate(import), Object);
+ }
+
+ Handle<JSFunction> function(JSFunction::cast(module->code()), isolate);
+ DCHECK_EQ(MODULE_SCOPE, function->shared()->scope_info()->scope_type());
+ Handle<Object> receiver = isolate->factory()->undefined_value();
+ Handle<Object> argv[] = {module};
+ return Execution::Call(isolate, function, receiver, arraysize(argv), argv);
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698