if name == os.Getenv("GOSSAFUNC") {
// TODO: tempfile? it is handy to have the location
// of this file be stable, so you can just reload in the browser.
- s.config.HTML = ssa.NewHTMLWriter("ssa.html", &s, name)
+ s.config.HTML = ssa.NewHTMLWriter("ssa.html", s.config, name)
// TODO: generate and print a mapping from nodes to values and blocks
}
defer func() {
return lab
}
-func (s *state) Logf(msg string, args ...interface{}) { s.config.Logf(msg, args...) }
-func (s *state) Fatalf(msg string, args ...interface{}) { s.config.Fatalf(msg, args...) }
-func (s *state) Unimplementedf(msg string, args ...interface{}) { s.config.Unimplementedf(msg, args...) }
+func (s *state) Logf(msg string, args ...interface{}) { s.config.Logf(msg, args...) }
+func (s *state) Fatalf(msg string, args ...interface{}) { s.config.Fatalf(s.peekLine(), msg, args...) }
+func (s *state) Unimplementedf(msg string, args ...interface{}) {
+ s.config.Unimplementedf(s.peekLine(), msg, args...)
+}
func (s *state) Warnl(line int, msg string, args ...interface{}) { s.config.Warnl(line, msg, args...) }
func (s *state) Debug_checknil() bool { return s.config.Debug_checknil() }
}
// Fatal reports a compiler error and exits.
-func (e *ssaExport) Fatalf(msg string, args ...interface{}) {
+func (e *ssaExport) Fatalf(line int32, msg string, args ...interface{}) {
// If e was marked as unimplemented, anything could happen. Ignore.
if !e.unimplemented {
+ lineno = line
Fatalf(msg, args...)
}
}
// Unimplemented reports that the function cannot be compiled.
// It will be removed once SSA work is complete.
-func (e *ssaExport) Unimplementedf(msg string, args ...interface{}) {
+func (e *ssaExport) Unimplementedf(line int32, msg string, args ...interface{}) {
if e.mustImplement {
+ lineno = line
Fatalf(msg, args...)
}
const alwaysLog = false // enable to calculate top unimplemented features
Logf(string, ...interface{})
// Fatal reports a compiler error and exits.
- Fatalf(string, ...interface{})
+ Fatalf(line int32, msg string, args ...interface{})
// Unimplemented reports that the function cannot be compiled.
// It will be removed once SSA work is complete.
- Unimplementedf(msg string, args ...interface{})
+ Unimplementedf(line int32, msg string, args ...interface{})
// Warnl writes compiler messages in the form expected by "errorcheck" tests
Warnl(line int, fmt_ string, args ...interface{})
c.lowerBlock = rewriteBlockAMD64
c.lowerValue = rewriteValueAMD64 // TODO(khr): full 32-bit support
default:
- fe.Unimplementedf("arch %s not implemented", arch)
+ fe.Unimplementedf(0, "arch %s not implemented", arch)
}
c.ctxt = ctxt
return &Func{Config: c, NamedValues: map[LocalSlot][]*Value{}}
}
-func (c *Config) Logf(msg string, args ...interface{}) { c.fe.Logf(msg, args...) }
-func (c *Config) Fatalf(msg string, args ...interface{}) { c.fe.Fatalf(msg, args...) }
-func (c *Config) Unimplementedf(msg string, args ...interface{}) { c.fe.Unimplementedf(msg, args...) }
+func (c *Config) Logf(msg string, args ...interface{}) { c.fe.Logf(msg, args...) }
+func (c *Config) Fatalf(line int32, msg string, args ...interface{}) { c.fe.Fatalf(line, msg, args...) }
+func (c *Config) Unimplementedf(line int32, msg string, args ...interface{}) {
+ c.fe.Unimplementedf(line, msg, args...)
+}
func (c *Config) Warnl(line int, msg string, args ...interface{}) { c.fe.Warnl(line, msg, args...) }
func (c *Config) Debug_checknil() bool { return c.fe.Debug_checknil() }
return nil
}
-func (d DummyFrontend) Logf(msg string, args ...interface{}) { d.t.Logf(msg, args...) }
-func (d DummyFrontend) Fatalf(msg string, args ...interface{}) { d.t.Fatalf(msg, args...) }
-func (d DummyFrontend) Unimplementedf(msg string, args ...interface{}) { d.t.Fatalf(msg, args...) }
+func (d DummyFrontend) Logf(msg string, args ...interface{}) { d.t.Logf(msg, args...) }
+
+func (d DummyFrontend) Fatalf(line int32, msg string, args ...interface{}) { d.t.Fatalf(msg, args...) }
+func (d DummyFrontend) Unimplementedf(line int32, msg string, args ...interface{}) {
+ d.t.Fatalf(msg, args...)
+}
func (d DummyFrontend) Warnl(line int, msg string, args ...interface{}) { d.t.Logf(msg, args...) }
func (d DummyFrontend) Debug_checknil() bool { return false }
return f.Entry.NewValue0I(line, OpConst64F, t, int64(math.Float64bits(c)))
}
-func (f *Func) Logf(msg string, args ...interface{}) { f.Config.Logf(msg, args...) }
-func (f *Func) Fatalf(msg string, args ...interface{}) { f.Config.Fatalf(msg, args...) }
-func (f *Func) Unimplementedf(msg string, args ...interface{}) { f.Config.Unimplementedf(msg, args...) }
+func (f *Func) Logf(msg string, args ...interface{}) { f.Config.Logf(msg, args...) }
+func (f *Func) Fatalf(msg string, args ...interface{}) { f.Config.Fatalf(f.Entry.Line, msg, args...) }
+func (f *Func) Unimplementedf(msg string, args ...interface{}) {
+ f.Config.Unimplementedf(f.Entry.Line, msg, args...)
+}
func NewHTMLWriter(path string, logger Logger, funcname string) *HTMLWriter {
out, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
- logger.Fatalf("%v", err)
+ logger.Fatalf(0, "%v", err)
}
html := HTMLWriter{File: out, Logger: logger}
html.start(funcname)
func (w *HTMLWriter) Printf(msg string, v ...interface{}) {
if _, err := fmt.Fprintf(w.File, msg, v...); err != nil {
- w.Fatalf("%v", err)
+ w.Fatalf(0, "%v", err)
}
}
func (w *HTMLWriter) WriteString(s string) {
if _, err := w.File.WriteString(s); err != nil {
- w.Fatalf("%v", err)
+ w.Fatalf(0, "%v", err)
}
}
return c
}
-func (v *Value) Logf(msg string, args ...interface{}) { v.Block.Logf(msg, args...) }
-func (v *Value) Fatalf(msg string, args ...interface{}) { v.Block.Fatalf(msg, args...) }
-func (v *Value) Unimplementedf(msg string, args ...interface{}) { v.Block.Unimplementedf(msg, args...) }
+func (v *Value) Logf(msg string, args ...interface{}) { v.Block.Logf(msg, args...) }
+func (v *Value) Fatalf(msg string, args ...interface{}) {
+ v.Block.Func.Config.Fatalf(v.Line, msg, args...)
+}
+func (v *Value) Unimplementedf(msg string, args ...interface{}) {
+ v.Block.Func.Config.Unimplementedf(v.Line, msg, args...)
+}
// ExternSymbol is an aux value that encodes a variable's
// constant offset from the static base pointer.