diff options
author | Mike Pall <mike> | 2011-01-26 21:14:58 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-01-26 21:14:58 +0100 |
commit | 2526498c7126f3e60d1f3a8d72c97bf20bf4a49e (patch) | |
tree | dcbb57709139f3b0bbd61f347c4b5f869ccc8d3f /src | |
parent | de0781d610595da2e57fb17d867926ba214e54fa (diff) | |
download | luajit-2526498c7126f3e60d1f3a8d72c97bf20bf4a49e.tar.gz luajit-2526498c7126f3e60d1f3a8d72c97bf20bf4a49e.tar.bz2 luajit-2526498c7126f3e60d1f3a8d72c97bf20bf4a49e.zip |
FFI: Record cdata indexing with integer cdata.
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_crecord.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c index 681c5029..3e429705 100644 --- a/src/lj_crecord.c +++ b/src/lj_crecord.c | |||
@@ -481,12 +481,25 @@ void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd) | |||
481 | if (tref_isnum(idx)) | 481 | if (tref_isnum(idx)) |
482 | idx = emitconv(idx, IRT_INT, IRT_NUM, IRCONV_TRUNC|IRCONV_ANY); | 482 | idx = emitconv(idx, IRT_INT, IRT_NUM, IRCONV_TRUNC|IRCONV_ANY); |
483 | #endif | 483 | #endif |
484 | integer_key: | ||
484 | if (ctype_ispointer(ct->info)) { | 485 | if (ctype_ispointer(ct->info)) { |
485 | CTSize sz = lj_ctype_size(cts, (sid = ctype_cid(ct->info))); | 486 | CTSize sz = lj_ctype_size(cts, (sid = ctype_cid(ct->info))); |
486 | idx = crec_reassoc_ofs(J, idx, &ofs, sz); | 487 | idx = crec_reassoc_ofs(J, idx, &ofs, sz); |
487 | idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz)); | 488 | idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz)); |
488 | ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr); | 489 | ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr); |
489 | } | 490 | } |
491 | } else if (tref_iscdata(idx)) { | ||
492 | GCcdata *cdk = cdataV(&rd->argv[1]); | ||
493 | CType *ctk = ctype_raw(cts, cdk->typeid); | ||
494 | IRType t; | ||
495 | if (ctype_isenum(ctk->info)) ctk = ctype_child(cts, ctk); | ||
496 | if (ctype_isinteger(ctk->info) && (t = crec_ct2irt(ctk)) != IRT_CDATA) { | ||
497 | idx = emitir(IRT(IR_ADD, IRT_PTR), idx, lj_ir_kintp(J, sizeof(GCcdata))); | ||
498 | idx = emitir(IRT(IR_XLOAD, t), idx, 0); | ||
499 | if (!LJ_64 && (t == IRT_I64 || t == IRT_U64)) | ||
500 | idx = emitconv(idx, IRT_INT, t, 0); | ||
501 | goto integer_key; | ||
502 | } | ||
490 | } else if (tref_isstr(idx)) { | 503 | } else if (tref_isstr(idx)) { |
491 | GCstr *name = strV(&rd->argv[1]); | 504 | GCstr *name = strV(&rd->argv[1]); |
492 | /* Always specialize to the field name. */ | 505 | /* Always specialize to the field name. */ |