]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/gc: expand DBG macro in lex.go
authorRuss Cox <rsc@golang.org>
Mon, 23 Feb 2015 22:34:49 +0000 (17:34 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 25 Feb 2015 18:29:30 +0000 (18:29 +0000)
The dummy implementation was causing lots of argument lists
to be prepared and thrown away.

Change-Id: Id0040dec6b0937f3daa8a8d8911fa3280123e863
Reviewed-on: https://go-review.googlesource.com/5700
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/internal/gc/go.go
src/cmd/internal/gc/lex.go

index a1ddb6250da9d981bb8924b85618e0a474cb3384..b87dcf7370c2440ab98ff8f2c3636c22ab0797c1 100644 (file)
@@ -753,8 +753,6 @@ var namebuf string
 var lexbuf bytes.Buffer
 var strbuf bytes.Buffer
 
-func DBG(...interface{}) {}
-
 var litbuf string
 
 var Debug [256]int
index 96273370777693de547f918a688331850dbe930b..19b969e57f9d0316681cf86964d19db67efedb2f 100644 (file)
@@ -861,7 +861,9 @@ l0:
        if yy_isspace(c) {
                if c == '\n' && curio.nlsemi != 0 {
                        ungetc(c)
-                       DBG("lex: implicit semi\n")
+                       if Debug['x'] != 0 {
+                               fmt.Printf("lex: implicit semi\n")
+                       }
                        return ';'
                }
 
@@ -983,7 +985,9 @@ l0:
                yylval.val.U.Xval = new(Mpint)
                Mpmovecfix(yylval.val.U.Xval, v)
                yylval.val.Ctype = CTRUNE
-               DBG("lex: codepoint literal\n")
+               if Debug['x'] != 0 {
+                       fmt.Printf("lex: codepoint literal\n")
+               }
                litbuf = "string literal"
                return LLITERAL
 
@@ -1229,7 +1233,9 @@ l0:
 
        case '{':
                if loophack == 1 {
-                       DBG("%L lex: LBODY\n", lexlineno)
+                       if Debug['x'] != 0 {
+                               fmt.Printf("%v lex: LBODY\n", Ctxt.Line(int(lexlineno)))
+                       }
                        loophack = 0
                        return LBODY
                }
@@ -1244,9 +1250,13 @@ l0:
 
 lx:
        if c > 0xff {
-               DBG("%L lex: TOKEN %s\n", lexlineno, lexname(c))
+               if Debug['x'] != 0 {
+                       fmt.Printf("%v lex: TOKEN %s\n", Ctxt.Line(int(lexlineno)), lexname(c))
+               }
        } else {
-               DBG("%L lex: TOKEN '%c'\n", lexlineno, c)
+               if Debug['x'] != 0 {
+                       fmt.Printf("%v lex: TOKEN '%c'\n", Ctxt.Line(int(lexlineno)), c)
+               }
        }
        if isfrog(c) {
                Yyerror("illegal character 0x%x", uint(c))
@@ -1262,7 +1272,9 @@ lx:
 
 asop:
        yylval.i = c // rathole to hold which asop
-       DBG("lex: TOKEN ASOP %c\n", c)
+       if Debug['x'] != 0 {
+               fmt.Printf("lex: TOKEN ASOP %c\n", c)
+       }
        return LASOP
 
        /*
@@ -1303,7 +1315,9 @@ talph:
                loophack = 1 // see comment about loophack above
        }
 
-       DBG("lex: %S %s\n", s, lexname(int(s.Lexical)))
+       if Debug['x'] != 0 {
+               fmt.Printf("lex: %s %s\n", Sconv(s, 0), lexname(int(s.Lexical)))
+       }
        yylval.sym = s
        return int32(s.Lexical)
 
@@ -1399,7 +1413,9 @@ ncu:
        }
 
        yylval.val.Ctype = CTINT
-       DBG("lex: integer literal\n")
+       if Debug['x'] != 0 {
+               fmt.Printf("lex: integer literal\n")
+       }
        litbuf = "literal "
        litbuf += lexbuf.String()
        return LLITERAL
@@ -1454,7 +1470,9 @@ casei:
        }
 
        yylval.val.Ctype = CTCPLX
-       DBG("lex: imaginary literal\n")
+       if Debug['x'] != 0 {
+               fmt.Printf("lex: imaginary literal\n")
+       }
        litbuf = "literal "
        litbuf += lexbuf.String()
        return LLITERAL
@@ -1471,7 +1489,9 @@ caseout:
        }
 
        yylval.val.Ctype = CTFLT
-       DBG("lex: floating literal\n")
+       if Debug['x'] != 0 {
+               fmt.Printf("lex: floating literal\n")
+       }
        litbuf = "literal "
        litbuf += lexbuf.String()
        return LLITERAL
@@ -1479,7 +1499,9 @@ caseout:
 strlit:
        yylval.val.U.Sval = &Strlit{S: cp.String()}
        yylval.val.Ctype = CTSTR
-       DBG("lex: string literal\n")
+       if Debug['x'] != 0 {
+               fmt.Printf("lex: string literal\n")
+       }
        litbuf = "string literal"
        return LLITERAL
 }