diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-11-29 15:40:04 -0500 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-01-03 09:45:40 -0500 |
commit | bba0ed3185f30218e015ccd32cc0c8ae14ebba01 (patch) | |
tree | aa00e844bf262e6a81dda890d0755dcca4ac7f58 /libdeno/internal.h | |
parent | cbb18a596a0696b65fcb116744ee86492421ec2b (diff) |
Add ESM support to libdeno
Introduces deno_execute_mod() for executing ES modules.
Diffstat (limited to 'libdeno/internal.h')
-rw-r--r-- | libdeno/internal.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libdeno/internal.h b/libdeno/internal.h index 91e06bead..d8316ce6b 100644 --- a/libdeno/internal.h +++ b/libdeno/internal.h @@ -20,6 +20,7 @@ class DenoIsolate { snapshot_creator_(nullptr), global_import_buf_ptr_(nullptr), recv_cb_(config.recv_cb), + resolve_cb_(config.resolve_cb), next_req_id_(0), user_data_(nullptr) { array_buffer_allocator_ = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); @@ -40,6 +41,9 @@ class DenoIsolate { } void AddIsolate(v8::Isolate* isolate); + void RegisterModule(const char* filename, v8::Local<v8::Module> module); + void ResolveOk(const char* filename, const char* source); + void ClearModules(); v8::Isolate* isolate_; v8::ArrayBuffer::Allocator* array_buffer_allocator_; @@ -48,9 +52,17 @@ class DenoIsolate { v8::SnapshotCreator* snapshot_creator_; void* global_import_buf_ptr_; deno_recv_cb recv_cb_; + deno_resolve_cb resolve_cb_; int32_t next_req_id_; void* user_data_; + // identity hash -> filename + std::map<int, std::string> module_filename_map_; + // filename -> Module + std::map<std::string, v8::Persistent<v8::Module>> module_map_; + // Set by deno_resolve_ok + v8::Persistent<v8::Module> resolve_module_; + v8::Persistent<v8::Context> context_; std::map<int32_t, v8::Persistent<v8::Value>> async_data_map_; std::map<int, v8::Persistent<v8::Value>> pending_promise_map_; @@ -121,6 +133,8 @@ void DeleteDataRef(DenoIsolate* d, int32_t req_id); bool Execute(v8::Local<v8::Context> context, const char* js_filename, const char* js_source); +bool ExecuteMod(v8::Local<v8::Context> context, const char* js_filename, + const char* js_source); } // namespace deno |