Phasor 3.3.0
Stack VM based Programming Language
Loading...
Searching...
No Matches
PhasorRT.h
Go to the documentation of this file.
1// Copyright 2026 Daniel McGuire
2// Licensed under the Apache License (with LLVM-Exceptions), Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5// https://llvm.org/LICENSE.txt
6// Unless required by applicable law or agreed to in writing, software
7// distributed under the License is distributed on an "AS IS" BASIS,
8// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9// See the License for the specific language governing permissions and
10// limitations under the License.
11
12// README
13//
14// This is the main header file for the Phasor Runtime C ABI.
15// The goal is to keep this ABI as stable as possible, see the details below, or at
16// https://phasor-docs.pages.dev/man?f=phasorrt.3
17// man phasorrt
18
19#ifndef PHASOR_RT_H
20#define PHASOR_RT_H
21
22#ifdef __cplusplus
23#include <cstddef>
24#else
25#include <stdbool.h>
26#include <stddef.h>
27#endif
28
29#ifdef _WIN32
30#ifdef PHASOR_EXPORTS
31#define PHASOR_API __declspec(dllexport)
32#else
33#define PHASOR_API __declspec(dllimport)
34#endif
35#elif defined(__GNUC__) || defined(__clang__)
36#ifdef PHASOR_EXPORTS
37#define PHASOR_API __attribute__((visibility("default")))
38#else
39#define PHASOR_API
40#endif
41#else
42#define PHASOR_API
43#endif
44
45#ifdef __cplusplus
46extern "C"
47{
48#endif
53 PHASOR_API const char *getVersion();
54
68 PHASOR_API int exec(void *state, const unsigned char *bytecode, size_t bytecodeSize, const char *moduleName,
69 int argc, const char **argv);
70
84 PHASOR_API int execFuncInt(void *state, const unsigned char *bytecode, size_t bytecodeSize, const char *moduleName,
85 int argc, const char **argv, const char *functionName);
86
102 PHASOR_API const char *execFuncString(void *state, const unsigned char *bytecode, size_t bytecodeSize,
103 const char *moduleName, int argc, const char **argv,
104 const char *functionName);
105
117 PHASOR_API int evaluatePHS(void *state, const char *script, const char *moduleName, const char *modulePath,
118 bool verbose);
119
129 PHASOR_API int evaluatePUL(void *state, const char *script, const char *moduleName);
130
148 PHASOR_API bool compilePHS(const char *script, const char *moduleName, const char *modulePath,
149 unsigned char *buffer, size_t bufferSize, size_t *outSize);
150
166 PHASOR_API bool compilePUL(const char *script, const char *moduleName, unsigned char *buffer, size_t bufferSize,
167 size_t *outSize);
168
199 PHASOR_API void *createState();
200
208 PHASOR_API void initStdLib(void *state);
209
219 PHASOR_API bool freeState(void *state);
220
230 PHASOR_API bool resetState(void *state, bool resetFunctions, bool resetVariables);
231
232#ifdef __cplusplus
233}
234#endif
235
236#endif // PHASOR_RT_H
#define PHASOR_API
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 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 evaluatePUL(void *state, const char *script, const char *moduleName)
Executes a Pulsar Scripting Language script.
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 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 const char * getVersion()
Get the version string for Phasor VM.
PHASOR_API bool resetState(void *state, bool resetFunctions, bool resetVariables)
Resets the state.
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 int evaluatePHS(void *state, const char *script, const char *moduleName, const char *modulePath, bool verbose)
Executes a Phasor Programming Language script.
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.