39 lines
617 B
C
39 lines
617 B
C
#include "am.h"
|
|
|
|
#include "env.h"
|
|
#include "store.h"
|
|
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
|
|
void am_init(am_t *am)
|
|
{
|
|
memset(am, 0, sizeof(am_t));
|
|
am->sp = am->stack + AM_STACK_SIZE - 1;
|
|
store_init(am);
|
|
env_init(am);
|
|
}
|
|
|
|
void am_push(am_t *am)
|
|
{
|
|
assert(am->sp >= am->stack);
|
|
*am->sp-- = AM_EXPR(am);
|
|
}
|
|
|
|
void am_pop(am_t *am)
|
|
{
|
|
assert(am->sp < am->stack + AM_STACK_SIZE - 1);
|
|
AM_EXPR(am) = *++am->sp;
|
|
}
|
|
|
|
void am_append_arg(am_t *am)
|
|
{
|
|
expr_t *list = AM_ARGL(am);
|
|
while (!list->is_atom)
|
|
list = list->pair.cdr;
|
|
|
|
list->is_atom = false;
|
|
list->pair.car = AM_VAL(am);
|
|
list->pair.cdr = expr_empty_list(am);
|
|
}
|