d := push()
dcopy(d, s)
if dflag() {
- fmt.Printf("\t%v push %v %p\n", Ctxt.Line(int(lineno)), s, s.Def)
+ fmt.Printf("\t%v push %v %p\n", linestr(lineno), s, s.Def)
}
return d
}
dcopy(s, d)
d.Lastlineno = lno
if dflag() {
- fmt.Printf("\t%v pop %v %p\n", Ctxt.Line(int(lineno)), s, s.Def)
+ fmt.Printf("\t%v pop %v %p\n", linestr(lineno), s, s.Def)
}
}
line1 = s.Lastlineno
}
- yyerrorl(line1, "%v redeclared %s\n"+"\tprevious declaration at %v", s, where, Ctxt.Line(int(line2)))
+ yyerrorl(line1, "%v redeclared %s\n"+"\tprevious declaration at %v", s, where, linestr(line2))
}
}
if ctxt == PEXTERN {
externdcl = append(externdcl, n)
if dflag() {
- fmt.Printf("\t%v global decl %v %p\n", Ctxt.Line(int(lineno)), s, n)
+ fmt.Printf("\t%v global decl %v %p\n", linestr(lineno), s, n)
}
} else {
if Curfn == nil && ctxt == PAUTO {
// Build the error message in reverse.
err := ""
for call.target != nil {
- err = fmt.Sprintf("\n\t%v: called by %v%s", Ctxt.Line(int(call.lineno)), n.Func.Nname, err)
+ err = fmt.Sprintf("\n\t%v: called by %v%s", linestr(call.lineno), n.Func.Nname, err)
n = call.target
call = c.best[n]
}
}
if Debug['m'] > 1 {
- fmt.Printf("%v:[%d] %v esc: %v\n", Ctxt.Line(int(lineno)), e.loopdepth, funcSym(Curfn), n)
+ fmt.Printf("%v:[%d] %v esc: %v\n", linestr(lineno), e.loopdepth, funcSym(Curfn), n)
}
switch n.Op {
case OLABEL:
if n.Left.Sym.Label == &nonlooping {
if Debug['m'] > 1 {
- fmt.Printf("%v:%v non-looping label\n", Ctxt.Line(int(lineno)), n)
+ fmt.Printf("%v:%v non-looping label\n", linestr(lineno), n)
}
} else if n.Left.Sym.Label == &looping {
if Debug['m'] > 1 {
- fmt.Printf("%v: %v looping label\n", Ctxt.Line(int(lineno)), n)
+ fmt.Printf("%v: %v looping label\n", linestr(lineno), n)
}
e.loopdepth++
}
if Debug['m'] > 1 {
fmt.Printf("%v:[%d] %v escassign: %v(%v)[%v] = %v(%v)[%v]\n",
- Ctxt.Line(int(lineno)), e.loopdepth, funcSym(Curfn),
+ linestr(lineno), e.loopdepth, funcSym(Curfn),
Nconv(dst, obj.FmtShort), Jconv(dst, obj.FmtShort), Oconv(int(dst.Op), 0),
Nconv(src, obj.FmtShort), Jconv(src, obj.FmtShort), Oconv(int(src.Op), 0))
}
if Debug['m'] > 2 {
fmt.Printf("%v::assignfromtag:: src=%v, em=%s\n",
- Ctxt.Line(int(lineno)), Nconv(src, obj.FmtShort), describeEscape(em))
+ linestr(lineno), Nconv(src, obj.FmtShort), describeEscape(em))
}
if em == EscUnknown {
for ; ll != nil; ll = ll.Next {
escassign(e, &e.theSink, ll.N)
if Debug['m'] > 2 {
- fmt.Printf("%v::esccall:: indirect call <- %v, untracked\n", Ctxt.Line(int(lineno)), Nconv(ll.N, obj.FmtShort))
+ fmt.Printf("%v::esccall:: indirect call <- %v, untracked\n", linestr(lineno), Nconv(ll.N, obj.FmtShort))
}
}
// Set up bogus outputs
if fn != nil && fn.Op == ONAME && fn.Class == PFUNC &&
fn.Name.Defn != nil && len(fn.Name.Defn.Nbody.Slice()) != 0 && fn.Name.Param.Ntype != nil && fn.Name.Defn.Esc < EscFuncTagged {
if Debug['m'] > 2 {
- fmt.Printf("%v::esccall:: %v in recursive group\n", Ctxt.Line(int(lineno)), Nconv(n, obj.FmtShort))
+ fmt.Printf("%v::esccall:: %v in recursive group\n", linestr(lineno), Nconv(n, obj.FmtShort))
}
// function in same mutually recursive group. Incorporate into flow graph.
// "..." arguments are untracked
for ; ll != nil; ll = ll.Next {
if Debug['m'] > 2 {
- fmt.Printf("%v::esccall:: ... <- %v, untracked\n", Ctxt.Line(int(lineno)), Nconv(ll.N, obj.FmtShort))
+ fmt.Printf("%v::esccall:: ... <- %v, untracked\n", linestr(lineno), Nconv(ll.N, obj.FmtShort))
}
escassign(e, &e.theSink, ll.N)
}
}
if Debug['m'] > 2 {
- fmt.Printf("%v::esccall:: %v not recursive\n", Ctxt.Line(int(lineno)), Nconv(n, obj.FmtShort))
+ fmt.Printf("%v::esccall:: %v not recursive\n", linestr(lineno), Nconv(n, obj.FmtShort))
}
// set up out list on this call node with dummy auto ONAMES in the current (calling) function.
for ; ll != nil; ll = ll.Next {
if Debug['m'] > 2 {
- fmt.Printf("%v::esccall:: ... <- %v\n", Ctxt.Line(int(lineno)), Nconv(ll.N, obj.FmtShort))
+ fmt.Printf("%v::esccall:: ... <- %v\n", linestr(lineno), Nconv(ll.N, obj.FmtShort))
}
escassign(e, src, ll.N) // args to slice
}
}
if Debug['m'] > 2 {
- fmt.Printf("%v::flows:: %v <- %v\n", Ctxt.Line(int(lineno)), Nconv(dst, obj.FmtShort), Nconv(src, obj.FmtShort))
+ fmt.Printf("%v::flows:: %v <- %v\n", linestr(lineno), Nconv(dst, obj.FmtShort), Nconv(src, obj.FmtShort))
}
dstE := e.nodeEscState(dst)
if srcE.Escretval != nil {
if Debug['m'] > 1 {
fmt.Printf("%v:[%d] dst %v escwalk replace src: %v with %v\n",
- Ctxt.Line(int(lineno)), e.loopdepth,
+ linestr(lineno), e.loopdepth,
Nconv(dst, obj.FmtShort), Nconv(src, obj.FmtShort), Nconv(srcE.Escretval.N, obj.FmtShort))
}
src = srcE.Escretval.N
}
if block != nil {
- Yyerror("goto %v jumps into block starting at %v", from.Left.Sym, Ctxt.Line(int(block.Lastlineno)))
+ Yyerror("goto %v jumps into block starting at %v", from.Left.Sym, linestr(block.Lastlineno))
} else {
- Yyerror("goto %v jumps over declaration of %v at %v", from.Left.Sym, dcl, Ctxt.Line(int(dcl.Lastlineno)))
+ Yyerror("goto %v jumps over declaration of %v at %v", from.Left.Sym, dcl, linestr(dcl.Lastlineno))
}
lineno = int32(lno)
}
lx:
if Debug['x'] != 0 {
if c >= utf8.RuneSelf {
- fmt.Printf("%v lex: TOKEN %s\n", Ctxt.Line(int(lineno)), lexname(c))
+ fmt.Printf("%v lex: TOKEN %s\n", linestr(lineno), lexname(c))
} else {
- fmt.Printf("%v lex: TOKEN '%c'\n", Ctxt.Line(int(lineno)), c)
+ fmt.Printf("%v lex: TOKEN '%c'\n", linestr(lineno), c)
}
}
if !lab.defined() {
lab.defNode = n
} else {
- s.Error("label %v already defined at %v", sym, Ctxt.Line(int(lab.defNode.Lineno)))
+ s.Error("label %v already defined at %v", sym, linestr(lab.defNode.Lineno))
lab.reported = true
}
// The label might already have a target block via a goto.
lno := from.Left.Lineno
if block != nil {
- yyerrorl(lno, "goto %v jumps into block starting at %v", from.Left.Sym, Ctxt.Line(int(block.Lastlineno)))
+ yyerrorl(lno, "goto %v jumps into block starting at %v", from.Left.Sym, linestr(block.Lastlineno))
} else {
- yyerrorl(lno, "goto %v jumps over declaration of %v at %v", from.Left.Sym, dcl, Ctxt.Line(int(dcl.Lastlineno)))
+ yyerrorl(lno, "goto %v jumps over declaration of %v at %v", from.Left.Sym, dcl, linestr(dcl.Lastlineno))
}
}
}
}
func (e *ssaExport) Line(line int32) string {
- return Ctxt.Line(int(line))
+ return linestr(line)
}
// Log logs a message from the compiler.
func adderr(line int32, format string, args ...interface{}) {
errors = append(errors, Error{
lineno: line,
- msg: fmt.Sprintf("%v: %s\n", Ctxt.Line(int(line)), fmt.Sprintf(format, args...)),
+ msg: fmt.Sprintf("%v: %s\n", linestr(line), fmt.Sprintf(format, args...)),
})
}
}
}
+func linestr(line int32) string {
+ return Ctxt.Line(int(line))
+}
+
func yyerrorl(line int32, format string, args ...interface{}) {
adderr(line, format, args...)
nerrors++
if nsavederrors+nerrors >= 10 && Debug['e'] == 0 {
Flusherrors()
- fmt.Printf("%v: too many errors\n", Ctxt.Line(int(line)))
+ fmt.Printf("%v: too many errors\n", linestr(line))
errorexit()
}
}
nerrors++
if nsavederrors+nerrors >= 10 && Debug['e'] == 0 {
Flusherrors()
- fmt.Printf("%v: too many errors\n", Ctxt.Line(int(lineno)))
+ fmt.Printf("%v: too many errors\n", linestr(lineno))
errorexit()
}
}
func Fatalf(fmt_ string, args ...interface{}) {
Flusherrors()
- fmt.Printf("%v: internal compiler error: ", Ctxt.Line(int(lineno)))
+ fmt.Printf("%v: internal compiler error: ", linestr(lineno))
fmt.Printf(fmt_, args...)
fmt.Printf("\n")
func linehistpragma(file string) {
if Debug['i'] != 0 {
- fmt.Printf("pragma %s at line %v\n", file, Ctxt.Line(int(lexlineno)))
+ fmt.Printf("pragma %s at line %v\n", file, linestr(lexlineno))
}
Ctxt.AddImport(file)
}
func linehistpush(file string) {
if Debug['i'] != 0 {
- fmt.Printf("import %s at line %v\n", file, Ctxt.Line(int(lexlineno)))
+ fmt.Printf("import %s at line %v\n", file, linestr(lexlineno))
}
Ctxt.LineHist.Push(int(lexlineno), file)
}
func linehistpop() {
if Debug['i'] != 0 {
- fmt.Printf("end of import at line %v\n", Ctxt.Line(int(lexlineno)))
+ fmt.Printf("end of import at line %v\n", linestr(lexlineno))
}
Ctxt.LineHist.Pop(int(lexlineno))
}
func linehistupdate(file string, off int) {
if Debug['i'] != 0 {
- fmt.Printf("line %s at line %v\n", file, Ctxt.Line(int(lexlineno)))
+ fmt.Printf("line %s at line %v\n", file, linestr(lexlineno))
}
Ctxt.LineHist.Update(int(lexlineno), file, off)
}