diff options
Diffstat (limited to 'src/lj_crecord.c')
-rw-r--r-- | src/lj_crecord.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c index 6a22544a..f9220322 100644 --- a/src/lj_crecord.c +++ b/src/lj_crecord.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "lj_cconv.h" | 20 | #include "lj_cconv.h" |
21 | #include "lj_clib.h" | 21 | #include "lj_clib.h" |
22 | #include "lj_ccall.h" | 22 | #include "lj_ccall.h" |
23 | #include "lj_ff.h" | ||
23 | #include "lj_ir.h" | 24 | #include "lj_ir.h" |
24 | #include "lj_jit.h" | 25 | #include "lj_jit.h" |
25 | #include "lj_ircall.h" | 26 | #include "lj_ircall.h" |
@@ -1587,7 +1588,27 @@ void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd) | |||
1587 | emitir(IRTG(IR_EQ, IRT_STR), J->base[0], lj_ir_kstr(J, strV(&rd->argv[0]))); | 1588 | emitir(IRTG(IR_EQ, IRT_STR), J->base[0], lj_ir_kstr(J, strV(&rd->argv[0]))); |
1588 | J->postproc = LJ_POST_FIXBOOL; | 1589 | J->postproc = LJ_POST_FIXBOOL; |
1589 | J->base[0] = TREF_TRUE; | 1590 | J->base[0] = TREF_TRUE; |
1590 | } /* else: interpreter will throw. */ | 1591 | } else { |
1592 | lj_trace_err(J, LJ_TRERR_BADTYPE); | ||
1593 | } | ||
1594 | } | ||
1595 | |||
1596 | /* Record ffi.sizeof(), ffi.alignof(), ffi.offsetof(). */ | ||
1597 | void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd) | ||
1598 | { | ||
1599 | CTypeID id = argv2ctype(J, J->base[0], &rd->argv[0]); | ||
1600 | if (rd->data == FF_ffi_sizeof) { | ||
1601 | CType *ct = lj_ctype_rawref(ctype_ctsG(J2G(J)), id); | ||
1602 | if (ctype_isvltype(ct->info)) | ||
1603 | lj_trace_err(J, LJ_TRERR_BADTYPE); | ||
1604 | } else if (rd->data == FF_ffi_offsetof) { /* Specialize to the field name. */ | ||
1605 | if (!tref_isstr(J->base[1])) | ||
1606 | lj_trace_err(J, LJ_TRERR_BADTYPE); | ||
1607 | emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, strV(&rd->argv[1]))); | ||
1608 | rd->nres = 3; /* Just in case. */ | ||
1609 | } | ||
1610 | J->postproc = LJ_POST_FIXCONST; | ||
1611 | J->base[0] = J->base[1] = J->base[2] = TREF_NIL; | ||
1591 | } | 1612 | } |
1592 | 1613 | ||
1593 | /* -- Miscellaneous library functions ------------------------------------- */ | 1614 | /* -- Miscellaneous library functions ------------------------------------- */ |