var_table.h#
Variable table interface using Nst_MapObj.
Authors#
TheSilvered
Structs#
Nst_VarTable#
Synopsis:
typedef struct _Nst_VarTable {
Nst_ObjRef *vars;
Nst_ObjRef *global_table;
} Nst_VarTable
Description:
Structure representing the Nest variable table
Fields:
vars: the map of local variablesglobal_table: the map of global variables
Functions#
Nst_vt_init#
Synopsis:
bool Nst_vt_init(Nst_VarTable *vt, Nst_Obj *global_table, Nst_Obj *args,
bool no_default)
Description:
Initialize a variable table.
Parameters:
global_table: the current global variable table, can beNULLcwd: the current working directory, ignored whenglobal_tableis notNULLorno_defaultistrueargs: the command line arguments, ignored whenglobal_tableis notNULLorno_defaultistrueno_default: whether to create predefined variables
Returns:
true on success and false on failure. The error is set.
Nst_vt_destroy#
Synopsis:
void Nst_vt_destroy(Nst_VarTable *vt)
Description:
Destroy the contents of an Nst_VarTable. If
_vars_ still points to the vars field of the table it is dropped.
Nst_vt_get#
Synopsis:
Nst_ObjRef *Nst_vt_get(Nst_VarTable vt, Nst_Obj *name)
Description:
Get a value from a variable table.
Parameters:
vt: the variable table to get the value fromname: the name of the value to get
Returns:
The value associated with the key or
Nst_null() if the key is not present in the
table.
Nst_vt_set#
Synopsis:
bool Nst_vt_set(Nst_VarTable vt, Nst_Obj *name, Nst_Obj *val)
Description:
Set a value in a variable table.
Parameters:
vt: the variable table to set the value intoname: the name of the value to setvalue: the value to associate to name
Returns:
true on success and false on failure. The error is set.