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);
38 DLLEXPORT void exec(
const unsigned char embeddedBytecode[],
size_t embeddedBytecodeSize,
const char *moduleName,
39 const void *nativeFunctionsVector,
const int argc,
const char **argv)
41 DLLEXPORT void exec(
const unsigned char embeddedBytecode[],
size_t embeddedBytecodeSize,
const char *,
42 const void *nativeFunctionsVector,
const int argc,
const char **argv)
47 std::vector<uint8_t> bytecodeData(embeddedBytecode, embeddedBytecode + embeddedBytecodeSize);
50 if (nativeFunctionsVector !=
nullptr)
52 const void *ptr = nativeFunctionsVector;
53 const auto *funcVector =
static_cast<const std::vector<std::pair<std::string, void *>
> *>(ptr);
54 for (
const auto &nativeFunction : *funcVector)
62 catch (
const std::exception &e)
65 MessageBoxA(
nullptr, e.what(), (std::string(moduleName) +
" | Phasor Runtime - Error").c_str(),
66 MB_OK | MB_ICONERROR);
68 std::cerr <<
"Error: " << e.what() <<
"\n\a";
73 DLLEXPORT void jitExec(
const char *script,
const char *moduleName,
const void *nativeFunctionsVector)
75 DLLEXPORT void jitExec(
const char *script,
const char *,
const void *nativeFunctionsVector)
82 if (nativeFunctionsVector !=
nullptr)
84 const void *ptr = nativeFunctionsVector;
85 const auto *funcVector =
static_cast<const std::vector<std::pair<std::string, void *>
> *>(ptr);
86 for (
const auto &nativeFunction : *funcVector)
94 catch (
const std::exception &e)
97 MessageBoxA(
nullptr, e.what(), (std::string(moduleName) +
" | Phasor Runtime - Error").c_str(),
98 MB_OK | MB_ICONERROR);
100 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 exec(const unsigned char embeddedBytecode[], size_t embeddedBytecodeSize, const char *, const void *nativeFunctionsVector, const int argc, const char **argv)
Executes pre-compiled Phasor bytecode.
DLLEXPORT void jitExec(const char *script, const char *, const void *nativeFunctionsVector)
Executes a Phasor script using Just-In-Time (JIT) compilation.
CLI wrapper for running Phasor scripts and bytecode in-process.
void addNativeFunction(const std::string &name, void *function)
static int eval(VM *vm, const std::string &script)