Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(678)

Delta Between Two Patch Sets: src/cmd/gofmt/rewrite.go

Issue 4301043: update tree for reflect changes (Closed)
Left Patch Set: Created 13 years ago
Right Patch Set: diff -r f692a5e90f6f https://go.googlecode.com/hg/ Created 13 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/asn1/asn1.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "go/ast" 9 "go/ast"
10 "go/parser" 10 "go/parser"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // use new position only if old position was valid in the first place 225 // use new position only if old position was valid in the first place
226 if old := pattern.Interface().(token.Pos); !old.IsValid() { 226 if old := pattern.Interface().(token.Pos); !old.IsValid() {
227 return pattern 227 return pattern
228 } 228 }
229 return pos 229 return pos
230 } 230 }
231 231
232 // Otherwise copy. 232 // Otherwise copy.
233 switch p := pattern.(type) { 233 switch p := pattern.(type) {
234 case *reflect.SliceValue: 234 case *reflect.SliceValue:
235 » » v := reflect.MakeSlice(p.Type().(*reflect.SliceType), p.Len(), p .Len()) 235 » » v := reflect.MakeSlice(p.Type(), p.Len(), p.Len())
236 for i := 0; i < p.Len(); i++ { 236 for i := 0; i < p.Len(); i++ {
237 v.Elem(i).SetValue(subst(m, p.Elem(i), pos)) 237 v.Elem(i).SetValue(subst(m, p.Elem(i), pos))
238 } 238 }
239 return v 239 return v
240 240
241 case *reflect.StructValue: 241 case *reflect.StructValue:
242 v := reflect.MakeZero(p.Type()).(*reflect.StructValue) 242 v := reflect.MakeZero(p.Type()).(*reflect.StructValue)
243 for i := 0; i < p.NumField(); i++ { 243 for i := 0; i < p.NumField(); i++ {
244 v.Field(i).SetValue(subst(m, p.Field(i), pos)) 244 v.Field(i).SetValue(subst(m, p.Field(i), pos))
245 } 245 }
246 return v 246 return v
247 247
248 case *reflect.PtrValue: 248 case *reflect.PtrValue:
249 v := reflect.MakeZero(p.Type()).(*reflect.PtrValue) 249 v := reflect.MakeZero(p.Type()).(*reflect.PtrValue)
250 v.PointTo(subst(m, p.Elem(), pos)) 250 v.PointTo(subst(m, p.Elem(), pos))
251 return v 251 return v
252 252
253 case *reflect.InterfaceValue: 253 case *reflect.InterfaceValue:
254 v := reflect.MakeZero(p.Type()).(*reflect.InterfaceValue) 254 v := reflect.MakeZero(p.Type()).(*reflect.InterfaceValue)
255 v.SetValue(subst(m, p.Elem(), pos)) 255 v.SetValue(subst(m, p.Elem(), pos))
256 return v 256 return v
257 } 257 }
258 258
259 return pattern 259 return pattern
260 } 260 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b