Skip to content

Commit

Permalink
fix tree for reflect rename
Browse files Browse the repository at this point in the history
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4435067
  • Loading branch information
rsc committed Apr 25, 2011
1 parent 0e2bb62 commit 07abf1c
Show file tree
Hide file tree
Showing 46 changed files with 195 additions and 195 deletions.
20 changes: 10 additions & 10 deletions src/cmd/gofmt/rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func dump(msg string, val reflect.Value) {
// rewriteFile applies the rewrite rule 'pattern -> replace' to an entire file.
func rewriteFile(pattern, replace ast.Expr, p *ast.File) *ast.File {
m := make(map[string]reflect.Value)
pat := reflect.NewValue(pattern)
repl := reflect.NewValue(replace)
pat := reflect.ValueOf(pattern)
repl := reflect.ValueOf(replace)
var f func(val reflect.Value) reflect.Value // f is recursive
f = func(val reflect.Value) reflect.Value {
// don't bother if val is invalid to start with
Expand All @@ -73,11 +73,11 @@ func rewriteFile(pattern, replace ast.Expr, p *ast.File) *ast.File {
}
val = apply(f, val)
if match(m, pat, val) {
val = subst(m, repl, reflect.NewValue(val.Interface().(ast.Node).Pos()))
val = subst(m, repl, reflect.ValueOf(val.Interface().(ast.Node).Pos()))
}
return val
}
return apply(f, reflect.NewValue(p)).Interface().(*ast.File)
return apply(f, reflect.ValueOf(p)).Interface().(*ast.File)
}


Expand All @@ -103,13 +103,13 @@ func setValue(x, y reflect.Value) {

// Values/types for special cases.
var (
objectPtrNil = reflect.NewValue((*ast.Object)(nil))
scopePtrNil = reflect.NewValue((*ast.Scope)(nil))
objectPtrNil = reflect.ValueOf((*ast.Object)(nil))
scopePtrNil = reflect.ValueOf((*ast.Scope)(nil))

identType = reflect.Typeof((*ast.Ident)(nil))
objectPtrType = reflect.Typeof((*ast.Object)(nil))
positionType = reflect.Typeof(token.NoPos)
scopePtrType = reflect.Typeof((*ast.Scope)(nil))
identType = reflect.TypeOf((*ast.Ident)(nil))
objectPtrType = reflect.TypeOf((*ast.Object)(nil))
positionType = reflect.TypeOf(token.NoPos)
scopePtrType = reflect.TypeOf((*ast.Scope)(nil))
)


Expand Down
4 changes: 2 additions & 2 deletions src/cmd/gofmt/simplify.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s *simplifier) Visit(node ast.Node) ast.Visitor {
}

if eltType != nil {
typ := reflect.NewValue(eltType)
typ := reflect.ValueOf(eltType)
for _, x := range outer.Elts {
// look at value of indexed/named elements
if t, ok := x.(*ast.KeyValueExpr); ok {
Expand All @@ -37,7 +37,7 @@ func (s *simplifier) Visit(node ast.Node) ast.Visitor {
// matches the outer literal's element type exactly, the inner
// literal type may be omitted
if inner, ok := x.(*ast.CompositeLit); ok {
if match(nil, typ, reflect.NewValue(inner.Type)) {
if match(nil, typ, reflect.ValueOf(inner.Type)) {
inner.Type = nil
}
}
Expand Down
30 changes: 15 additions & 15 deletions src/pkg/asn1/asn1.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,13 @@ func parseSequenceOf(bytes []byte, sliceType reflect.Type, elemType reflect.Type
}

var (
bitStringType = reflect.Typeof(BitString{})
objectIdentifierType = reflect.Typeof(ObjectIdentifier{})
enumeratedType = reflect.Typeof(Enumerated(0))
flagType = reflect.Typeof(Flag(false))
timeType = reflect.Typeof(&time.Time{})
rawValueType = reflect.Typeof(RawValue{})
rawContentsType = reflect.Typeof(RawContent(nil))
bitStringType = reflect.TypeOf(BitString{})
objectIdentifierType = reflect.TypeOf(ObjectIdentifier{})
enumeratedType = reflect.TypeOf(Enumerated(0))
flagType = reflect.TypeOf(Flag(false))
timeType = reflect.TypeOf(&time.Time{})
rawValueType = reflect.TypeOf(RawValue{})
rawContentsType = reflect.TypeOf(RawContent(nil))
)

// invalidLength returns true iff offset + length > sliceLength, or if the
Expand Down Expand Up @@ -461,7 +461,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
}
result := RawValue{t.class, t.tag, t.isCompound, bytes[offset : offset+t.length], bytes[initOffset : offset+t.length]}
offset += t.length
v.Set(reflect.NewValue(result))
v.Set(reflect.ValueOf(result))
return
}

Expand Down Expand Up @@ -505,7 +505,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
return
}
if result != nil {
v.Set(reflect.NewValue(result))
v.Set(reflect.ValueOf(result))
}
return
}
Expand Down Expand Up @@ -605,14 +605,14 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
newSlice, err1 := parseObjectIdentifier(innerBytes)
v.Set(reflect.MakeSlice(v.Type(), len(newSlice), len(newSlice)))
if err1 == nil {
reflect.Copy(v, reflect.NewValue(newSlice))
reflect.Copy(v, reflect.ValueOf(newSlice))
}
err = err1
return
case bitStringType:
bs, err1 := parseBitString(innerBytes)
if err1 == nil {
v.Set(reflect.NewValue(bs))
v.Set(reflect.ValueOf(bs))
}
err = err1
return
Expand All @@ -625,7 +625,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
time, err1 = parseGeneralizedTime(innerBytes)
}
if err1 == nil {
v.Set(reflect.NewValue(time))
v.Set(reflect.ValueOf(time))
}
err = err1
return
Expand Down Expand Up @@ -671,7 +671,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
if structType.NumField() > 0 &&
structType.Field(0).Type == rawContentsType {
bytes := bytes[initOffset:offset]
val.Field(0).Set(reflect.NewValue(RawContent(bytes)))
val.Field(0).Set(reflect.ValueOf(RawContent(bytes)))
}

innerOffset := 0
Expand All @@ -693,7 +693,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
sliceType := fieldType
if sliceType.Elem().Kind() == reflect.Uint8 {
val.Set(reflect.MakeSlice(sliceType, len(innerBytes), len(innerBytes)))
reflect.Copy(val, reflect.NewValue(innerBytes))
reflect.Copy(val, reflect.ValueOf(innerBytes))
return
}
newSlice, err1 := parseSequenceOf(innerBytes, sliceType, sliceType.Elem())
Expand Down Expand Up @@ -798,7 +798,7 @@ func Unmarshal(b []byte, val interface{}) (rest []byte, err os.Error) {
// UnmarshalWithParams allows field parameters to be specified for the
// top-level element. The form of the params is the same as the field tags.
func UnmarshalWithParams(b []byte, val interface{}, params string) (rest []byte, err os.Error) {
v := reflect.NewValue(val).Elem()
v := reflect.ValueOf(val).Elem()
offset, err := parseField(v, b, 0, parseFieldParameters(params))
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/asn1/asn1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ var unmarshalTestData = []struct {

func TestUnmarshal(t *testing.T) {
for i, test := range unmarshalTestData {
pv := reflect.New(reflect.Typeof(test.out).Elem())
pv := reflect.New(reflect.TypeOf(test.out).Elem())
val := pv.Interface()
_, err := Unmarshal(test.in, val)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/asn1/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func marshalField(out *forkableWriter, v reflect.Value, params fieldParameters)
// Marshal returns the ASN.1 encoding of val.
func Marshal(val interface{}) ([]byte, os.Error) {
var out bytes.Buffer
v := reflect.NewValue(val)
v := reflect.ValueOf(val)
f := newForkableWriter()
err := marshalField(f, v, fieldParameters{})
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions src/pkg/crypto/tls/handshake_messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type testMessage interface {
func TestMarshalUnmarshal(t *testing.T) {
rand := rand.New(rand.NewSource(0))
for i, iface := range tests {
ty := reflect.NewValue(iface).Type()
ty := reflect.ValueOf(iface).Type()

n := 100
if testing.Short() {
Expand Down Expand Up @@ -125,7 +125,7 @@ func (*clientHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value {
m.supportedCurves[i] = uint16(rand.Intn(30000))
}

return reflect.NewValue(m)
return reflect.ValueOf(m)
}

func (*serverHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value {
Expand All @@ -146,7 +146,7 @@ func (*serverHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value {
}
}

return reflect.NewValue(m)
return reflect.ValueOf(m)
}

func (*certificateMsg) Generate(rand *rand.Rand, size int) reflect.Value {
Expand All @@ -156,7 +156,7 @@ func (*certificateMsg) Generate(rand *rand.Rand, size int) reflect.Value {
for i := 0; i < numCerts; i++ {
m.certificates[i] = randomBytes(rand.Intn(10)+1, rand)
}
return reflect.NewValue(m)
return reflect.ValueOf(m)
}

func (*certificateRequestMsg) Generate(rand *rand.Rand, size int) reflect.Value {
Expand All @@ -167,13 +167,13 @@ func (*certificateRequestMsg) Generate(rand *rand.Rand, size int) reflect.Value
for i := 0; i < numCAs; i++ {
m.certificateAuthorities[i] = randomBytes(rand.Intn(15)+1, rand)
}
return reflect.NewValue(m)
return reflect.ValueOf(m)
}

func (*certificateVerifyMsg) Generate(rand *rand.Rand, size int) reflect.Value {
m := &certificateVerifyMsg{}
m.signature = randomBytes(rand.Intn(15)+1, rand)
return reflect.NewValue(m)
return reflect.ValueOf(m)
}

func (*certificateStatusMsg) Generate(rand *rand.Rand, size int) reflect.Value {
Expand All @@ -184,23 +184,23 @@ func (*certificateStatusMsg) Generate(rand *rand.Rand, size int) reflect.Value {
} else {
m.statusType = 42
}
return reflect.NewValue(m)
return reflect.ValueOf(m)
}

func (*clientKeyExchangeMsg) Generate(rand *rand.Rand, size int) reflect.Value {
m := &clientKeyExchangeMsg{}
m.ciphertext = randomBytes(rand.Intn(1000)+1, rand)
return reflect.NewValue(m)
return reflect.ValueOf(m)
}

func (*finishedMsg) Generate(rand *rand.Rand, size int) reflect.Value {
m := &finishedMsg{}
m.verifyData = randomBytes(12, rand)
return reflect.NewValue(m)
return reflect.ValueOf(m)
}

func (*nextProtoMsg) Generate(rand *rand.Rand, size int) reflect.Value {
m := &nextProtoMsg{}
m.proto = randomString(rand.Intn(255), rand)
return reflect.NewValue(m)
return reflect.ValueOf(m)
}
4 changes: 2 additions & 2 deletions src/pkg/encoding/binary/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (bigEndian) GoString() string { return "binary.BigEndian" }
// and written to successive fields of the data.
func Read(r io.Reader, order ByteOrder, data interface{}) os.Error {
var v reflect.Value
switch d := reflect.NewValue(data); d.Kind() {
switch d := reflect.ValueOf(data); d.Kind() {
case reflect.Ptr:
v = d.Elem()
case reflect.Slice:
Expand Down Expand Up @@ -155,7 +155,7 @@ func Read(r io.Reader, order ByteOrder, data interface{}) os.Error {
// Bytes written to w are encoded using the specified byte order
// and read from successive fields of the data.
func Write(w io.Writer, order ByteOrder, data interface{}) os.Error {
v := reflect.Indirect(reflect.NewValue(data))
v := reflect.Indirect(reflect.ValueOf(data))
size := TotalSize(v)
if size < 0 {
return os.NewError("binary.Write: invalid type " + v.Type().String())
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/encoding/binary/binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestWriteT(t *testing.T) {
t.Errorf("WriteT: have nil, want non-nil")
}

tv := reflect.Indirect(reflect.NewValue(ts))
tv := reflect.Indirect(reflect.ValueOf(ts))
for i, n := 0, tv.NumField(); i < n; i++ {
err = Write(buf, BigEndian, tv.Field(i).Interface())
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/exp/datafmt/datafmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ func (f Format) Eval(env Environment, args ...interface{}) ([]byte, os.Error) {

go func() {
for _, v := range args {
fld := reflect.NewValue(v)
fld := reflect.ValueOf(v)
if !fld.IsValid() {
errors <- os.NewError("nil argument")
return
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/exp/eval/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TypeFromNative(t reflect.Type) Type {
}

// TypeOfNative returns the interpreter Type of a regular Go value.
func TypeOfNative(v interface{}) Type { return TypeFromNative(reflect.Typeof(v)) }
func TypeOfNative(v interface{}) Type { return TypeFromNative(reflect.TypeOf(v)) }

/*
* Function bridging
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/exp/eval/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func hashTypeArray(key []Type) uintptr {
if t == nil {
continue
}
addr := reflect.NewValue(t).Pointer()
addr := reflect.ValueOf(t).Pointer()
hash ^= addr
}
return hash
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/exp/ogle/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (p *Process) bootstrap() {
p.runtime.G = newManualType(eval.TypeOfNative(rt1G{}), p.Arch)

// Get addresses of type.*runtime.XType for discrimination.
rtv := reflect.Indirect(reflect.NewValue(&p.runtime))
rtv := reflect.Indirect(reflect.ValueOf(&p.runtime))
rtvt := rtv.Type()
for i := 0; i < rtv.NumField(); i++ {
n := rtvt.Field(i).Name
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/exp/ogle/rruntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ type runtimeValues struct {
// indexes gathered from the remoteTypes recorded in a runtimeValues
// structure.
func fillRuntimeIndexes(runtime *runtimeValues, out *runtimeIndexes) {
outv := reflect.Indirect(reflect.NewValue(out))
outv := reflect.Indirect(reflect.ValueOf(out))
outt := outv.Type()
runtimev := reflect.Indirect(reflect.NewValue(runtime))
runtimev := reflect.Indirect(reflect.ValueOf(runtime))

// out contains fields corresponding to each runtime type
for i := 0; i < outt.NumField(); i++ {
Expand Down
Loading

0 comments on commit 07abf1c

Please sign in to comment.