Commit 09c672d5 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: add typChan

Passes toolstash -cmp.

Change-Id: I2c71882f957c44047c7ac83c78236dcc3dfa15a1
Reviewed-on: https://go-review.googlesource.com/21304Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
parent 331f9625
...@@ -3050,9 +3050,7 @@ func (p *parser) hidden_type_misc() *Type { ...@@ -3050,9 +3050,7 @@ func (p *parser) hidden_type_misc() *Type {
default: default:
// LCHAN hidden_type_non_recv_chan // LCHAN hidden_type_non_recv_chan
s2 := p.hidden_type_non_recv_chan() s2 := p.hidden_type_non_recv_chan()
ss := typ(TCHAN) ss := typeChan(s2, Cboth)
ss.Type = s2
ss.Chan = Cboth
return ss return ss
case '(': case '(':
...@@ -3060,18 +3058,14 @@ func (p *parser) hidden_type_misc() *Type { ...@@ -3060,18 +3058,14 @@ func (p *parser) hidden_type_misc() *Type {
p.next() p.next()
s3 := p.hidden_type_recv_chan() s3 := p.hidden_type_recv_chan()
p.want(')') p.want(')')
ss := typ(TCHAN) ss := typeChan(s3, Cboth)
ss.Type = s3
ss.Chan = Cboth
return ss return ss
case LCOMM: case LCOMM:
// LCHAN hidden_type // LCHAN hidden_type
p.next() p.next()
s3 := p.hidden_type() s3 := p.hidden_type()
ss := typ(TCHAN) ss := typeChan(s3, Csend)
ss.Type = s3
ss.Chan = Csend
return ss return ss
} }
...@@ -3090,9 +3084,7 @@ func (p *parser) hidden_type_recv_chan() *Type { ...@@ -3090,9 +3084,7 @@ func (p *parser) hidden_type_recv_chan() *Type {
p.want(LCHAN) p.want(LCHAN)
s3 := p.hidden_type() s3 := p.hidden_type()
ss := typ(TCHAN) ss := typeChan(s3, Crecv)
ss.Type = s3
ss.Chan = Crecv
return ss return ss
} }
......
...@@ -259,6 +259,14 @@ func typeDDDArray(elem *Type) *Type { ...@@ -259,6 +259,14 @@ func typeDDDArray(elem *Type) *Type {
return t return t
} }
// typeChan returns a new chan Type with direction dir.
func typeChan(elem *Type, dir uint8) *Type {
t := typ(TCHAN)
t.Type = elem
t.Chan = dir
return t
}
func newField() *Field { func newField() *Field {
return &Field{ return &Field{
Offset: BADWIDTH, Offset: BADWIDTH,
......
...@@ -413,10 +413,7 @@ OpSwitch: ...@@ -413,10 +413,7 @@ OpSwitch:
n.Type = nil n.Type = nil
return n return n
} }
t := typ(TCHAN) t := typeChan(l.Type, uint8(n.Etype)) // TODO(marvin): Fix Node.EType type union.
t.Type = l.Type
// TODO(marvin): Fix Node.EType type union.
t.Chan = uint8(n.Etype)
n.Op = OTYPE n.Op = OTYPE
n.Type = t n.Type = t
n.Left = nil n.Left = nil
......
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