Ejemplo n.º 1
0
static Cons *copyCons(Cons *cons) {
	if(cons == NULL) return NULL;
	Cons *c = new Cons(cons->type);
	switch(cons->type) {
	case CONS_INT: c->i = cons->i; break;
	case CONS_STR: c->str = newStr(cons->str); break;
	case CONS_FLOAT: c->f = cons->f; break;
	case CONS_CAR: c->car = copyCons(cons->car); break;
	default: abort();
	}
	if(cons->cdr != NULL) c->cdr = copyCons(cons->cdr);
	return c;
}
Ejemplo n.º 2
0
void fun_sub ()
{
    VAR_ rval = *copyCons(top());    /* make a copy              */
    pop();                          /* remove the r-operand     */

    subtract(top(), &rval);         /* subtract the rval to the top  */
    destructor(&rval);              /* remove the local var     */
}
Ejemplo n.º 3
0
static ValueType genDefun(Func *, Cons *cons, CodeBuilder *cb, int sp) {
	Cons *c = copyCons(cons);
	cb->createConsIns(INS_DEFUN, c);
	cb->getCtx()->code_cons.add(c);
	return VT_VOID;
}