...
1
2
3
4
5 package types2
6
7 import (
8 "cmd/compile/internal/syntax"
9 "fmt"
10 )
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 func (s *Signature) RenameResult(results []*syntax.Field, i int) (*Var, *syntax.Name) {
26 a := results[i]
27 obj := s.Results().At(i)
28
29 if !(obj.name == "" || obj.name == "_" && a.Name == nil || a.Name.Value == "_") {
30 panic("Cannot change an existing name")
31 }
32
33 pos := a.Pos()
34 typ := a.Type.GetTypeInfo().Type
35
36 name := fmt.Sprintf("#rv%d", i+1)
37 obj.name = name
38 s.scope.Insert(obj)
39 obj.setScopePos(pos)
40
41 tv := syntax.TypeAndValue{Type: typ}
42 tv.SetIsValue()
43
44 n := syntax.NewName(pos, obj.Name())
45 n.SetTypeInfo(tv)
46
47 a.Name = n
48
49 return obj, n
50 }
51
View as plain text