mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Add a genlinenum flag
This commit is contained in:
1 parent
dd94ad3821
commit
20c474b32a
4 files changed
+24
-13
No files matched your search
@@ -22,12 +22,6 @@ import (
|
||||
t "github.com/google/wuffs/lang/token"
|
||||
)
|
||||
|
||||
// genFilenameLineComments is whether to print "// foo.wuffs:123\n" comments in
|
||||
// the generated code. This can be useful for debugging, although it is not
|
||||
// enabled by default as it can lead to many spurious changes in the generated
|
||||
// C code (due to line numbers changing) when editing Wuffs code.
|
||||
const genFilenameLineComments = false
|
||||
|
||||
func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
if depth > a.MaxBodyDepth {
|
||||
return fmt.Errorf("body recursion depth too large")
|
||||
@@ -48,7 +42,7 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
defer b.writes("}\n")
|
||||
}
|
||||
|
||||
if genFilenameLineComments {
|
||||
if g.genlinenum {
|
||||
filename, line := n.AsRaw().FilenameLine()
|
||||
if i := strings.LastIndexByte(filename, '/'); i >= 0 {
|
||||
filename = filename[i+1:]
|
||||
|
||||
Reference in new issue
Block a user