reflect.PtrValue.SetSub() to set pointers
R=rsc
OCL=19101
CL=19101
diff --git a/src/lib/reflect/value.go b/src/lib/reflect/value.go
index fe41e3f..bace93b 100644
--- a/src/lib/reflect/value.go
+++ b/src/lib/reflect/value.go
@@ -39,6 +39,7 @@
export type Value interface {
Kind() int;
Type() Type;
+ Addr() Addr;
Interface() Empty;
}
@@ -58,6 +59,10 @@
return c.typ
}
+func (c *Common) Addr() Addr {
+ return c.addr
+}
+
func (c *Common) Interface() Empty {
return sys.unreflect(*AddrToPtrAddr(c.addr), c.typ.String());
}
@@ -493,6 +498,7 @@
Type() Type;
Sub() Value;
Get() Addr;
+ SetSub(Value);
}
type PtrValueStruct struct {
@@ -507,6 +513,10 @@
return NewValueAddr(v.typ.(PtrType).Sub(), v.Get());
}
+func (v *PtrValueStruct) SetSub(subv Value) {
+ *AddrToPtrAddr(v.addr) = subv.Addr();
+}
+
func PtrCreator(typ Type, addr Addr) Value {
return &PtrValueStruct{ Common{PtrKind, typ, addr} };
}