]> Cypherpunks repositories - gostls13.git/commitdiff
add creator for missing types, to avoid crashes when
authorRob Pike <r@golang.org>
Sun, 2 Nov 2008 20:32:14 +0000 (12:32 -0800)
committerRob Pike <r@golang.org>
Sun, 2 Nov 2008 20:32:14 +0000 (12:32 -0800)
signature is absent from object file.

R=rsc
DELTA=18  (18 added, 0 deleted, 0 changed)
OCL=18315
CL=18323

src/lib/reflect/test.go
src/lib/reflect/value.go

index 864220d4e2fc8173a0d68568e114178e979e6b70..49d97a6df4186080a1d6ccaab4340f5c64129a6b 100644 (file)
@@ -91,6 +91,7 @@ func main() {
        var s string;
        var t reflect.Type;
 
+       typedump("missing", "$missing$");
        typedump("int", "int");
        typedump("int8", "int8");
        typedump("int16", "int16");
@@ -106,6 +107,7 @@ func main() {
        typedump("float64", "float64");
        typedump("float80", "float80");
        typedump("int8", "int8");
+       typedump("whoknows.whatsthis", "$missing$");
        typedump("**int8", "**int8");
        typedump("**P.integer", "**P.integer");
        typedump("[32]int32", "[32]int32");
index 554da2d53e74d9624dd461806942ee51001255a1..82ceb531a55f5908e5c1e4646ace0544110f6060 100644 (file)
@@ -60,6 +60,21 @@ func AddrToPtrFloat80(Addr) *float80
 func AddrToPtrString(Addr) *string
 func AddrToPtrBool(Addr) *bool
 
+// -- Missing
+
+export type MissingValue interface {
+       Kind()  int;
+       Type()  Type;
+}
+
+type MissingValueStruct struct {
+       CommonV
+}
+
+func MissingCreator(typ Type, addr Addr) Value {
+       return &MissingValueStruct{ CommonV{IntKind, typ, addr} }
+}
+
 // -- Int
 
 export type IntValue interface {
@@ -676,6 +691,7 @@ var creator *map[int] Creator
 
 func init() {
        creator = new(map[int] Creator);
+       creator[MissingKind] = &MissingCreator;
        creator[IntKind] = &IntCreator;
        creator[Int8Kind] = &Int8Creator;
        creator[Int16Kind] = &Int16Creator;