fixed bug in mpconst float multiply by 0.
more complex -- constants, variables and print.
R=rsc
CC=golang-dev
https://golang.org/cl/217061
diff --git a/src/pkg/runtime/print.c b/src/pkg/runtime/print.c
index 1214fed5..d721f39 100644
--- a/src/pkg/runtime/print.c
+++ b/src/pkg/runtime/print.c
@@ -118,6 +118,9 @@
case 'f':
·printfloat(*(float64*)arg);
break;
+ case 'C':
+ ·printcomplex(*(Complex128*)arg);
+ break;
case 'i':
·printiface(*(Iface*)arg);
break;
@@ -259,6 +262,16 @@
}
void
+·printcomplex(Complex128 v)
+{
+ write(fd, "(", 1);
+ ·printfloat(v.real);
+ write(fd, ",", 1);
+ ·printfloat(v.imag);
+ write(fd, "i)", 2);
+}
+
+void
·printuint(uint64 v)
{
byte buf[100];
diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h
index b361bac..194503e 100644
--- a/src/pkg/runtime/runtime.h
+++ b/src/pkg/runtime/runtime.h
@@ -59,11 +59,13 @@
typedef struct MCache MCache;
typedef struct Iface Iface;
typedef struct Itab Itab;
-typedef struct Eface Eface;
+typedef struct Eface Eface;
typedef struct Type Type;
typedef struct Defer Defer;
typedef struct hash Hmap;
typedef struct Hchan Hchan;
+typedef struct Complex64 Complex64;
+typedef struct Complex128 Complex128;
/*
* per-cpu declaration.
@@ -145,6 +147,16 @@
Type* type;
void* data;
};
+struct Complex64
+{
+ float32 real;
+ float32 imag;
+};
+struct Complex128
+{
+ float64 real;
+ float64 imag;
+};
struct Slice
{ // must not move anything
@@ -460,6 +472,7 @@
#define runtime_printpointer ·printpointer
#define runtime_printstring ·printstring
#define runtime_printuint ·printuint
+#define runtime_printcomplex ·printcomplex
#define runtime_setcallerpc ·setcallerpc
#endif
@@ -492,6 +505,7 @@
void runtime_printuint(uint64);
void runtime_printhex(uint64);
void runtime_printslice(Slice);
+void runtime_printcomplex(Complex128);
void ·panicl(int32);
/*