17 #define ASM_TPL_IMM 1024 // bitflag for immediate gettuple op.b value
25 #define MAKE_TARGET(arch) PNTarget potion_target_##arch = { \
26 .setup = potion_##arch##_setup, \
27 .stack = potion_##arch##_stack, \
28 .registers = potion_##arch##_registers, \
29 .local = potion_##arch##_local, \
30 .upvals = potion_##arch##_upvals, \
31 .jmpedit = potion_##arch##_jmpedit, \
34 (OP_F)potion_##arch##_move, \
35 (OP_F)potion_##arch##_loadk, \
36 (OP_F)potion_##arch##_loadpn, \
37 (OP_F)potion_##arch##_self, \
38 (OP_F)potion_##arch##_newtuple, \
39 (OP_F)potion_##arch##_gettuple, \
40 (OP_F)potion_##arch##_settuple, \
41 (OP_F)potion_##arch##_getlocal, \
42 (OP_F)potion_##arch##_setlocal, \
43 (OP_F)potion_##arch##_getupval, \
44 (OP_F)potion_##arch##_setupval, \
45 (OP_F)potion_##arch##_global, \
46 (OP_F)potion_##arch##_gettable, \
47 (OP_F)potion_##arch##_settable, \
48 (OP_F)potion_##arch##_newlick, \
49 (OP_F)potion_##arch##_getpath, \
50 (OP_F)potion_##arch##_setpath, \
51 (OP_F)potion_##arch##_add, \
52 (OP_F)potion_##arch##_sub, \
53 (OP_F)potion_##arch##_mult, \
54 (OP_F)potion_##arch##_div, \
55 (OP_F)potion_##arch##_rem, \
56 (OP_F)potion_##arch##_pow, \
57 (OP_F)potion_##arch##_not, \
58 (OP_F)potion_##arch##_cmp, \
59 (OP_F)potion_##arch##_eq, \
60 (OP_F)potion_##arch##_neq, \
61 (OP_F)potion_##arch##_lt, \
62 (OP_F)potion_##arch##_lte, \
63 (OP_F)potion_##arch##_gt, \
64 (OP_F)potion_##arch##_gte, \
65 (OP_F)potion_##arch##_bitn, \
66 (OP_F)potion_##arch##_bitl, \
67 (OP_F)potion_##arch##_bitr, \
68 (OP_F)potion_##arch##_def, \
69 (OP_F)potion_##arch##_bind, \
70 (OP_F)potion_##arch##_message, \
71 (OP_F)potion_##arch##_jmp, \
72 (OP_F)potion_##arch##_test, \
73 (OP_F)potion_##arch##_testjmp, \
74 (OP_F)potion_##arch##_notjmp, \
75 (OP_F)potion_##arch##_named, \
76 (OP_F)potion_##arch##_call, \
77 (OP_F)potion_##arch##_callset, \
78 (OP_F)potion_##arch##_tailcall, \
79 (OP_F)potion_##arch##_return, \
80 (OP_F)potion_##arch##_method, \
81 (OP_F)potion_##arch##_class \
83 .finish = potion_##arch##_finish, \
84 .mcache = potion_##arch##_mcache, \
85 .ivars = potion_##arch##_ivars \
88 #define PN_HAS_UPVALS(v) \
90 if (PN_TUPLE_LEN(f->protos) > 0) { \
91 PN_TUPLE_EACH(f->protos, i, proto2, { \
92 if (PN_TUPLE_LEN(PN_PROTO(proto2)->upvals) > 0) { \
98 #define ASM(ins) *asmp = potion_asm_put(P, *asmp, (PN)(ins), sizeof(u8))
99 #define ASM2(pn) *asmp = potion_asm_put(P, *asmp, (PN)(pn), 2)
100 #define ASMI(pn) *asmp = potion_asm_put(P, *asmp, (PN)(pn), sizeof(int))
101 #define ASMN(pn) *asmp = potion_asm_put(P, *asmp, (PN)(pn), sizeof(PN))
102 #define ASMS(cstr) *asmp = potion_asm_write(P, *asmp, cstr, sizeof(cstr)-1)
PNAsm * potion_asm_clear(Potion *, PNAsm *)
record labels to be patched
PNAsm * potion_asm_new(Potion *)
PNAsm * potion_asm_write(Potion *, PNAsm *, char *, size_t)
PNAsm * potion_asm_op(Potion *, PNAsm *, u8, int, int)
the global interpreter state P. currently singleton (not threads yet)
PNAsm * potion_asm_put(Potion *, PNAsm *, PN, size_t)