Commit 9786f69f authored by Ken Thompson's avatar Ken Thompson

print(array)

R=r
OCL=21570
CL=21570
parent c9954c63
......@@ -17,6 +17,7 @@ export func printint(int64);
export func printstring(string);
export func printpointer(*any);
export func printinter(any);
export func printarray(any);
export func printnl();
export func printsp();
......
......@@ -11,6 +11,7 @@ char *sysimport =
"export func sys.printstring (? string)\n"
"export func sys.printpointer (? *any)\n"
"export func sys.printinter (? any)\n"
"export func sys.printarray (? any)\n"
"export func sys.printnl ()\n"
"export func sys.printsp ()\n"
"export func sys.catstring (? string, ? string) (? string)\n"
......
......@@ -1936,6 +1936,11 @@ loop:
argtype(on, l->type->type); // any-1
break;
}
if(isdarray(l->type)) {
on = syslook("printarray", 1);
argtype(on, l->type); // any-1
break;
}
badtype(n->op, l->type, T);
l = listnext(&save);
goto loop;
......
......@@ -30,7 +30,7 @@ sys·newarray(uint32 nel, uint32 cap, uint32 width, Array ret)
prints("; width=");
sys·printint(width);
prints("; ret=");
sys·printarray(&ret);
sys·printarray(ret);
prints("\n");
}
}
......@@ -56,7 +56,7 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
if(hb > old.cap || lb > hb) {
if(debug) {
prints("sys·arraysliced: old=");
sys·printarray(&old);
sys·printarray(old);
prints("; lb=");
sys·printint(lb);
prints("; hb=");
......@@ -83,7 +83,7 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
if(debug) {
prints("sys·arraysliced: old=");
sys·printarray(&old);
sys·printarray(old);
prints("; lb=");
sys·printint(lb);
prints("; hb=");
......@@ -91,7 +91,7 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
prints("; width=");
sys·printint(width);
prints("; ret=");
sys·printarray(&ret);
sys·printarray(ret);
prints("\n");
}
}
......@@ -137,7 +137,7 @@ sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Arra
prints("; width=");
sys·printint(width);
prints("; ret=");
sys·printarray(&ret);
sys·printarray(ret);
prints("\n");
}
}
......@@ -158,18 +158,18 @@ sys·arrays2d(byte* old, uint32 nel, Array ret)
prints("sys·arrays2d: old=");
sys·printpointer(old);
prints("; ret=");
sys·printarray(&ret);
sys·printarray(ret);
prints("\n");
}
}
void
sys·printarray(Array *a)
sys·printarray(Array a)
{
prints("[");
sys·printint(a->nel);
sys·printint(a.nel);
prints("/");
sys·printint(a->cap);
sys·printint(a.cap);
prints("]");
sys·printpointer(a->array);
sys·printpointer(a.array);
}
......@@ -350,7 +350,7 @@ void sys·printpc(void*);
void sys·printpointer(void*);
void sys·printuint(uint64);
void sys·printhex(uint64);
void sys·printarray(Array*);
void sys·printarray(Array);
void sys·catstring(string, string, string);
void sys·cmpstring(string, string, int32);
void sys·slicestring(string, int32, int32, string);
......
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