Dcl []*Name
ClosureEnter Nodes // list of ONAME nodes (or OADDR-of-ONAME nodes, for output parameters) of captured variables
- ClosureType Node // closure representation type
+ ClosureType Ntype // closure representation type
ClosureVars []*Name // closure params; each has closurevar set
// Parents records the parent scope of each scope within a
}
func (n *ArrayType) editChildren(edit func(Node) Node) {
n.Len = maybeEdit(n.Len, edit)
- n.Elem = maybeEdit(n.Elem, edit)
+ n.Elem = toNtype(maybeEdit(n.Elem, edit))
}
func (n *AssignListStmt) Format(s fmt.State, verb rune) { FmtNode(n, s, verb) }
return err
}
func (n *ChanType) editChildren(edit func(Node) Node) {
- n.Elem = maybeEdit(n.Elem, edit)
+ n.Elem = toNtype(maybeEdit(n.Elem, edit))
}
func (n *ClosureExpr) Format(s fmt.State, verb rune) { FmtNode(n, s, verb) }
return err
}
func (n *MapType) editChildren(edit func(Node) Node) {
- n.Key = maybeEdit(n.Key, edit)
- n.Elem = maybeEdit(n.Elem, edit)
+ n.Key = toNtype(maybeEdit(n.Key, edit))
+ n.Elem = toNtype(maybeEdit(n.Elem, edit))
}
func (n *Name) Format(s fmt.State, verb rune) { FmtNode(n, s, verb) }
return err
}
func (n *SliceType) editChildren(edit func(Node) Node) {
- n.Elem = maybeEdit(n.Elem, edit)
+ n.Elem = toNtype(maybeEdit(n.Elem, edit))
}
func (n *StarExpr) Format(s fmt.State, verb rune) { FmtNode(n, s, verb) }
// setOTYPE also records t.Nod = self if t.Nod is not already set.
// (Some types are shared by multiple OTYPE nodes, so only
// the first such node is used as t.Nod.)
-func (n *miniType) setOTYPE(t *types.Type, self Node) {
+func (n *miniType) setOTYPE(t *types.Type, self Ntype) {
if n.typ != nil {
panic(n.op.String() + " SetType: type already set")
}
// A ChanType represents a chan Elem syntax with the direction Dir.
type ChanType struct {
miniType
- Elem Node
+ Elem Ntype
Dir types.ChanDir
}
-func NewChanType(pos src.XPos, elem Node, dir types.ChanDir) *ChanType {
+func NewChanType(pos src.XPos, elem Ntype, dir types.ChanDir) *ChanType {
n := &ChanType{Elem: elem, Dir: dir}
n.op = OTCHAN
n.pos = pos
// A MapType represents a map[Key]Value type syntax.
type MapType struct {
miniType
- Key Node
- Elem Node
+ Key Ntype
+ Elem Ntype
}
-func NewMapType(pos src.XPos, key, elem Node) *MapType {
+func NewMapType(pos src.XPos, key, elem Ntype) *MapType {
n := &MapType{Key: key, Elem: elem}
n.op = OTMAP
n.pos = pos
// If DDD is true, it's the ...Elem at the end of a function list.
type SliceType struct {
miniType
- Elem Node
+ Elem Ntype
DDD bool
}
-func NewSliceType(pos src.XPos, elem Node) *SliceType {
+func NewSliceType(pos src.XPos, elem Ntype) *SliceType {
n := &SliceType{Elem: elem}
n.op = OTSLICE
n.pos = pos
type ArrayType struct {
miniType
Len Node
- Elem Node
+ Elem Ntype
}
-func NewArrayType(pos src.XPos, size Node, elem Node) *ArrayType {
- n := &ArrayType{Len: size, Elem: elem}
+func NewArrayType(pos src.XPos, len Node, elem Ntype) *ArrayType {
+ n := &ArrayType{Len: len, Elem: elem}
n.op = OTARRAY
n.pos = pos
return n
// Need to handle [...]T arrays specially.
if array, ok := n.Ntype.(*ir.ArrayType); ok && array.Elem != nil && array.Len == nil {
- array.Elem = typecheck(array.Elem, ctxType)
+ array.Elem = typecheckNtype(array.Elem)
elemType := array.Elem.Type()
if elemType == nil {
n.SetType(nil)
return n
}
- n.Ntype = ir.Node(typecheck(n.Ntype, ctxType)).(ir.Ntype)
+ n.Ntype = typecheckNtype(n.Ntype)
t := n.Ntype.Type()
if t == nil {
n.SetType(nil)
fn.Iota = x
}
- fn.ClosureType = typecheck(fn.ClosureType, ctxType)
+ fn.ClosureType = typecheckNtype(fn.ClosureType)
clo.SetType(fn.ClosureType.Type())
fn.SetClosureCalled(top&ctxCallee != 0)
// tcArrayType typechecks an OTARRAY node.
func tcArrayType(n *ir.ArrayType) ir.Node {
- n.Elem = typecheck(n.Elem, ctxType)
+ n.Elem = typecheckNtype(n.Elem)
if n.Elem.Type() == nil {
return n
}
// tcChanType typechecks an OTCHAN node.
func tcChanType(n *ir.ChanType) ir.Node {
- n.Elem = typecheck(n.Elem, ctxType)
+ n.Elem = typecheckNtype(n.Elem)
l := n.Elem
if l.Type() == nil {
return n
n.SetOTYPE(types.Types[types.TINTER])
return n
}
-
+
lno := base.Pos
methods := tcFields(n.Methods, nil)
base.Pos = lno
// tcMapType typechecks an OTMAP node.
func tcMapType(n *ir.MapType) ir.Node {
- n.Key = typecheck(n.Key, ctxType)
- n.Elem = typecheck(n.Elem, ctxType)
+ n.Key = typecheckNtype(n.Key)
+ n.Elem = typecheckNtype(n.Elem)
l := n.Key
r := n.Elem
if l.Type() == nil || r.Type() == nil {
// tcSliceType typechecks an OTSLICE node.
func tcSliceType(n *ir.SliceType) ir.Node {
- n.Elem = typecheck(n.Elem, ctxType)
+ n.Elem = typecheckNtype(n.Elem)
if n.Elem.Type() == nil {
return n
}