forked from rogchap/v8go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
v8go.cc
702 lines (575 loc) · 17.2 KB
/
v8go.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
#include "v8go.h"
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include "libplatform/libplatform.h"
#include "v8.h"
using namespace v8;
auto default_platform = platform::NewDefaultPlatform();
auto default_allocator = ArrayBuffer::Allocator::NewDefaultAllocator();
typedef struct {
Persistent<Context> ptr;
Isolate* iso;
} m_ctx;
typedef struct {
Persistent<Value> ptr;
Isolate* iso;
m_ctx* ctx_ptr;
} m_value;
typedef struct {
Persistent<ObjectTemplate> ptr;
Isolate* iso;
} m_object_template;
const char* CopyString(std::string str) {
int len = str.length();
char* mem = (char*)malloc(len + 1);
memcpy(mem, str.data(), len);
mem[len] = 0;
return mem;
}
const char* CopyString(String::Utf8Value& value) {
if (value.length() == 0) {
return nullptr;
}
return CopyString(*value);
}
RtnError ExceptionError(TryCatch& try_catch, Isolate* iso, Local<Context> ctx) {
Locker locker(iso);
Isolate::Scope isolate_scope(iso);
HandleScope handle_scope(iso);
RtnError rtn = {nullptr, nullptr, nullptr};
if (try_catch.HasTerminated()) {
rtn.msg =
CopyString("ExecutionTerminated: script execution has been terminated");
return rtn;
}
String::Utf8Value exception(iso, try_catch.Exception());
rtn.msg = CopyString(exception);
Local<Message> msg = try_catch.Message();
if (!msg.IsEmpty()) {
String::Utf8Value origin(iso, msg->GetScriptOrigin().ResourceName());
std::ostringstream sb;
sb << *origin;
Maybe<int> line = try_catch.Message()->GetLineNumber(ctx);
if (line.IsJust()) {
sb << ":" << line.ToChecked();
}
Maybe<int> start = try_catch.Message()->GetStartColumn(ctx);
if (start.IsJust()) {
sb << ":"
<< start.ToChecked() + 1; // + 1 to match output from stack trace
}
rtn.location = CopyString(sb.str());
}
MaybeLocal<Value> mstack = try_catch.StackTrace(ctx);
if (!mstack.IsEmpty()) {
String::Utf8Value stack(iso, mstack.ToLocalChecked());
rtn.stack = CopyString(stack);
}
return rtn;
}
extern "C" {
/********** Isolate **********/
#define ISOLATE_SCOPE(iso_ptr) \
Isolate* iso = static_cast<Isolate*>(iso_ptr); \
Locker locker(iso); \
Isolate::Scope isolate_scope(iso); \
HandleScope handle_scope(iso); \
void Init() {
#ifdef _WIN32
V8::InitializeExternalStartupData(".");
#endif
V8::InitializePlatform(default_platform.get());
V8::Initialize();
return;
}
IsolatePtr NewIsolate() {
Isolate::CreateParams params;
params.array_buffer_allocator = default_allocator;
return static_cast<IsolatePtr>(Isolate::New(params));
}
void IsolateDispose(IsolatePtr ptr) {
if (ptr == nullptr) {
return;
}
Isolate* iso = static_cast<Isolate*>(ptr);
iso->Dispose();
}
void IsolateTerminateExecution(IsolatePtr ptr) {
Isolate* iso = static_cast<Isolate*>(ptr);
iso->TerminateExecution();
}
IsolateHStatistics IsolationGetHeapStatistics(IsolatePtr ptr) {
if (ptr == nullptr) {
return IsolateHStatistics{0};
}
Isolate* iso = static_cast<Isolate*>(ptr);
v8::HeapStatistics hs;
iso->GetHeapStatistics(&hs);
return IsolateHStatistics{hs.total_heap_size(),
hs.total_heap_size_executable(),
hs.total_physical_size(),
hs.total_available_size(),
hs.used_heap_size(),
hs.heap_size_limit(),
hs.malloced_memory(),
hs.external_memory(),
hs.peak_malloced_memory(),
hs.number_of_native_contexts(),
hs.number_of_detached_contexts()};
}
/********** ObjectTemplate **********/
#define LOCAL_OBJECT_TEMPLATE(ptr) \
m_object_template* ot = static_cast<m_object_template*>(ptr); \
Isolate* iso = ot->iso; \
Locker locker(iso); \
Isolate::Scope isolate_scope(iso); \
HandleScope handle_scope(iso); \
Local<ObjectTemplate> object_template = ot->ptr.Get(iso);
ObjectTemplatePtr NewObjectTemplate(IsolatePtr iso_ptr) {
Isolate* iso = static_cast<Isolate*>(iso_ptr);
Locker locker(iso);
Isolate::Scope isolate_scope(iso);
HandleScope handle_scope(iso);
m_object_template* ot = new m_object_template;
ot->iso = iso;
ot->ptr.Reset(iso, ObjectTemplate::New(iso));
return static_cast<ObjectTemplatePtr>(ot);
}
void ObjectTemplateDispose(ObjectTemplatePtr ptr) {
delete static_cast<m_object_template*>(ptr);
}
void ObjectTemplateSetValue(ObjectTemplatePtr ptr,
const char* name,
ValuePtr val_ptr,
int attributes) {
LOCAL_OBJECT_TEMPLATE(ptr);
Local<String> prop_name =
String::NewFromUtf8(iso, name, NewStringType::kNormal).ToLocalChecked();
m_value* val = static_cast<m_value*>(val_ptr);
object_template->Set(prop_name, val->ptr.Get(iso), (PropertyAttribute)attributes);
}
void ObjectTemplateSetObjectTemplate(ObjectTemplatePtr ptr, const char* name, ObjectTemplatePtr obj_ptr, int attributes) {
LOCAL_OBJECT_TEMPLATE(ptr);
Local<String> prop_name =
String::NewFromUtf8(iso, name, NewStringType::kNormal).ToLocalChecked();
m_object_template* obj = static_cast<m_object_template*>(obj_ptr);
object_template->Set(prop_name, obj->ptr.Get(iso), (PropertyAttribute)attributes);
}
/********** Context **********/
ContextPtr NewContext(IsolatePtr iso_ptr,
ObjectTemplatePtr global_template_ptr) {
Isolate* iso = static_cast<Isolate*>(iso_ptr);
Locker locker(iso);
Isolate::Scope isolate_scope(iso);
HandleScope handle_scope(iso);
Local<ObjectTemplate> global_template;
if (global_template_ptr != nullptr) {
m_object_template* ob =
static_cast<m_object_template*>(global_template_ptr);
global_template = ob->ptr.Get(iso);
} else {
global_template = ObjectTemplate::New(iso);
}
iso->SetCaptureStackTraceForUncaughtExceptions(true);
m_ctx* ctx = new m_ctx;
ctx->ptr.Reset(iso, Context::New(iso, nullptr, global_template));
ctx->iso = iso;
return static_cast<ContextPtr>(ctx);
}
RtnValue RunScript(ContextPtr ctx_ptr, const char* source, const char* origin) {
m_ctx* ctx = static_cast<m_ctx*>(ctx_ptr);
Isolate* iso = ctx->iso;
Locker locker(iso);
Isolate::Scope isolate_scope(iso);
HandleScope handle_scope(iso);
TryCatch try_catch(iso);
Local<Context> local_ctx = ctx->ptr.Get(iso);
Context::Scope context_scope(local_ctx);
Local<String> src =
String::NewFromUtf8(iso, source, NewStringType::kNormal).ToLocalChecked();
Local<String> ogn =
String::NewFromUtf8(iso, origin, NewStringType::kNormal).ToLocalChecked();
RtnValue rtn = {nullptr, nullptr};
ScriptOrigin script_origin(ogn);
MaybeLocal<Script> script = Script::Compile(local_ctx, src, &script_origin);
if (script.IsEmpty()) {
rtn.error = ExceptionError(try_catch, iso, local_ctx);
return rtn;
}
MaybeLocal<v8::Value> result = script.ToLocalChecked()->Run(local_ctx);
if (result.IsEmpty()) {
rtn.error = ExceptionError(try_catch, iso, local_ctx);
return rtn;
}
m_value* val = new m_value;
val->iso = iso;
val->ctx_ptr = ctx;
val->ptr.Reset(iso, Persistent<Value>(iso, result.ToLocalChecked()));
rtn.value = static_cast<ValuePtr>(val);
return rtn;
}
void ContextDispose(ContextPtr ptr) {
if (ptr == nullptr) {
return;
}
m_ctx* ctx = static_cast<m_ctx*>(ptr);
if (ctx == nullptr) {
return;
}
ctx->ptr.Reset();
delete ctx;
}
/********** Value **********/
#define LOCAL_VALUE(ptr) \
m_value* val = static_cast<m_value*>(ptr); \
m_ctx* ctx = val->ctx_ptr; \
Isolate* iso = val->iso; \
Locker locker(iso); \
Isolate::Scope isolate_scope(iso); \
HandleScope handle_scope(iso); \
Context::Scope context_scope(ctx->ptr.Get(iso)); \
Local<Value> value = val->ptr.Get(iso);
ValuePtr NewValueInteger(IsolatePtr iso_ptr, int32_t v) {
ISOLATE_SCOPE(iso_ptr);
m_value* val = new m_value;
val->iso = iso;
val->ptr.Reset(iso, Persistent<Value>(iso, Integer::New(iso, v)));
return static_cast<ValuePtr>(val);
}
ValuePtr NewValueIntegerFromUnsigned(IsolatePtr iso_ptr, uint32_t v) {
ISOLATE_SCOPE(iso_ptr);
m_value* val = new m_value;
val->iso = iso;
val->ptr.Reset(iso, Persistent<Value>(iso, Integer::NewFromUnsigned(iso, v)));
return static_cast<ValuePtr>(val);
}
ValuePtr NewValueString(IsolatePtr iso_ptr, const char* v) {
ISOLATE_SCOPE(iso_ptr);
m_value* val = new m_value;
val->iso = iso;
val->ptr.Reset(iso, Persistent<Value>(iso, String::NewFromUtf8(iso, v).ToLocalChecked()));
return static_cast<ValuePtr>(val);
}
ValuePtr NewValueBoolean(IsolatePtr iso_ptr, int v) {
ISOLATE_SCOPE(iso_ptr);
m_value* val = new m_value;
val->iso = iso;
val->ptr.Reset(iso, Persistent<Value>(iso, Boolean::New(iso, v)));
return static_cast<ValuePtr>(val);
}
ValuePtr NewValueNumber(IsolatePtr iso_ptr, double v) {
ISOLATE_SCOPE(iso_ptr);
m_value* val = new m_value;
val->iso = iso;
val->ptr.Reset(iso, Persistent<Value>(iso, Number::New(iso, v)));
return static_cast<ValuePtr>(val);
}
ValuePtr NewValueBigInt(IsolatePtr iso_ptr, int64_t v) {
ISOLATE_SCOPE(iso_ptr);
m_value* val = new m_value;
val->iso = iso;
val->ptr.Reset(iso, Persistent<Value>(iso, BigInt::New(iso, v)));
return static_cast<ValuePtr>(val);
}
ValuePtr NewValueBigIntFromUnsigned(IsolatePtr iso_ptr, uint64_t v) {
ISOLATE_SCOPE(iso_ptr);
m_value* val = new m_value;
val->iso = iso;
val->ptr.Reset(iso, Persistent<Value>(iso, BigInt::NewFromUnsigned(iso, v)));
return static_cast<ValuePtr>(val);
}
ValuePtr NewValueBigIntFromWords(IsolatePtr iso_ptr, int sign_bit, int word_count, const uint64_t* words) {
ISOLATE_SCOPE(iso_ptr);
m_value* val = new m_value;
val->iso = iso;
// V8::BigInt::NewFromWords requires a context, which is different from all the other V8::Primitive types
// It seems that the implementation just gets the Isolate from the Context and nothing else, so this function
// should really only need the Isolate.
// We'll have to create a temp context to hold the Isolate to create the BigInt.
Local<Context> ctx = Context::New(iso);
MaybeLocal<BigInt> bigint = BigInt::NewFromWords(ctx, sign_bit, word_count, words);
val->ptr.Reset(iso, Persistent<Value>(iso, bigint.ToLocalChecked()));
return static_cast<ValuePtr>(val);
}
void ValueDispose(ValuePtr ptr) {
delete static_cast<m_value*>(ptr);
}
const uint32_t* ValueToArrayIndex(ValuePtr ptr) {
LOCAL_VALUE(ptr);
MaybeLocal<Uint32> array_index = value->ToArrayIndex(ctx->ptr.Get(iso));
if (array_index.IsEmpty()) {
return nullptr;
}
uint32_t* idx = new uint32_t;
*idx = array_index.ToLocalChecked()->Value();
return idx;
}
int ValueToBoolean(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->BooleanValue(iso);
}
int32_t ValueToInt32(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->Int32Value(ctx->ptr.Get(iso)).ToChecked();
}
int64_t ValueToInteger(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IntegerValue(ctx->ptr.Get(iso)).ToChecked();
}
double ValueToNumber(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->NumberValue(ctx->ptr.Get(iso)).ToChecked();
}
const char* ValueToDetailString(ValuePtr ptr) {
LOCAL_VALUE(ptr);
String::Utf8Value ds(
iso, value->ToDetailString(ctx->ptr.Get(iso)).ToLocalChecked());
return CopyString(ds);
}
const char* ValueToString(ValuePtr ptr) {
LOCAL_VALUE(ptr);
String::Utf8Value utf8(iso, value);
return CopyString(utf8);
}
uint32_t ValueToUint32(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->Uint32Value(ctx->ptr.Get(iso)).ToChecked();
}
ValueBigInt ValueToBigInt(ValuePtr ptr) {
LOCAL_VALUE(ptr);
MaybeLocal<BigInt> bint = value->ToBigInt(ctx->ptr.Get(iso));
if (bint.IsEmpty()) {
return {nullptr, 0};
}
int word_count = bint.ToLocalChecked()->WordCount();
int sign_bit = 0;
uint64_t* words = new uint64_t[word_count];
bint.ToLocalChecked()->ToWordsArray(&sign_bit, &word_count, words);
ValueBigInt rtn = {words, word_count, sign_bit};
return rtn;
}
int ValueIsUndefined(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsUndefined();
}
int ValueIsNull(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsNull();
}
int ValueIsNullOrUndefined(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsNullOrUndefined();
}
int ValueIsTrue(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsTrue();
}
int ValueIsFalse(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsFalse();
}
int ValueIsName(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsName();
}
int ValueIsString(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsString();
}
int ValueIsSymbol(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsSymbol();
}
int ValueIsFunction(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsFunction();
}
int ValueIsObject(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsObject();
}
int ValueIsBigInt(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsBigInt();
}
int ValueIsBoolean(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsBoolean();
}
int ValueIsNumber(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsNumber();
}
int ValueIsExternal(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsExternal();
}
int ValueIsInt32(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsInt32();
}
int ValueIsUint32(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsUint32();
}
int ValueIsDate(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsDate();
}
int ValueIsArgumentsObject(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsArgumentsObject();
}
int ValueIsBigIntObject(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsBigIntObject();
}
int ValueIsNumberObject(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsNumberObject();
}
int ValueIsStringObject(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsStringObject();
}
int ValueIsSymbolObject(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsSymbolObject();
}
int ValueIsNativeError(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsNativeError();
}
int ValueIsRegExp(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsRegExp();
}
int ValueIsAsyncFunction(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsAsyncFunction();
}
int ValueIsGeneratorFunction(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsGeneratorFunction();
}
int ValueIsGeneratorObject(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsGeneratorObject();
}
int ValueIsPromise(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsPromise();
}
int ValueIsMap(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsMap();
}
int ValueIsSet(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsSet();
}
int ValueIsMapIterator(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsMapIterator();
}
int ValueIsSetIterator(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsSetIterator();
}
int ValueIsWeakMap(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsWeakMap();
}
int ValueIsWeakSet(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsWeakSet();
}
int ValueIsArray(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsArray();
}
int ValueIsArrayBuffer(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsArrayBuffer();
}
int ValueIsArrayBufferView(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsArrayBufferView();
}
int ValueIsTypedArray(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsTypedArray();
}
int ValueIsUint8Array(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsUint8Array();
}
int ValueIsUint8ClampedArray(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsUint8ClampedArray();
}
int ValueIsInt8Array(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsInt8Array();
}
int ValueIsUint16Array(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsUint16Array();
}
int ValueIsInt16Array(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsInt16Array();
}
int ValueIsUint32Array(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsUint32Array();
}
int ValueIsInt32Array(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsInt32Array();
}
int ValueIsFloat32Array(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsFloat32Array();
}
int ValueIsFloat64Array(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsFloat64Array();
}
int ValueIsBigInt64Array(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsBigInt64Array();
}
int ValueIsBigUint64Array(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsBigUint64Array();
}
int ValueIsDataView(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsDataView();
}
int ValueIsSharedArrayBuffer(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsSharedArrayBuffer();
}
int ValueIsProxy(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsProxy();
}
int ValueIsWasmModuleObject(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsWasmModuleObject();
}
int ValueIsModuleNamespaceObject(ValuePtr ptr) {
LOCAL_VALUE(ptr);
return value->IsModuleNamespaceObject();
}
/********** Version **********/
const char* Version() {
return V8::GetVersion();
}
}