Skip to content

Commit

Permalink
[unity]ExecuteModule处理语法错误,fix #1670
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Mar 20, 2024
1 parent 6d385b5 commit 4720a7b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions unity/native_src/Src/BackendEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "v8.h"
#pragma warning(pop)

#include "V8Utils.h"

#if WITH_NODEJS

#pragma warning(push, 0)
Expand Down Expand Up @@ -553,8 +555,13 @@ void puerts::esmodule::ExecuteModule(const v8::FunctionCallbackInfo<v8::Value>&
v8::PrimitiveArray::New(Isolate, 10)
);
v8::ScriptCompiler::Source source(emptyStrV8, origin);
v8::Local<v8::Module> entryModule = v8::ScriptCompiler::CompileModule(Isolate, &source, v8::ScriptCompiler::kNoCompileOptions)
.ToLocalChecked();
v8::Local<v8::Module> entryModule;

if (v8::ScriptCompiler::CompileModule(Isolate, &source, v8::ScriptCompiler::kNoCompileOptions).ToLocal(&entryModule))
{
FV8Utils::ThrowException(Isolate, "Syntax error");
return;
}

v8::MaybeLocal<v8::Module> mod = puerts::esmodule::ResolveModule(Context, Specifier_v8, entryModule);
if (mod.IsEmpty())
Expand Down

0 comments on commit 4720a7b

Please sign in to comment.