LispBM
Functions
env.h File Reference
#include "lbm_types.h"
Include dependency graph for env.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int lbm_init_env (void)
 
lbm_valuelbm_get_env_ptr (void)
 
lbm_value lbm_get_env (void)
 
lbm_value lbm_env_copy_spine (lbm_value env)
 
bool lbm_env_lookup_b (lbm_value *res, lbm_value sym, lbm_value env)
 
lbm_value lbm_env_lookup (lbm_value sym, lbm_value env)
 
lbm_value lbm_env_set (lbm_value env, lbm_value key, lbm_value val)
 
lbm_value lbm_env_set_functional (lbm_value env, lbm_value key, lbm_value val)
 
lbm_value lbm_env_modify_binding (lbm_value env, lbm_value key, lbm_value val)
 
lbm_value lbm_env_drop_binding (lbm_value env, lbm_value key)
 
lbm_value lbm_env_build_params_args (lbm_value params, lbm_value args, lbm_value env0)
 

Function Documentation

◆ lbm_env_build_params_args()

lbm_value lbm_env_build_params_args ( lbm_value  params,
lbm_value  args,
lbm_value  env0 
)

Extend an environment given a list of keys and a list of values.

Parameters
paramsThe list of keys.
argsThe list of values.
env0An initial environment to extend
Returns
The extended environment on success and lbm_enc_sym(SYM_MERROR) if GC needs to be run.

◆ lbm_env_copy_spine()

lbm_value lbm_env_copy_spine ( lbm_value  env)

Copy the spine of an environment. The list structure is recreated but the values themselves are not copied but rather just referenced.

Parameters
envEnvironment to copy.
Returns
Copy of environment.

◆ lbm_env_drop_binding()

lbm_value lbm_env_drop_binding ( lbm_value  env,
lbm_value  key 
)

Removes a binding (destructively) from the input environment.

Parameters
envEnvironment to modify.
keyKey to remove from environment.
Returns
Updated environment or not_found symbol.

◆ lbm_env_lookup()

lbm_value lbm_env_lookup ( lbm_value  sym,
lbm_value  env 
)

Lookup a value in from the global environment.

Parameters
symThe key to look for in the environment
envThe environment to search for the key.
Returns
The value bound to key or lbm_enc_sym(SYM_NOT_FOUND).

◆ lbm_env_lookup_b()

bool lbm_env_lookup_b ( lbm_value res,
lbm_value  sym,
lbm_value  env 
)

Lookup a value in from the global environment.

Parameters
symThe key to look for in the environment
envThe environment to search for the key.
Returns
The value bound to key or lbm_enc_sym(SYM_NOT_FOUND).

◆ lbm_env_modify_binding()

lbm_value lbm_env_modify_binding ( lbm_value  env,
lbm_value  key,
lbm_value  val 
)

Modifies an existing binding on the environment.

Parameters
envThe environment to modify.
keyThe key.
valThe new value to associate with the key.
Returns
The modified environment of Success and lbm_enc_sym(SYM_NOT_FOUND) if the key does not exist.

◆ lbm_env_set()

lbm_value lbm_env_set ( lbm_value  env,
lbm_value  key,
lbm_value  val 
)

Create a new binding on the environment or replace an old binding.

Parameters
envEnvironment to modify.
keyA symbol to associate with a value.
valThe value.
Returns
The modified environment or lbm_enc_sym(SYM_MERROR) if GC needs to be run.

◆ lbm_env_set_functional()

lbm_value lbm_env_set_functional ( lbm_value  env,
lbm_value  key,
lbm_value  val 
)

Create a new binding on the environment without destroying the old value. If the old value is unused (the key-value pair) it will be freed by GC at next convenience.

Parameters
envEnvironment to modify.
keyA symbol to associate with a value.
valThe value.
Returns
The modified environment or lbm_enc_sym(SYM_MERROR) if GC needs to be run.

◆ lbm_get_env()

lbm_value lbm_get_env ( void  )
Returns
the global environment

◆ lbm_get_env_ptr()

lbm_value* lbm_get_env_ptr ( void  )

Get a pointer to the global environment.

Returns
A pointer to the global environment variable.

◆ lbm_init_env()

int lbm_init_env ( void  )

Initialize the global environment. This sets the global environment to NIL

Returns
1