![]() |
Phasor 3.3.0
Stack VM based Programming Language
|
#include <stdbool.h>#include <stddef.h>Go to the source code of this file.
Macros | |
| #define | PHASOR_API |
Functions | |
| PHASOR_API const char * | getVersion () |
| Get the version string for Phasor VM. | |
| PHASOR_API int | exec (void *state, const unsigned char *bytecode, size_t bytecodeSize, const char *moduleName, int argc, const char **argv) |
| Executes pre-compiled Phasor bytecode. | |
| PHASOR_API int | execFuncInt (void *state, const unsigned char *bytecode, size_t bytecodeSize, const char *moduleName, int argc, const char **argv, const char *functionName) |
| Executes a function from pre-compiled Phasor bytecode, and casts return to an integer. | |
| PHASOR_API const char * | execFuncString (void *state, const unsigned char *bytecode, size_t bytecodeSize, const char *moduleName, int argc, const char **argv, const char *functionName) |
| Executes a function from pre-compiled Phasor bytecode, and casts return to an string. | |
| PHASOR_API int | evaluatePHS (void *state, const char *script, const char *moduleName, const char *modulePath, bool verbose) |
| Executes a Phasor Programming Language script. | |
| PHASOR_API int | evaluatePUL (void *state, const char *script, const char *moduleName) |
| Executes a Pulsar Scripting Language script. | |
| PHASOR_API bool | compilePHS (const char *script, const char *moduleName, const char *modulePath, unsigned char *buffer, size_t bufferSize, size_t *outSize) |
| Compiles a Phasor Programming Language script into Phasor VM bytecode. | |
| PHASOR_API bool | compilePUL (const char *script, const char *moduleName, unsigned char *buffer, size_t bufferSize, size_t *outSize) |
| Compiles a Pulsar Scripting Language script into Phasor VM bytecode. | |
| PHASOR_API void * | createState () |
| Creates a new state instance. | |
| PHASOR_API void | initStdLib (void *state) |
| Register standard library to state instance. | |
| PHASOR_API bool | freeState (void *state) |
| Frees an existing state instance. | |
| PHASOR_API bool | resetState (void *state, bool resetFunctions, bool resetVariables) |
| Resets the state. | |
| PHASOR_API bool | isErrorStatus (void *state) |
| Checks if the state is in an error status. | |
| #define PHASOR_API |
Definition at line 42 of file PhasorRT.h.
| PHASOR_API bool compilePHS | ( | const char * | script, |
| const char * | moduleName, | ||
| const char * | modulePath, | ||
| unsigned char * | buffer, | ||
| size_t | bufferSize, | ||
| size_t * | outSize ) |
Compiles a Phasor Programming Language script into Phasor VM bytecode.
| [in] | script | A string containing the Phasor source to compile. |
| [in] | moduleName | The name of the module, used for error reporting. |
| [in] | modulePath | An required path to the parent folder for the script, used for resolving compile time imports. |
| [out] | buffer | A pointer to a buffer where the compiled bytecode will be written. If null, the function will only calculate the required buffer size and return it via outSize. |
| [in] | bufferSize | The size of the provided buffer. This is ignored if buffer is null. |
| [out] | outSize | If buffer is null, this will be set to the required buffer size to hold the compiled bytecode. If buffer is not null, this will be set to the actual size of the compiled bytecode. |
if bufferSize < data.size(), buffer will not be modified, however outSize will be set.
Definition at line 151 of file NativeRuntime_library.cpp.
| PHASOR_API bool compilePUL | ( | const char * | script, |
| const char * | moduleName, | ||
| unsigned char * | buffer, | ||
| size_t | bufferSize, | ||
| size_t * | outSize ) |
Compiles a Pulsar Scripting Language script into Phasor VM bytecode.
| [in] | script | A string containing the Pulsar source to compile. |
| [in] | moduleName | The name of the module, used for error reporting. |
| [out] | buffer | A pointer to a buffer where the compiled bytecode will be written. If null, the function will only calculate the required buffer size and return it via outSize. |
| [in] | bufferSize | The size of the provided buffer. This is ignored if buffer is null. |
| [out] | outSize | If buffer is null, this will be set to the required buffer size to hold the compiled bytecode. If buffer is not null, this will be set to the actual size of the compiled bytecode. |
if bufferSize < data.size(), buffer will not be modified, however outSize will be set.
Definition at line 191 of file NativeRuntime_library.cpp.
| PHASOR_API void * createState | ( | ) |
Creates a new state instance.
A state is a Phasor::VM object, refered to as State from a high level to avoid bad programming. Dependence on the internal structure of the VM class is not officially supported and will not work across compilers. This version of the C API is designed to work across compilers and outlive minor, potentially even major versions of the VM.
Definition at line 226 of file NativeRuntime_library.cpp.
| PHASOR_API int evaluatePHS | ( | void * | state, |
| const char * | script, | ||
| const char * | moduleName, | ||
| const char * | modulePath, | ||
| bool | verbose ) |
Executes a Phasor Programming Language script.
| state | A pointer to an state to execute the script within. If null, new state will be created and managed for you. |
| script | A string containing the Phasor source to compile and execute. |
| moduleName | The name of the module, used for error reporting. |
| modulePath | A required path to the parent folder for the script, used for resolving compile time imports. |
| verbose | Prints AST to stdout. |
Definition at line 122 of file NativeRuntime_library.cpp.
| PHASOR_API int evaluatePUL | ( | void * | state, |
| const char * | script, | ||
| const char * | moduleName ) |
Executes a Pulsar Scripting Language script.
| state | A pointer to an state to execute the script within. If null, new state will be created and managed for you. |
| script | A string containing the Pulsar source to compile and execute. |
| moduleName | The name of the module, used for error reporting. |
Definition at line 137 of file NativeRuntime_library.cpp.
| PHASOR_API int exec | ( | void * | state, |
| const unsigned char * | bytecode, | ||
| size_t | bytecodeSize, | ||
| const char * | moduleName, | ||
| int | argc, | ||
| const char ** | argv ) |
Executes pre-compiled Phasor bytecode.
| state | A pointer to an state to execute the script within. If null, new state will be created and managed for you. |
| bytecode | An array of unsigned chars containing the Phasor bytecode. |
| bytecodeSize | The size of the bytecode array. |
| moduleName | The name of the module, used for error reporting. |
| argc | Argument count. |
| argv | Argument vector. |
Definition at line 62 of file NativeRuntime_library.cpp.
| PHASOR_API int execFuncInt | ( | void * | state, |
| const unsigned char * | bytecode, | ||
| size_t | bytecodeSize, | ||
| const char * | moduleName, | ||
| int | argc, | ||
| const char ** | argv, | ||
| const char * | functionName ) |
Executes a function from pre-compiled Phasor bytecode, and casts return to an integer.
| state | A pointer to an state to execute the script within. If null, new state will be created and managed for you. |
| bytecode | An array of unsigned chars containing the Phasor bytecode. |
| bytecodeSize | The size of the bytecode array. |
| moduleName | The name of the module, used for error reporting. |
| argc | Argument count. |
| argv | Argument vector. |
| functionName | The name of the function to execute. |
Definition at line 80 of file NativeRuntime_library.cpp.
| PHASOR_API const char * execFuncString | ( | void * | state, |
| const unsigned char * | bytecode, | ||
| size_t | bytecodeSize, | ||
| const char * | moduleName, | ||
| int | argc, | ||
| const char ** | argv, | ||
| const char * | functionName ) |
Executes a function from pre-compiled Phasor bytecode, and casts return to an string.
| state | A pointer to an state to execute the script within. If null, new state will be created and managed for you. |
| bytecode | An array of unsigned chars containing the Phasor bytecode. |
| bytecodeSize | The size of the bytecode array. |
| moduleName | The name of the module, used for error reporting. |
| argc | Argument count. |
| argv | Argument vector. |
| functionName | The name of the function to execute. |
Definition at line 98 of file NativeRuntime_library.cpp.
| PHASOR_API bool freeState | ( | void * | state | ) |
Frees an existing state instance.
| state | Pointer to state to free. |
This function like any low level function could be potentially unsafe if given the wrong thing. Support will not be accepted in these scenarios. Do not call many times on the same pointer.
Definition at line 237 of file NativeRuntime_library.cpp.
| PHASOR_API const char * getVersion | ( | ) |
Get the version string for Phasor VM.
Definition at line 57 of file NativeRuntime_library.cpp.
| PHASOR_API void initStdLib | ( | void * | state | ) |
Register standard library to state instance.
| state | Pointer to state. |
Registers standard library functions to a State instance.
Definition at line 232 of file NativeRuntime_library.cpp.
| PHASOR_API bool isErrorStatus | ( | void * | state | ) |
Checks if the state is in an error status.
| state | Pointer to the state to check. |
Returns false if the pointer is invalid or null.
Definition at line 256 of file NativeRuntime_library.cpp.
| PHASOR_API bool resetState | ( | void * | state, |
| bool | resetFunctions, | ||
| bool | resetVariables ) |
Resets the state.
| state | Pointer to the state to reset. |
| resetFunctions | Reset functions if set to true. |
| resetVariables | Reset variables if set to true. |
This will always clear the stack, reset the PC, and clear bytecode.
Definition at line 246 of file NativeRuntime_library.cpp.