Commit 65d397f7 authored by Russ Cox's avatar Russ Cox

compiler implementation of array slice change

R=ken
OCL=27533
CL=27533
parent 37a5374c
...@@ -1956,7 +1956,13 @@ ascompat(Type *dst, Type *src) ...@@ -1956,7 +1956,13 @@ ascompat(Type *dst, Type *src)
if(eqtype(dst, src, 0)) if(eqtype(dst, src, 0))
return 1; return 1;
if(isslice(dst) && isfixedarray(src) && eqtype(dst->type, src->type, 0)) if(dst == T || src == T)
return 0;
if(isslice(dst)
&& isptr[src->etype]
&& isfixedarray(src->type)
&& eqtype(dst->type, src->type->type, 0))
return 1; return 1;
if(isnilinter(dst) || isnilinter(src)) if(isnilinter(dst) || isnilinter(src))
...@@ -2194,6 +2200,8 @@ stringop(Node *n, int top) ...@@ -2194,6 +2200,8 @@ stringop(Node *n, int top)
case OARRAY: case OARRAY:
// arraystring([]byte) string; // arraystring([]byte) string;
r = n->left; r = n->left;
if(isfixedarray(r->type))
r = nod(OADDR, r, N);
on = syslook("arraystring", 0); on = syslook("arraystring", 0);
r = nod(OCALL, on, r); r = nod(OCALL, on, r);
break; break;
...@@ -2716,7 +2724,7 @@ arrayop(Node *n, int top) ...@@ -2716,7 +2724,7 @@ arrayop(Node *n, int top)
case OAS: case OAS:
// arrays2d(old *any, nel int) (ary []any) // arrays2d(old *any, nel int) (ary []any)
t = fixarray(n->right->type); t = fixarray(n->right->type->type);
tl = fixarray(n->left->type); tl = fixarray(n->left->type);
if(t == T || tl == T) if(t == T || tl == T)
break; break;
...@@ -2726,9 +2734,7 @@ arrayop(Node *n, int top) ...@@ -2726,9 +2734,7 @@ arrayop(Node *n, int top)
a->type = types[TINT]; a->type = types[TINT];
r = a; r = a;
a = nod(OADDR, n->right, N); // old r = list(n->right, r); // old
addrescapes(n->right);
r = list(a, r);
on = syslook("arrays2d", 1); on = syslook("arrays2d", 1);
argtype(on, t); // any-1 argtype(on, t); // any-1
...@@ -3019,8 +3025,8 @@ convas(Node *n) ...@@ -3019,8 +3025,8 @@ convas(Node *n)
goto out; goto out;
} }
if(isslice(lt) && isfixedarray(rt)) { if(isslice(lt) && isptr[rt->etype] && isfixedarray(rt->type)) {
if(!eqtype(lt->type->type, rt->type->type, 0)) if(!eqtype(lt->type->type, rt->type->type->type, 0))
goto bad; goto bad;
indir(n, arrayop(n, Etop)); indir(n, arrayop(n, Etop));
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment