6#define DLLEXPORT __declspec(dllexport)
11#define DLLEXPORT __attribute__((visibility("default")))
22std::vector<std::string>
splits(
const std::string &input)
24 std::vector<std::string> parts;
26 std::istringstream iss(input);
30 parts.push_back(word);
37 DLLEXPORT void exec(
const unsigned char embeddedBytecode[],
size_t embeddedBytecodeSize,
const char *moduleName,
38 const void *nativeFunctionsVector,
const int argc,
const char** argv)
42 std::vector<uint8_t> bytecodeData(embeddedBytecode, embeddedBytecode + embeddedBytecodeSize);
45 if (nativeFunctionsVector !=
nullptr)
47 const void* ptr = nativeFunctionsVector;
48 const auto* funcVector =
static_cast<const std::vector<std::pair<std::string, void*>
>*>(ptr);
49 for (
const auto &nativeFunction : *funcVector)
57 catch (
const std::exception &e)
60 MessageBoxA(
nullptr, e.what(), (std::string(moduleName) +
" | Phasor Runtime - Error").c_str(),
61 MB_OK | MB_ICONERROR);
63 std::cerr <<
"Error: " << e.what() <<
"\n\a";
68 DLLEXPORT void jitExec(
const char *script,
const char *moduleName,
const void *nativeFunctionsVector)
74 if (nativeFunctionsVector !=
nullptr)
76 const void* ptr = nativeFunctionsVector;
77 const auto* funcVector =
static_cast<const std::vector<std::pair<std::string, void*>
>*>(ptr);
78 for (
const auto &nativeFunction : *funcVector)
86 catch (
const std::exception &e)
89 MessageBoxA(
nullptr, e.what(), (std::string(moduleName) +
" | Phasor Runtime - Error").c_str(),
90 MB_OK | MB_ICONERROR);
92 std::cerr <<
"Error: " << e.what() <<
"\n\a";
std::vector< std::string > splits(const std::string &input)
DLLEXPORT void executeScript(void *vm, const char *script)
Executes a Phasor script within an existing VM instance.
DLLEXPORT void jitExec(const char *script, const char *moduleName, const void *nativeFunctionsVector)
Executes a Phasor script using Just-In-Time (JIT) compilation.
DLLEXPORT void exec(const unsigned char embeddedBytecode[], size_t embeddedBytecodeSize, const char *moduleName, const void *nativeFunctionsVector, const int argc, const char **argv)
Executes pre-compiled Phasor bytecode.
CLI wrapper for running Phasor scripts and bytecode in-process.
void addNativeFunction(const std::string &name, void *function)
static void eval(VM *vm, const std::string &script)