{"tailcall", 2}, {"return", 1}, {"proto", 2}, {"class", 2}
};
+PN potion_proto_tree(Potion *P, PN cl, PN self) {
+ return PN_PROTO(self)->tree;
+}
+
PN potion_proto_call(Potion *P, PN cl, PN self, PN args) {
return potion_vm(P, self, P->lobby, args, 0, NULL);
}
f->locals = PN_TUP0();
f->upvals = PN_TUP0();
f->values = PN_TUP0();
+ f->tree = self;
f->sig = (sig == PN_NIL ? PN_TUP0() : potion_sig_compile(P, f, sig));
f->asmb = (PN)potion_asm_new(P);
void potion_compiler_init(Potion *P) {
PN pro_vt = PN_VTABLE(PN_TPROTO);
potion_method(pro_vt, "call", potion_proto_call, 0);
+ potion_method(pro_vt, "tree", potion_proto_tree, 0);
potion_method(pro_vt, "string", potion_proto_string, 0);
}
return (PN)c;
}
+PN potion_closure_code(Potion *P, PN cl, PN self) {
+ if (PN_CLOSURE(self)->extra > 0 && PN_IS_PROTO(PN_CLOSURE(self)->data[0]))
+ return PN_CLOSURE(self)->data[0];
+ return PN_NIL;
+}
+
PN potion_closure_string(Potion *P, PN cl, PN self, PN len) {
int x = 0;
PN out = potion_byte_str(P, "Function(");
PN clo_vt = PN_VTABLE(PN_TCLOSURE);
PN ref_vt = PN_VTABLE(PN_TWEAK);
PN obj_vt = PN_VTABLE(PN_TOBJECT);
+ potion_method(clo_vt, "code", potion_closure_code, 0);
potion_method(clo_vt, "string", potion_closure_string, 0);
potion_method(ref_vt, "string", potion_ref_string, 0);
potion_method(obj_vt, "forward", potion_object_forward, 0);
PN upvals; // variables in upper scopes
PN values; // numbers, strings, etc.
PN protos; // nested closures
+ PN tree; // abstract syntax tree
PN_SIZE pathsize, localsize, upvalsize;
PN asmb; // assembled instructions
PN_F jit; // jit function pointer