"strings"
)
-var ddumped int
-
-var dfirst *obj.Prog
-
-var dpc *obj.Prog
+var (
+ ddumped bool
+ dfirst *obj.Prog
+ dpc *obj.Prog
+)
// Is this node a memory operand?
func Ismem(n *Node) bool {
var p *obj.Prog
if as == obj.ADATA || as == obj.AGLOBL {
- if ddumped != 0 {
+ if ddumped {
Fatalf("already dumped data")
}
if dpc == nil {
p.Link = Pc
}
- if lineno == 0 {
- if Debug['K'] != 0 {
- Warn("prog: line 0")
- }
+ if lineno == 0 && Debug['K'] != 0 {
+ Warn("prog: line 0")
}
p.As = as
}
func dumpdata() {
- ddumped = 1
+ ddumped = true
if dfirst == nil {
return
}
if s == nil {
s = Lookup(".noname")
}
- if n.Name.Method {
- if n.Type != nil {
- if n.Type.Sym != nil {
- if n.Type.Sym.Pkg != nil {
- s = Pkglookup(s.Name, n.Type.Sym.Pkg)
- }
- }
- }
+ if n.Name.Method && n.Type != nil && n.Type.Sym != nil && n.Type.Sym.Pkg != nil {
+ s = Pkglookup(s.Name, n.Type.Sym.Pkg)
}
a.Type = obj.TYPE_MEM
a.Width = int64(Widthint)
}
}
- return
}
func newplist() *obj.Plist {
flushplist(ctxt, false)
}
func flushplist(ctxt *Link, freeProgs bool) {
- var flag int
- var s *LSym
- var p *Prog
- var plink *Prog
- var a *Auto
-
// Build list of symbols, and assign instructions to lists.
// Ignore ctxt->plist boundaries. There are no guarantees there,
// and the assemblers just use one big list.
- var curtext *LSym
- var text *LSym
- var etext *LSym
+ var curtext, text, etext *LSym
for pl := ctxt.Plist; pl != nil; pl = pl.Link {
- for p = pl.Firstpc; p != nil; p = plink {
+ var plink *Prog
+ for p := pl.Firstpc; p != nil; p = plink {
if ctxt.Debugasm != 0 && ctxt.Debugvlog != 0 {
fmt.Printf("obj: %v\n", p)
}
plink = p.Link
p.Link = nil
- if p.As == AEND {
+ switch p.As {
+ case AEND:
continue
- }
- if p.As == ATYPE {
+ case ATYPE:
// Assume each TYPE instruction describes
// a different local variable or parameter,
// so no dedup.
if curtext == nil {
continue
}
- a = new(Auto)
+ a := new(Auto)
a.Asym = p.From.Sym
a.Aoffset = int32(p.From.Offset)
a.Name = int16(p.From.Name)
a.Link = curtext.Autom
curtext.Autom = a
continue
- }
- if p.As == AGLOBL {
- s = p.From.Sym
+ case AGLOBL:
+ s := p.From.Sym
tmp6 := s.Seenglobl
s.Seenglobl++
if tmp6 != 0 {
if s.Type == 0 || s.Type == SXREF {
s.Type = SBSS
}
- flag = int(p.From3.Offset)
+ flag := int(p.From3.Offset)
if flag&DUPOK != 0 {
s.Dupok = 1
}
}
ctxt.Edata = s
continue
- }
- if p.As == ADATA {
+ case ADATA:
savedata(ctxt, p.From.Sym, p, "<input>")
continue
- }
- if p.As == ATEXT {
- s = p.From.Sym
+ case ATEXT:
+ s := p.From.Sym
if s == nil {
// func _() { }
curtext = nil
etext.Next = s
}
etext = s
- flag = int(p.From3Offset())
+ flag := int(p.From3Offset())
if flag&DUPOK != 0 {
s.Dupok = 1
}
s.Etext = p
curtext = s
continue
- }
- if p.As == AFUNCDATA {
+ case AFUNCDATA:
// Rewrite reference to go_args_stackmap(SB) to the Go-provided declaration information.
if curtext == nil { // func _() {}
continue
}
p.To.Sym = Linklookup(ctxt, fmt.Sprintf("%s.args_stackmap", curtext.Name), int(curtext.Version))
}
+
}
if curtext == nil {
continue
}
- s = curtext
+ s := curtext
s.Etext.Link = p
s.Etext = p
}
}
// Add reference to Go arguments for C or assembly functions without them.
- var found int
for s := text; s != nil; s = s.Next {
if !strings.HasPrefix(s.Name, "\"\".") {
continue
}
- found = 0
+ found := false
+ var p *Prog
for p = s.Text; p != nil; p = p.Link {
if p.As == AFUNCDATA && p.From.Type == TYPE_CONST && p.From.Offset == FUNCDATA_ArgsPointerMaps {
- found = 1
+ found = true
break
}
}
- if found == 0 {
+ if !found {
p = Appendp(ctxt, s.Text)
p.As = AFUNCDATA
p.From.Type = TYPE_CONST