Wi API Reference - cyxigo/wi GitHub Wiki
Using Wi API to create a library
If you're using Wi API to create a library, your library must have an entry point function WI_MODULE_EXPORT wi_module* wi_module_init(wi_state* state), which returns a valid Wi module.
wi.h
Macros
WI_API
Expands to:
#ifdef _WIN32:__declspec(dllexport)#elif defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4):__attribute__((visibility("default")))#else:
Used to mark all public API functions
WI_MODULE_EXPORT
Expands to:
#ifdef _WIN32:__declspec(dllexport)#elif defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4):__attribute__((visibility("default")))#else:
Used to mark a foreign library's entry point (wi_module_init), which must return a Wi module handle
WI_DEF_FOREIGN_ALL
Define a table of foreign (C) functions as globals in one call.
Equivalent to calling wi_push_foreign + wi_def for each wi_foreign_entry in functions
Parameters:
state: Wi state instancefunctions: A C array ofwi_foreign_entry
Expands to:
for (size_t i = 0; i < sizeof(functions) / sizeof(functions[0]); i++) {
wi_foreign_entry* entry = &functions[i];
wi_push_foreign(state, entry->fn, entry->arity, entry->is_variadic);
wi_def(state, entry->name);
}
WI_OBJECT_SET_FOREIGN_ALL
Set a table of foreign (C) functions as fields on an object in one call.
Equivalent to calling wi_push_foreign + wi_object_set for each wi_foreign_entry in functions
Parameters:
state: Wi state instanceobject: Target objectfunctions: A C array ofwi_foreign_entry
Expands to:
for (size_t i = 0; i < sizeof(functions) / sizeof(functions[0]); i++) {
wi_foreign_entry* entry = &functions[i];
wi_push_foreign(state, entry->fn, entry->arity, entry->is_variadic);
wi_object_set(state, object, entry->name);
}
WI_MODULE_EXPORT_FOREIGN_ALL
Export a table of foreign (C) functions as exported variables in a module in one call.
Equivalent to calling wi_push_foreign + wi_module_set for each wi_foreign_entry in functions
Parameters:
state: Wi state instancemodule: Target modulefunctions: A C array ofwi_foreign_entry
Expands to:
for (size_t i = 0; i < sizeof(functions) / sizeof(functions[0]); i++) {
wi_foreign_entry* entry = &functions[i];
wi_push_foreign(state, entry->fn, entry->arity, entry->is_variadic);
wi_module_set(state, module, entry->name);
}
WI_CHECK_VERSION
Calls wi_check_version with WI_VERSION_MAJOR provided by the included wi_conf.h
Parameters:
state: Wi state instance
Expands to:
wi_check_version(state, WI_VERSION_MAJOR)
Types
wi_real
Wi's number type
wi_ref
Handle to a persistent Wi value reference, see wi_ref_create
wi_array
Opaque Wi array handle
wi_map
Opaque Wi map handle
wi_object
Opaque Wi object handle
wi_module
Opaque Wi module handle
wi_state
Opaque Wi state handle
wi_run_result
The result of running Wi code
WI_RUN_OK: No errors occurredWI_RUN_ERROR: A runtime error or a compile error occurred, also used when out of memoryWI_RUN_ABORT: Execution was aborted early viawi_state_abort
wi_print_fn(wi_state* state, const char* text)
Callback to print... something. Used by Wi for standard/error output printing
wi_on_compile_fn(wi_state* state)
Function called right after a successful compilation of a script.
Use example: print all warnings
wi_import_load_fn(wi_state* state, const char* path)
Function called in the import statement. Use this in a custom virtual filesystem (your app, for example).
Must return Wi code as a NUL-terminated malloced string (Wi takes ownership and frees it) or NULL if the file failed to load
wi_import_exists_fn(wi_state* state, const char* path)
Function used to check whether a imported file exists, called at compile time. If it returns false, import falls back to treating the path as a foreign library.
Must return whether a file exists
wi_foreign_fn(wi_state* state, uint8_t arg_count)
Foreign (C) function pointer, called from Wi scripts
wi_userdata_finalizer_fn(void* data)
Userdata finalizer - function called when the userdata gets collected by GC
wi_foreign_entry
A single { name, function, arity, is_variadic } row, used to register foreign (C) functions via WI_DEF_FOREIGN_ALL/WI_OBJECT_SET_FOREIGN_ALL/WI_MODULE_EXPORT_FOREIGN_ALL
Functions
wi_abi_version
Get the MAJOR version of the Wi library used
Returns: int WI_VERSION_MAJOR of the Wi library used
wi_check_version
Check whether the Wi library used and the code making the call match MAJOR versions.
Will raise a compile or a runtime error depending on the call context
Parameters:
wi_state* state: Wi state instanceint version:WI_VERSION_MAJORof the code making the call
wi_new_state
Create a new Wi state instance. Must be freed via wi_delete_state
Parameters:
wi_conf* conf: Wi configuration, seewi_conf.hfor more (must outlive the state, Wi keeps the pointer)
Returns: wi_state* The new Wi state instance, or NULL if out of memory
wi_delete_state
Delete a Wi state instance and free all associated memory
Parameters:
wi_state* state: Wi state instance
wi_state_tune_gc
Tune the garbage collector's generational thresholds. Call right after wi_new_state, before any wi_state_run. For default settings, see wi_conf.h
Parameters:
wi_state* state: Wi state instancesize_t min_heap: Total heap size before the first major collectionsize_t heap_grow_factor: Heap growth factor per major collectionsize_t young_max: Young generation size before a minor collection
wi_state_memory_used
Get the total number of bytes currently allocated by the garbage collector
Parameters:
wi_state* state: Wi state instance
Returns: size_t Total bytes allocated
wi_state_collect_garbage
Force a major garbage collection cycle
Parameters:
wi_state* state: Wi state instance
wi_state_was_eof_error
Check if the last compile error occurred at EOF Parameters:
wi_state* state: Wi state instance
Returns: bool true if the last compile error occurred at EOF, false otherwise
wi_state_exit_code
Get the exit code set by the last call to std::exit (defaults to 0)
Parameters:
wi_state* state: Wi state instance
Returns: int The exit code
wi_state_set_callbacks
Set the state callbacks. Safe to pass NULL for each. For more info about callbacks, check their definitions
Parameters:
wi_state* state: Wi state instancewi_print_fn out_fn: Standard output callbackwi_print_fn error_fn: Error output callbackwi_on_compile_fn on_compile_fn: On compile callbackwi_import_load_fn import_load_fn: Load import callbackwi_import_exists_fn import_exists_fn: Import existence check callback
wi_state_set_args
Set the command line arguments that will be available to Wi scripts via os::args
Parameters:
wi_state* state: Wi state instanceint argc: Number of argumentsconst char** argv: Array of argument strings (must be valid UTF-8, invalid - undefined behavior, and must outlive the state, Wi keeps the pointer)
wi_state_set_extra
Set an opaque pointer on the state, for the embedder to attach application context to (e.g. a widget, some handle, anything).
Extra pointer is not touched by Wi in any way
Parameters:
wi_state* state: Wi state instancevoid* extra: Pointer to store, orNULL
wi_state_extra
Get the pointer set by wi_state_set_extra
Parameters:
wi_state* state: Wi state instance
Returns: void* The extra pointer, or NULL if none was set
wi_state_error
Throw a runtime error in the state
Parameters:
wi_state* state: Wi state instanceconst char* format:printfformat string...: Format arguments
wi_state_abort
Request the state to stop execution, returning WI_RUN_ABORT from wi_state_run.
Must only be called while a script is running (e.g., from a foreign (C) function).
Calling it outside wi_state_run is undefined behavior
Parameters:
wi_state* state: Wi state instance
wi_state_interrupt
Request the state to stop execution as soon as possible, returning WI_RUN_ABORT from wi_state_run. In contrast to wi_state_abort, this function is safe to call asynchronously (e.g., from a signal handler or another thread)
Parameters:
wi_state* state: Wi state instance
wi_state_run
Execute Wi code.
Must not be called from a foreign library's wi_module_init or from wi_import_exists_fn
Parameters:
wi_state* state: Wi state instanceconst char* file_path: Path to the script, used for error messages (must outlive the state, Wi keeps the pointer)const char* src: Code string
Returns: wi_run_result Run result
wi_load
Compile Wi code into a function without running it, pushing it onto the stack.
Running this function will run the code and hand you back a module on the stack, so technically the same as importing a script.
arg_count for the said function will be 0.
Must not be called from a foreign library's wi_module_init or from wi_import_exists_fn
Parameters:
wi_state* state: Wi state instanceconst char* file_path: Path to the script, used for error messages (must outlive the state, Wi keeps the pointer)const char* src: Code string
Returns: bool true and pushes the function on success, false and pushes nothing on a compile error
wi_ref_create
Create a persistent reference to the value at the stack top, popping it.
Reference created by this function will survive until it is deleted (wi_ref_delete) or the state is (wi_delete_state)
Parameters:
wi_state* state: Wi state instance
Returns: wi_ref The new reference
wi_ref_push
Push the value held by a reference onto the stack
Parameters:
wi_state* state: Wi state instancewi_ref ref: Target reference
Returns: bool true if the reference exists and its value was pushed, false if it does not exist (already deleted or invalid)
wi_ref_delete
Release a reference, letting the garbage collector reclaim its value
Parameters:
wi_state* state: Wi state instancewi_ref ref: Target reference
wi_def_std
Define the standard library (STD) in a state
Parameters:
wi_state* state: Wi state instance
wi_def_stm
Define the standard method library (STM) in a state - methods for builtin types:
string, array, map. Only reachable via the -> method-call operator
Parameters:
wi_state* state: Wi state instance
wi_def
Define the value at the stack top as a foreign (global) variable, popping it.
If the variable already exists, it is overwritten
Parameters:
wi_state* state: Wi state instanceconst char* name: Variable name
wi_find
Find a global variable (a foreign one defined via wi_def, or one from the main module) and push it onto the stack
Parameters:
wi_state* state: Wi state instanceconst char *name: Variable name
Returns: bool true if the variable was found and pushed, false otherwise
wi_call
Call a Wi function that is at the stack top.
Must only be called while the state is running (i.e. from within a foreign function called by Wi code).
Calling it outside that context is undefined behavior
Parameters:
wi_state* state: Wi state instanceuint8_t arg_count: Argument countbool drop: Whether to leave the return value at the stack or not
wi_pcall
Call a Wi function that is at the stack top; is protected
Parameters:
wi_state* state: Wi state instanceuint8_t arg_count: Argument countbool drop: Whether to leave the return value at the stack or notchar** error: Optional pointer to store the error message (if any), can beNULL, must be freed manually
Returns: bool true if the call succeeded, false if it raised an error
wi_type
Get the type of the value at the stack top
Parameters:
wi_state* state: Wi state instance
Returns: const char* Type name
wi_is_real
Check if the value at the stack top is a real
Parameters:
wi_state* state: Wi state instance
Returns: bool true if the value is a real, false otherwise
wi_is_null
Check if the value at the stack top is null
Parameters:
wi_state* state: Wi state instance
Returns: bool true if the value is null, false otherwise
wi_is_bool
Check if the value at the stack top is a bool
Parameters:
wi_state* state: Wi state instance
Returns: bool true if the value is a bool, false otherwise
wi_is_string
Check if the value at the stack top is a string
Parameters:
wi_state* state: Wi state instance
Returns: bool true if the value is a string, false otherwise
wi_is_function
Check if the value at the stack top is a function (Wi or C)
Parameters:
wi_state* state: Wi state instance
Returns: bool true if the value is a function (Wi or C), false otherwise
wi_is_array
Check if the value at the stack top is an array
Parameters:
wi_state* state: Wi state instance
Returns: bool true if the value is an array, false otherwise
wi_is_map
Check if the value at the stack top is a map
Parameters:
wi_state* state: Wi state instance
Returns: bool true if the value is a map, false otherwise
wi_is_object
Check if the value at the stack top is an object
Parameters:
wi_state* state: Wi state instance
Returns: bool true if the value is an object, false otherwise
wi_is_userdata
Check if the value at the stack top is userdata
Parameters:
wi_state* state: Wi state instanceconst char* name: Userdata name, used for type-checking
Returns: bool true if the value is userdata of the given name, false otherwise
wi_is_module
Check if the value at the stack top is a module
Parameters:
wi_state* state: Wi state instance
Returns: bool true if the value is a module, false otherwise
wi_push_real
Push a real onto the stack
Parameters:
wi_state* state: Wi state instancewi_real real: Real
wi_push_null
Push null onto the stack
Parameters:
wi_state* state: Wi state instance
wi_push_bool
Push a bool onto the stack
Parameters:
wi_state* state: Wi state instancebool bool_: Bool
wi_push_string
Push a string onto the stack
Parameters:
wi_state* state: Wi state instanceconst char* string: String (must be valid UTF-8, invalid - undefined behavior)
wi_push_lstring
Push a string with an explicit byte count onto the stack
Parameters:
wi_state* state: Wi state instanceconst char* string: String (must be valid UTF-8, invalid - undefined behavior)int count: String byte count
wi_push_array
Push a new, empty array onto the stack
Parameters:
wi_state* state: Wi state instance
Returns: wi_array* Pointer to the created array
wi_push_map
Push a new, empty map onto the stack
Parameters:
wi_state* state: Wi state instance
Returns: wi_map* Pointer to the created map
wi_push_foreign
Push a foreign (C) function onto the stack
Parameters:
wi_state* state: Wi state instancewi_foreign_fn fn: Pointer to the C function implementationuint8_t arity: Function's arity (number of arguments it expects)bool is_variadic: Whether function is variadic or not
wi_push_userdata
Push userdata onto the stack
Parameters:
wi_state* state: Wi state instanceconst char* name: Userdata name, used for type-checkingvoid* userdata: Pointer to userdatawi_userdata_finalizer_fn finalizer: Userdata finalizer
wi_push_object
Push a new, empty object onto the stack
Parameters:
wi_state* state: Wi state instance
Returns: wi_object* Pointer to the created object
wi_push_module
Push a new, empty module onto the stack.
path of said module will be just "foreign"
Parameters:
wi_state* state: Wi state instance
Returns: wi_module* Pointer to the created module
wi_drop
Drop a value from the stack
Parameters:
wi_state* state: Wi state instance
wi_pop_real
Pop a real from the stack with type-checking
Parameters:
wi_state* state: Wi state instance
Returns: wi_real The popped real
wi_pop_null
Pop null from the stack with type-checking
Parameters:
wi_state* state: Wi state instance
wi_pop_bool
Pop a bool from the stack with type-checking
Parameters:
wi_state* state: Wi state instance
Returns: bool The popped bool
wi_pop_string
Pop a string from the stack with type-checking
Parameters:
wi_state* state: Wi state instanceint* count: Optional pointer to store the string byte count, can beNULLint* len: Optional pointer to store the string length (codepoint count), can beNULL
Returns: char* The popped string
wi_pop_array
Pop an array from the stack with type-checking
Parameters:
wi_state* state: Wi state instance
Returns: wi_array* The popped array
wi_pop_map
Pop a map from the stack with type-checking
Parameters:
wi_state* state: Wi state instance
Returns: wi_map* The popped map
wi_pop_userdata
Pop userdata from the stack with type-checking
Parameters:
wi_state* state: Wi state instanceconst char* name: Userdata name, used for type-checking
Returns: void* The popped userdata's data pointer
wi_pop_object
Pop an object from the stack with type-checking
Parameters:
wi_state* state: Wi state instance
Returns: wi_object* The popped object
wi_pop_module
Pop a module from the stack with type-checking
Parameters:
wi_state* state: Wi state instance
Returns: wi_module* The popped module
wi_arg_type
Get the type name of an argument
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: const char* Type name
wi_arg_is_real
Check if argument is a real
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: bool true if the argument is a real, false otherwise
wi_arg_is_null
Check if argument is null
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: bool true if the argument is null, false otherwise
wi_arg_is_bool
Check if argument is a bool
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: bool true if the argument is a bool, false otherwise
wi_arg_is_string
Check if argument is a string
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: bool true if the argument is a string, false otherwise
wi_arg_is_function
Check if argument is a function
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: bool true if the argument is a function (Wi or C), false otherwise
wi_arg_is_array
Check if argument is an array Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: bool true if the argument is an array, false otherwise
wi_arg_is_map
Check if argument is a map
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: bool true if the argument is a map, false otherwise
wi_arg_is_userdata
Check if argument is userdata
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])const char* name: Userdata name, used for type-checking
Returns: bool true if the argument is userdata of the given name, false otherwise
wi_arg_is_object
Check if argument is an object
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: bool true if the argument is an object, false otherwise
wi_arg_is_module
Check if argument is a module
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: bool true if the argument is a module, false otherwise
wi_push_arg
Push a copy of an argument (of any type) onto the stack
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
wi_arg_real
Get a real argument with type-checking
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: wi_real Real argument
wi_arg_null
Type-check if argument is null Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
wi_arg_bool
Get a bool argument with type-checking
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: bool Bool argument
wi_arg_string
Get a string argument with type-checking
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])int* count: Optional pointer to store the string byte count, can beNULLint* len: Optional pointer to store the string length (codepoint count), can beNULL
Returns: char* String argument
wi_arg_check_function
Check if argument is a function and check its arity, without pushing it onto the stack
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])uint8_t arity: Function arity
wi_arg_function
Check if argument is a function, check its arity, and push it onto the stack
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])uint8_t arity: Function arity
wi_arg_array
Get an array argument with type-checking
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: wi_array* Array argument
wi_arg_map
Get a map argument with type-checking
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: wi_map* Map argument
wi_arg_userdata
Get userdata argument with type-checking
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])const char* name: Userdata name, used for type-checking
Returns: void* Userdata argument
wi_arg_object
Get an object argument with type-checking
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: wi_object* Object argument
wi_arg_module
Get a module argument with type-checking
Parameters:
wi_state* state: Wi state instanceuint8_t arg: Argument index (1-[arg_count])
Returns: wi_module* Module argument
wi_array_count
Get the number of items in an array
Parameters:
wi_array* array: Target array
Returns: int The item count
wi_array_add
Append the value at the stack top to an array, popping it
Parameters:
wi_state* state: Wi state instancewi_array* array: Target array
wi_array_set
Set the value at the stack top as an array item at index, popping it
Parameters:
wi_state* state: Wi state instancewi_array* array: Target arrayint index: Item index
Returns: bool true if the index was in range and the item was set, false otherwise
wi_array_get
Get an array item by index and push it onto the stack
Parameters:
wi_state* state: Wi state instancewi_array* array: Target arrayint index: Item index
Returns: bool true and pushes the item if the index was in range, false and pushes nothing otherwise
wi_map_count
Get the number of entries in a map
Parameters:
wi_map* map: Target map
Returns: int The entry count
wi_map_set
Set map key to a value, both need to be at the stack top pushed in order key -> value
Parameters:
wi_state* state: Wi state instancewi_map* map: Target map
wi_map_get
Look up map key which is at the stack top
Parameters:
wi_state* state: Wi state instancewi_map* map: Target map
Returns: bool true and pushes the value if the key was found, false and pushes nothing otherwise
wi_map_next
Iterate over a map's entries. Pass *iter = 0 on the first call.
Each call that finds a live entry pushes its key then value and advances *iter
Parameters:
wi_state* state: Wi state instancewi_map* map: Target mapint* iter: Iteration cursor, updated in place
Returns: bool true and pushes key/value, false and pushes nothing once every entry has been visited
wi_object_set
Set the value at the stack top as a field on an object, popping it
Parameters:
wi_state* state: Wi state instancewi_object* object: Target objectconst char* name: Field name
wi_object_get
Get a field from an object and push it onto the stack
Parameters:
wi_state* state: Wi state instancewi_object* object: Target objectconst char* name: Field name
Returns: bool true and pushes the value if the field exists, false and pushes nothing otherwise
wi_object_next
Iterate over an object's fields. Pass *iter = 0 on the first call.
Each call that finds a live field entry pushes its name then value and advances *iter
Parameters:
wi_state* state: Wi state instancewi_object* object: Target objectint* iter: Iteration cursor, updated in place
Returns: bool true and pushes name/value, false and pushes nothing once every field entry has been visited
wi_module_set
Export the value at the stack top as a module variable, popping it
Parameters:
wi_state* state: Wi state instancewi_module* module: Target moduleconst char* name: Variable name
wi_module_get
Get a global variable from a module and push it onto the stack
Parameters:
wi_state* state: Wi state instancewi_module* module: Target moduleconst char* name: Variable name
Returns: bool true and pushes the value if the variable exists, false and pushes nothing otherwise
wi_module_next
Iterate over a module's variables, including ones that were not exported. Pass *iter = 0 on the first call.
Each call that finds a live variable entry pushes its name then value and advances *iter
Parameters:
wi_state* state: Wi state instancewi_module* module: Target moduleint* iter: Iteration cursor, updated in place
Returns: bool true and pushes name/value, false and pushes nothing once every variable entry has been visited
wi_conf.h
Macros
WI_VERSION_STRING
Expands to: "9.8.0-beta"
Wi version as a string
WI_REAL_FORMAT
Expands to: "%.15g"
Format that Wi uses to print any real
WI_DEFAULT_CONF
Expands to: 0
Default configuration (all flags disabled)
Constants
| Category | Name | Value | Description |
|---|---|---|---|
| Version numbers | WI_VERSION_MAJOR |
9 |
Wi MAJOR version |
WI_VERSION_MINOR |
8 |
Wi MINOR version | |
WI_VERSION_PATCH |
0 |
Wi PATCH version | |
| Compiler limits | WI_CONSTANT_MAX |
65535 |
Maximum number of constants in a function |
WI_GLOBAL_MAX |
65535 |
Maximum number of globals in a module | |
WI_JUMP_MAX |
65535 |
Maximum jump offset | |
WI_LOOP_MAX |
65535 |
Maximum loop offset | |
WI_LOCAL_MAX |
255 |
Maximum number of local variables in a function | |
WI_UPVALUE_MAX |
255 |
Maximum number of upvalues in a function (closure) | |
WI_PARAMETER_MAX |
255 |
Maximum number of parameters in a function and arguments in a call | |
WI_INTERP_MAX |
8 |
Maximum depth of string interpolation | |
| Default GC settings | WI_GC_MIN_HEAP |
10485760 |
Total heap size before the first major collection (10MB) |
WI_GC_HEAP_GROW_FACTOR |
2 |
Heap growth factor per major collection | |
WI_GC_YOUNG_MAX |
1048576 |
Young generation size before a minor collection (1MB) |
|
| VM limits | WI_CSTACK_MAX |
200 |
Maximum depth of nested expressions, wi_state_call, and of recoveries |
WI_STACK_MIN |
20 |
Minimum number of values on the VM stack | |
WI_STACK_MAX |
1000000 |
Maximum number of values on the VM stack |
Types
wi_conf_flag
Configuration flags for the Wi state
WI_CONF_PRINT_CODE: Print bytecode after compilationWI_CONF_STRESS_GC: Run garbage collection on every allocationWI_CONF_LOG_GC: Log garbage collectionWI_CONF_NO_WARNINGS: Suppress compiler warningsWI_CONF_REPL: Set Wi in REPL mode
wi_conf
Configuration bitmask type
Functions
wi_conf_set
Set a configuration flag
Parameters:
wi_conf* conf: Configuration bitmaskwi_conf_flag flag: Configuration flag
wi_conf_is_set
Check if a configuration flag is set
Parameters:
wi_conf* conf: Configuration bitmaskwi_conf_flag flag: Configuration flag
Returns: bool true if the flag is set, false otherwise