Commit de531fc2 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile: remove gratuituous type conversions

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/17249Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent e18cd34c
...@@ -931,7 +931,7 @@ type yySymType struct { ...@@ -931,7 +931,7 @@ type yySymType struct {
typ *Type typ *Type
sym *Sym sym *Sym
val Val val Val
i int op Op
} }
const ( const (
...@@ -984,6 +984,7 @@ const ( ...@@ -984,6 +984,7 @@ const (
func _yylex(yylval *yySymType) int32 { func _yylex(yylval *yySymType) int32 {
var c1 int var c1 int
var op Op
var escflag int var escflag int
var v int64 var v int64
var cp *bytes.Buffer var cp *bytes.Buffer
...@@ -1245,7 +1246,7 @@ l0: ...@@ -1245,7 +1246,7 @@ l0:
} }
if c1 == '=' { if c1 == '=' {
c = int(ODIV) op = ODIV
goto asop goto asop
} }
...@@ -1259,14 +1260,14 @@ l0: ...@@ -1259,14 +1260,14 @@ l0:
case '*': case '*':
c1 = getc() c1 = getc()
if c1 == '=' { if c1 == '=' {
c = int(OMUL) op = OMUL
goto asop goto asop
} }
case '%': case '%':
c1 = getc() c1 = getc()
if c1 == '=' { if c1 == '=' {
c = int(OMOD) op = OMOD
goto asop goto asop
} }
...@@ -1278,7 +1279,7 @@ l0: ...@@ -1278,7 +1279,7 @@ l0:
} }
if c1 == '=' { if c1 == '=' {
c = int(OADD) op = OADD
goto asop goto asop
} }
...@@ -1290,7 +1291,7 @@ l0: ...@@ -1290,7 +1291,7 @@ l0:
} }
if c1 == '=' { if c1 == '=' {
c = int(OSUB) op = OSUB
goto asop goto asop
} }
...@@ -1300,7 +1301,7 @@ l0: ...@@ -1300,7 +1301,7 @@ l0:
c = int(LRSH) c = int(LRSH)
c1 = getc() c1 = getc()
if c1 == '=' { if c1 == '=' {
c = int(ORSH) op = ORSH
goto asop goto asop
} }
...@@ -1320,7 +1321,7 @@ l0: ...@@ -1320,7 +1321,7 @@ l0:
c = int(LLSH) c = int(LLSH)
c1 = getc() c1 = getc()
if c1 == '=' { if c1 == '=' {
c = int(OLSH) op = OLSH
goto asop goto asop
} }
...@@ -1364,7 +1365,7 @@ l0: ...@@ -1364,7 +1365,7 @@ l0:
c = int(LANDNOT) c = int(LANDNOT)
c1 = getc() c1 = getc()
if c1 == '=' { if c1 == '=' {
c = int(OANDNOT) op = OANDNOT
goto asop goto asop
} }
...@@ -1372,7 +1373,7 @@ l0: ...@@ -1372,7 +1373,7 @@ l0:
} }
if c1 == '=' { if c1 == '=' {
c = int(OAND) op = OAND
goto asop goto asop
} }
...@@ -1384,14 +1385,14 @@ l0: ...@@ -1384,14 +1385,14 @@ l0:
} }
if c1 == '=' { if c1 == '=' {
c = int(OOR) op = OOR
goto asop goto asop
} }
case '^': case '^':
c1 = getc() c1 = getc()
if c1 == '=' { if c1 == '=' {
c = int(OXOR) op = OXOR
goto asop goto asop
} }
...@@ -1402,12 +1403,10 @@ l0: ...@@ -1402,12 +1403,10 @@ l0:
ungetc(c1) ungetc(c1)
lx: 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)) fmt.Printf("%v lex: TOKEN %s\n", Ctxt.Line(int(lexlineno)), lexname(c))
}
} else { } else {
if Debug['x'] != 0 {
fmt.Printf("%v lex: TOKEN '%c'\n", Ctxt.Line(int(lexlineno)), c) fmt.Printf("%v lex: TOKEN '%c'\n", Ctxt.Line(int(lexlineno)), c)
} }
} }
...@@ -1424,9 +1423,9 @@ lx: ...@@ -1424,9 +1423,9 @@ lx:
return int32(c) return int32(c)
asop: asop:
yylval.i = c // rathole to hold which asop yylval.op = op
if Debug['x'] != 0 { if Debug['x'] != 0 {
fmt.Printf("lex: TOKEN ASOP %c\n", c) fmt.Printf("lex: TOKEN ASOP %s=\n", goopnames[op])
} }
return LASOP return LASOP
......
...@@ -92,7 +92,7 @@ type parser struct { ...@@ -92,7 +92,7 @@ type parser struct {
func (p *parser) next() { func (p *parser) next() {
p.tok = yylex(&p.yy) p.tok = yylex(&p.yy)
p.op = Op(p.yy.i) p.op = p.yy.op
p.val = p.yy.val p.val = p.yy.val
p.sym_ = p.yy.sym p.sym_ = p.yy.sym
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment