1
0
mirror of https://github.com/golang/go synced 2024-11-23 00:20:12 -07:00

add creator for missing types, to avoid crashes when

signature is absent from object file.

R=rsc
DELTA=18  (18 added, 0 deleted, 0 changed)
OCL=18315
CL=18323
This commit is contained in:
Rob Pike 2008-11-02 12:32:14 -08:00
parent d2472eb812
commit 178e37e766
2 changed files with 18 additions and 0 deletions

View File

@ -91,6 +91,7 @@ func main() {
var s string; var s string;
var t reflect.Type; var t reflect.Type;
typedump("missing", "$missing$");
typedump("int", "int"); typedump("int", "int");
typedump("int8", "int8"); typedump("int8", "int8");
typedump("int16", "int16"); typedump("int16", "int16");
@ -106,6 +107,7 @@ func main() {
typedump("float64", "float64"); typedump("float64", "float64");
typedump("float80", "float80"); typedump("float80", "float80");
typedump("int8", "int8"); typedump("int8", "int8");
typedump("whoknows.whatsthis", "$missing$");
typedump("**int8", "**int8"); typedump("**int8", "**int8");
typedump("**P.integer", "**P.integer"); typedump("**P.integer", "**P.integer");
typedump("[32]int32", "[32]int32"); typedump("[32]int32", "[32]int32");

View File

@ -60,6 +60,21 @@ func AddrToPtrFloat80(Addr) *float80
func AddrToPtrString(Addr) *string func AddrToPtrString(Addr) *string
func AddrToPtrBool(Addr) *bool 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 // -- Int
export type IntValue interface { export type IntValue interface {
@ -676,6 +691,7 @@ var creator *map[int] Creator
func init() { func init() {
creator = new(map[int] Creator); creator = new(map[int] Creator);
creator[MissingKind] = &MissingCreator;
creator[IntKind] = &IntCreator; creator[IntKind] = &IntCreator;
creator[Int8Kind] = &Int8Creator; creator[Int8Kind] = &Int8Creator;
creator[Int16Kind] = &Int16Creator; creator[Int16Kind] = &Int16Creator;