Skip to content

Running and Compiling

Axel Faes edited this page Sep 13, 2015 · 2 revisions

Some functions can return an error code: CardinalLangResult.

Possible errors are:

  • Compile error CARDINAL_COMPILE_ERROR
  • Runtime error CARDINAL_RUNTIME_ERROR
  • No error, succes running CARDINAL_SUCCESS

Running and compiling source

Compiles and runs the string of source in the given VM

CardinalLangResult cardinalInterpret(CardinalVM* vm, const char* sourcePath, const char* source);

Running source

Runs a fiber loaded with a function [val] in the virtual machine [vm].

CardinalLangResult cardinalRunFunction(CardinalVM* vm, CardinalValue* val);

Runs [source], a string of Cardinal source code in a new fiber in [vm].

CardinalLangResult cardinalInterpretModule(CardinalVM* vm, const char* sourcePath, const char* source, const char* module);

Compiling source

Compiles [source], a string of Cardinal source code, to an [ObjFn] that will execute that code when invoked.

CardinalValue* cardinalCompileScript(CardinalVM* vm, const char* sourcePath, const char* source);

Compiles [source], a string of Cardinal source code, to an [ObjFn] that will execute that code when invoked.

CardinalValue* cardinalCompileScriptModule(CardinalVM* vm, const char* sourcePath, const char* source, const char* module);

Bytecode loading and saving

Loads [source], a string of Cardinal byte code, to an [ObjFn] that will execute that code when invoked.

CardinalValue* cardinalLoadByteCode(CardinalVM* vm, const char* sourcePath, const char* source);

Saves the entire state of the VM to a string The value has to be released by the host application

CardinalValue* cardinalSaveByteCode(CardinalVM* vm);

Debug Mode

Sets the debug mode of the VM [vm] to boolean value [set]

void cardinalSetDebugMode(CardinalVM* vm, bool set);
Clone this wiki locally