Fetch a Boolean from the stack.
int lily_arg_boolean ( lily_state * s, int index )
Fetch a Byte from the stack.
uint8_t lily_arg_byte ( lily_state * s, int index )
Fetch a ByteString from the stack.
lily_bytestring_val *lily_arg_bytestring( lily_state * s, int index )
Fetch a user-defined class, (non-empty) variant, List, or Tuple.
lily_container_val * lily_arg_container ( lily_state * s, int index )
How many arguments the function being called was given.
uint16_t lily_arg_count( lily_state * s )
Fetch a Double from the stack.
double lily_arg_double ( lily_state * s, int index )
Fetch a File from the stack.
lily_file_val * lily_arg_file ( lily_state * s, int index )
Fetch a Function from the stack.
lily_function_val * lily_arg_function ( lily_state * s, int index )
Fetch a pointer-based (foreign) value from the stack.
lily_generic_val * lily_arg_generic ( lily_state * s, int index )
Fetch a Hash from the stack.
lily_hash_val * lily_arg_hash ( lily_state * s, int index )
Fetch a Integer from the stack.
int64_t lily_arg_integer ( lily_state * s, int index )
Check if an argument has an exact class id.
int lily_arg_isa( lily_state * s, int index, uint16_t class_id )
Fetch a String from the stack.
lily_string_val * lily_arg_string ( lily_state * s, int index )
Fetch the underlying buffer of a String from the stack.
char * lily_arg_string_raw( lily_state * s, int index )
Fetch a complete value with flags and class information.
lily_value * lily_arg_value ( lily_state * s, int index )
Extract a Boolean.
int lily_as_boolean ( lily_value * value )
Extract a Byte.
uint8_t lily_as_byte ( lily_value * value )
Extract a ByteString.
lily_bytestring_val *lily_as_bytestring( lily_value * value )
Extract a container (user-defined class, non-empty variant, List, or Tuple).
lily_container_val * lily_as_container ( lily_value * value )
Extract a Double.
double lily_as_double ( lily_value * value )
Extract a File.
lily_file_val * lily_as_file ( lily_value * value )
Extract a Function.
lily_function_val * lily_as_function ( lily_value * value )
Extract a generic pointer (to be cast to some other type)..
lily_generic_val * lily_as_generic ( lily_value * value )
Extract a Hash.
lily_hash_val * lily_as_hash ( lily_value * value )
Extract a Integer.
int64_t lily_as_integer ( lily_value * value )
Extract a String.
lily_string_val * lily_as_string ( lily_value * value )
Extract the raw buffer behind a String.
char * lily_as_string_raw( lily_value * value )
Get the size (in bytes) of a ByteString.
uint32_t lily_bytestring_length( lily_bytestring_val * byte_val )
Get the raw buffer behind a ByteString.
char *lily_bytestring_raw( lily_bytestring_val * byte_val )
(Stack: -count) Perform a prepared call using values from the stack.
void lily_call( lily_state * s, uint16_t count )
(Stack: +1) Reserve a result register and prepare ‘func’.
void lily_call_prepare( lily_state * s, lily_function_val * func )
Return the register that ‘lily_call_prepare’ reserved.
lily_value *lily_call_result( lily_state * s )
Function for autogenerated ID_* macros to get a class id.
uint16_t lily_cid_at( lily_state * s, int index )
Fetch an element from a container.
lily_value *lily_con_get( lily_container_val * con, uint32_t index )
Set an element into a container.
void lily_con_set( lily_container_val * con, uint32_t index, lily_value * value )
(Stack: -1) Set an element into a container from the stack.
void lily_con_set_from_stack( lily_state * s, lily_container_val * con, uint32_t index )
Return the number of occupied values in a container.
uint32_t lily_con_size( lily_container_val * con )
Fetch an interpreter’s config struct.
lily_config *lily_config_get( lily_state * s )
Initialize a config to default values.
void lily_config_init( lily_config * config )
This is the default import hook.
void lily_default_import_func( lily_state * s, const char * target )
Raise DivisionByZeroError with the given message and args.
void lily_DivisionByZeroError( lily_state * s, const char * format, ... )
Remove an error callback (typically at foreign function exit).
void lily_error_callback_pop( lily_state * s )
Push an error callback for the current foreign function.
void lily_error_callback_push( lily_state * s, lily_error_callback_func callback_fn )
Fetch the message and traceback of the last failed parse/render.
const char *lily_error_message( lily_state * s )
Fetch only the message of the last failed parse/render.
const char *lily_error_message_no_trace( lily_state * s )
Return a suitable exit code based on the status of the interpreter.
int lily_exit_code( lily_state * s )
Return the underlying FILE * of a File (if in read mode), or raise IOError.
FILE *lily_file_for_read( lily_state * s, lily_file_val * file )
Return the underlying FILE * of a File (if in write mode), or raise IOError.
FILE *lily_file_for_write( lily_state * s, lily_file_val * file )
Search for a function called ‘name’.
lily_function_val *lily_find_function( lily_state * s, const char * name )
Free a msgbuf struct and the underlying buffer.
void lily_free_msgbuf( lily_msgbuf * msgbuf )
Destroy an interpreter and any values it holds.
void lily_free_state( lily_state * s )
Return the bytecode of a Function.
uint16_t *lily_function_bytecode( lily_function_val * func, uint16_t * length )
Return 1 if the Function has a foreign implementation, 0 otherwise.
int lily_function_is_foreign( lily_function_val * func )
Return 1 if the Function has a native implementation, 0 otherwise.
int lily_function_is_native( lily_function_val * func )
Return 1 if an exit function has been called, 0 otherwise.
int lily_has_exited( lily_state * s )
Look for a given key within a Hash.
lily_value *lily_hash_get( lily_state * s, lily_hash_val * hash, lily_value * key )
Set ‘key’ to ‘value’ within a given hash.
void lily_hash_set( lily_state * s, lily_hash_val * hash, lily_value * key, lily_value * record )
(Stack: -2) lily_hash_set, but key and value come from the stack.
void lily_hash_set_from_stack( lily_state * s, lily_hash_val * hash )
(Stack: +1?)
int lily_hash_take( lily_state * s, lily_hash_val * hash, lily_value * key )
Return the directory of the package that the source import belongs to.
const char *lily_import_current_root_dir( lily_state * s )
Import a file for the interpreter.
int lily_import_file( lily_state * s, const char * target )
Load a library from a given path.
int lily_import_library( lily_state * s, const char * target )
Load a preloaded library.
int lily_import_library_data( lily_state * s, const char * target, const char ** info_table, lily_call_entry_func * call_table )
Load a string (context path, then content) as a library.
int lily_import_string( lily_state * s, const char * target, const char * content )
Use a local directory for upcoming imports.
void lily_import_use_local_dir( lily_state * s, const char * dir )
Use a package directory for upcoming imports.
void lily_import_use_package_dir( lily_state * s, const char * dir )
Raise IndexError with the given message and args.
void lily_IndexError( lily_state * s, const char * format, ... )
Raise IOError with the given message and args.
void lily_IOError( lily_state * s, const char * format, ... )
Check if ‘source’ is valid utf-8.
int lily_is_valid_utf8( const char * source )
Raise KeyError with the given message and args.
void lily_KeyError( lily_state * s, const char * format, ... )
Insert a value, pushing others to the right.
void lily_list_insert( lily_container_val * con, uint32_t index, lily_value * value )
Push a value onto the end of a List.
void lily_list_push( lily_container_val * con, lily_value * value )
Reserve N elements in a List.
void lily_list_reserve( lily_container_val * con, uint32_t size )
(Stack: +1) Take an element out of a List, pushing it onto the stack.
void lily_list_take( lily_state * s, lily_container_val * con, uint32_t index )
Prepare a file for the interpreter.
int lily_load_file( lily_state * s, const char * path )
Prepare a string for the interpreter.
int lily_load_string( lily_state * s, const char * context, const char * str )
Add ‘source’ to the msgbuf.
void lily_mb_add( lily_msgbuf * msgbuf, const char * source )
Add a single character ‘ch’ to the msgbuf.
void lily_mb_add_char( lily_msgbuf * msgbuf, char ch )
Add to the msgbuf based on a format string.
void lily_mb_add_fmt( lily_msgbuf * msgbuf, const char * format, ... )
lily_mb_add_fmt, but using a va_list.
void lily_mb_add_fmt_va( lily_msgbuf * msgbuf, const char * format, va_list )
Add ‘count’ characters of ‘source’ to the msgbuf.
void lily_mb_add_sized( lily_msgbuf * msgbuf, const char * source, int count )
Add ‘source’ to the msgbuf, from ‘start’ to ‘end’.
void lily_mb_add_slice( lily_msgbuf * msgbuf, const char * source, int start, int end )
Interpolate a value into the msgbuf.
void lily_mb_add_value( lily_msgbuf * msgbuf, lily_state * s, lily_value * value )
Drop all contents in the msgbuf.
lily_msgbuf *lily_mb_flush( lily_msgbuf * msgbuf )
Add html-escaped version of ‘input’ to the msgbuf.
const char *lily_mb_html_escape( lily_msgbuf * msgbuf, const char * input )
Return the length of the msgbuf.
int lily_mb_pos( lily_msgbuf * msgbuf )
Return the underlying buffer of a msgbuf.
const char *lily_mb_raw( lily_msgbuf * msgbuf )
Equivalent to flush, add_fmt, returning the underlying buffer.
const char *lily_mb_sprintf( lily_msgbuf * msgbuf, const char * format, ... )
Return the common msgbuf of the interpreter.
lily_msgbuf *lily_msgbuf_get( lily_state * )
Create a new msgbuf with a starting size of ‘size’.
lily_msgbuf *lily_new_msgbuf( uint32_t size )
Create a new interpreter.
lily_state *lily_new_state( lily_config * config )
Fetch a Boolean at ‘index’ or use the ‘fallback’ value.
int lily_optional_boolean( lily_state * s, int pos, int fallback )
Fetch an Integer at ‘index’ or use the ‘fallback’ value.
int64_t lily_optional_integer( lily_state * s, int pos, int64_t fallback )
Fetch the backing of a String at ‘index’ or use the ‘fallback’ value.
const char *lily_optional_string_raw( lily_state * s, int pos, const char * fallback )
Parse content prepared for the interpreter.
int lily_parse_content( lily_state * s )
Parse an expression prepared for the interpreter.
int lily_parse_expr( lily_state * s, const char ** output )
Parse content as a manifest file.
int lily_parse_manifest( lily_state * s )
(Stack: +1) Push a Boolean value onto the stack.
void lily_push_boolean ( lily_state * s, int value )
(Stack: +1) Push a Byte value onto the stack.
void lily_push_byte ( lily_state * s, uint8_t value )
(Stack: +1) Push a ByteString value onto the stack.
void lily_push_bytestring ( lily_state * s, const char * source, int size )
(Stack: +1) Push a Double value onto the stack.
void lily_push_double ( lily_state * s, double value )
(Stack: +1) Push an empty variant (such as None) onto the stack.
void lily_push_empty_variant( lily_state * s, uint16_t class_id )
(Stack: +1) Push a foreign class value onto the stack.
lily_foreign_val * lily_push_foreign ( lily_state * s, uint16_t class_id, lily_destroy_func destroy_fn, size_t size )
(Stack: +1) Push a new Hash with ‘size’ slots reserved onto the stack.
lily_hash_val * lily_push_hash ( lily_state * s, int size )
(Stack: +1) Push a user-defined class instance with ‘size’ values onto the stack.
lily_container_val *lily_push_instance ( lily_state * s, uint16_t class_id, uint32_t size )
(Stack: +1) Push a new Integer onto the stack.
void lily_push_integer ( lily_state * s, int64_t value )
(Stack: +1) Push a List with ‘size’ values onto the stack.
lily_container_val *lily_push_list ( lily_state * s, uint32_t size )
(Stack: +1) Push a String wrapping over ‘source’ onto the stack.
void lily_push_string ( lily_state * s, const char * source )
(Stack: +1) Push a String of ‘size’ bytes from ‘source’ onto the stack.
void lily_push_string_sized ( lily_state * s, const char * source, int size )
(Stack: +1) Push a superclass onto the stack.
lily_container_val *lily_push_super ( lily_state * s, uint16_t class_id, uint32_t size )
(Stack: +1) Push a Tuple with ‘size’ values onto the stack.
lily_container_val *lily_push_tuple ( lily_state * s, uint32_t size )
(Stack: +1) Push the unit value (of class Unit) onto the stack.
void lily_push_unit ( lily_state * s )
(Stack: +1) Push an unset value onto the stack.
void lily_push_unset ( lily_state * s )
(Stack: +1) Push a full value onto the stack.
void lily_push_value ( lily_state * s, lily_value * value )
(Stack: +1) Push a variant of ‘class_id’ and ‘size’ values onto the stack.
lily_container_val *lily_push_variant ( lily_state * s, uint16_t class_id, uint32_t size )
Parse content prepared for the interpreter.
int lily_render_content( lily_state * s )
Set a Boolean return value.
void lily_return_boolean( lily_state * s, int value )
Set a Byte return value.
void lily_return_byte ( lily_state * s, uint8_t value )
Set a Double return value.
void lily_return_double ( lily_state * s, double value )
Set an Integer return value.
void lily_return_integer( lily_state * s, int64_t value )
Set a None return value.
void lily_return_none ( lily_state * s )
Set a Some holding the top of the stack as the return value.
void lily_return_some_of_top( lily_state * s )
Set a String return value.
void lily_return_string ( lily_state * s, const char * value )
Use this if lily_push_super was used.
void lily_return_super ( lily_state * s )
Set the return value as the value currently at the top of the stack.
void lily_return_top ( lily_state * s )
Set a Unit return value.
void lily_return_unit ( lily_state * s )
Set the value given as the return value.
void lily_return_value ( lily_state * s, lily_value * value )
Raise RuntimeError with the given message and args.
void lily_RuntimeError( lily_state * s, const char * format, ... )
Pop the top of the stack, deref-ing it if necessary.
void lily_stack_drop_top( lily_state * s )
Return the value at the top of the stack.
lily_value *lily_stack_get_top( lily_state * s )
Returns the size (in bytes) of a String buffer.
uint32_t lily_string_length( lily_string_val * string_val )
Returns the raw buffer behind a String.
char *lily_string_raw( lily_string_val * string_val )
Parse (but don’t execute) content prepared for the interpreter.
int lily_validate_content( lily_state * s )
Find out what group that a value belongs to.
lily_value_group lily_value_get_group( lily_value * value )
Place a gc tag onto ‘value’.
void lily_value_tag( lily_state * s, lily_value * value )
Raise ValueError with the given message and args.
void lily_ValueError( lily_state * s, const char * format, ... )