-
Notifications
You must be signed in to change notification settings - Fork 9
Tagha API Reference
assyrianic edited this page Jun 17, 2018
·
64 revisions
struct NativeInfo {
const char *Name;
void (*NativeCFunc)(struct Tagha *, union Value *, size_t, union Value []);
};
struct Tagha {
union Value Regs[regsize];
struct Hashmap Natives;
union Value
ScriptHdr,
FuncTable,
GVarTable
;
bool CondFlag : 1; // conditional flag for conditional jumps!
};Unions in dsc.h
enum ScriptFlags {
FlagSafeMode =0x01,
FlagDebug =0x02,
FlagAllocMem =0x04, // allows malloc calls (for systems with healthy amounts of memory.)
};
enum RegID {
regAlaf, regBeth, regVeth, regGamal, regGhamal,
regDalath, regDhalath, regHeh, regWaw, regZain,
regHeth, regTeth, regYodh, regKaf, regKhaf, regLamad,
regMeem, regNoon, regSemkath, reg_Eh,
// Peh is start of first reg param, Thaw is last.
regPeh, regFeh, regSade, regQof, regReesh,
regSheen, regTaw, regThaw,
// Syriac alphabet makes great register names!
regStk, regBase, regInstr,
regsize
};void Tagha_Init(struct Tagha *vm, void *script);- intializes the Tagha VM with a script pointer.
void Tagha_Del(struct Tagha *vm);- frees the native's hashmap of the tagha vm and zeroes out its data.
struct Tagha *Tagha_New(void *script);- allocates, inits, and returns a pointer to a new Tagha system instance. Automatically calls
Tagha_Initif the instance isn't NULL.
void Tagha_Free(struct Tagha **vmref);- takes a reference to a Tagha VM pointer and frees the entire Tagha vm and sets the vm reference to NULL.
void Tagha_RunScript(struct Tagha *vm, int32_t args, char *argvector[]);- executes a script loaded on the vm until the script halts, returns on empty stack, or an error occurs.
bool Tagha_RegisterNatives(struct Tagha *vm, struct NativeInfo natives[]);- registers an array of natives to Tagha's native map. returns
trueon success,falseon failure.falsecan occur ifvmornativesisNULL, orNativesHashmap methods returns false.
int32_t Tagha_CallFunc(struct Tagha *vm, const char *funcname, size_t args, union Value values[]);- matches
strFuncin a script's function table to invoke the function's instructions.
void TaghaDebug_PrintRegisters(const struct Tagha *vm);- prints all the data in the VM's registers.
void *Tagha_GetGlobalVarByName(struct Tagha *vm, const char *varname);- matches
varnamein a script's var table to retrieve the address of the global variable and returns it as avoid *pointer. Returns NULL if the variable doesn't exist.
union Value Tagha_GetReturnValue(struct Tagha *vm);- pops the value of the VM's
Alafregister.