1
0
mirror of https://github.com/golang/go synced 2024-11-21 19:24:45 -07:00

print(array)

R=r
OCL=21570
CL=21570
This commit is contained in:
Ken Thompson 2008-12-18 22:17:05 -08:00
parent c9954c63a8
commit 9786f69f74
5 changed files with 18 additions and 11 deletions

View File

@ -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();

View File

@ -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"

View File

@ -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;

View File

@ -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);
}

View File

@ -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);