]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove gratuituous type conversions
authorRobert Griesemer <gri@golang.org>
Sat, 28 Nov 2015 00:11:05 +0000 (16:11 -0800)
committerRobert Griesemer <gri@golang.org>
Sat, 28 Nov 2015 03:36:21 +0000 (03:36 +0000)
Follow-up cleanup for https://go-review.googlesource.com/17248:
Use properly typed local variable op now that that variable use
is not overloaded anymore.

Also: Remove unnecessary if stmt from common lexical path.

Change-Id: I984b0b346f3fdccd5aedc937330c0a5f99acf324
Reviewed-on: https://go-review.googlesource.com/17249
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/lex.go
src/cmd/compile/internal/gc/parser.go

index 55ba2ed3f4cdc11c0d8418281649cebab5a4dd7b..830c56df6088671e0a34db60d66ba4366b3ba9e9 100644 (file)
@@ -931,7 +931,7 @@ type yySymType struct {
        typ  *Type
        sym  *Sym
        val  Val
-       i    int
+       op   Op
 }
 
 const (
@@ -984,6 +984,7 @@ const (
 
 func _yylex(yylval *yySymType) int32 {
        var c1 int
+       var op Op
        var escflag int
        var v int64
        var cp *bytes.Buffer
@@ -1245,7 +1246,7 @@ l0:
                }
 
                if c1 == '=' {
-                       c = int(ODIV)
+                       op = ODIV
                        goto asop
                }
 
@@ -1259,14 +1260,14 @@ l0:
        case '*':
                c1 = getc()
                if c1 == '=' {
-                       c = int(OMUL)
+                       op = OMUL
                        goto asop
                }
 
        case '%':
                c1 = getc()
                if c1 == '=' {
-                       c = int(OMOD)
+                       op = OMOD
                        goto asop
                }
 
@@ -1278,7 +1279,7 @@ l0:
                }
 
                if c1 == '=' {
-                       c = int(OADD)
+                       op = OADD
                        goto asop
                }
 
@@ -1290,7 +1291,7 @@ l0:
                }
 
                if c1 == '=' {
-                       c = int(OSUB)
+                       op = OSUB
                        goto asop
                }
 
@@ -1300,7 +1301,7 @@ l0:
                        c = int(LRSH)
                        c1 = getc()
                        if c1 == '=' {
-                               c = int(ORSH)
+                               op = ORSH
                                goto asop
                        }
 
@@ -1320,7 +1321,7 @@ l0:
                        c = int(LLSH)
                        c1 = getc()
                        if c1 == '=' {
-                               c = int(OLSH)
+                               op = OLSH
                                goto asop
                        }
 
@@ -1364,7 +1365,7 @@ l0:
                        c = int(LANDNOT)
                        c1 = getc()
                        if c1 == '=' {
-                               c = int(OANDNOT)
+                               op = OANDNOT
                                goto asop
                        }
 
@@ -1372,7 +1373,7 @@ l0:
                }
 
                if c1 == '=' {
-                       c = int(OAND)
+                       op = OAND
                        goto asop
                }
 
@@ -1384,14 +1385,14 @@ l0:
                }
 
                if c1 == '=' {
-                       c = int(OOR)
+                       op = OOR
                        goto asop
                }
 
        case '^':
                c1 = getc()
                if c1 == '=' {
-                       c = int(OXOR)
+                       op = OXOR
                        goto asop
                }
 
@@ -1402,12 +1403,10 @@ l0:
        ungetc(c1)
 
 lx:
-       if c > 0xff {
-               if Debug['x'] != 0 {
+       if Debug['x'] != 0 {
+               if c > 0xff {
                        fmt.Printf("%v lex: TOKEN %s\n", Ctxt.Line(int(lexlineno)), lexname(c))
-               }
-       } else {
-               if Debug['x'] != 0 {
+               } else {
                        fmt.Printf("%v lex: TOKEN '%c'\n", Ctxt.Line(int(lexlineno)), c)
                }
        }
@@ -1424,9 +1423,9 @@ lx:
        return int32(c)
 
 asop:
-       yylval.i = c // rathole to hold which asop
+       yylval.op = op
        if Debug['x'] != 0 {
-               fmt.Printf("lex: TOKEN ASOP %c\n", c)
+               fmt.Printf("lex: TOKEN ASOP %s=\n", goopnames[op])
        }
        return LASOP
 
index 20a1202d2530e9876bead525962c5d3b61ddfc68..37b244cdc4308cfcf65420cc785a485a39306b37 100644 (file)
@@ -92,7 +92,7 @@ type parser struct {
 
 func (p *parser) next() {
        p.tok = yylex(&p.yy)
-       p.op = Op(p.yy.i)
+       p.op = p.yy.op
        p.val = p.yy.val
        p.sym_ = p.yy.sym
 }