summaryrefslogtreecommitdiff
path: root/src/lj_crecord.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_crecord.c')
-rw-r--r--src/lj_crecord.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c
index 96b62efe..c688caa3 100644
--- a/src/lj_crecord.c
+++ b/src/lj_crecord.c
@@ -1031,6 +1031,7 @@ void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd)
1031 CType *ct; 1031 CType *ct;
1032 CTypeID id = lj_ctype_getname(cts, &ct, name, CLNS_INDEX); 1032 CTypeID id = lj_ctype_getname(cts, &ct, name, CLNS_INDEX);
1033 cTValue *tv = lj_tab_getstr(cl->cache, name); 1033 cTValue *tv = lj_tab_getstr(cl->cache, name);
1034 rd->nres = rd->data;
1034 if (id && tv && !tvisnil(tv)) { 1035 if (id && tv && !tvisnil(tv)) {
1035 /* Specialize to the symbol name and make the result a constant. */ 1036 /* Specialize to the symbol name and make the result a constant. */
1036 emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, name)); 1037 emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, name));
@@ -1041,7 +1042,21 @@ void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd)
1041 else 1042 else
1042 J->base[0] = lj_ir_kint(J, (int32_t)ct->size); 1043 J->base[0] = lj_ir_kint(J, (int32_t)ct->size);
1043 } else if (ctype_isextern(ct->info)) { 1044 } else if (ctype_isextern(ct->info)) {
1044 lj_trace_err(J, LJ_TRERR_BADTYPE); /* NYI: access extern variables. */ 1045 CTypeID sid = ctype_cid(ct->info);
1046 void *sp = *(void **)cdataptr(cdataV(tv));
1047 TRef ptr;
1048 ct = ctype_raw(cts, sid);
1049 if (rd->data && ctype_isenum(ct->info)) ct = ctype_child(cts, ct);
1050 if (LJ_64 && !checkptr32(sp))
1051 ptr = lj_ir_kintp(J, (uintptr_t)sp);
1052 else
1053 ptr = lj_ir_kptr(J, sp);
1054 if (rd->data) {
1055 J->base[0] = crec_tv_ct(J, ct, sid, ptr);
1056 } else {
1057 J->needsnap = 1;
1058 crec_ct_tv(J, ct, ptr, J->base[2], &rd->argv[2]);
1059 }
1045 } else { 1060 } else {
1046 J->base[0] = lj_ir_kgc(J, obj2gco(cdataV(tv)), IRT_CDATA); 1061 J->base[0] = lj_ir_kgc(J, obj2gco(cdataV(tv)), IRT_CDATA);
1047 } 1062 }