diff options
Diffstat (limited to 'libdeno/api.cc')
-rw-r--r-- | libdeno/api.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libdeno/api.cc b/libdeno/api.cc index e6bc670c7..2c779fb68 100644 --- a/libdeno/api.cc +++ b/libdeno/api.cc @@ -80,7 +80,10 @@ deno::DenoIsolate* unwrap(Deno* d_) { deno_buf deno_get_snapshot(Deno* d_) { auto* d = unwrap(d_); CHECK_NE(d->snapshot_creator_, nullptr); + CHECK(d->resolve_module_.IsEmpty()); + d->ClearModules(); d->context_.Reset(); + auto blob = d->snapshot_creator_->CreateBlob( v8::SnapshotCreator::FunctionCodeHandling::kClear); return {nullptr, 0, reinterpret_cast<uint8_t*>(const_cast<char*>(blob.data)), @@ -123,6 +126,19 @@ int deno_execute(Deno* d_, void* user_data, const char* js_filename, return deno::Execute(context, js_filename, js_source) ? 1 : 0; } +int deno_execute_mod(Deno* d_, void* user_data, const char* js_filename, + const char* js_source) { + auto* d = unwrap(d_); + deno::UserDataScope user_data_scope(d, user_data); + auto* isolate = d->isolate_; + v8::Locker locker(isolate); + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope handle_scope(isolate); + auto context = d->context_.Get(d->isolate_); + CHECK(!context.IsEmpty()); + return deno::ExecuteMod(context, js_filename, js_source) ? 1 : 0; +} + int deno_respond(Deno* d_, void* user_data, int32_t req_id, deno_buf buf) { auto* d = unwrap(d_); if (d->current_args_ != nullptr) { @@ -193,4 +209,9 @@ void deno_terminate_execution(Deno* d_) { deno::DenoIsolate* d = reinterpret_cast<deno::DenoIsolate*>(d_); d->isolate_->TerminateExecution(); } + +void deno_resolve_ok(Deno* d_, const char* filename, const char* source) { + deno::DenoIsolate* d = reinterpret_cast<deno::DenoIsolate*>(d_); + d->ResolveOk(filename, source); +} } |