aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2015-11-27 16:11:05 -0800
committerRobert Griesemer <gri@golang.org>2015-11-28 03:36:21 +0000
commitde531fc255e4b8ec6c38fa839546cddcac1e074b (patch)
tree759875d470f4cb3470af642269eef223db21cab2 /src
parente18cd34c76892cd62f4857e56ffbbe503acd508a (diff)
downloadgo-de531fc255e4b8ec6c38fa839546cddcac1e074b.tar.xz
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/17249 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/gc/lex.go37
-rw-r--r--src/cmd/compile/internal/gc/parser.go2
2 files changed, 19 insertions, 20 deletions
diff --git a/src/cmd/compile/internal/gc/lex.go b/src/cmd/compile/internal/gc/lex.go
index 55ba2ed3f4..830c56df60 100644
--- a/src/cmd/compile/internal/gc/lex.go
+++ b/src/cmd/compile/internal/gc/lex.go
@@ -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
diff --git a/src/cmd/compile/internal/gc/parser.go b/src/cmd/compile/internal/gc/parser.go
index 20a1202d25..37b244cdc4 100644
--- a/src/cmd/compile/internal/gc/parser.go
+++ b/src/cmd/compile/internal/gc/parser.go
@@ -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
}