Automated g4 rollback of changelist 19916.

*** Reason for rollback ***

broke build

*** Original change description ***

utf8: add InString routines for decoding in strings
reflect: add InterfaceValue.Get(), remove Empty
strconv: add Quote, CanBackquote
fmt:
	* %q go-quoted " string
	* %#q go-quoted ` string if possible, " string otherwise
	* %x hexadecimal string
	* anywhere a string is okay, *[]byte is okay
	* flags # 0 - + space
	* print value inside interface, not interface itself
	* tests

TBR=r
OCL=19920
CL=19920
This commit is contained in:
Russ Cox 2008-11-24 13:24:15 -08:00
parent b65a930453
commit 85fea81d70
14 changed files with 158 additions and 636 deletions

View file

@ -36,13 +36,14 @@ func AddrToPtrString(Addr) *string
func AddrToPtrBool(Addr) *bool
func AddrToPtrRuntimeArray(Addr) *RuntimeArray
func PtrRuntimeArrayToAddr(*RuntimeArray) Addr
func AddrToPtrInterface(Addr) *interface{}
export type Empty interface {} // TODO(r): Delete when no longer needed?
export type Value interface {
Kind() int;
Type() Type;
Addr() Addr;
Interface() interface {};
Interface() Empty;
}
// Common fields and functionality for all values
@ -65,7 +66,7 @@ func (c *Common) Addr() Addr {
return c.addr
}
func (c *Common) Interface() interface {} {
func (c *Common) Interface() Empty {
return sys.unreflect(*AddrToPtrAddr(c.addr), c.typ.String());
}
@ -713,17 +714,12 @@ func StructCreator(typ Type, addr Addr) Value {
export type InterfaceValue interface {
Kind() int;
Type() Type;
Get() interface {};
}
type InterfaceValueStruct struct {
Common
}
func (v *InterfaceValueStruct) Get() interface{} {
return *AddrToPtrInterface(v.addr);
}
func InterfaceCreator(typ Type, addr Addr) Value {
return &InterfaceValueStruct{ Common{InterfaceKind, typ, addr} }
}
@ -828,7 +824,7 @@ export func NewOpenArrayValue(typ ArrayType, len, cap int) ArrayValue {
return NewValueAddr(typ, PtrRuntimeArrayToAddr(array));
}
export func NewValue(e interface {}) Value {
export func NewValue(e Empty) Value {
value, typestring := sys.reflect(e);
p, ok := typecache[typestring];
if !ok {