diff options
Diffstat (limited to 'src/lj_crecord.c')
-rw-r--r-- | src/lj_crecord.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c index 3097cbf0..95d09e48 100644 --- a/src/lj_crecord.c +++ b/src/lj_crecord.c | |||
@@ -941,30 +941,36 @@ static int crec_call(jit_State *J, RecordFFData *rd, GCcdata *cd) | |||
941 | return 0; | 941 | return 0; |
942 | } | 942 | } |
943 | 943 | ||
944 | /* Record ctype call metamethod. */ | 944 | void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd) |
945 | static void crec_call_meta(jit_State *J, RecordFFData *rd, CTypeID id) | ||
946 | { | 945 | { |
947 | CTState *cts = ctype_ctsG(J2G(J)); | 946 | CTState *cts = ctype_ctsG(J2G(J)); |
948 | CType *ct = ctype_raw(cts, id); | 947 | GCcdata *cd = argv2cdata(J, J->base[0], &rd->argv[0]); |
948 | CTypeID id = cd->typeid; | ||
949 | CType *ct; | ||
949 | cTValue *tv; | 950 | cTValue *tv; |
951 | MMS mm = MM_call; | ||
952 | if (id == CTID_CTYPEID) { | ||
953 | id = crec_constructor(J, cd, J->base[0]); | ||
954 | mm = MM_new; | ||
955 | } else if (crec_call(J, rd, cd)) { | ||
956 | return; | ||
957 | } | ||
958 | /* Record ctype __call/__new metamethod. */ | ||
959 | ct = ctype_raw(cts, id); | ||
950 | if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); | 960 | if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); |
951 | tv = lj_ctype_meta(cts, id, MM_call); | 961 | tv = lj_ctype_meta(cts, id, mm); |
952 | if (tv && tvisfunc(tv)) { | 962 | if (tv) { |
953 | J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; | 963 | if (tvisfunc(tv)) { |
954 | rd->nres = -1; /* Pending tailcall. */ | 964 | J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; |
955 | } else { | 965 | rd->nres = -1; /* Pending tailcall. */ |
956 | /* NYI: non-function metamethods. */ | 966 | return; |
957 | lj_trace_err(J, LJ_TRERR_BADTYPE); | 967 | } |
968 | } else if (mm == MM_new) { | ||
969 | crec_alloc(J, rd, id); | ||
970 | return; | ||
958 | } | 971 | } |
959 | } | 972 | /* No metamethod or NYI: non-function metamethods. */ |
960 | 973 | lj_trace_err(J, LJ_TRERR_BADTYPE); | |
961 | void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd) | ||
962 | { | ||
963 | GCcdata *cd = argv2cdata(J, J->base[0], &rd->argv[0]); | ||
964 | if (cd->typeid == CTID_CTYPEID) | ||
965 | crec_alloc(J, rd, crec_constructor(J, cd, J->base[0])); | ||
966 | else if (!crec_call(J, rd, cd)) | ||
967 | crec_call_meta(J, rd, cd->typeid); | ||
968 | } | 974 | } |
969 | 975 | ||
970 | static TRef crec_arith_int64(jit_State *J, TRef *sp, CType **s, MMS mm) | 976 | static TRef crec_arith_int64(jit_State *J, TRef *sp, CType **s, MMS mm) |