return ret;
}
+Sexpr* c_z(Sexpr* b, Sexpr* rest, Sexpr* env) {
+ // Zgv = g(Zg)v
+ if(COMB_Z_ARGS != u64_get_num_args(b)) {
+ return cons(b, rest);
+ }
+ Sexpr* args = b->value.b.args;
+ Sexpr* g = clone(car(cdr(args)));
+ Sexpr* v = clone(car(args));
+ sexpr_free(b);
+ Sexpr* g2 = clone(g);
+ Sexpr* z = from_opcode((COMB_PREFIX << 8) | COMB_Z);
+ Sexpr* zg = cons(z, cons(g2, from_nil()));
+ //return cons(g, rest);
+ return cons(g,cons(zg, cons(v, rest)));
+}
+
+
Sexpr* x_comb_dispatch(Sexpr* b, Sexpr* rest, Sexpr* env) {
return c_phi(b, rest, env);
case COMB_PSI:
return c_psi(b, rest, env);
+ case COMB_Z:
+ return c_z(b, rest, env);
default:
return from_nil();
}
load_builtin("W", (COMB_PREFIX << 8) | COMB_W, env);
load_builtin("Phi", (COMB_PREFIX << 8) | COMB_PHI, env);
load_builtin("Psi", (COMB_PREFIX << 8) | COMB_PSI, env);
+ load_builtin("Z", (COMB_PREFIX << 8) | COMB_Z, env);
return env;
}