From deaa290f857425c0dacb0ac65312925490da8bbe Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Fri, 12 Jul 2013 01:58:47 +0200 Subject: aml: preserve reference type when indexing into package to prevent implicit type conversion when storing to arg or local if LocalX or ArgX is a package, the store into a element should *not* type convert. so when taking the index reference, we have to carry over the type. --- sys/src/libaml/aml.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/src/libaml/aml.c b/sys/src/libaml/aml.c index a05e939a4..c9bc82525 100644 --- a/sys/src/libaml/aml.c +++ b/sys/src/libaml/aml.c @@ -1553,7 +1553,7 @@ evalindex(void) int x; x = ival(FP->arg[1]); - if(p = FP->arg[0]) switch(TAG(p)){ + if(p = deref(FP->arg[0])) switch(TAG(p)){ case 's': if(x >= strlen((char*)p)) break; @@ -1570,7 +1570,10 @@ evalindex(void) case 'p': if(x < 0 || x >= ((Package*)p)->n) break; - r = mk('R', sizeof(Ref)); + if(TAG(FP->arg[0]) == 'A' || TAG(FP->arg[0]) == 'L') + r = mk(TAG(FP->arg[0]), sizeof(Ref)); + else + r = mk('R', sizeof(Ref)); r->ref = p; r->ptr = &((Package*)p)->a[x]; store(r, FP->arg[2]); @@ -1814,7 +1817,7 @@ static Op optab[] = { [Ocall] "Call", "", evalcall, [Ostore] "Store", "*@", evalstore, - [Oindex] "Index", "*i@", evalindex, + [Oindex] "Index", "@i@", evalindex, [Osize] "SizeOf", "*", evalsize, [Oref] "RefOf", "@", evaliarg0, [Ocref] "CondRefOf", "@@", evalcondref, -- cgit v1.2.3