x-engine-c v0.2.13
The C engine for x-lang
Loading...
Searching...
No Matches
x-tco.c File Reference

The environment save and restore around a tail call. More...

#include "x-tco.h"
#include "x-eval.h"

Functions

x_obj_tx_tco_env_save (x_obj_t *p_base)
 
void x_tco_restore (x_obj_t *p_base, x_obj_t *p_env)
 

Detailed Description

The environment save and restore around a tail call.

Author
Jon Ruttan (jonru.nosp@m.ttan.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)

Function Documentation

◆ x_tco_env_save()

x_obj_t * x_tco_env_save ( x_obj_t p_base)

Push the current environment onto the save-stack and return it.

A procedure call and eval-with-env snapshot the environment this way before making another one current; the trampoline, or x_eval_body_tco's early exits, put it back with x_tco_restore(). The environment is a value, so the snapshot is the pointer and nothing else – there is no boundary, tree or shadow list to carry beside it.

Parameters
p_basex_obj_t* – Base (execution context)
Returns
x_obj_t* – The environment pushed
See also
x_tco_restore

◆ x_tco_restore()

void x_tco_restore ( x_obj_t p_base,
x_obj_t p_env 
)

Make p_env the current environment.

Does NOT touch the save-stack – a caller that took the environment from the save-stack top pops it separately. This is the single restore used by both trampoline exit points (x_eval, x_eval_tco_trampoline), x_eval_body_tco's early-exit paths, eval-with-env, and the operative return.

Parameters
p_basex_obj_t* – Base (execution context)
p_envx_obj_t* – The environment to make current
See also
x_tco_env_save