diff options
Diffstat (limited to 'src/ls_internal.h')
-rw-r--r-- | src/ls_internal.h | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/ls_internal.h b/src/ls_internal.h index 45892b1..524f5b4 100644 --- a/src/ls_internal.h +++ b/src/ls_internal.h @@ -37,7 +37,7 @@ /// Define a keyword function. This is used by the code generated by gen_kws.py #define LS_KW_FUN(n) \ void ls_kw_fun_ ## n ( \ - ls_context_t * ctx \ + ls_t * self \ ) /// Initial hash value. Set a uint8_t to this and then use @@ -63,7 +63,7 @@ // --- PRIVATE DATATYPES ------------------------------------------------------- // --- PUBLIC DATATYPES -------------------------------------------------------- -typedef void (*ls_kw_fun_t)(ls_context_t * ctx); +typedef void (*ls_kw_fun_t)(ls_t * self); typedef struct { char const LS_PROGMEM * name; @@ -99,16 +99,16 @@ extern const LS_PROGMEM ls_kwdef_t ls_kwmap[]; // --- PUBLIC VARIABLES -------------------------------------------------------- // --- PUBLIC FUNCTIONS -------------------------------------------------------- -/// Initialize a context as if to run, but do not execute. +/// Initialize an ls_t as if to run, but do not execute. /// /// @param pool - pool to load (can be null, but then pool and callstack will /// not get initialized) -void ls_init_ctx(ls_context_t * ctx, ls_value_t * pool, size_t szpool); +void ls_init(ls_t * self, ls_value_t * pool, size_t szpool); /// Identify what type the next token is, but do not consume it. /// /// Can throw on internal errors, but returns LS_TOK_INVALID on a syntax error. -ls_token_ty_t ls_ident_token(ls_context_t * ctx, int offset); +ls_token_ty_t ls_ident_token(ls_t * self, int offset); /// Try to convert a word to a keyword. Note that this does not take /// abbreviations. Those are converted simply by casting to ls_kw_t after @@ -120,57 +120,57 @@ ls_kw_t ls_convert_kw(char const * word); /// Throw an error, to be caught by the setjmp in the interpreter. If the error /// is LS_OK, no throw occurs. -void ls_throw_err(ls_context_t * ctx, ls_error_t e); +void ls_throw_err(ls_t * self, ls_error_t e); /// Fetch a character, relative to the current one. Throws if the fetcher /// returns an error other than LS_NO_PROGRAM. If there is no character, /// returns nul. -ls_uchar ls_fetch_rel(ls_context_t * ctx, int offset); +ls_uchar ls_fetch_rel(ls_t * self, int offset); /// Fetch a character at a specific location. If there is no character, returns /// nul. -ls_uchar ls_fetch(ls_context_t * ctx, ls_addr_t pc); +ls_uchar ls_fetch(ls_t * self, ls_addr_t pc); /// Allocate from the pool, throwing LS_OUT_OF_MEMORY if not possible. Always /// returns a valid pointer (or doesn't return) -ls_value_t * ls_alloc(ls_context_t * ctx); +ls_value_t * ls_alloc(ls_t * self); /// Deallocate, returning to the pool. -void ls_free(ls_context_t * ctx, ls_value_t * v); +void ls_free(ls_t * self, ls_value_t * v); /// Free a value, including anything it points to -void ls_free_val(ls_context_t * ctx, ls_value_t * v); +void ls_free_val(ls_t * self, ls_value_t * v); /// Count the number of free blocks -size_t ls_mem_avail(ls_context_t * ctx); +size_t ls_mem_avail(ls_t * self); /// Find and return a variable by name. /// /// @retval NULL if the variable does not exist -ls_value_t * ls_find_var(ls_context_t * ctx, char const * name); +ls_value_t * ls_find_var(ls_t * self, char const * name); /// Create a new variable in the current scope. /// /// @return the variable -ls_value_t * ls_new_var(ls_context_t * ctx, char const * name); +ls_value_t * ls_new_var(ls_t * self, char const * name); /// Read an integer variable. If the variable does not contain an integer, /// throw LS_TYPE_MISMATCH. -ls_int_t ls_read_int_var(ls_context_t * ctx, ls_value_t * var); +ls_int_t ls_read_int_var(ls_t * self, ls_value_t * var); /// Write an integer variable. If the variable contains a different type, its /// type will be changed. -void ls_write_int_var(ls_context_t * ctx, ls_value_t * var, ls_int_t val); +void ls_write_int_var(ls_t * self, ls_value_t * var, ls_int_t val); /// Write a variable of any type. val is not consumed and is assumed not /// to live in the pool (space is allocated as needed). -void ls_write_var(ls_context_t * ctx, ls_value_t * var, ls_value_t * val); +void ls_write_var(ls_t * self, ls_value_t * var, ls_value_t * val); /// Execute one line. /// /// @return whether there was a line to execute. This will return false if /// the script reaches the end, or if the END keyword or an external abort /// occur. -bool ls_exec_line(ls_context_t * ctx); +bool ls_exec_line(ls_t * self); #endif // !defined(LS_INTERNAL_H) |