ref: 774bb44e81442cb66eeb4794ea370e717df1b78b
parent: 7001bae42e895c31ad2b9eb57fd1caa7ad0077e4
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Thu Jul 11 21:58:47 EDT 2013
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.
--- a/sys/src/libaml/aml.c
+++ b/sys/src/libaml/aml.c
@@ -1553,7 +1553,7 @@
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 @@
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 @@
[Ocall] "Call", "", evalcall,
[Ostore] "Store", "*@", evalstore,
- [Oindex] "Index", "*i@", evalindex,
+ [Oindex] "Index", "@i@", evalindex,
[Osize] "SizeOf", "*", evalsize,
[Oref] "RefOf", "@", evaliarg0,
[Ocref] "CondRefOf", "@@", evalcondref,
--
⑨