summaryrefslogtreecommitdiff
path: root/sys/src/libaml
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-07-12 01:58:47 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-07-12 01:58:47 +0200
commitdeaa290f857425c0dacb0ac65312925490da8bbe (patch)
treeeee06d1a9a07f8636cf303b4d2b27a39539e24b3 /sys/src/libaml
parent7b08f4496bbb1f6ead932d650d6572e754a98ee7 (diff)
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.
Diffstat (limited to 'sys/src/libaml')
-rw-r--r--sys/src/libaml/aml.c9
1 files 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,