mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/gc: make Nod private
Follow up to CL 29134. Generated with gofmt -r 'Nod -> nod', plus three manual adjustments to the comments in syntax/parser.go Change-Id: I02920f7ab10c70b6e850457b42d5fe35f1f3821a Reviewed-on: https://go-review.googlesource.com/29136 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
bb12894d2b
commit
073d248bf5
29 changed files with 692 additions and 692 deletions
|
|
@ -191,20 +191,20 @@ func genhash(sym *Sym, t *Type) {
|
||||||
markdcl()
|
markdcl()
|
||||||
|
|
||||||
// func sym(p *T, h uintptr) uintptr
|
// func sym(p *T, h uintptr) uintptr
|
||||||
fn := Nod(ODCLFUNC, nil, nil)
|
fn := nod(ODCLFUNC, nil, nil)
|
||||||
|
|
||||||
fn.Func.Nname = newname(sym)
|
fn.Func.Nname = newname(sym)
|
||||||
fn.Func.Nname.Class = PFUNC
|
fn.Func.Nname.Class = PFUNC
|
||||||
tfn := Nod(OTFUNC, nil, nil)
|
tfn := nod(OTFUNC, nil, nil)
|
||||||
fn.Func.Nname.Name.Param.Ntype = tfn
|
fn.Func.Nname.Name.Param.Ntype = tfn
|
||||||
|
|
||||||
n := Nod(ODCLFIELD, newname(lookup("p")), typenod(ptrto(t)))
|
n := nod(ODCLFIELD, newname(lookup("p")), typenod(ptrto(t)))
|
||||||
tfn.List.Append(n)
|
tfn.List.Append(n)
|
||||||
np := n.Left
|
np := n.Left
|
||||||
n = Nod(ODCLFIELD, newname(lookup("h")), typenod(Types[TUINTPTR]))
|
n = nod(ODCLFIELD, newname(lookup("h")), typenod(Types[TUINTPTR]))
|
||||||
tfn.List.Append(n)
|
tfn.List.Append(n)
|
||||||
nh := n.Left
|
nh := n.Left
|
||||||
n = Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])) // return value
|
n = nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])) // return value
|
||||||
tfn.Rlist.Append(n)
|
tfn.Rlist.Append(n)
|
||||||
|
|
||||||
funchdr(fn)
|
funchdr(fn)
|
||||||
|
|
@ -223,7 +223,7 @@ func genhash(sym *Sym, t *Type) {
|
||||||
// pure memory.
|
// pure memory.
|
||||||
hashel := hashfor(t.Elem())
|
hashel := hashfor(t.Elem())
|
||||||
|
|
||||||
n := Nod(ORANGE, nil, Nod(OIND, np, nil))
|
n := nod(ORANGE, nil, nod(OIND, np, nil))
|
||||||
ni := newname(lookup("i"))
|
ni := newname(lookup("i"))
|
||||||
ni.Type = Types[TINT]
|
ni.Type = Types[TINT]
|
||||||
n.List.Set1(ni)
|
n.List.Set1(ni)
|
||||||
|
|
@ -232,15 +232,15 @@ func genhash(sym *Sym, t *Type) {
|
||||||
ni = n.List.First()
|
ni = n.List.First()
|
||||||
|
|
||||||
// h = hashel(&p[i], h)
|
// h = hashel(&p[i], h)
|
||||||
call := Nod(OCALL, hashel, nil)
|
call := nod(OCALL, hashel, nil)
|
||||||
|
|
||||||
nx := Nod(OINDEX, np, ni)
|
nx := nod(OINDEX, np, ni)
|
||||||
nx.Bounded = true
|
nx.Bounded = true
|
||||||
na := Nod(OADDR, nx, nil)
|
na := nod(OADDR, nx, nil)
|
||||||
na.Etype = 1 // no escape to heap
|
na.Etype = 1 // no escape to heap
|
||||||
call.List.Append(na)
|
call.List.Append(na)
|
||||||
call.List.Append(nh)
|
call.List.Append(nh)
|
||||||
n.Nbody.Append(Nod(OAS, nh, call))
|
n.Nbody.Append(nod(OAS, nh, call))
|
||||||
|
|
||||||
fn.Nbody.Append(n)
|
fn.Nbody.Append(n)
|
||||||
|
|
||||||
|
|
@ -259,13 +259,13 @@ func genhash(sym *Sym, t *Type) {
|
||||||
// Hash non-memory fields with appropriate hash function.
|
// Hash non-memory fields with appropriate hash function.
|
||||||
if !f.Type.IsRegularMemory() {
|
if !f.Type.IsRegularMemory() {
|
||||||
hashel := hashfor(f.Type)
|
hashel := hashfor(f.Type)
|
||||||
call := Nod(OCALL, hashel, nil)
|
call := nod(OCALL, hashel, nil)
|
||||||
nx := nodSym(OXDOT, np, f.Sym) // TODO: fields from other packages?
|
nx := nodSym(OXDOT, np, f.Sym) // TODO: fields from other packages?
|
||||||
na := Nod(OADDR, nx, nil)
|
na := nod(OADDR, nx, nil)
|
||||||
na.Etype = 1 // no escape to heap
|
na.Etype = 1 // no escape to heap
|
||||||
call.List.Append(na)
|
call.List.Append(na)
|
||||||
call.List.Append(nh)
|
call.List.Append(nh)
|
||||||
fn.Nbody.Append(Nod(OAS, nh, call))
|
fn.Nbody.Append(nod(OAS, nh, call))
|
||||||
i++
|
i++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -275,20 +275,20 @@ func genhash(sym *Sym, t *Type) {
|
||||||
|
|
||||||
// h = hashel(&p.first, size, h)
|
// h = hashel(&p.first, size, h)
|
||||||
hashel := hashmem(f.Type)
|
hashel := hashmem(f.Type)
|
||||||
call := Nod(OCALL, hashel, nil)
|
call := nod(OCALL, hashel, nil)
|
||||||
nx := nodSym(OXDOT, np, f.Sym) // TODO: fields from other packages?
|
nx := nodSym(OXDOT, np, f.Sym) // TODO: fields from other packages?
|
||||||
na := Nod(OADDR, nx, nil)
|
na := nod(OADDR, nx, nil)
|
||||||
na.Etype = 1 // no escape to heap
|
na.Etype = 1 // no escape to heap
|
||||||
call.List.Append(na)
|
call.List.Append(na)
|
||||||
call.List.Append(nh)
|
call.List.Append(nh)
|
||||||
call.List.Append(nodintconst(size))
|
call.List.Append(nodintconst(size))
|
||||||
fn.Nbody.Append(Nod(OAS, nh, call))
|
fn.Nbody.Append(nod(OAS, nh, call))
|
||||||
|
|
||||||
i = next
|
i = next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r := Nod(ORETURN, nil, nil)
|
r := nod(ORETURN, nil, nil)
|
||||||
r.List.Append(nh)
|
r.List.Append(nh)
|
||||||
fn.Nbody.Append(r)
|
fn.Nbody.Append(r)
|
||||||
|
|
||||||
|
|
@ -346,10 +346,10 @@ func hashfor(t *Type) *Node {
|
||||||
|
|
||||||
n := newname(sym)
|
n := newname(sym)
|
||||||
n.Class = PFUNC
|
n.Class = PFUNC
|
||||||
tfn := Nod(OTFUNC, nil, nil)
|
tfn := nod(OTFUNC, nil, nil)
|
||||||
tfn.List.Append(Nod(ODCLFIELD, nil, typenod(ptrto(t))))
|
tfn.List.Append(nod(ODCLFIELD, nil, typenod(ptrto(t))))
|
||||||
tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
|
tfn.List.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
|
||||||
tfn.Rlist.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
|
tfn.Rlist.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
|
||||||
tfn = typecheck(tfn, Etype)
|
tfn = typecheck(tfn, Etype)
|
||||||
n.Type = tfn.Type
|
n.Type = tfn.Type
|
||||||
return n
|
return n
|
||||||
|
|
@ -367,20 +367,20 @@ func geneq(sym *Sym, t *Type) {
|
||||||
markdcl()
|
markdcl()
|
||||||
|
|
||||||
// func sym(p, q *T) bool
|
// func sym(p, q *T) bool
|
||||||
fn := Nod(ODCLFUNC, nil, nil)
|
fn := nod(ODCLFUNC, nil, nil)
|
||||||
|
|
||||||
fn.Func.Nname = newname(sym)
|
fn.Func.Nname = newname(sym)
|
||||||
fn.Func.Nname.Class = PFUNC
|
fn.Func.Nname.Class = PFUNC
|
||||||
tfn := Nod(OTFUNC, nil, nil)
|
tfn := nod(OTFUNC, nil, nil)
|
||||||
fn.Func.Nname.Name.Param.Ntype = tfn
|
fn.Func.Nname.Name.Param.Ntype = tfn
|
||||||
|
|
||||||
n := Nod(ODCLFIELD, newname(lookup("p")), typenod(ptrto(t)))
|
n := nod(ODCLFIELD, newname(lookup("p")), typenod(ptrto(t)))
|
||||||
tfn.List.Append(n)
|
tfn.List.Append(n)
|
||||||
np := n.Left
|
np := n.Left
|
||||||
n = Nod(ODCLFIELD, newname(lookup("q")), typenod(ptrto(t)))
|
n = nod(ODCLFIELD, newname(lookup("q")), typenod(ptrto(t)))
|
||||||
tfn.List.Append(n)
|
tfn.List.Append(n)
|
||||||
nq := n.Left
|
nq := n.Left
|
||||||
n = Nod(ODCLFIELD, nil, typenod(Types[TBOOL]))
|
n = nod(ODCLFIELD, nil, typenod(Types[TBOOL]))
|
||||||
tfn.Rlist.Append(n)
|
tfn.Rlist.Append(n)
|
||||||
|
|
||||||
funchdr(fn)
|
funchdr(fn)
|
||||||
|
|
@ -399,7 +399,7 @@ func geneq(sym *Sym, t *Type) {
|
||||||
// pure memory. Even if we unrolled the range loop,
|
// pure memory. Even if we unrolled the range loop,
|
||||||
// each iteration would be a function call, so don't bother
|
// each iteration would be a function call, so don't bother
|
||||||
// unrolling.
|
// unrolling.
|
||||||
nrange := Nod(ORANGE, nil, Nod(OIND, np, nil))
|
nrange := nod(ORANGE, nil, nod(OIND, np, nil))
|
||||||
|
|
||||||
ni := newname(lookup("i"))
|
ni := newname(lookup("i"))
|
||||||
ni.Type = Types[TINT]
|
ni.Type = Types[TINT]
|
||||||
|
|
@ -409,22 +409,22 @@ func geneq(sym *Sym, t *Type) {
|
||||||
ni = nrange.List.First()
|
ni = nrange.List.First()
|
||||||
|
|
||||||
// if p[i] != q[i] { return false }
|
// if p[i] != q[i] { return false }
|
||||||
nx := Nod(OINDEX, np, ni)
|
nx := nod(OINDEX, np, ni)
|
||||||
|
|
||||||
nx.Bounded = true
|
nx.Bounded = true
|
||||||
ny := Nod(OINDEX, nq, ni)
|
ny := nod(OINDEX, nq, ni)
|
||||||
ny.Bounded = true
|
ny.Bounded = true
|
||||||
|
|
||||||
nif := Nod(OIF, nil, nil)
|
nif := nod(OIF, nil, nil)
|
||||||
nif.Left = Nod(ONE, nx, ny)
|
nif.Left = nod(ONE, nx, ny)
|
||||||
r := Nod(ORETURN, nil, nil)
|
r := nod(ORETURN, nil, nil)
|
||||||
r.List.Append(nodbool(false))
|
r.List.Append(nodbool(false))
|
||||||
nif.Nbody.Append(r)
|
nif.Nbody.Append(r)
|
||||||
nrange.Nbody.Append(nif)
|
nrange.Nbody.Append(nif)
|
||||||
fn.Nbody.Append(nrange)
|
fn.Nbody.Append(nrange)
|
||||||
|
|
||||||
// return true
|
// return true
|
||||||
ret := Nod(ORETURN, nil, nil)
|
ret := nod(ORETURN, nil, nil)
|
||||||
ret.List.Append(nodbool(true))
|
ret.List.Append(nodbool(true))
|
||||||
fn.Nbody.Append(ret)
|
fn.Nbody.Append(ret)
|
||||||
|
|
||||||
|
|
@ -435,7 +435,7 @@ func geneq(sym *Sym, t *Type) {
|
||||||
cond = n
|
cond = n
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cond = Nod(OANDAND, cond, n)
|
cond = nod(OANDAND, cond, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walk the struct using memequal for runs of AMEM
|
// Walk the struct using memequal for runs of AMEM
|
||||||
|
|
@ -477,7 +477,7 @@ func geneq(sym *Sym, t *Type) {
|
||||||
cond = nodbool(true)
|
cond = nodbool(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := Nod(ORETURN, nil, nil)
|
ret := nod(ORETURN, nil, nil)
|
||||||
ret.List.Append(cond)
|
ret.List.Append(cond)
|
||||||
fn.Nbody.Append(ret)
|
fn.Nbody.Append(ret)
|
||||||
}
|
}
|
||||||
|
|
@ -520,22 +520,22 @@ func geneq(sym *Sym, t *Type) {
|
||||||
func eqfield(p *Node, q *Node, field *Sym) *Node {
|
func eqfield(p *Node, q *Node, field *Sym) *Node {
|
||||||
nx := nodSym(OXDOT, p, field)
|
nx := nodSym(OXDOT, p, field)
|
||||||
ny := nodSym(OXDOT, q, field)
|
ny := nodSym(OXDOT, q, field)
|
||||||
ne := Nod(OEQ, nx, ny)
|
ne := nod(OEQ, nx, ny)
|
||||||
return ne
|
return ne
|
||||||
}
|
}
|
||||||
|
|
||||||
// eqmem returns the node
|
// eqmem returns the node
|
||||||
// memequal(&p.field, &q.field [, size])
|
// memequal(&p.field, &q.field [, size])
|
||||||
func eqmem(p *Node, q *Node, field *Sym, size int64) *Node {
|
func eqmem(p *Node, q *Node, field *Sym, size int64) *Node {
|
||||||
nx := Nod(OADDR, nodSym(OXDOT, p, field), nil)
|
nx := nod(OADDR, nodSym(OXDOT, p, field), nil)
|
||||||
nx.Etype = 1 // does not escape
|
nx.Etype = 1 // does not escape
|
||||||
ny := Nod(OADDR, nodSym(OXDOT, q, field), nil)
|
ny := nod(OADDR, nodSym(OXDOT, q, field), nil)
|
||||||
ny.Etype = 1 // does not escape
|
ny.Etype = 1 // does not escape
|
||||||
nx = typecheck(nx, Erv)
|
nx = typecheck(nx, Erv)
|
||||||
ny = typecheck(ny, Erv)
|
ny = typecheck(ny, Erv)
|
||||||
|
|
||||||
fn, needsize := eqmemfunc(size, nx.Type.Elem())
|
fn, needsize := eqmemfunc(size, nx.Type.Elem())
|
||||||
call := Nod(OCALL, fn, nil)
|
call := nod(OCALL, fn, nil)
|
||||||
call.List.Append(nx)
|
call.List.Append(nx)
|
||||||
call.List.Append(ny)
|
call.List.Append(ny)
|
||||||
if needsize {
|
if needsize {
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ func Import(in *bufio.Reader) {
|
||||||
// (not doing so can cause significant performance
|
// (not doing so can cause significant performance
|
||||||
// degradation due to unnecessary calls to empty
|
// degradation due to unnecessary calls to empty
|
||||||
// functions).
|
// functions).
|
||||||
body = []*Node{Nod(OEMPTY, nil, nil)}
|
body = []*Node{nod(OEMPTY, nil, nil)}
|
||||||
}
|
}
|
||||||
f.Func.Inl.Set(body)
|
f.Func.Inl.Set(body)
|
||||||
funcbody(f)
|
funcbody(f)
|
||||||
|
|
@ -391,9 +391,9 @@ func (p *importer) newtyp(etype EType) *Type {
|
||||||
// importtype declares that pt, an imported named type, has underlying type t.
|
// importtype declares that pt, an imported named type, has underlying type t.
|
||||||
func (p *importer) importtype(pt, t *Type) {
|
func (p *importer) importtype(pt, t *Type) {
|
||||||
if pt.Etype == TFORW {
|
if pt.Etype == TFORW {
|
||||||
n := pt.Nod
|
n := pt.nod
|
||||||
copytype(pt.Nod, t)
|
copytype(pt.nod, t)
|
||||||
pt.Nod = n // unzero nod
|
pt.nod = n // unzero nod
|
||||||
pt.Sym.Importdef = importpkg
|
pt.Sym.Importdef = importpkg
|
||||||
pt.Sym.Lastlineno = lineno
|
pt.Sym.Lastlineno = lineno
|
||||||
declare(n, PEXTERN)
|
declare(n, PEXTERN)
|
||||||
|
|
@ -574,7 +574,7 @@ func (p *importer) field() *Node {
|
||||||
|
|
||||||
var n *Node
|
var n *Node
|
||||||
if sym.Name != "" {
|
if sym.Name != "" {
|
||||||
n = Nod(ODCLFIELD, newname(sym), typenod(typ))
|
n = nod(ODCLFIELD, newname(sym), typenod(typ))
|
||||||
} else {
|
} else {
|
||||||
// anonymous field - typ must be T or *T and T must be a type name
|
// anonymous field - typ must be T or *T and T must be a type name
|
||||||
s := typ.Sym
|
s := typ.Sym
|
||||||
|
|
@ -610,7 +610,7 @@ func (p *importer) method() *Node {
|
||||||
sym := p.fieldName()
|
sym := p.fieldName()
|
||||||
params := p.paramList()
|
params := p.paramList()
|
||||||
result := p.paramList()
|
result := p.paramList()
|
||||||
return Nod(ODCLFIELD, newname(sym), typenod(functype(fakethis(), params, result)))
|
return nod(ODCLFIELD, newname(sym), typenod(functype(fakethis(), params, result)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// parser.go:sym,hidden_importsym
|
// parser.go:sym,hidden_importsym
|
||||||
|
|
@ -662,7 +662,7 @@ func (p *importer) param(named bool) *Node {
|
||||||
isddd = true
|
isddd = true
|
||||||
}
|
}
|
||||||
|
|
||||||
n := Nod(ODCLFIELD, nil, typenod(typ))
|
n := nod(ODCLFIELD, nil, typenod(typ))
|
||||||
n.Isddd = isddd
|
n.Isddd = isddd
|
||||||
|
|
||||||
if named {
|
if named {
|
||||||
|
|
@ -804,7 +804,7 @@ func (p *importer) elemList() []*Node {
|
||||||
c := p.int()
|
c := p.int()
|
||||||
list := make([]*Node, c)
|
list := make([]*Node, c)
|
||||||
for i := range list {
|
for i := range list {
|
||||||
list[i] = Nod(OKEY, mkname(p.fieldSym()), p.expr())
|
list[i] = nod(OKEY, mkname(p.fieldSym()), p.expr())
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
@ -839,11 +839,11 @@ func (p *importer) node() *Node {
|
||||||
// again. Re-introduce explicit uintptr(c) conversion.
|
// again. Re-introduce explicit uintptr(c) conversion.
|
||||||
// (issue 16317).
|
// (issue 16317).
|
||||||
if typ.IsUnsafePtr() {
|
if typ.IsUnsafePtr() {
|
||||||
conv := Nod(OCALL, typenod(Types[TUINTPTR]), nil)
|
conv := nod(OCALL, typenod(Types[TUINTPTR]), nil)
|
||||||
conv.List.Set1(n)
|
conv.List.Set1(n)
|
||||||
n = conv
|
n = conv
|
||||||
}
|
}
|
||||||
conv := Nod(OCALL, typenod(typ), nil)
|
conv := nod(OCALL, typenod(typ), nil)
|
||||||
conv.List.Set1(n)
|
conv.List.Set1(n)
|
||||||
n = conv
|
n = conv
|
||||||
}
|
}
|
||||||
|
|
@ -872,16 +872,16 @@ func (p *importer) node() *Node {
|
||||||
if !p.bool() /* !implicit, i.e. '&' operator */ {
|
if !p.bool() /* !implicit, i.e. '&' operator */ {
|
||||||
if n.Op == OCOMPLIT {
|
if n.Op == OCOMPLIT {
|
||||||
// Special case for &T{...}: turn into (*T){...}.
|
// Special case for &T{...}: turn into (*T){...}.
|
||||||
n.Right = Nod(OIND, n.Right, nil)
|
n.Right = nod(OIND, n.Right, nil)
|
||||||
n.Right.Implicit = true
|
n.Right.Implicit = true
|
||||||
} else {
|
} else {
|
||||||
n = Nod(OADDR, n, nil)
|
n = nod(OADDR, n, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
|
|
||||||
case OSTRUCTLIT:
|
case OSTRUCTLIT:
|
||||||
n := Nod(OCOMPLIT, nil, typenod(p.typ()))
|
n := nod(OCOMPLIT, nil, typenod(p.typ()))
|
||||||
n.List.Set(p.elemList()) // special handling of field names
|
n.List.Set(p.elemList()) // special handling of field names
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
@ -889,13 +889,13 @@ func (p *importer) node() *Node {
|
||||||
// unreachable - mapped to case OCOMPLIT below by exporter
|
// unreachable - mapped to case OCOMPLIT below by exporter
|
||||||
|
|
||||||
case OCOMPLIT:
|
case OCOMPLIT:
|
||||||
n := Nod(OCOMPLIT, nil, typenod(p.typ()))
|
n := nod(OCOMPLIT, nil, typenod(p.typ()))
|
||||||
n.List.Set(p.exprList())
|
n.List.Set(p.exprList())
|
||||||
return n
|
return n
|
||||||
|
|
||||||
case OKEY:
|
case OKEY:
|
||||||
left, right := p.exprsOrNil()
|
left, right := p.exprsOrNil()
|
||||||
return Nod(OKEY, left, right)
|
return nod(OKEY, left, right)
|
||||||
|
|
||||||
// case OCALLPART:
|
// case OCALLPART:
|
||||||
// unimplemented
|
// unimplemented
|
||||||
|
|
@ -911,7 +911,7 @@ func (p *importer) node() *Node {
|
||||||
// unreachable - mapped to case ODOTTYPE below by exporter
|
// unreachable - mapped to case ODOTTYPE below by exporter
|
||||||
|
|
||||||
case ODOTTYPE:
|
case ODOTTYPE:
|
||||||
n := Nod(ODOTTYPE, p.expr(), nil)
|
n := nod(ODOTTYPE, p.expr(), nil)
|
||||||
if p.bool() {
|
if p.bool() {
|
||||||
n.Right = p.expr()
|
n.Right = p.expr()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -923,10 +923,10 @@ func (p *importer) node() *Node {
|
||||||
// unreachable - mapped to cases below by exporter
|
// unreachable - mapped to cases below by exporter
|
||||||
|
|
||||||
case OINDEX:
|
case OINDEX:
|
||||||
return Nod(op, p.expr(), p.expr())
|
return nod(op, p.expr(), p.expr())
|
||||||
|
|
||||||
case OSLICE, OSLICE3:
|
case OSLICE, OSLICE3:
|
||||||
n := Nod(op, p.expr(), nil)
|
n := nod(op, p.expr(), nil)
|
||||||
low, high := p.exprsOrNil()
|
low, high := p.exprsOrNil()
|
||||||
var max *Node
|
var max *Node
|
||||||
if n.Op.IsSlice3() {
|
if n.Op.IsSlice3() {
|
||||||
|
|
@ -939,7 +939,7 @@ func (p *importer) node() *Node {
|
||||||
// unreachable - mapped to OCONV case below by exporter
|
// unreachable - mapped to OCONV case below by exporter
|
||||||
|
|
||||||
case OCONV:
|
case OCONV:
|
||||||
n := Nod(OCALL, typenod(p.typ()), nil)
|
n := nod(OCALL, typenod(p.typ()), nil)
|
||||||
n.List.Set(p.exprList())
|
n.List.Set(p.exprList())
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
@ -955,7 +955,7 @@ func (p *importer) node() *Node {
|
||||||
// unreachable - mapped to OCALL case below by exporter
|
// unreachable - mapped to OCALL case below by exporter
|
||||||
|
|
||||||
case OCALL:
|
case OCALL:
|
||||||
n := Nod(OCALL, p.expr(), nil)
|
n := nod(OCALL, p.expr(), nil)
|
||||||
n.List.Set(p.exprList())
|
n.List.Set(p.exprList())
|
||||||
n.Isddd = p.bool()
|
n.Isddd = p.bool()
|
||||||
return n
|
return n
|
||||||
|
|
@ -968,18 +968,18 @@ func (p *importer) node() *Node {
|
||||||
|
|
||||||
// unary expressions
|
// unary expressions
|
||||||
case OPLUS, OMINUS, OADDR, OCOM, OIND, ONOT, ORECV:
|
case OPLUS, OMINUS, OADDR, OCOM, OIND, ONOT, ORECV:
|
||||||
return Nod(op, p.expr(), nil)
|
return nod(op, p.expr(), nil)
|
||||||
|
|
||||||
// binary expressions
|
// binary expressions
|
||||||
case OADD, OAND, OANDAND, OANDNOT, ODIV, OEQ, OGE, OGT, OLE, OLT,
|
case OADD, OAND, OANDAND, OANDNOT, ODIV, OEQ, OGE, OGT, OLE, OLT,
|
||||||
OLSH, OMOD, OMUL, ONE, OOR, OOROR, ORSH, OSEND, OSUB, OXOR:
|
OLSH, OMOD, OMUL, ONE, OOR, OOROR, ORSH, OSEND, OSUB, OXOR:
|
||||||
return Nod(op, p.expr(), p.expr())
|
return nod(op, p.expr(), p.expr())
|
||||||
|
|
||||||
case OADDSTR:
|
case OADDSTR:
|
||||||
list := p.exprList()
|
list := p.exprList()
|
||||||
x := list[0]
|
x := list[0]
|
||||||
for _, y := range list[1:] {
|
for _, y := range list[1:] {
|
||||||
x = Nod(OADD, x, y)
|
x = nod(OADD, x, y)
|
||||||
}
|
}
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
@ -988,7 +988,7 @@ func (p *importer) node() *Node {
|
||||||
|
|
||||||
case ODCLCONST:
|
case ODCLCONST:
|
||||||
// TODO(gri) these should not be exported in the first place
|
// TODO(gri) these should not be exported in the first place
|
||||||
return Nod(OEMPTY, nil, nil)
|
return nod(OEMPTY, nil, nil)
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// statements
|
// statements
|
||||||
|
|
@ -1009,10 +1009,10 @@ func (p *importer) node() *Node {
|
||||||
// unreachable - mapped to OAS case below by exporter
|
// unreachable - mapped to OAS case below by exporter
|
||||||
|
|
||||||
case OAS:
|
case OAS:
|
||||||
return Nod(OAS, p.expr(), p.expr())
|
return nod(OAS, p.expr(), p.expr())
|
||||||
|
|
||||||
case OASOP:
|
case OASOP:
|
||||||
n := Nod(OASOP, nil, nil)
|
n := nod(OASOP, nil, nil)
|
||||||
n.Etype = EType(p.int())
|
n.Etype = EType(p.int())
|
||||||
n.Left = p.expr()
|
n.Left = p.expr()
|
||||||
if !p.bool() {
|
if !p.bool() {
|
||||||
|
|
@ -1027,13 +1027,13 @@ func (p *importer) node() *Node {
|
||||||
// unreachable - mapped to OAS2 case below by exporter
|
// unreachable - mapped to OAS2 case below by exporter
|
||||||
|
|
||||||
case OAS2:
|
case OAS2:
|
||||||
n := Nod(OAS2, nil, nil)
|
n := nod(OAS2, nil, nil)
|
||||||
n.List.Set(p.exprList())
|
n.List.Set(p.exprList())
|
||||||
n.Rlist.Set(p.exprList())
|
n.Rlist.Set(p.exprList())
|
||||||
return n
|
return n
|
||||||
|
|
||||||
case ORETURN:
|
case ORETURN:
|
||||||
n := Nod(ORETURN, nil, nil)
|
n := nod(ORETURN, nil, nil)
|
||||||
n.List.Set(p.exprList())
|
n.List.Set(p.exprList())
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
@ -1041,11 +1041,11 @@ func (p *importer) node() *Node {
|
||||||
// unreachable - generated by compiler for trampolin routines (not exported)
|
// unreachable - generated by compiler for trampolin routines (not exported)
|
||||||
|
|
||||||
case OPROC, ODEFER:
|
case OPROC, ODEFER:
|
||||||
return Nod(op, p.expr(), nil)
|
return nod(op, p.expr(), nil)
|
||||||
|
|
||||||
case OIF:
|
case OIF:
|
||||||
markdcl()
|
markdcl()
|
||||||
n := Nod(OIF, nil, nil)
|
n := nod(OIF, nil, nil)
|
||||||
n.Ninit.Set(p.stmtList())
|
n.Ninit.Set(p.stmtList())
|
||||||
n.Left = p.expr()
|
n.Left = p.expr()
|
||||||
n.Nbody.Set(p.stmtList())
|
n.Nbody.Set(p.stmtList())
|
||||||
|
|
@ -1055,7 +1055,7 @@ func (p *importer) node() *Node {
|
||||||
|
|
||||||
case OFOR:
|
case OFOR:
|
||||||
markdcl()
|
markdcl()
|
||||||
n := Nod(OFOR, nil, nil)
|
n := nod(OFOR, nil, nil)
|
||||||
n.Ninit.Set(p.stmtList())
|
n.Ninit.Set(p.stmtList())
|
||||||
n.Left, n.Right = p.exprsOrNil()
|
n.Left, n.Right = p.exprsOrNil()
|
||||||
n.Nbody.Set(p.stmtList())
|
n.Nbody.Set(p.stmtList())
|
||||||
|
|
@ -1064,7 +1064,7 @@ func (p *importer) node() *Node {
|
||||||
|
|
||||||
case ORANGE:
|
case ORANGE:
|
||||||
markdcl()
|
markdcl()
|
||||||
n := Nod(ORANGE, nil, nil)
|
n := nod(ORANGE, nil, nil)
|
||||||
n.List.Set(p.stmtList())
|
n.List.Set(p.stmtList())
|
||||||
n.Right = p.expr()
|
n.Right = p.expr()
|
||||||
n.Nbody.Set(p.stmtList())
|
n.Nbody.Set(p.stmtList())
|
||||||
|
|
@ -1073,7 +1073,7 @@ func (p *importer) node() *Node {
|
||||||
|
|
||||||
case OSELECT, OSWITCH:
|
case OSELECT, OSWITCH:
|
||||||
markdcl()
|
markdcl()
|
||||||
n := Nod(op, nil, nil)
|
n := nod(op, nil, nil)
|
||||||
n.Ninit.Set(p.stmtList())
|
n.Ninit.Set(p.stmtList())
|
||||||
n.Left, _ = p.exprsOrNil()
|
n.Left, _ = p.exprsOrNil()
|
||||||
n.List.Set(p.stmtList())
|
n.List.Set(p.stmtList())
|
||||||
|
|
@ -1085,7 +1085,7 @@ func (p *importer) node() *Node {
|
||||||
|
|
||||||
case OXCASE:
|
case OXCASE:
|
||||||
markdcl()
|
markdcl()
|
||||||
n := Nod(OXCASE, nil, nil)
|
n := nod(OXCASE, nil, nil)
|
||||||
n.Xoffset = int64(block)
|
n.Xoffset = int64(block)
|
||||||
n.List.Set(p.exprList())
|
n.List.Set(p.exprList())
|
||||||
// TODO(gri) eventually we must declare variables for type switch
|
// TODO(gri) eventually we must declare variables for type switch
|
||||||
|
|
@ -1098,7 +1098,7 @@ func (p *importer) node() *Node {
|
||||||
// unreachable - mapped to OXFALL case below by exporter
|
// unreachable - mapped to OXFALL case below by exporter
|
||||||
|
|
||||||
case OXFALL:
|
case OXFALL:
|
||||||
n := Nod(OXFALL, nil, nil)
|
n := nod(OXFALL, nil, nil)
|
||||||
n.Xoffset = int64(block)
|
n.Xoffset = int64(block)
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
@ -1107,13 +1107,13 @@ func (p *importer) node() *Node {
|
||||||
if left != nil {
|
if left != nil {
|
||||||
left = newname(left.Sym)
|
left = newname(left.Sym)
|
||||||
}
|
}
|
||||||
return Nod(op, left, nil)
|
return nod(op, left, nil)
|
||||||
|
|
||||||
// case OEMPTY:
|
// case OEMPTY:
|
||||||
// unreachable - not emitted by exporter
|
// unreachable - not emitted by exporter
|
||||||
|
|
||||||
case OGOTO, OLABEL:
|
case OGOTO, OLABEL:
|
||||||
n := Nod(op, newname(p.expr().Sym), nil)
|
n := nod(op, newname(p.expr().Sym), nil)
|
||||||
n.Sym = dclstack // context, for goto restrictions
|
n.Sym = dclstack // context, for goto restrictions
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
@ -1128,7 +1128,7 @@ func (p *importer) node() *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
func builtinCall(op Op) *Node {
|
func builtinCall(op Op) *Node {
|
||||||
return Nod(OCALL, mkname(builtinpkg.Lookup(goopnames[op])), nil)
|
return nod(OCALL, mkname(builtinpkg.Lookup(goopnames[op])), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *importer) exprsOrNil() (a, b *Node) {
|
func (p *importer) exprsOrNil() (a, b *Node) {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
// function literals aka closures
|
// function literals aka closures
|
||||||
func closurehdr(ntype *Node) {
|
func closurehdr(ntype *Node) {
|
||||||
n := Nod(OCLOSURE, nil, nil)
|
n := nod(OCLOSURE, nil, nil)
|
||||||
n.Func.Ntype = ntype
|
n.Func.Ntype = ntype
|
||||||
n.Func.Depth = funcdepth
|
n.Func.Depth = funcdepth
|
||||||
n.Func.Outerfunc = Curfn
|
n.Func.Outerfunc = Curfn
|
||||||
|
|
@ -32,7 +32,7 @@ func closurehdr(ntype *Node) {
|
||||||
if name != nil {
|
if name != nil {
|
||||||
name = newname(name.Sym)
|
name = newname(name.Sym)
|
||||||
}
|
}
|
||||||
a := Nod(ODCLFIELD, name, n1.Right)
|
a := nod(ODCLFIELD, name, n1.Right)
|
||||||
a.Isddd = n1.Isddd
|
a.Isddd = n1.Isddd
|
||||||
if name != nil {
|
if name != nil {
|
||||||
name.Isddd = a.Isddd
|
name.Isddd = a.Isddd
|
||||||
|
|
@ -44,13 +44,13 @@ func closurehdr(ntype *Node) {
|
||||||
if name != nil {
|
if name != nil {
|
||||||
name = newname(name.Sym)
|
name = newname(name.Sym)
|
||||||
}
|
}
|
||||||
ntype.Rlist.Append(Nod(ODCLFIELD, name, n2.Right))
|
ntype.Rlist.Append(nod(ODCLFIELD, name, n2.Right))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func closurebody(body []*Node) *Node {
|
func closurebody(body []*Node) *Node {
|
||||||
if len(body) == 0 {
|
if len(body) == 0 {
|
||||||
body = []*Node{Nod(OEMPTY, nil, nil)}
|
body = []*Node{nod(OEMPTY, nil, nil)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func_ := Curfn
|
func_ := Curfn
|
||||||
|
|
@ -202,13 +202,13 @@ func closurename(n *Node) *Sym {
|
||||||
func makeclosure(func_ *Node) *Node {
|
func makeclosure(func_ *Node) *Node {
|
||||||
// wrap body in external function
|
// wrap body in external function
|
||||||
// that begins by reading closure parameters.
|
// that begins by reading closure parameters.
|
||||||
xtype := Nod(OTFUNC, nil, nil)
|
xtype := nod(OTFUNC, nil, nil)
|
||||||
|
|
||||||
xtype.List.Set(func_.List.Slice())
|
xtype.List.Set(func_.List.Slice())
|
||||||
xtype.Rlist.Set(func_.Rlist.Slice())
|
xtype.Rlist.Set(func_.Rlist.Slice())
|
||||||
|
|
||||||
// create the function
|
// create the function
|
||||||
xfunc := Nod(ODCLFUNC, nil, nil)
|
xfunc := nod(ODCLFUNC, nil, nil)
|
||||||
|
|
||||||
xfunc.Func.Nname = newfuncname(closurename(func_))
|
xfunc.Func.Nname = newfuncname(closurename(func_))
|
||||||
xfunc.Func.Nname.Sym.Flags |= SymExported // disable export
|
xfunc.Func.Nname.Sym.Flags |= SymExported // disable export
|
||||||
|
|
@ -274,7 +274,7 @@ func capturevars(xfunc *Node) {
|
||||||
v.Name.Byval = true
|
v.Name.Byval = true
|
||||||
} else {
|
} else {
|
||||||
outermost.Addrtaken = true
|
outermost.Addrtaken = true
|
||||||
outer = Nod(OADDR, outer, nil)
|
outer = nod(OADDR, outer, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if Debug['m'] > 1 {
|
if Debug['m'] > 1 {
|
||||||
|
|
@ -378,7 +378,7 @@ func transformclosure(xfunc *Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// cv refers to the field inside of closure OSTRUCTLIT.
|
// cv refers to the field inside of closure OSTRUCTLIT.
|
||||||
cv := Nod(OCLOSUREVAR, nil, nil)
|
cv := nod(OCLOSUREVAR, nil, nil)
|
||||||
|
|
||||||
cv.Type = v.Type
|
cv.Type = v.Type
|
||||||
if !v.Name.Byval {
|
if !v.Name.Byval {
|
||||||
|
|
@ -393,21 +393,21 @@ func transformclosure(xfunc *Node) {
|
||||||
v.Class = PAUTO
|
v.Class = PAUTO
|
||||||
v.Ullman = 1
|
v.Ullman = 1
|
||||||
xfunc.Func.Dcl = append(xfunc.Func.Dcl, v)
|
xfunc.Func.Dcl = append(xfunc.Func.Dcl, v)
|
||||||
body = append(body, Nod(OAS, v, cv))
|
body = append(body, nod(OAS, v, cv))
|
||||||
} else {
|
} else {
|
||||||
// Declare variable holding addresses taken from closure
|
// Declare variable holding addresses taken from closure
|
||||||
// and initialize in entry prologue.
|
// and initialize in entry prologue.
|
||||||
addr := newname(lookupf("&%s", v.Sym.Name))
|
addr := newname(lookupf("&%s", v.Sym.Name))
|
||||||
addr.Name.Param.Ntype = Nod(OIND, typenod(v.Type), nil)
|
addr.Name.Param.Ntype = nod(OIND, typenod(v.Type), nil)
|
||||||
addr.Class = PAUTO
|
addr.Class = PAUTO
|
||||||
addr.Used = true
|
addr.Used = true
|
||||||
addr.Name.Curfn = xfunc
|
addr.Name.Curfn = xfunc
|
||||||
xfunc.Func.Dcl = append(xfunc.Func.Dcl, addr)
|
xfunc.Func.Dcl = append(xfunc.Func.Dcl, addr)
|
||||||
v.Name.Heapaddr = addr
|
v.Name.Heapaddr = addr
|
||||||
if v.Name.Byval {
|
if v.Name.Byval {
|
||||||
cv = Nod(OADDR, cv, nil)
|
cv = nod(OADDR, cv, nil)
|
||||||
}
|
}
|
||||||
body = append(body, Nod(OAS, addr, cv))
|
body = append(body, nod(OAS, addr, cv))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -474,27 +474,27 @@ func walkclosure(func_ *Node, init *Nodes) *Node {
|
||||||
// the struct is unnamed so that closures in multiple packages with the
|
// the struct is unnamed so that closures in multiple packages with the
|
||||||
// same struct type can share the descriptor.
|
// same struct type can share the descriptor.
|
||||||
|
|
||||||
typ := Nod(OTSTRUCT, nil, nil)
|
typ := nod(OTSTRUCT, nil, nil)
|
||||||
|
|
||||||
typ.List.Set1(Nod(ODCLFIELD, newname(lookup(".F")), typenod(Types[TUINTPTR])))
|
typ.List.Set1(nod(ODCLFIELD, newname(lookup(".F")), typenod(Types[TUINTPTR])))
|
||||||
for _, v := range func_.Func.Cvars.Slice() {
|
for _, v := range func_.Func.Cvars.Slice() {
|
||||||
if v.Op == OXXX {
|
if v.Op == OXXX {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
typ1 := typenod(v.Type)
|
typ1 := typenod(v.Type)
|
||||||
if !v.Name.Byval {
|
if !v.Name.Byval {
|
||||||
typ1 = Nod(OIND, typ1, nil)
|
typ1 = nod(OIND, typ1, nil)
|
||||||
}
|
}
|
||||||
typ.List.Append(Nod(ODCLFIELD, newname(v.Sym), typ1))
|
typ.List.Append(nod(ODCLFIELD, newname(v.Sym), typ1))
|
||||||
}
|
}
|
||||||
|
|
||||||
clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
|
clos := nod(OCOMPLIT, nil, nod(OIND, typ, nil))
|
||||||
clos.Esc = func_.Esc
|
clos.Esc = func_.Esc
|
||||||
clos.Right.Implicit = true
|
clos.Right.Implicit = true
|
||||||
clos.List.Set(append([]*Node{Nod(OCFUNC, func_.Func.Closure.Func.Nname, nil)}, func_.Func.Enter.Slice()...))
|
clos.List.Set(append([]*Node{nod(OCFUNC, func_.Func.Closure.Func.Nname, nil)}, func_.Func.Enter.Slice()...))
|
||||||
|
|
||||||
// Force type conversion from *struct to the func type.
|
// Force type conversion from *struct to the func type.
|
||||||
clos = Nod(OCONVNOP, clos, nil)
|
clos = nod(OCONVNOP, clos, nil)
|
||||||
|
|
||||||
clos.Type = func_.Type
|
clos.Type = func_.Type
|
||||||
|
|
||||||
|
|
@ -573,18 +573,18 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node {
|
||||||
savecurfn := Curfn
|
savecurfn := Curfn
|
||||||
Curfn = nil
|
Curfn = nil
|
||||||
|
|
||||||
xtype := Nod(OTFUNC, nil, nil)
|
xtype := nod(OTFUNC, nil, nil)
|
||||||
var l []*Node
|
var l []*Node
|
||||||
var callargs []*Node
|
var callargs []*Node
|
||||||
ddd := false
|
ddd := false
|
||||||
xfunc := Nod(ODCLFUNC, nil, nil)
|
xfunc := nod(ODCLFUNC, nil, nil)
|
||||||
Curfn = xfunc
|
Curfn = xfunc
|
||||||
for i, t := range t0.Params().Fields().Slice() {
|
for i, t := range t0.Params().Fields().Slice() {
|
||||||
n := newname(lookupN("a", i))
|
n := newname(lookupN("a", i))
|
||||||
n.Class = PPARAM
|
n.Class = PPARAM
|
||||||
xfunc.Func.Dcl = append(xfunc.Func.Dcl, n)
|
xfunc.Func.Dcl = append(xfunc.Func.Dcl, n)
|
||||||
callargs = append(callargs, n)
|
callargs = append(callargs, n)
|
||||||
fld := Nod(ODCLFIELD, n, typenod(t.Type))
|
fld := nod(ODCLFIELD, n, typenod(t.Type))
|
||||||
if t.Isddd {
|
if t.Isddd {
|
||||||
fld.Isddd = true
|
fld.Isddd = true
|
||||||
ddd = true
|
ddd = true
|
||||||
|
|
@ -601,7 +601,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node {
|
||||||
n.Class = PPARAMOUT
|
n.Class = PPARAMOUT
|
||||||
xfunc.Func.Dcl = append(xfunc.Func.Dcl, n)
|
xfunc.Func.Dcl = append(xfunc.Func.Dcl, n)
|
||||||
retargs = append(retargs, n)
|
retargs = append(retargs, n)
|
||||||
l = append(l, Nod(ODCLFIELD, n, typenod(t.Type)))
|
l = append(l, nod(ODCLFIELD, n, typenod(t.Type)))
|
||||||
}
|
}
|
||||||
|
|
||||||
xtype.Rlist.Set(l)
|
xtype.Rlist.Set(l)
|
||||||
|
|
@ -616,13 +616,13 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node {
|
||||||
// Declare and initialize variable holding receiver.
|
// Declare and initialize variable holding receiver.
|
||||||
|
|
||||||
xfunc.Func.Needctxt = true
|
xfunc.Func.Needctxt = true
|
||||||
cv := Nod(OCLOSUREVAR, nil, nil)
|
cv := nod(OCLOSUREVAR, nil, nil)
|
||||||
cv.Xoffset = int64(Widthptr)
|
cv.Xoffset = int64(Widthptr)
|
||||||
cv.Type = rcvrtype
|
cv.Type = rcvrtype
|
||||||
if int(cv.Type.Align) > Widthptr {
|
if int(cv.Type.Align) > Widthptr {
|
||||||
cv.Xoffset = int64(cv.Type.Align)
|
cv.Xoffset = int64(cv.Type.Align)
|
||||||
}
|
}
|
||||||
ptr := Nod(ONAME, nil, nil)
|
ptr := nod(ONAME, nil, nil)
|
||||||
ptr.Sym = lookup("rcvr")
|
ptr.Sym = lookup("rcvr")
|
||||||
ptr.Class = PAUTO
|
ptr.Class = PAUTO
|
||||||
ptr.Addable = true
|
ptr.Addable = true
|
||||||
|
|
@ -634,23 +634,23 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node {
|
||||||
var body []*Node
|
var body []*Node
|
||||||
if rcvrtype.IsPtr() || rcvrtype.IsInterface() {
|
if rcvrtype.IsPtr() || rcvrtype.IsInterface() {
|
||||||
ptr.Name.Param.Ntype = typenod(rcvrtype)
|
ptr.Name.Param.Ntype = typenod(rcvrtype)
|
||||||
body = append(body, Nod(OAS, ptr, cv))
|
body = append(body, nod(OAS, ptr, cv))
|
||||||
} else {
|
} else {
|
||||||
ptr.Name.Param.Ntype = typenod(ptrto(rcvrtype))
|
ptr.Name.Param.Ntype = typenod(ptrto(rcvrtype))
|
||||||
body = append(body, Nod(OAS, ptr, Nod(OADDR, cv, nil)))
|
body = append(body, nod(OAS, ptr, nod(OADDR, cv, nil)))
|
||||||
}
|
}
|
||||||
|
|
||||||
call := Nod(OCALL, nodSym(OXDOT, ptr, meth), nil)
|
call := nod(OCALL, nodSym(OXDOT, ptr, meth), nil)
|
||||||
call.List.Set(callargs)
|
call.List.Set(callargs)
|
||||||
call.Isddd = ddd
|
call.Isddd = ddd
|
||||||
if t0.Results().NumFields() == 0 {
|
if t0.Results().NumFields() == 0 {
|
||||||
body = append(body, call)
|
body = append(body, call)
|
||||||
} else {
|
} else {
|
||||||
n := Nod(OAS2, nil, nil)
|
n := nod(OAS2, nil, nil)
|
||||||
n.List.Set(retargs)
|
n.List.Set(retargs)
|
||||||
n.Rlist.Set1(call)
|
n.Rlist.Set1(call)
|
||||||
body = append(body, n)
|
body = append(body, n)
|
||||||
n = Nod(ORETURN, nil, nil)
|
n = nod(ORETURN, nil, nil)
|
||||||
body = append(body, n)
|
body = append(body, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -680,18 +680,18 @@ func walkpartialcall(n *Node, init *Nodes) *Node {
|
||||||
checknil(n.Left, init)
|
checknil(n.Left, init)
|
||||||
}
|
}
|
||||||
|
|
||||||
typ := Nod(OTSTRUCT, nil, nil)
|
typ := nod(OTSTRUCT, nil, nil)
|
||||||
typ.List.Set1(Nod(ODCLFIELD, newname(lookup("F")), typenod(Types[TUINTPTR])))
|
typ.List.Set1(nod(ODCLFIELD, newname(lookup("F")), typenod(Types[TUINTPTR])))
|
||||||
typ.List.Append(Nod(ODCLFIELD, newname(lookup("R")), typenod(n.Left.Type)))
|
typ.List.Append(nod(ODCLFIELD, newname(lookup("R")), typenod(n.Left.Type)))
|
||||||
|
|
||||||
clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
|
clos := nod(OCOMPLIT, nil, nod(OIND, typ, nil))
|
||||||
clos.Esc = n.Esc
|
clos.Esc = n.Esc
|
||||||
clos.Right.Implicit = true
|
clos.Right.Implicit = true
|
||||||
clos.List.Set1(Nod(OCFUNC, n.Func.Nname, nil))
|
clos.List.Set1(nod(OCFUNC, n.Func.Nname, nil))
|
||||||
clos.List.Append(n.Left)
|
clos.List.Append(n.Left)
|
||||||
|
|
||||||
// Force type conversion from *struct to the func type.
|
// Force type conversion from *struct to the func type.
|
||||||
clos = Nod(OCONVNOP, clos, nil)
|
clos = nod(OCONVNOP, clos, nil)
|
||||||
|
|
||||||
clos.Type = n.Type
|
clos.Type = n.Type
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -588,7 +588,7 @@ func Isconst(n *Node, ct Ctype) bool {
|
||||||
func saveorig(n *Node) *Node {
|
func saveorig(n *Node) *Node {
|
||||||
if n == n.Orig {
|
if n == n.Orig {
|
||||||
// duplicate node for n->orig.
|
// duplicate node for n->orig.
|
||||||
n1 := Nod(OLITERAL, nil, nil)
|
n1 := nod(OLITERAL, nil, nil)
|
||||||
|
|
||||||
n.Orig = n1
|
n.Orig = n1
|
||||||
*n1 = *n
|
*n1 = *n
|
||||||
|
|
@ -1227,7 +1227,7 @@ illegal:
|
||||||
}
|
}
|
||||||
|
|
||||||
func nodlit(v Val) *Node {
|
func nodlit(v Val) *Node {
|
||||||
n := Nod(OLITERAL, nil, nil)
|
n := nod(OLITERAL, nil, nil)
|
||||||
n.SetVal(v)
|
n.SetVal(v)
|
||||||
switch v.Ctype() {
|
switch v.Ctype() {
|
||||||
default:
|
default:
|
||||||
|
|
@ -1254,7 +1254,7 @@ func nodcplxlit(r Val, i Val) *Node {
|
||||||
i = toflt(i)
|
i = toflt(i)
|
||||||
|
|
||||||
c := new(Mpcplx)
|
c := new(Mpcplx)
|
||||||
n := Nod(OLITERAL, nil, nil)
|
n := nod(OLITERAL, nil, nil)
|
||||||
n.Type = Types[TIDEAL]
|
n.Type = Types[TIDEAL]
|
||||||
n.SetVal(Val{c})
|
n.SetVal(Val{c})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ func variter(vl []*Node, t *Node, el []*Node) []*Node {
|
||||||
|
|
||||||
if len(el) == 1 && len(vl) > 1 {
|
if len(el) == 1 && len(vl) > 1 {
|
||||||
e := el[0]
|
e := el[0]
|
||||||
as2 := Nod(OAS2, nil, nil)
|
as2 := nod(OAS2, nil, nil)
|
||||||
as2.List.Set(vl)
|
as2.List.Set(vl)
|
||||||
as2.Rlist.Set1(e)
|
as2.Rlist.Set1(e)
|
||||||
for _, v := range vl {
|
for _, v := range vl {
|
||||||
|
|
@ -244,7 +244,7 @@ func variter(vl []*Node, t *Node, el []*Node) []*Node {
|
||||||
v.Name.Param.Ntype = t
|
v.Name.Param.Ntype = t
|
||||||
v.Name.Defn = as2
|
v.Name.Defn = as2
|
||||||
if funcdepth > 0 {
|
if funcdepth > 0 {
|
||||||
init = append(init, Nod(ODCL, v, nil))
|
init = append(init, nod(ODCL, v, nil))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -268,9 +268,9 @@ func variter(vl []*Node, t *Node, el []*Node) []*Node {
|
||||||
|
|
||||||
if e != nil || funcdepth > 0 || isblank(v) {
|
if e != nil || funcdepth > 0 || isblank(v) {
|
||||||
if funcdepth > 0 {
|
if funcdepth > 0 {
|
||||||
init = append(init, Nod(ODCL, v, nil))
|
init = append(init, nod(ODCL, v, nil))
|
||||||
}
|
}
|
||||||
e = Nod(OAS, v, e)
|
e = nod(OAS, v, e)
|
||||||
init = append(init, e)
|
init = append(init, e)
|
||||||
if e.Right != nil {
|
if e.Right != nil {
|
||||||
v.Name.Defn = e
|
v.Name.Defn = e
|
||||||
|
|
@ -317,7 +317,7 @@ func constiter(vl []*Node, t *Node, cl []*Node) []*Node {
|
||||||
v.Name.Param.Ntype = t
|
v.Name.Param.Ntype = t
|
||||||
v.Name.Defn = c
|
v.Name.Defn = c
|
||||||
|
|
||||||
vv = append(vv, Nod(ODCLCONST, v, nil))
|
vv = append(vv, nod(ODCLCONST, v, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(clcopy) != 0 {
|
if len(clcopy) != 0 {
|
||||||
|
|
@ -333,7 +333,7 @@ func newname(s *Sym) *Node {
|
||||||
Fatalf("newname nil")
|
Fatalf("newname nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
n := Nod(ONAME, nil, nil)
|
n := nod(ONAME, nil, nil)
|
||||||
n.Sym = s
|
n.Sym = s
|
||||||
n.Type = nil
|
n.Type = nil
|
||||||
n.Addable = true
|
n.Addable = true
|
||||||
|
|
@ -363,13 +363,13 @@ func typenod(t *Type) *Node {
|
||||||
// if we copied another type with *t = *u
|
// if we copied another type with *t = *u
|
||||||
// then t->nod might be out of date, so
|
// then t->nod might be out of date, so
|
||||||
// check t->nod->type too
|
// check t->nod->type too
|
||||||
if t.Nod == nil || t.Nod.Type != t {
|
if t.nod == nil || t.nod.Type != t {
|
||||||
t.Nod = Nod(OTYPE, nil, nil)
|
t.nod = nod(OTYPE, nil, nil)
|
||||||
t.Nod.Type = t
|
t.nod.Type = t
|
||||||
t.Nod.Sym = t.Sym
|
t.nod.Sym = t.Sym
|
||||||
}
|
}
|
||||||
|
|
||||||
return t.Nod
|
return t.nod
|
||||||
}
|
}
|
||||||
|
|
||||||
// oldname returns the Node that declares symbol s in the current scope.
|
// oldname returns the Node that declares symbol s in the current scope.
|
||||||
|
|
@ -396,7 +396,7 @@ func oldname(s *Sym) *Node {
|
||||||
c := n.Name.Param.Innermost
|
c := n.Name.Param.Innermost
|
||||||
if c == nil || c.Name.Funcdepth != funcdepth {
|
if c == nil || c.Name.Funcdepth != funcdepth {
|
||||||
// Do not have a closure var for the active closure yet; make one.
|
// Do not have a closure var for the active closure yet; make one.
|
||||||
c = Nod(ONAME, nil, nil)
|
c = nod(ONAME, nil, nil)
|
||||||
c.Sym = s
|
c.Sym = s
|
||||||
c.Class = PAUTOHEAP
|
c.Class = PAUTOHEAP
|
||||||
c.setIsClosureVar(true)
|
c.setIsClosureVar(true)
|
||||||
|
|
@ -470,7 +470,7 @@ func colasdefn(left []*Node, defn *Node) {
|
||||||
n = newname(n.Sym)
|
n = newname(n.Sym)
|
||||||
declare(n, dclcontext)
|
declare(n, dclcontext)
|
||||||
n.Name.Defn = defn
|
n.Name.Defn = defn
|
||||||
defn.Ninit.Append(Nod(ODCL, n, nil))
|
defn.Ninit.Append(nod(ODCL, n, nil))
|
||||||
left[i] = n
|
left[i] = n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -480,7 +480,7 @@ func colasdefn(left []*Node, defn *Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func colas(left, right []*Node, lno int32) *Node {
|
func colas(left, right []*Node, lno int32) *Node {
|
||||||
n := Nod(OAS, nil, nil) // assume common case
|
n := nod(OAS, nil, nil) // assume common case
|
||||||
n.Colas = true
|
n.Colas = true
|
||||||
n.Lineno = lno // set before calling colasdefn for correct error line
|
n.Lineno = lno // set before calling colasdefn for correct error line
|
||||||
colasdefn(left, n) // modifies left, call before using left[0] in common case
|
colasdefn(left, n) // modifies left, call before using left[0] in common case
|
||||||
|
|
@ -713,7 +713,7 @@ func typedcl0(s *Sym) *Node {
|
||||||
func typedcl1(n *Node, t *Node, local bool) *Node {
|
func typedcl1(n *Node, t *Node, local bool) *Node {
|
||||||
n.Name.Param.Ntype = t
|
n.Name.Param.Ntype = t
|
||||||
n.Local = local
|
n.Local = local
|
||||||
return Nod(ODCLTYPE, n, nil)
|
return nod(ODCLTYPE, n, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// structs, functions, and methods.
|
// structs, functions, and methods.
|
||||||
|
|
@ -991,13 +991,13 @@ func embedded(s *Sym, pkg *Pkg) *Node {
|
||||||
} else {
|
} else {
|
||||||
n = newname(Pkglookup(name, s.Pkg))
|
n = newname(Pkglookup(name, s.Pkg))
|
||||||
}
|
}
|
||||||
n = Nod(ODCLFIELD, n, oldname(s))
|
n = nod(ODCLFIELD, n, oldname(s))
|
||||||
n.Embedded = 1
|
n.Embedded = 1
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func fakethis() *Node {
|
func fakethis() *Node {
|
||||||
n := Nod(ODCLFIELD, nil, typenod(ptrto(typ(TSTRUCT))))
|
n := nod(ODCLFIELD, nil, typenod(ptrto(typ(TSTRUCT))))
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1215,7 +1215,7 @@ func addmethod(msym *Sym, t *Type, local, nointerface bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n := Nod(ODCLFIELD, newname(msym), nil)
|
n := nod(ODCLFIELD, newname(msym), nil)
|
||||||
n.Type = t
|
n.Type = t
|
||||||
|
|
||||||
for _, f := range mt.Methods().Slice() {
|
for _, f := range mt.Methods().Slice() {
|
||||||
|
|
|
||||||
|
|
@ -910,7 +910,7 @@ func esc(e *EscState, n *Node, up *Node) {
|
||||||
}
|
}
|
||||||
a := v.Name.Defn
|
a := v.Name.Defn
|
||||||
if !v.Name.Byval {
|
if !v.Name.Byval {
|
||||||
a = Nod(OADDR, a, nil)
|
a = nod(OADDR, a, nil)
|
||||||
a.Lineno = v.Lineno
|
a.Lineno = v.Lineno
|
||||||
e.nodeEscState(a).Escloopdepth = e.loopdepth
|
e.nodeEscState(a).Escloopdepth = e.loopdepth
|
||||||
a = typecheck(a, Erv)
|
a = typecheck(a, Erv)
|
||||||
|
|
@ -1094,7 +1094,7 @@ func escassign(e *EscState, dst, src *Node, step *EscStep) {
|
||||||
case OCLOSURE:
|
case OCLOSURE:
|
||||||
// OCLOSURE is lowered to OPTRLIT,
|
// OCLOSURE is lowered to OPTRLIT,
|
||||||
// insert OADDR to account for the additional indirection.
|
// insert OADDR to account for the additional indirection.
|
||||||
a := Nod(OADDR, src, nil)
|
a := nod(OADDR, src, nil)
|
||||||
a.Lineno = src.Lineno
|
a.Lineno = src.Lineno
|
||||||
e.nodeEscState(a).Escloopdepth = e.nodeEscState(src).Escloopdepth
|
e.nodeEscState(a).Escloopdepth = e.nodeEscState(src).Escloopdepth
|
||||||
a.Type = ptrto(src.Type)
|
a.Type = ptrto(src.Type)
|
||||||
|
|
@ -1336,7 +1336,7 @@ func escassignDereference(e *EscState, dst *Node, src *Node, step *EscStep) {
|
||||||
// Because this is for purposes of escape accounting, not execution,
|
// Because this is for purposes of escape accounting, not execution,
|
||||||
// some semantically dubious node combinations are (currently) possible.
|
// some semantically dubious node combinations are (currently) possible.
|
||||||
func (e *EscState) addDereference(n *Node) *Node {
|
func (e *EscState) addDereference(n *Node) *Node {
|
||||||
ind := Nod(OIND, n, nil)
|
ind := nod(OIND, n, nil)
|
||||||
e.nodeEscState(ind).Escloopdepth = e.nodeEscState(n).Escloopdepth
|
e.nodeEscState(ind).Escloopdepth = e.nodeEscState(n).Escloopdepth
|
||||||
ind.Lineno = n.Lineno
|
ind.Lineno = n.Lineno
|
||||||
t := n.Type
|
t := n.Type
|
||||||
|
|
@ -1389,7 +1389,7 @@ func initEscretval(e *EscState, n *Node, fntype *Type) {
|
||||||
nE := e.nodeEscState(n)
|
nE := e.nodeEscState(n)
|
||||||
nE.Escretval.Set(nil) // Suspect this is not nil for indirect calls.
|
nE.Escretval.Set(nil) // Suspect this is not nil for indirect calls.
|
||||||
for _, t := range fntype.Results().Fields().Slice() {
|
for _, t := range fntype.Results().Fields().Slice() {
|
||||||
src := Nod(ONAME, nil, nil)
|
src := nod(ONAME, nil, nil)
|
||||||
buf := fmt.Sprintf(".out%d", i)
|
buf := fmt.Sprintf(".out%d", i)
|
||||||
i++
|
i++
|
||||||
src.Sym = lookup(buf)
|
src.Sym = lookup(buf)
|
||||||
|
|
@ -1500,7 +1500,7 @@ func esccall(e *EscState, n *Node, up *Node) {
|
||||||
src = lls[0]
|
src = lls[0]
|
||||||
if n2.Isddd && !n.Isddd {
|
if n2.Isddd && !n.Isddd {
|
||||||
// Introduce ODDDARG node to represent ... allocation.
|
// Introduce ODDDARG node to represent ... allocation.
|
||||||
src = Nod(ODDDARG, nil, nil)
|
src = nod(ODDDARG, nil, nil)
|
||||||
arr := typArray(n2.Type.Elem(), int64(len(lls)))
|
arr := typArray(n2.Type.Elem(), int64(len(lls)))
|
||||||
src.Type = ptrto(arr) // make pointer so it will be tracked
|
src.Type = ptrto(arr) // make pointer so it will be tracked
|
||||||
src.Lineno = n.Lineno
|
src.Lineno = n.Lineno
|
||||||
|
|
@ -1563,7 +1563,7 @@ func esccall(e *EscState, n *Node, up *Node) {
|
||||||
note = t.Note
|
note = t.Note
|
||||||
if t.Isddd && !n.Isddd {
|
if t.Isddd && !n.Isddd {
|
||||||
// Introduce ODDDARG node to represent ... allocation.
|
// Introduce ODDDARG node to represent ... allocation.
|
||||||
src = Nod(ODDDARG, nil, nil)
|
src = nod(ODDDARG, nil, nil)
|
||||||
src.Lineno = n.Lineno
|
src.Lineno = n.Lineno
|
||||||
arr := typArray(t.Type.Elem(), int64(len(lls)-i))
|
arr := typArray(t.Type.Elem(), int64(len(lls)-i))
|
||||||
src.Type = ptrto(arr) // make pointer so it will be tracked
|
src.Type = ptrto(arr) // make pointer so it will be tracked
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ func moveToHeap(n *Node) {
|
||||||
// Preserve a copy so we can still write code referring to the original,
|
// Preserve a copy so we can still write code referring to the original,
|
||||||
// and substitute that copy into the function declaration list
|
// and substitute that copy into the function declaration list
|
||||||
// so that analyses of the local (on-stack) variables use it.
|
// so that analyses of the local (on-stack) variables use it.
|
||||||
stackcopy := Nod(ONAME, nil, nil)
|
stackcopy := nod(ONAME, nil, nil)
|
||||||
stackcopy.Sym = n.Sym
|
stackcopy.Sym = n.Sym
|
||||||
stackcopy.Type = n.Type
|
stackcopy.Type = n.Type
|
||||||
stackcopy.Xoffset = n.Xoffset
|
stackcopy.Xoffset = n.Xoffset
|
||||||
|
|
@ -208,7 +208,7 @@ func tempname(nn *Node, t *Type) {
|
||||||
// a chance to registerizer them
|
// a chance to registerizer them
|
||||||
s := lookupN("autotmp_", statuniqgen)
|
s := lookupN("autotmp_", statuniqgen)
|
||||||
statuniqgen++
|
statuniqgen++
|
||||||
n := Nod(ONAME, nil, nil)
|
n := nod(ONAME, nil, nil)
|
||||||
n.Sym = s
|
n.Sym = s
|
||||||
s.Def = n
|
s.Def = n
|
||||||
n.Type = t
|
n.Type = t
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ func nodarg(t interface{}, fp int) *Node {
|
||||||
funarg = t.StructType().Funarg
|
funarg = t.StructType().Funarg
|
||||||
|
|
||||||
// Build fake variable name for whole arg struct.
|
// Build fake variable name for whole arg struct.
|
||||||
n = Nod(ONAME, nil, nil)
|
n = nod(ONAME, nil, nil)
|
||||||
n.Sym = lookup(".args")
|
n.Sym = lookup(".args")
|
||||||
n.Type = t
|
n.Type = t
|
||||||
first := t.Field(0)
|
first := t.Field(0)
|
||||||
|
|
@ -536,7 +536,7 @@ func nodarg(t interface{}, fp int) *Node {
|
||||||
// Build fake name for individual variable.
|
// Build fake name for individual variable.
|
||||||
// This is safe because if there was a real declared name
|
// This is safe because if there was a real declared name
|
||||||
// we'd have used it above.
|
// we'd have used it above.
|
||||||
n = Nod(ONAME, nil, nil)
|
n = nod(ONAME, nil, nil)
|
||||||
n.Type = t.Type
|
n.Type = t.Type
|
||||||
n.Sym = t.Sym
|
n.Sym = t.Sym
|
||||||
if t.Offset == BADWIDTH {
|
if t.Offset == BADWIDTH {
|
||||||
|
|
|
||||||
|
|
@ -107,34 +107,34 @@ func fninit(n []*Node) {
|
||||||
// (2)
|
// (2)
|
||||||
Maxarg = 0
|
Maxarg = 0
|
||||||
|
|
||||||
fn := Nod(ODCLFUNC, nil, nil)
|
fn := nod(ODCLFUNC, nil, nil)
|
||||||
initsym := lookup("init")
|
initsym := lookup("init")
|
||||||
fn.Func.Nname = newname(initsym)
|
fn.Func.Nname = newname(initsym)
|
||||||
fn.Func.Nname.Name.Defn = fn
|
fn.Func.Nname.Name.Defn = fn
|
||||||
fn.Func.Nname.Name.Param.Ntype = Nod(OTFUNC, nil, nil)
|
fn.Func.Nname.Name.Param.Ntype = nod(OTFUNC, nil, nil)
|
||||||
declare(fn.Func.Nname, PFUNC)
|
declare(fn.Func.Nname, PFUNC)
|
||||||
funchdr(fn)
|
funchdr(fn)
|
||||||
|
|
||||||
// (3)
|
// (3)
|
||||||
a := Nod(OIF, nil, nil)
|
a := nod(OIF, nil, nil)
|
||||||
a.Left = Nod(OGT, gatevar, nodintconst(1))
|
a.Left = nod(OGT, gatevar, nodintconst(1))
|
||||||
a.Likely = 1
|
a.Likely = 1
|
||||||
r = append(r, a)
|
r = append(r, a)
|
||||||
// (3a)
|
// (3a)
|
||||||
a.Nbody.Set1(Nod(ORETURN, nil, nil))
|
a.Nbody.Set1(nod(ORETURN, nil, nil))
|
||||||
|
|
||||||
// (4)
|
// (4)
|
||||||
b := Nod(OIF, nil, nil)
|
b := nod(OIF, nil, nil)
|
||||||
b.Left = Nod(OEQ, gatevar, nodintconst(1))
|
b.Left = nod(OEQ, gatevar, nodintconst(1))
|
||||||
// this actually isn't likely, but code layout is better
|
// this actually isn't likely, but code layout is better
|
||||||
// like this: no JMP needed after the call.
|
// like this: no JMP needed after the call.
|
||||||
b.Likely = 1
|
b.Likely = 1
|
||||||
r = append(r, b)
|
r = append(r, b)
|
||||||
// (4a)
|
// (4a)
|
||||||
b.Nbody.Set1(Nod(OCALL, syslook("throwinit"), nil))
|
b.Nbody.Set1(nod(OCALL, syslook("throwinit"), nil))
|
||||||
|
|
||||||
// (5)
|
// (5)
|
||||||
a = Nod(OAS, gatevar, nodintconst(1))
|
a = nod(OAS, gatevar, nodintconst(1))
|
||||||
|
|
||||||
r = append(r, a)
|
r = append(r, a)
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ func fninit(n []*Node) {
|
||||||
for _, s := range initSyms {
|
for _, s := range initSyms {
|
||||||
if s.Def != nil && s != initsym {
|
if s.Def != nil && s != initsym {
|
||||||
// could check that it is fn of no args/returns
|
// could check that it is fn of no args/returns
|
||||||
a = Nod(OCALL, s.Def, nil)
|
a = nod(OCALL, s.Def, nil)
|
||||||
r = append(r, a)
|
r = append(r, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -157,17 +157,17 @@ func fninit(n []*Node) {
|
||||||
if s.Def == nil {
|
if s.Def == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
a = Nod(OCALL, s.Def, nil)
|
a = nod(OCALL, s.Def, nil)
|
||||||
r = append(r, a)
|
r = append(r, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
// (9)
|
// (9)
|
||||||
a = Nod(OAS, gatevar, nodintconst(2))
|
a = nod(OAS, gatevar, nodintconst(2))
|
||||||
|
|
||||||
r = append(r, a)
|
r = append(r, a)
|
||||||
|
|
||||||
// (10)
|
// (10)
|
||||||
a = Nod(ORETURN, nil, nil)
|
a = nod(ORETURN, nil, nil)
|
||||||
|
|
||||||
r = append(r, a)
|
r = append(r, a)
|
||||||
exportsym(fn.Func.Nname)
|
exportsym(fn.Func.Nname)
|
||||||
|
|
|
||||||
|
|
@ -592,7 +592,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
|
||||||
if ln.Op == ONAME {
|
if ln.Op == ONAME {
|
||||||
ln.Name.Inlvar = typecheck(inlvar(ln), Erv)
|
ln.Name.Inlvar = typecheck(inlvar(ln), Erv)
|
||||||
if ln.Class == PPARAM || ln.Name.Param.Stackcopy != nil && ln.Name.Param.Stackcopy.Class == PPARAM {
|
if ln.Class == PPARAM || ln.Name.Param.Stackcopy != nil && ln.Name.Param.Stackcopy.Class == PPARAM {
|
||||||
ninit.Append(Nod(ODCL, ln.Name.Inlvar, nil))
|
ninit.Append(nod(ODCL, ln.Name.Inlvar, nil))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -610,7 +610,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
ninit.Append(Nod(ODCL, m, nil))
|
ninit.Append(nod(ODCL, m, nil))
|
||||||
retvars = append(retvars, m)
|
retvars = append(retvars, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -628,7 +628,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
Fatalf("method call unknown receiver type: %+v", n)
|
Fatalf("method call unknown receiver type: %+v", n)
|
||||||
}
|
}
|
||||||
as := Nod(OAS, tinlvar(t), n.Left.Left)
|
as := nod(OAS, tinlvar(t), n.Left.Left)
|
||||||
if as != nil {
|
if as != nil {
|
||||||
as = typecheck(as, Etop)
|
as = typecheck(as, Etop)
|
||||||
ninit.Append(as)
|
ninit.Append(as)
|
||||||
|
|
@ -673,7 +673,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign arguments to the parameters' temp names
|
// assign arguments to the parameters' temp names
|
||||||
as := Nod(OAS2, nil, nil)
|
as := nod(OAS2, nil, nil)
|
||||||
|
|
||||||
as.Rlist.Set(n.List.Slice())
|
as.Rlist.Set(n.List.Slice())
|
||||||
li := 0
|
li := 0
|
||||||
|
|
@ -763,15 +763,15 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
|
||||||
|
|
||||||
// turn the variadic args into a slice.
|
// turn the variadic args into a slice.
|
||||||
if variadic {
|
if variadic {
|
||||||
as = Nod(OAS, vararg, nil)
|
as = nod(OAS, vararg, nil)
|
||||||
if varargcount == 0 {
|
if varargcount == 0 {
|
||||||
as.Right = nodnil()
|
as.Right = nodnil()
|
||||||
as.Right.Type = varargtype
|
as.Right.Type = varargtype
|
||||||
} else {
|
} else {
|
||||||
vararrtype := typArray(varargtype.Elem(), int64(varargcount))
|
vararrtype := typArray(varargtype.Elem(), int64(varargcount))
|
||||||
as.Right = Nod(OCOMPLIT, nil, typenod(vararrtype))
|
as.Right = nod(OCOMPLIT, nil, typenod(vararrtype))
|
||||||
as.Right.List.Set(varargs)
|
as.Right.List.Set(varargs)
|
||||||
as.Right = Nod(OSLICE, as.Right, nil)
|
as.Right = nod(OSLICE, as.Right, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
as = typecheck(as, Etop)
|
as = typecheck(as, Etop)
|
||||||
|
|
@ -780,7 +780,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
|
||||||
|
|
||||||
// zero the outparams
|
// zero the outparams
|
||||||
for _, n := range retvars {
|
for _, n := range retvars {
|
||||||
as = Nod(OAS, n, nil)
|
as = nod(OAS, n, nil)
|
||||||
as = typecheck(as, Etop)
|
as = typecheck(as, Etop)
|
||||||
ninit.Append(as)
|
ninit.Append(as)
|
||||||
}
|
}
|
||||||
|
|
@ -797,7 +797,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
|
||||||
|
|
||||||
body := subst.list(fn.Func.Inl)
|
body := subst.list(fn.Func.Inl)
|
||||||
|
|
||||||
lab := Nod(OLABEL, retlabel, nil)
|
lab := nod(OLABEL, retlabel, nil)
|
||||||
lab.Used = true // avoid 'not used' when function doesn't have return
|
lab.Used = true // avoid 'not used' when function doesn't have return
|
||||||
body = append(body, lab)
|
body = append(body, lab)
|
||||||
|
|
||||||
|
|
@ -805,7 +805,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
|
||||||
|
|
||||||
//dumplist("ninit post", ninit);
|
//dumplist("ninit post", ninit);
|
||||||
|
|
||||||
call := Nod(OINLCALL, nil, nil)
|
call := nod(OINLCALL, nil, nil)
|
||||||
|
|
||||||
call.Ninit.Set(ninit.Slice())
|
call.Ninit.Set(ninit.Slice())
|
||||||
call.Nbody.Set(body)
|
call.Nbody.Set(body)
|
||||||
|
|
@ -940,12 +940,12 @@ func (subst *inlsubst) node(n *Node) *Node {
|
||||||
|
|
||||||
// dump("Return before substitution", n);
|
// dump("Return before substitution", n);
|
||||||
case ORETURN:
|
case ORETURN:
|
||||||
m := Nod(OGOTO, subst.retlabel, nil)
|
m := nod(OGOTO, subst.retlabel, nil)
|
||||||
|
|
||||||
m.Ninit.Set(subst.list(n.Ninit))
|
m.Ninit.Set(subst.list(n.Ninit))
|
||||||
|
|
||||||
if len(subst.retvars) != 0 && n.List.Len() != 0 {
|
if len(subst.retvars) != 0 && n.List.Len() != 0 {
|
||||||
as := Nod(OAS2, nil, nil)
|
as := nod(OAS2, nil, nil)
|
||||||
|
|
||||||
// Make a shallow copy of retvars.
|
// Make a shallow copy of retvars.
|
||||||
// Otherwise OINLCALL.Rlist will be the same list,
|
// Otherwise OINLCALL.Rlist will be the same list,
|
||||||
|
|
@ -965,7 +965,7 @@ func (subst *inlsubst) node(n *Node) *Node {
|
||||||
return m
|
return m
|
||||||
|
|
||||||
case OGOTO, OLABEL:
|
case OGOTO, OLABEL:
|
||||||
m := Nod(OXXX, nil, nil)
|
m := nod(OXXX, nil, nil)
|
||||||
*m = *n
|
*m = *n
|
||||||
m.Ninit.Set(nil)
|
m.Ninit.Set(nil)
|
||||||
p := fmt.Sprintf("%s·%d", n.Left.Sym.Name, inlgen)
|
p := fmt.Sprintf("%s·%d", n.Left.Sym.Name, inlgen)
|
||||||
|
|
@ -973,7 +973,7 @@ func (subst *inlsubst) node(n *Node) *Node {
|
||||||
|
|
||||||
return m
|
return m
|
||||||
default:
|
default:
|
||||||
m := Nod(OXXX, nil, nil)
|
m := nod(OXXX, nil, nil)
|
||||||
*m = *n
|
*m = *n
|
||||||
m.Ninit.Set(nil)
|
m.Ninit.Set(nil)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -405,7 +405,7 @@ func (p *noder) expr(expr syntax.Expr) *Node {
|
||||||
// Special case for &T{...}: turn into (*T){...}.
|
// Special case for &T{...}: turn into (*T){...}.
|
||||||
// TODO(mdempsky): Switch back to p.nod after we
|
// TODO(mdempsky): Switch back to p.nod after we
|
||||||
// get rid of gcCompat.
|
// get rid of gcCompat.
|
||||||
x.Right = Nod(OIND, x.Right, nil)
|
x.Right = nod(OIND, x.Right, nil)
|
||||||
x.Right.Implicit = true
|
x.Right.Implicit = true
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
@ -687,7 +687,7 @@ func (p *noder) body(body []syntax.Stmt) *Node {
|
||||||
l := p.bodyList(body)
|
l := p.bodyList(body)
|
||||||
if len(l) == 0 {
|
if len(l) == 0 {
|
||||||
// TODO(mdempsky): Line number?
|
// TODO(mdempsky): Line number?
|
||||||
return Nod(OEMPTY, nil, nil)
|
return nod(OEMPTY, nil, nil)
|
||||||
}
|
}
|
||||||
return liststmt(l)
|
return liststmt(l)
|
||||||
}
|
}
|
||||||
|
|
@ -973,7 +973,7 @@ func (p *noder) wrapname(n syntax.Node, x *Node) *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *noder) nod(orig syntax.Node, op Op, left, right *Node) *Node {
|
func (p *noder) nod(orig syntax.Node, op Op, left, right *Node) *Node {
|
||||||
return p.setlineno(orig, Nod(op, left, right))
|
return p.setlineno(orig, nod(op, left, right))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *noder) setlineno(src syntax.Node, dst *Node) *Node {
|
func (p *noder) setlineno(src syntax.Node, dst *Node) *Node {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ func order(fn *Node) {
|
||||||
func ordertemp(t *Type, order *Order, clear bool) *Node {
|
func ordertemp(t *Type, order *Order, clear bool) *Node {
|
||||||
var_ := temp(t)
|
var_ := temp(t)
|
||||||
if clear {
|
if clear {
|
||||||
a := Nod(OAS, var_, nil)
|
a := nod(OAS, var_, nil)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
order.out = append(order.out, a)
|
order.out = append(order.out, a)
|
||||||
}
|
}
|
||||||
|
|
@ -85,7 +85,7 @@ func ordertemp(t *Type, order *Order, clear bool) *Node {
|
||||||
// to be filled in.)
|
// to be filled in.)
|
||||||
func ordercopyexpr(n *Node, t *Type, order *Order, clear int) *Node {
|
func ordercopyexpr(n *Node, t *Type, order *Order, clear int) *Node {
|
||||||
var_ := ordertemp(t, order, clear != 0)
|
var_ := ordertemp(t, order, clear != 0)
|
||||||
a := Nod(OAS, var_, n)
|
a := nod(OAS, var_, n)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
order.out = append(order.out, a)
|
order.out = append(order.out, a)
|
||||||
return var_
|
return var_
|
||||||
|
|
@ -222,11 +222,11 @@ func cleantempnopop(mark ordermarker, order *Order, out *[]*Node) {
|
||||||
if n.Name.Keepalive {
|
if n.Name.Keepalive {
|
||||||
n.Name.Keepalive = false
|
n.Name.Keepalive = false
|
||||||
n.Addrtaken = true // ensure SSA keeps the n variable
|
n.Addrtaken = true // ensure SSA keeps the n variable
|
||||||
kill = Nod(OVARLIVE, n, nil)
|
kill = nod(OVARLIVE, n, nil)
|
||||||
kill = typecheck(kill, Etop)
|
kill = typecheck(kill, Etop)
|
||||||
*out = append(*out, kill)
|
*out = append(*out, kill)
|
||||||
}
|
}
|
||||||
kill = Nod(OVARKILL, n, nil)
|
kill = nod(OVARKILL, n, nil)
|
||||||
kill = typecheck(kill, Etop)
|
kill = typecheck(kill, Etop)
|
||||||
*out = append(*out, kill)
|
*out = append(*out, kill)
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +336,7 @@ func copyret(n *Node, order *Order) []*Node {
|
||||||
l2 = append(l2, tmp)
|
l2 = append(l2, tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
as := Nod(OAS2, nil, nil)
|
as := nod(OAS2, nil, nil)
|
||||||
as.List.Set(l1)
|
as.List.Set(l1)
|
||||||
as.Rlist.Set1(n)
|
as.Rlist.Set1(n)
|
||||||
as = typecheck(as, Etop)
|
as = typecheck(as, Etop)
|
||||||
|
|
@ -431,7 +431,7 @@ func ordermapassign(n *Node, order *Order) {
|
||||||
if (n.Left.Op == OINDEXMAP || (needwritebarrier(n.Left, n.Right) && n.Left.Type.Width > int64(4*Widthptr))) && !isaddrokay(n.Right) {
|
if (n.Left.Op == OINDEXMAP || (needwritebarrier(n.Left, n.Right) && n.Left.Type.Width > int64(4*Widthptr))) && !isaddrokay(n.Right) {
|
||||||
m := n.Left
|
m := n.Left
|
||||||
n.Left = ordertemp(m.Type, order, false)
|
n.Left = ordertemp(m.Type, order, false)
|
||||||
a := Nod(OAS, m, n.Left)
|
a := nod(OAS, m, n.Left)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
order.out = append(order.out, a)
|
order.out = append(order.out, a)
|
||||||
}
|
}
|
||||||
|
|
@ -450,14 +450,14 @@ func ordermapassign(n *Node, order *Order) {
|
||||||
m.Right = ordercopyexpr(m.Right, m.Right.Type, order, 0)
|
m.Right = ordercopyexpr(m.Right, m.Right.Type, order, 0)
|
||||||
}
|
}
|
||||||
n.List.SetIndex(i1, ordertemp(m.Type, order, false))
|
n.List.SetIndex(i1, ordertemp(m.Type, order, false))
|
||||||
a = Nod(OAS, m, n.List.Index(i1))
|
a = nod(OAS, m, n.List.Index(i1))
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
post = append(post, a)
|
post = append(post, a)
|
||||||
} else if instrumenting && n.Op == OAS2FUNC && !isblank(n.List.Index(i1)) {
|
} else if instrumenting && n.Op == OAS2FUNC && !isblank(n.List.Index(i1)) {
|
||||||
m = n.List.Index(i1)
|
m = n.List.Index(i1)
|
||||||
t := ordertemp(m.Type, order, false)
|
t := ordertemp(m.Type, order, false)
|
||||||
n.List.SetIndex(i1, t)
|
n.List.SetIndex(i1, t)
|
||||||
a = Nod(OAS, m, t)
|
a = nod(OAS, m, t)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
post = append(post, a)
|
post = append(post, a)
|
||||||
}
|
}
|
||||||
|
|
@ -530,7 +530,7 @@ func orderstmt(n *Node, order *Order) {
|
||||||
}
|
}
|
||||||
tmp1 = ordercopyexpr(tmp1, n.Left.Type, order, 0)
|
tmp1 = ordercopyexpr(tmp1, n.Left.Type, order, 0)
|
||||||
// TODO(marvin): Fix Node.EType type union.
|
// TODO(marvin): Fix Node.EType type union.
|
||||||
n.Right = Nod(Op(n.Etype), tmp1, n.Right)
|
n.Right = nod(Op(n.Etype), tmp1, n.Right)
|
||||||
n.Right = typecheck(n.Right, Erv)
|
n.Right = typecheck(n.Right, Erv)
|
||||||
n.Right = orderexpr(n.Right, order, nil)
|
n.Right = orderexpr(n.Right, order, nil)
|
||||||
n.Etype = 0
|
n.Etype = 0
|
||||||
|
|
@ -586,7 +586,7 @@ func orderstmt(n *Node, order *Order) {
|
||||||
order.out = append(order.out, n)
|
order.out = append(order.out, n)
|
||||||
|
|
||||||
if tmp1 != nil {
|
if tmp1 != nil {
|
||||||
r := Nod(OAS, n.List.First(), tmp1)
|
r := nod(OAS, n.List.First(), tmp1)
|
||||||
r = typecheck(r, Etop)
|
r = typecheck(r, Etop)
|
||||||
ordermapassign(r, order)
|
ordermapassign(r, order)
|
||||||
n.List.SetIndex(0, tmp1)
|
n.List.SetIndex(0, tmp1)
|
||||||
|
|
@ -611,7 +611,7 @@ func orderstmt(n *Node, order *Order) {
|
||||||
tmp1 := ordertemp(ch.Elem(), order, haspointers(ch.Elem()))
|
tmp1 := ordertemp(ch.Elem(), order, haspointers(ch.Elem()))
|
||||||
tmp2 := ordertemp(Types[TBOOL], order, false)
|
tmp2 := ordertemp(Types[TBOOL], order, false)
|
||||||
order.out = append(order.out, n)
|
order.out = append(order.out, n)
|
||||||
r := Nod(OAS, n.List.First(), tmp1)
|
r := nod(OAS, n.List.First(), tmp1)
|
||||||
r = typecheck(r, Etop)
|
r = typecheck(r, Etop)
|
||||||
ordermapassign(r, order)
|
ordermapassign(r, order)
|
||||||
r = okas(n.List.Second(), tmp2)
|
r = okas(n.List.Second(), tmp2)
|
||||||
|
|
@ -757,7 +757,7 @@ func orderstmt(n *Node, order *Order) {
|
||||||
r := n.Right
|
r := n.Right
|
||||||
|
|
||||||
if r.Type.IsString() && r.Type != Types[TSTRING] {
|
if r.Type.IsString() && r.Type != Types[TSTRING] {
|
||||||
r = Nod(OCONV, r, nil)
|
r = nod(OCONV, r, nil)
|
||||||
r.Type = Types[TSTRING]
|
r.Type = Types[TSTRING]
|
||||||
r = typecheck(r, Erv)
|
r = typecheck(r, Erv)
|
||||||
}
|
}
|
||||||
|
|
@ -868,13 +868,13 @@ func orderstmt(n *Node, order *Order) {
|
||||||
tmp1 = r.Left
|
tmp1 = r.Left
|
||||||
|
|
||||||
if r.Colas {
|
if r.Colas {
|
||||||
tmp2 = Nod(ODCL, tmp1, nil)
|
tmp2 = nod(ODCL, tmp1, nil)
|
||||||
tmp2 = typecheck(tmp2, Etop)
|
tmp2 = typecheck(tmp2, Etop)
|
||||||
n2.Ninit.Append(tmp2)
|
n2.Ninit.Append(tmp2)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Left = ordertemp(r.Right.Left.Type.Elem(), order, haspointers(r.Right.Left.Type.Elem()))
|
r.Left = ordertemp(r.Right.Left.Type.Elem(), order, haspointers(r.Right.Left.Type.Elem()))
|
||||||
tmp2 = Nod(OAS, tmp1, r.Left)
|
tmp2 = nod(OAS, tmp1, r.Left)
|
||||||
tmp2 = typecheck(tmp2, Etop)
|
tmp2 = typecheck(tmp2, Etop)
|
||||||
n2.Ninit.Append(tmp2)
|
n2.Ninit.Append(tmp2)
|
||||||
}
|
}
|
||||||
|
|
@ -885,7 +885,7 @@ func orderstmt(n *Node, order *Order) {
|
||||||
if r.List.Len() != 0 {
|
if r.List.Len() != 0 {
|
||||||
tmp1 = r.List.First()
|
tmp1 = r.List.First()
|
||||||
if r.Colas {
|
if r.Colas {
|
||||||
tmp2 = Nod(ODCL, tmp1, nil)
|
tmp2 = nod(ODCL, tmp1, nil)
|
||||||
tmp2 = typecheck(tmp2, Etop)
|
tmp2 = typecheck(tmp2, Etop)
|
||||||
n2.Ninit.Append(tmp2)
|
n2.Ninit.Append(tmp2)
|
||||||
}
|
}
|
||||||
|
|
@ -1221,5 +1221,5 @@ func okas(ok, val *Node) *Node {
|
||||||
if !isblank(ok) {
|
if !isblank(ok) {
|
||||||
val = conv(val, ok.Type)
|
val = conv(val, ok.Type)
|
||||||
}
|
}
|
||||||
return Nod(OAS, ok, val)
|
return nod(OAS, ok, val)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -361,7 +361,7 @@ func (p *parser) importdcl() {
|
||||||
my = lookup(ipkg.Name)
|
my = lookup(ipkg.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pack := Nod(OPACK, nil, nil)
|
pack := nod(OPACK, nil, nil)
|
||||||
pack.Sym = my
|
pack.Sym = my
|
||||||
pack.Name.Pkg = ipkg
|
pack.Name.Pkg = ipkg
|
||||||
pack.Lineno = line
|
pack.Lineno = line
|
||||||
|
|
@ -500,7 +500,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
|
||||||
|
|
||||||
if rangeOk && p.got(LRANGE) {
|
if rangeOk && p.got(LRANGE) {
|
||||||
// LRANGE expr
|
// LRANGE expr
|
||||||
r := Nod(ORANGE, nil, p.expr())
|
r := nod(ORANGE, nil, p.expr())
|
||||||
r.Etype = 0 // := flag
|
r.Etype = 0 // := flag
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
@ -517,7 +517,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
|
||||||
p.next()
|
p.next()
|
||||||
rhs := p.expr()
|
rhs := p.expr()
|
||||||
|
|
||||||
stmt := Nod(OASOP, lhs, rhs)
|
stmt := nod(OASOP, lhs, rhs)
|
||||||
stmt.Etype = EType(op) // rathole to pass opcode
|
stmt.Etype = EType(op) // rathole to pass opcode
|
||||||
return stmt
|
return stmt
|
||||||
|
|
||||||
|
|
@ -525,7 +525,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
|
||||||
// expr LINCOP
|
// expr LINCOP
|
||||||
p.next()
|
p.next()
|
||||||
|
|
||||||
stmt := Nod(OASOP, lhs, nodintconst(1))
|
stmt := nod(OASOP, lhs, nodintconst(1))
|
||||||
stmt.Implicit = true
|
stmt.Implicit = true
|
||||||
stmt.Etype = EType(p.op)
|
stmt.Etype = EType(p.op)
|
||||||
return stmt
|
return stmt
|
||||||
|
|
@ -547,7 +547,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
|
||||||
p.syntax_error("expecting semicolon or newline or }")
|
p.syntax_error("expecting semicolon or newline or }")
|
||||||
// we already progressed, no need to advance
|
// we already progressed, no need to advance
|
||||||
}
|
}
|
||||||
lhs := Nod(OLABEL, lhs, nil)
|
lhs := nod(OLABEL, lhs, nil)
|
||||||
lhs.Sym = dclstack // context, for goto restrictions
|
lhs.Sym = dclstack // context, for goto restrictions
|
||||||
p.next() // consume ':' after making label node for correct lineno
|
p.next() // consume ':' after making label node for correct lineno
|
||||||
return p.labeled_stmt(lhs)
|
return p.labeled_stmt(lhs)
|
||||||
|
|
@ -569,7 +569,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
|
||||||
p.next()
|
p.next()
|
||||||
if rangeOk && p.got(LRANGE) {
|
if rangeOk && p.got(LRANGE) {
|
||||||
// expr_list '=' LRANGE expr
|
// expr_list '=' LRANGE expr
|
||||||
r := Nod(ORANGE, nil, p.expr())
|
r := nod(ORANGE, nil, p.expr())
|
||||||
r.List.Set(lhs)
|
r.List.Set(lhs)
|
||||||
r.Etype = 0 // := flag
|
r.Etype = 0 // := flag
|
||||||
return r
|
return r
|
||||||
|
|
@ -580,10 +580,10 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
|
||||||
|
|
||||||
if len(lhs) == 1 && len(rhs) == 1 {
|
if len(lhs) == 1 && len(rhs) == 1 {
|
||||||
// simple
|
// simple
|
||||||
return Nod(OAS, lhs[0], rhs[0])
|
return nod(OAS, lhs[0], rhs[0])
|
||||||
}
|
}
|
||||||
// multiple
|
// multiple
|
||||||
stmt := Nod(OAS2, nil, nil)
|
stmt := nod(OAS2, nil, nil)
|
||||||
stmt.List.Set(lhs)
|
stmt.List.Set(lhs)
|
||||||
stmt.Rlist.Set(rhs)
|
stmt.Rlist.Set(rhs)
|
||||||
return stmt
|
return stmt
|
||||||
|
|
@ -594,7 +594,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
|
||||||
|
|
||||||
if rangeOk && p.got(LRANGE) {
|
if rangeOk && p.got(LRANGE) {
|
||||||
// expr_list LCOLAS LRANGE expr
|
// expr_list LCOLAS LRANGE expr
|
||||||
r := Nod(ORANGE, nil, p.expr())
|
r := nod(ORANGE, nil, p.expr())
|
||||||
r.List.Set(lhs)
|
r.List.Set(lhs)
|
||||||
r.Colas = true
|
r.Colas = true
|
||||||
colasdefn(lhs, r)
|
colasdefn(lhs, r)
|
||||||
|
|
@ -605,7 +605,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
|
||||||
rhs := p.expr_list()
|
rhs := p.expr_list()
|
||||||
|
|
||||||
if rhs[0].Op == OTYPESW {
|
if rhs[0].Op == OTYPESW {
|
||||||
ts := Nod(OTYPESW, nil, rhs[0].Right)
|
ts := nod(OTYPESW, nil, rhs[0].Right)
|
||||||
if len(rhs) > 1 {
|
if len(rhs) > 1 {
|
||||||
yyerror("expr.(type) must be alone in list")
|
yyerror("expr.(type) must be alone in list")
|
||||||
}
|
}
|
||||||
|
|
@ -683,7 +683,7 @@ func (p *parser) case_(tswitch *Node) *Node {
|
||||||
// right will point to next case
|
// right will point to next case
|
||||||
// done in casebody()
|
// done in casebody()
|
||||||
markdcl() // matching popdcl in caseblock
|
markdcl() // matching popdcl in caseblock
|
||||||
stmt := Nod(OXCASE, nil, nil)
|
stmt := nod(OXCASE, nil, nil)
|
||||||
stmt.List.Set(cases)
|
stmt.List.Set(cases)
|
||||||
if tswitch != nil {
|
if tswitch != nil {
|
||||||
if n := tswitch.Left; n != nil {
|
if n := tswitch.Left; n != nil {
|
||||||
|
|
@ -709,12 +709,12 @@ func (p *parser) case_(tswitch *Node) *Node {
|
||||||
// right will point to next case
|
// right will point to next case
|
||||||
// done in casebody()
|
// done in casebody()
|
||||||
markdcl() // matching popdcl in caseblock
|
markdcl() // matching popdcl in caseblock
|
||||||
stmt := Nod(OXCASE, nil, nil)
|
stmt := nod(OXCASE, nil, nil)
|
||||||
var n *Node
|
var n *Node
|
||||||
if len(cases) == 1 {
|
if len(cases) == 1 {
|
||||||
n = Nod(OAS, cases[0], rhs)
|
n = nod(OAS, cases[0], rhs)
|
||||||
} else {
|
} else {
|
||||||
n = Nod(OAS2, nil, nil)
|
n = nod(OAS2, nil, nil)
|
||||||
n.List.Set(cases)
|
n.List.Set(cases)
|
||||||
n.Rlist.Set1(rhs)
|
n.Rlist.Set1(rhs)
|
||||||
}
|
}
|
||||||
|
|
@ -733,7 +733,7 @@ func (p *parser) case_(tswitch *Node) *Node {
|
||||||
// right will point to next case
|
// right will point to next case
|
||||||
// done in casebody()
|
// done in casebody()
|
||||||
markdcl() // matching popdcl in caseblock
|
markdcl() // matching popdcl in caseblock
|
||||||
stmt := Nod(OXCASE, nil, nil)
|
stmt := nod(OXCASE, nil, nil)
|
||||||
stmt.List.Set1(colas(cases, []*Node{rhs}, lno))
|
stmt.List.Set1(colas(cases, []*Node{rhs}, lno))
|
||||||
|
|
||||||
p.want(':') // consume ':' after declaring select cases for correct lineno
|
p.want(':') // consume ':' after declaring select cases for correct lineno
|
||||||
|
|
@ -741,7 +741,7 @@ func (p *parser) case_(tswitch *Node) *Node {
|
||||||
|
|
||||||
default:
|
default:
|
||||||
markdcl() // for matching popdcl in caseblock
|
markdcl() // for matching popdcl in caseblock
|
||||||
stmt := Nod(OXCASE, nil, nil) // don't return nil
|
stmt := nod(OXCASE, nil, nil) // don't return nil
|
||||||
p.syntax_error("expecting := or = or : or comma")
|
p.syntax_error("expecting := or = or : or comma")
|
||||||
p.advance(LCASE, LDEFAULT, '}')
|
p.advance(LCASE, LDEFAULT, '}')
|
||||||
return stmt
|
return stmt
|
||||||
|
|
@ -752,7 +752,7 @@ func (p *parser) case_(tswitch *Node) *Node {
|
||||||
p.next()
|
p.next()
|
||||||
|
|
||||||
markdcl() // matching popdcl in caseblock
|
markdcl() // matching popdcl in caseblock
|
||||||
stmt := Nod(OXCASE, nil, nil)
|
stmt := nod(OXCASE, nil, nil)
|
||||||
if tswitch != nil {
|
if tswitch != nil {
|
||||||
if n := tswitch.Left; n != nil {
|
if n := tswitch.Left; n != nil {
|
||||||
// type switch - declare variable
|
// type switch - declare variable
|
||||||
|
|
@ -770,7 +770,7 @@ func (p *parser) case_(tswitch *Node) *Node {
|
||||||
|
|
||||||
default:
|
default:
|
||||||
markdcl() // matching popdcl in caseblock
|
markdcl() // matching popdcl in caseblock
|
||||||
stmt := Nod(OXCASE, nil, nil) // don't return nil
|
stmt := nod(OXCASE, nil, nil) // don't return nil
|
||||||
p.syntax_error("expecting case or default or }")
|
p.syntax_error("expecting case or default or }")
|
||||||
p.advance(LCASE, LDEFAULT, '}')
|
p.advance(LCASE, LDEFAULT, '}')
|
||||||
return stmt
|
return stmt
|
||||||
|
|
@ -791,7 +791,7 @@ func (p *parser) compound_stmt() *Node {
|
||||||
popdcl()
|
popdcl()
|
||||||
|
|
||||||
if len(l) == 0 {
|
if len(l) == 0 {
|
||||||
return Nod(OEMPTY, nil, nil)
|
return nod(OEMPTY, nil, nil)
|
||||||
}
|
}
|
||||||
return liststmt(l)
|
return liststmt(l)
|
||||||
}
|
}
|
||||||
|
|
@ -868,7 +868,7 @@ func (p *parser) for_header() *Node {
|
||||||
if post != nil && post.Colas {
|
if post != nil && post.Colas {
|
||||||
yyerror("cannot declare in the for-increment")
|
yyerror("cannot declare in the for-increment")
|
||||||
}
|
}
|
||||||
h := Nod(OFOR, nil, nil)
|
h := nod(OFOR, nil, nil)
|
||||||
if init != nil {
|
if init != nil {
|
||||||
h.Ninit.Set1(init)
|
h.Ninit.Set1(init)
|
||||||
}
|
}
|
||||||
|
|
@ -883,7 +883,7 @@ func (p *parser) for_header() *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// normal test
|
// normal test
|
||||||
h := Nod(OFOR, nil, nil)
|
h := nod(OFOR, nil, nil)
|
||||||
h.Left = cond
|
h.Left = cond
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
@ -972,7 +972,7 @@ func (p *parser) if_header() *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
init, cond, _ := p.header(false)
|
init, cond, _ := p.header(false)
|
||||||
h := Nod(OIF, nil, nil)
|
h := nod(OIF, nil, nil)
|
||||||
if init != nil {
|
if init != nil {
|
||||||
h.Ninit.Set1(init)
|
h.Ninit.Set1(init)
|
||||||
}
|
}
|
||||||
|
|
@ -1052,7 +1052,7 @@ func (p *parser) select_stmt() *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
p.want(LSELECT)
|
p.want(LSELECT)
|
||||||
hdr := Nod(OSELECT, nil, nil)
|
hdr := nod(OSELECT, nil, nil)
|
||||||
hdr.List.Set(p.caseblock_list(nil))
|
hdr.List.Set(p.caseblock_list(nil))
|
||||||
return hdr
|
return hdr
|
||||||
}
|
}
|
||||||
|
|
@ -1068,7 +1068,7 @@ func (p *parser) bexpr(prec OpPrec) *Node {
|
||||||
for p.prec > prec {
|
for p.prec > prec {
|
||||||
op, prec1 := p.op, p.prec
|
op, prec1 := p.op, p.prec
|
||||||
p.next()
|
p.next()
|
||||||
x = Nod(op, x, p.bexpr(prec1))
|
x = nod(op, x, p.bexpr(prec1))
|
||||||
}
|
}
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
@ -1106,10 +1106,10 @@ func (p *parser) uexpr() *Node {
|
||||||
x := unparen(p.uexpr())
|
x := unparen(p.uexpr())
|
||||||
if x.Op == OCOMPLIT {
|
if x.Op == OCOMPLIT {
|
||||||
// Special case for &T{...}: turn into (*T){...}.
|
// Special case for &T{...}: turn into (*T){...}.
|
||||||
x.Right = Nod(OIND, x.Right, nil)
|
x.Right = nod(OIND, x.Right, nil)
|
||||||
x.Right.Implicit = true
|
x.Right.Implicit = true
|
||||||
} else {
|
} else {
|
||||||
x = Nod(OADDR, x, nil)
|
x = nod(OADDR, x, nil)
|
||||||
}
|
}
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
@ -1170,7 +1170,7 @@ func (p *parser) uexpr() *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// x is not a channel type => we have a receive op
|
// x is not a channel type => we have a receive op
|
||||||
return Nod(ORECV, x, nil)
|
return nod(ORECV, x, nil)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return p.pexpr(false)
|
return p.pexpr(false)
|
||||||
|
|
@ -1178,7 +1178,7 @@ func (p *parser) uexpr() *Node {
|
||||||
|
|
||||||
// simple uexpr
|
// simple uexpr
|
||||||
p.next()
|
p.next()
|
||||||
return Nod(op, p.uexpr(), nil)
|
return nod(op, p.uexpr(), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pseudocall parses call-like statements that can be preceded by 'defer' and 'go'.
|
// pseudocall parses call-like statements that can be preceded by 'defer' and 'go'.
|
||||||
|
|
@ -1248,7 +1248,7 @@ func (p *parser) operand(keep_parens bool) *Node {
|
||||||
// in a go/defer statement. In that case, operand is called
|
// in a go/defer statement. In that case, operand is called
|
||||||
// with keep_parens set.
|
// with keep_parens set.
|
||||||
if keep_parens {
|
if keep_parens {
|
||||||
x = Nod(OPAREN, x, nil)
|
x = nod(OPAREN, x, nil)
|
||||||
}
|
}
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
@ -1330,13 +1330,13 @@ loop:
|
||||||
// pexpr '.' '(' expr_or_type ')'
|
// pexpr '.' '(' expr_or_type ')'
|
||||||
t := p.expr() // expr_or_type
|
t := p.expr() // expr_or_type
|
||||||
p.want(')')
|
p.want(')')
|
||||||
x = Nod(ODOTTYPE, x, t)
|
x = nod(ODOTTYPE, x, t)
|
||||||
|
|
||||||
case LTYPE:
|
case LTYPE:
|
||||||
// pexpr '.' '(' LTYPE ')'
|
// pexpr '.' '(' LTYPE ')'
|
||||||
p.next()
|
p.next()
|
||||||
p.want(')')
|
p.want(')')
|
||||||
x = Nod(OTYPESW, nil, x)
|
x = nod(OTYPESW, nil, x)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -1367,9 +1367,9 @@ loop:
|
||||||
if i == nil {
|
if i == nil {
|
||||||
yyerror("missing index in index expression")
|
yyerror("missing index in index expression")
|
||||||
}
|
}
|
||||||
x = Nod(OINDEX, x, i)
|
x = nod(OINDEX, x, i)
|
||||||
case 1:
|
case 1:
|
||||||
x = Nod(OSLICE, x, nil)
|
x = nod(OSLICE, x, nil)
|
||||||
x.SetSliceBounds(index[0], index[1], nil)
|
x.SetSliceBounds(index[0], index[1], nil)
|
||||||
case 2:
|
case 2:
|
||||||
if index[1] == nil {
|
if index[1] == nil {
|
||||||
|
|
@ -1378,7 +1378,7 @@ loop:
|
||||||
if index[2] == nil {
|
if index[2] == nil {
|
||||||
yyerror("final index required in 3-index slice")
|
yyerror("final index required in 3-index slice")
|
||||||
}
|
}
|
||||||
x = Nod(OSLICE3, x, nil)
|
x = nod(OSLICE3, x, nil)
|
||||||
x.SetSliceBounds(index[0], index[1], index[2])
|
x.SetSliceBounds(index[0], index[1], index[2])
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -1390,7 +1390,7 @@ loop:
|
||||||
args, ddd := p.arg_list()
|
args, ddd := p.arg_list()
|
||||||
|
|
||||||
// call or conversion
|
// call or conversion
|
||||||
x = Nod(OCALL, x, nil)
|
x = nod(OCALL, x, nil)
|
||||||
x.List.Set(args)
|
x.List.Set(args)
|
||||||
x.Isddd = ddd
|
x.Isddd = ddd
|
||||||
|
|
||||||
|
|
@ -1444,7 +1444,7 @@ func (p *parser) keyval() *Node {
|
||||||
|
|
||||||
if p.got(':') {
|
if p.got(':') {
|
||||||
// key ':' value
|
// key ':' value
|
||||||
return Nod(OKEY, x, wrapname(p.bare_complitexpr()))
|
return nod(OKEY, x, wrapname(p.bare_complitexpr()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// value
|
// value
|
||||||
|
|
@ -1456,7 +1456,7 @@ func wrapname(x *Node) *Node {
|
||||||
// Introduce a wrapper node to give the correct line.
|
// Introduce a wrapper node to give the correct line.
|
||||||
switch x.Op {
|
switch x.Op {
|
||||||
case ONAME, ONONAME, OTYPE, OPACK, OLITERAL:
|
case ONAME, ONONAME, OTYPE, OPACK, OLITERAL:
|
||||||
x = Nod(OPAREN, x, nil)
|
x = nod(OPAREN, x, nil)
|
||||||
x.Implicit = true
|
x.Implicit = true
|
||||||
}
|
}
|
||||||
return x
|
return x
|
||||||
|
|
@ -1483,7 +1483,7 @@ func (p *parser) complitexpr() *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// make node early so we get the right line number
|
// make node early so we get the right line number
|
||||||
n := Nod(OCOMPLIT, nil, nil)
|
n := nod(OCOMPLIT, nil, nil)
|
||||||
|
|
||||||
p.want('{')
|
p.want('{')
|
||||||
p.xnest++
|
p.xnest++
|
||||||
|
|
@ -1578,11 +1578,11 @@ func (p *parser) dotdotdot() *Node {
|
||||||
|
|
||||||
p.want(LDDD)
|
p.want(LDDD)
|
||||||
if typ := p.try_ntype(); typ != nil {
|
if typ := p.try_ntype(); typ != nil {
|
||||||
return Nod(ODDD, typ, nil)
|
return nod(ODDD, typ, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
yyerror("final argument in variadic function missing type")
|
yyerror("final argument in variadic function missing type")
|
||||||
return Nod(ODDD, typenod(typ(TINTER)), nil)
|
return nod(ODDD, typenod(typ(TINTER)), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) ntype() *Node {
|
func (p *parser) ntype() *Node {
|
||||||
|
|
@ -1613,10 +1613,10 @@ func (p *parser) signature(recv *Node) *Node {
|
||||||
if p.tok == '(' {
|
if p.tok == '(' {
|
||||||
result = p.param_list(false)
|
result = p.param_list(false)
|
||||||
} else if t := p.try_ntype(); t != nil {
|
} else if t := p.try_ntype(); t != nil {
|
||||||
result = []*Node{Nod(ODCLFIELD, nil, t)}
|
result = []*Node{nod(ODCLFIELD, nil, t)}
|
||||||
}
|
}
|
||||||
|
|
||||||
typ := Nod(OTFUNC, recv, nil)
|
typ := nod(OTFUNC, recv, nil)
|
||||||
typ.List.Set(params)
|
typ.List.Set(params)
|
||||||
typ.Rlist.Set(result)
|
typ.Rlist.Set(result)
|
||||||
|
|
||||||
|
|
@ -1640,7 +1640,7 @@ func (p *parser) try_ntype() *Node {
|
||||||
// recvchantype
|
// recvchantype
|
||||||
p.next()
|
p.next()
|
||||||
p.want(LCHAN)
|
p.want(LCHAN)
|
||||||
t := Nod(OTCHAN, p.chan_elem(), nil)
|
t := nod(OTCHAN, p.chan_elem(), nil)
|
||||||
t.Etype = EType(Crecv)
|
t.Etype = EType(Crecv)
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
|
@ -1657,14 +1657,14 @@ func (p *parser) try_ntype() *Node {
|
||||||
var len *Node
|
var len *Node
|
||||||
if p.tok != ']' {
|
if p.tok != ']' {
|
||||||
if p.got(LDDD) {
|
if p.got(LDDD) {
|
||||||
len = Nod(ODDD, nil, nil)
|
len = nod(ODDD, nil, nil)
|
||||||
} else {
|
} else {
|
||||||
len = p.expr()
|
len = p.expr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.xnest--
|
p.xnest--
|
||||||
p.want(']')
|
p.want(']')
|
||||||
return Nod(OTARRAY, len, p.ntype())
|
return nod(OTARRAY, len, p.ntype())
|
||||||
|
|
||||||
case LCHAN:
|
case LCHAN:
|
||||||
// LCHAN non_recvchantype
|
// LCHAN non_recvchantype
|
||||||
|
|
@ -1674,7 +1674,7 @@ func (p *parser) try_ntype() *Node {
|
||||||
if p.got(LCOMM) {
|
if p.got(LCOMM) {
|
||||||
dir = EType(Csend)
|
dir = EType(Csend)
|
||||||
}
|
}
|
||||||
t := Nod(OTCHAN, p.chan_elem(), nil)
|
t := nod(OTCHAN, p.chan_elem(), nil)
|
||||||
t.Etype = dir
|
t.Etype = dir
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
|
@ -1685,7 +1685,7 @@ func (p *parser) try_ntype() *Node {
|
||||||
key := p.ntype()
|
key := p.ntype()
|
||||||
p.want(']')
|
p.want(']')
|
||||||
val := p.ntype()
|
val := p.ntype()
|
||||||
return Nod(OTMAP, key, val)
|
return nod(OTMAP, key, val)
|
||||||
|
|
||||||
case LSTRUCT:
|
case LSTRUCT:
|
||||||
return p.structtype()
|
return p.structtype()
|
||||||
|
|
@ -1696,7 +1696,7 @@ func (p *parser) try_ntype() *Node {
|
||||||
case '*':
|
case '*':
|
||||||
// ptrtype
|
// ptrtype
|
||||||
p.next()
|
p.next()
|
||||||
return Nod(OIND, p.ntype(), nil)
|
return nod(OIND, p.ntype(), nil)
|
||||||
|
|
||||||
case LNAME:
|
case LNAME:
|
||||||
return p.dotname()
|
return p.dotname()
|
||||||
|
|
@ -1769,7 +1769,7 @@ func (p *parser) structtype() *Node {
|
||||||
}
|
}
|
||||||
p.want('}')
|
p.want('}')
|
||||||
|
|
||||||
t := Nod(OTSTRUCT, nil, nil)
|
t := nod(OTSTRUCT, nil, nil)
|
||||||
t.List.Set(l)
|
t.List.Set(l)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
@ -1791,7 +1791,7 @@ func (p *parser) interfacetype() *Node {
|
||||||
}
|
}
|
||||||
p.want('}')
|
p.want('}')
|
||||||
|
|
||||||
t := Nod(OTINTER, nil, nil)
|
t := nod(OTINTER, nil, nil)
|
||||||
t.List.Set(l)
|
t.List.Set(l)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
@ -1854,7 +1854,7 @@ func (p *parser) fndcl() *Node {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f := Nod(ODCLFUNC, nil, nil)
|
f := nod(ODCLFUNC, nil, nil)
|
||||||
f.Func.Nname = newfuncname(name)
|
f.Func.Nname = newfuncname(name)
|
||||||
f.Func.Nname.Name.Defn = f
|
f.Func.Nname.Name.Defn = f
|
||||||
f.Func.Nname.Name.Param.Ntype = t // TODO: check if nname already has an ntype
|
f.Func.Nname.Name.Param.Ntype = t // TODO: check if nname already has an ntype
|
||||||
|
|
@ -1889,7 +1889,7 @@ func (p *parser) fndcl() *Node {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
f := Nod(ODCLFUNC, nil, nil)
|
f := nod(ODCLFUNC, nil, nil)
|
||||||
f.Func.Shortname = newfuncname(name)
|
f.Func.Shortname = newfuncname(name)
|
||||||
f.Func.Nname = methodname(f.Func.Shortname, recv.Right)
|
f.Func.Nname = methodname(f.Func.Shortname, recv.Right)
|
||||||
f.Func.Nname.Name.Defn = f
|
f.Func.Nname.Name.Defn = f
|
||||||
|
|
@ -1918,7 +1918,7 @@ func (p *parser) fnbody() []*Node {
|
||||||
p.fnest--
|
p.fnest--
|
||||||
p.want('}')
|
p.want('}')
|
||||||
if body == nil {
|
if body == nil {
|
||||||
body = []*Node{Nod(OEMPTY, nil, nil)}
|
body = []*Node{nod(OEMPTY, nil, nil)}
|
||||||
}
|
}
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
@ -2011,7 +2011,7 @@ func (p *parser) structdcl() []*Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, n := range fields {
|
for i, n := range fields {
|
||||||
fields[i] = Nod(ODCLFIELD, n, typ)
|
fields[i] = nod(ODCLFIELD, n, typ)
|
||||||
fields[i].SetVal(tag)
|
fields[i].SetVal(tag)
|
||||||
}
|
}
|
||||||
return fields
|
return fields
|
||||||
|
|
@ -2024,7 +2024,7 @@ func (p *parser) structdcl() []*Node {
|
||||||
p.want(')')
|
p.want(')')
|
||||||
tag := p.oliteral()
|
tag := p.oliteral()
|
||||||
|
|
||||||
field.Right = Nod(OIND, field.Right, nil)
|
field.Right = nod(OIND, field.Right, nil)
|
||||||
field.SetVal(tag)
|
field.SetVal(tag)
|
||||||
yyerror("cannot parenthesize embedded type")
|
yyerror("cannot parenthesize embedded type")
|
||||||
return []*Node{field}
|
return []*Node{field}
|
||||||
|
|
@ -2048,7 +2048,7 @@ func (p *parser) structdcl() []*Node {
|
||||||
p.want(')')
|
p.want(')')
|
||||||
tag := p.oliteral()
|
tag := p.oliteral()
|
||||||
|
|
||||||
field.Right = Nod(OIND, field.Right, nil)
|
field.Right = nod(OIND, field.Right, nil)
|
||||||
field.SetVal(tag)
|
field.SetVal(tag)
|
||||||
yyerror("cannot parenthesize embedded type")
|
yyerror("cannot parenthesize embedded type")
|
||||||
return []*Node{field}
|
return []*Node{field}
|
||||||
|
|
@ -2058,7 +2058,7 @@ func (p *parser) structdcl() []*Node {
|
||||||
field := p.embed(nil)
|
field := p.embed(nil)
|
||||||
tag := p.oliteral()
|
tag := p.oliteral()
|
||||||
|
|
||||||
field.Right = Nod(OIND, field.Right, nil)
|
field.Right = nod(OIND, field.Right, nil)
|
||||||
field.SetVal(tag)
|
field.SetVal(tag)
|
||||||
return []*Node{field}
|
return []*Node{field}
|
||||||
}
|
}
|
||||||
|
|
@ -2152,14 +2152,14 @@ func (p *parser) interfacedcl() *Node {
|
||||||
if p.tok != '(' {
|
if p.tok != '(' {
|
||||||
// packname
|
// packname
|
||||||
pname := p.packname(sym)
|
pname := p.packname(sym)
|
||||||
return Nod(ODCLFIELD, nil, oldname(pname))
|
return nod(ODCLFIELD, nil, oldname(pname))
|
||||||
}
|
}
|
||||||
|
|
||||||
// MethodName Signature
|
// MethodName Signature
|
||||||
mname := newname(sym)
|
mname := newname(sym)
|
||||||
sig := p.signature(fakethis())
|
sig := p.signature(fakethis())
|
||||||
|
|
||||||
meth := Nod(ODCLFIELD, mname, sig)
|
meth := nod(ODCLFIELD, mname, sig)
|
||||||
ifacedcl(meth)
|
ifacedcl(meth)
|
||||||
return meth
|
return meth
|
||||||
|
|
||||||
|
|
@ -2167,7 +2167,7 @@ func (p *parser) interfacedcl() *Node {
|
||||||
p.next()
|
p.next()
|
||||||
pname := p.packname(nil)
|
pname := p.packname(nil)
|
||||||
p.want(')')
|
p.want(')')
|
||||||
n := Nod(ODCLFIELD, nil, oldname(pname))
|
n := nod(ODCLFIELD, nil, oldname(pname))
|
||||||
yyerror("cannot parenthesize embedded type")
|
yyerror("cannot parenthesize embedded type")
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
@ -2309,7 +2309,7 @@ func (p *parser) param_list(dddOk bool) []*Node {
|
||||||
// p.name must be a type name (or nil in case of syntax error)
|
// p.name must be a type name (or nil in case of syntax error)
|
||||||
typ = mkname(p.name)
|
typ = mkname(p.name)
|
||||||
}
|
}
|
||||||
n := Nod(ODCLFIELD, name, typ)
|
n := nod(ODCLFIELD, name, typ)
|
||||||
|
|
||||||
// rewrite ...T parameter
|
// rewrite ...T parameter
|
||||||
if typ != nil && typ.Op == ODDD {
|
if typ != nil && typ.Op == ODDD {
|
||||||
|
|
@ -2333,7 +2333,7 @@ func (p *parser) param_list(dddOk bool) []*Node {
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
var missing_stmt = Nod(OXXX, nil, nil)
|
var missing_stmt = nod(OXXX, nil, nil)
|
||||||
|
|
||||||
// Statement =
|
// Statement =
|
||||||
// Declaration | LabeledStmt | SimpleStmt |
|
// Declaration | LabeledStmt | SimpleStmt |
|
||||||
|
|
@ -2374,29 +2374,29 @@ func (p *parser) stmt() *Node {
|
||||||
case LFALL:
|
case LFALL:
|
||||||
p.next()
|
p.next()
|
||||||
// will be converted to OFALL
|
// will be converted to OFALL
|
||||||
stmt := Nod(OXFALL, nil, nil)
|
stmt := nod(OXFALL, nil, nil)
|
||||||
stmt.Xoffset = int64(block)
|
stmt.Xoffset = int64(block)
|
||||||
return stmt
|
return stmt
|
||||||
|
|
||||||
case LBREAK:
|
case LBREAK:
|
||||||
p.next()
|
p.next()
|
||||||
return Nod(OBREAK, p.onew_name(), nil)
|
return nod(OBREAK, p.onew_name(), nil)
|
||||||
|
|
||||||
case LCONTINUE:
|
case LCONTINUE:
|
||||||
p.next()
|
p.next()
|
||||||
return Nod(OCONTINUE, p.onew_name(), nil)
|
return nod(OCONTINUE, p.onew_name(), nil)
|
||||||
|
|
||||||
case LGO:
|
case LGO:
|
||||||
p.next()
|
p.next()
|
||||||
return Nod(OPROC, p.pseudocall(), nil)
|
return nod(OPROC, p.pseudocall(), nil)
|
||||||
|
|
||||||
case LDEFER:
|
case LDEFER:
|
||||||
p.next()
|
p.next()
|
||||||
return Nod(ODEFER, p.pseudocall(), nil)
|
return nod(ODEFER, p.pseudocall(), nil)
|
||||||
|
|
||||||
case LGOTO:
|
case LGOTO:
|
||||||
p.next()
|
p.next()
|
||||||
stmt := Nod(OGOTO, p.new_name(p.sym()), nil)
|
stmt := nod(OGOTO, p.new_name(p.sym()), nil)
|
||||||
stmt.Sym = dclstack // context, for goto restrictions
|
stmt.Sym = dclstack // context, for goto restrictions
|
||||||
return stmt
|
return stmt
|
||||||
|
|
||||||
|
|
@ -2407,7 +2407,7 @@ func (p *parser) stmt() *Node {
|
||||||
results = p.expr_list()
|
results = p.expr_list()
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt := Nod(ORETURN, nil, nil)
|
stmt := nod(ORETURN, nil, nil)
|
||||||
stmt.List.Set(results)
|
stmt.List.Set(results)
|
||||||
if stmt.List.Len() == 0 && Curfn != nil {
|
if stmt.List.Len() == 0 && Curfn != nil {
|
||||||
for _, ln := range Curfn.Func.Dcl {
|
for _, ln := range Curfn.Func.Dcl {
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ func compile(fn *Node) {
|
||||||
// add clearing of the output parameters
|
// add clearing of the output parameters
|
||||||
for _, t := range Curfn.Type.Results().Fields().Slice() {
|
for _, t := range Curfn.Type.Results().Fields().Slice() {
|
||||||
if t.Nname != nil {
|
if t.Nname != nil {
|
||||||
n := Nod(OAS, t.Nname, nil)
|
n := nod(OAS, t.Nname, nil)
|
||||||
n = typecheck(n, Etop)
|
n = typecheck(n, Etop)
|
||||||
Curfn.Nbody.Prepend(n)
|
Curfn.Nbody.Prepend(n)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -229,9 +229,9 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) {
|
||||||
case OSPTR, OLEN, OCAP:
|
case OSPTR, OLEN, OCAP:
|
||||||
instrumentnode(&n.Left, init, 0, 0)
|
instrumentnode(&n.Left, init, 0, 0)
|
||||||
if n.Left.Type.IsMap() {
|
if n.Left.Type.IsMap() {
|
||||||
n1 := Nod(OCONVNOP, n.Left, nil)
|
n1 := nod(OCONVNOP, n.Left, nil)
|
||||||
n1.Type = ptrto(Types[TUINT8])
|
n1.Type = ptrto(Types[TUINT8])
|
||||||
n1 = Nod(OIND, n1, nil)
|
n1 = nod(OIND, n1, nil)
|
||||||
n1 = typecheck(n1, Erv)
|
n1 = typecheck(n1, Erv)
|
||||||
callinstr(&n1, init, 0, skip)
|
callinstr(&n1, init, 0, skip)
|
||||||
}
|
}
|
||||||
|
|
@ -578,7 +578,7 @@ func makeaddable(n *Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func uintptraddr(n *Node) *Node {
|
func uintptraddr(n *Node) *Node {
|
||||||
r := Nod(OADDR, n, nil)
|
r := nod(OADDR, n, nil)
|
||||||
r.Bounded = true
|
r.Bounded = true
|
||||||
r = conv(r, Types[TUNSAFEPTR])
|
r = conv(r, Types[TUNSAFEPTR])
|
||||||
r = conv(r, Types[TUINTPTR])
|
r = conv(r, Types[TUINTPTR])
|
||||||
|
|
@ -586,13 +586,13 @@ func uintptraddr(n *Node) *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
func detachexpr(n *Node, init *Nodes) *Node {
|
func detachexpr(n *Node, init *Nodes) *Node {
|
||||||
addr := Nod(OADDR, n, nil)
|
addr := nod(OADDR, n, nil)
|
||||||
l := temp(ptrto(n.Type))
|
l := temp(ptrto(n.Type))
|
||||||
as := Nod(OAS, l, addr)
|
as := nod(OAS, l, addr)
|
||||||
as = typecheck(as, Etop)
|
as = typecheck(as, Etop)
|
||||||
as = walkexpr(as, init)
|
as = walkexpr(as, init)
|
||||||
init.Append(as)
|
init.Append(as)
|
||||||
ind := Nod(OIND, l, nil)
|
ind := nod(OIND, l, nil)
|
||||||
ind = typecheck(ind, Erv)
|
ind = typecheck(ind, Erv)
|
||||||
ind = walkexpr(ind, init)
|
ind = walkexpr(ind, init)
|
||||||
return ind
|
return ind
|
||||||
|
|
@ -638,7 +638,7 @@ func appendinit(np **Node, init Nodes) {
|
||||||
// There may be multiple refs to this node;
|
// There may be multiple refs to this node;
|
||||||
// introduce OCONVNOP to hold init list.
|
// introduce OCONVNOP to hold init list.
|
||||||
case ONAME, OLITERAL:
|
case ONAME, OLITERAL:
|
||||||
n = Nod(OCONVNOP, n, nil)
|
n = nod(OCONVNOP, n, nil)
|
||||||
|
|
||||||
n.Type = n.Left.Type
|
n.Type = n.Left.Type
|
||||||
n.Typecheck = 1
|
n.Typecheck = 1
|
||||||
|
|
|
||||||
|
|
@ -179,25 +179,25 @@ func walkrange(n *Node) {
|
||||||
hn := temp(Types[TINT])
|
hn := temp(Types[TINT])
|
||||||
var hp *Node
|
var hp *Node
|
||||||
|
|
||||||
init = append(init, Nod(OAS, hv1, nil))
|
init = append(init, nod(OAS, hv1, nil))
|
||||||
init = append(init, Nod(OAS, hn, Nod(OLEN, ha, nil)))
|
init = append(init, nod(OAS, hn, nod(OLEN, ha, nil)))
|
||||||
if v2 != nil {
|
if v2 != nil {
|
||||||
hp = temp(ptrto(n.Type.Elem()))
|
hp = temp(ptrto(n.Type.Elem()))
|
||||||
tmp := Nod(OINDEX, ha, nodintconst(0))
|
tmp := nod(OINDEX, ha, nodintconst(0))
|
||||||
tmp.Bounded = true
|
tmp.Bounded = true
|
||||||
init = append(init, Nod(OAS, hp, Nod(OADDR, tmp, nil)))
|
init = append(init, nod(OAS, hp, nod(OADDR, tmp, nil)))
|
||||||
}
|
}
|
||||||
|
|
||||||
n.Left = Nod(OLT, hv1, hn)
|
n.Left = nod(OLT, hv1, hn)
|
||||||
n.Right = Nod(OAS, hv1, Nod(OADD, hv1, nodintconst(1)))
|
n.Right = nod(OAS, hv1, nod(OADD, hv1, nodintconst(1)))
|
||||||
if v1 == nil {
|
if v1 == nil {
|
||||||
body = nil
|
body = nil
|
||||||
} else if v2 == nil {
|
} else if v2 == nil {
|
||||||
body = []*Node{Nod(OAS, v1, hv1)}
|
body = []*Node{nod(OAS, v1, hv1)}
|
||||||
} else {
|
} else {
|
||||||
a := Nod(OAS2, nil, nil)
|
a := nod(OAS2, nil, nil)
|
||||||
a.List.Set([]*Node{v1, v2})
|
a.List.Set([]*Node{v1, v2})
|
||||||
a.Rlist.Set([]*Node{hv1, Nod(OIND, hp, nil)})
|
a.Rlist.Set([]*Node{hv1, nod(OIND, hp, nil)})
|
||||||
body = []*Node{a}
|
body = []*Node{a}
|
||||||
|
|
||||||
// Advance pointer as part of increment.
|
// Advance pointer as part of increment.
|
||||||
|
|
@ -208,13 +208,13 @@ func walkrange(n *Node) {
|
||||||
// Advancing during the increment ensures that the pointer p only points
|
// Advancing during the increment ensures that the pointer p only points
|
||||||
// pass the end of the array during the final "p++; i++; if(i >= len(x)) break;",
|
// pass the end of the array during the final "p++; i++; if(i >= len(x)) break;",
|
||||||
// after which p is dead, so it cannot confuse the collector.
|
// after which p is dead, so it cannot confuse the collector.
|
||||||
tmp := Nod(OADD, hp, nodintconst(t.Elem().Width))
|
tmp := nod(OADD, hp, nodintconst(t.Elem().Width))
|
||||||
|
|
||||||
tmp.Type = hp.Type
|
tmp.Type = hp.Type
|
||||||
tmp.Typecheck = 1
|
tmp.Typecheck = 1
|
||||||
tmp.Right.Type = Types[Tptr]
|
tmp.Right.Type = Types[Tptr]
|
||||||
tmp.Right.Typecheck = 1
|
tmp.Right.Typecheck = 1
|
||||||
a = Nod(OAS, hp, tmp)
|
a = nod(OAS, hp, tmp)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
n.Right.Ninit.Set1(a)
|
n.Right.Ninit.Set1(a)
|
||||||
}
|
}
|
||||||
|
|
@ -234,23 +234,23 @@ func walkrange(n *Node) {
|
||||||
fn := syslook("mapiterinit")
|
fn := syslook("mapiterinit")
|
||||||
|
|
||||||
fn = substArgTypes(fn, t.Key(), t.Val(), th)
|
fn = substArgTypes(fn, t.Key(), t.Val(), th)
|
||||||
init = append(init, mkcall1(fn, nil, nil, typename(t), ha, Nod(OADDR, hit, nil)))
|
init = append(init, mkcall1(fn, nil, nil, typename(t), ha, nod(OADDR, hit, nil)))
|
||||||
n.Left = Nod(ONE, nodSym(ODOT, hit, keysym), nodnil())
|
n.Left = nod(ONE, nodSym(ODOT, hit, keysym), nodnil())
|
||||||
|
|
||||||
fn = syslook("mapiternext")
|
fn = syslook("mapiternext")
|
||||||
fn = substArgTypes(fn, th)
|
fn = substArgTypes(fn, th)
|
||||||
n.Right = mkcall1(fn, nil, nil, Nod(OADDR, hit, nil))
|
n.Right = mkcall1(fn, nil, nil, nod(OADDR, hit, nil))
|
||||||
|
|
||||||
key := nodSym(ODOT, hit, keysym)
|
key := nodSym(ODOT, hit, keysym)
|
||||||
key = Nod(OIND, key, nil)
|
key = nod(OIND, key, nil)
|
||||||
if v1 == nil {
|
if v1 == nil {
|
||||||
body = nil
|
body = nil
|
||||||
} else if v2 == nil {
|
} else if v2 == nil {
|
||||||
body = []*Node{Nod(OAS, v1, key)}
|
body = []*Node{nod(OAS, v1, key)}
|
||||||
} else {
|
} else {
|
||||||
val := nodSym(ODOT, hit, valsym)
|
val := nodSym(ODOT, hit, valsym)
|
||||||
val = Nod(OIND, val, nil)
|
val = nod(OIND, val, nil)
|
||||||
a := Nod(OAS2, nil, nil)
|
a := nod(OAS2, nil, nil)
|
||||||
a.List.Set([]*Node{v1, v2})
|
a.List.Set([]*Node{v1, v2})
|
||||||
a.Rlist.Set([]*Node{key, val})
|
a.Rlist.Set([]*Node{key, val})
|
||||||
body = []*Node{a}
|
body = []*Node{a}
|
||||||
|
|
@ -265,25 +265,25 @@ func walkrange(n *Node) {
|
||||||
hv1 := temp(t.Elem())
|
hv1 := temp(t.Elem())
|
||||||
hv1.Typecheck = 1
|
hv1.Typecheck = 1
|
||||||
if haspointers(t.Elem()) {
|
if haspointers(t.Elem()) {
|
||||||
init = append(init, Nod(OAS, hv1, nil))
|
init = append(init, nod(OAS, hv1, nil))
|
||||||
}
|
}
|
||||||
hb := temp(Types[TBOOL])
|
hb := temp(Types[TBOOL])
|
||||||
|
|
||||||
n.Left = Nod(ONE, hb, nodbool(false))
|
n.Left = nod(ONE, hb, nodbool(false))
|
||||||
a := Nod(OAS2RECV, nil, nil)
|
a := nod(OAS2RECV, nil, nil)
|
||||||
a.Typecheck = 1
|
a.Typecheck = 1
|
||||||
a.List.Set([]*Node{hv1, hb})
|
a.List.Set([]*Node{hv1, hb})
|
||||||
a.Rlist.Set1(Nod(ORECV, ha, nil))
|
a.Rlist.Set1(nod(ORECV, ha, nil))
|
||||||
n.Left.Ninit.Set1(a)
|
n.Left.Ninit.Set1(a)
|
||||||
if v1 == nil {
|
if v1 == nil {
|
||||||
body = nil
|
body = nil
|
||||||
} else {
|
} else {
|
||||||
body = []*Node{Nod(OAS, v1, hv1)}
|
body = []*Node{nod(OAS, v1, hv1)}
|
||||||
}
|
}
|
||||||
// Zero hv1. This prevents hv1 from being the sole, inaccessible
|
// Zero hv1. This prevents hv1 from being the sole, inaccessible
|
||||||
// reference to an otherwise GC-able value during the next channel receive.
|
// reference to an otherwise GC-able value during the next channel receive.
|
||||||
// See issue 15281.
|
// See issue 15281.
|
||||||
body = append(body, Nod(OAS, hv1, nil))
|
body = append(body, nod(OAS, hv1, nil))
|
||||||
|
|
||||||
case TSTRING:
|
case TSTRING:
|
||||||
// Transform string range statements like "for v1, v2 = range a" into
|
// Transform string range statements like "for v1, v2 = range a" into
|
||||||
|
|
@ -308,30 +308,30 @@ func walkrange(n *Node) {
|
||||||
hv2 := temp(runetype)
|
hv2 := temp(runetype)
|
||||||
|
|
||||||
// hv1 := 0
|
// hv1 := 0
|
||||||
init = append(init, Nod(OAS, hv1, nil))
|
init = append(init, nod(OAS, hv1, nil))
|
||||||
|
|
||||||
// hv1 < len(ha)
|
// hv1 < len(ha)
|
||||||
n.Left = Nod(OLT, hv1, Nod(OLEN, ha, nil))
|
n.Left = nod(OLT, hv1, nod(OLEN, ha, nil))
|
||||||
|
|
||||||
if v1 != nil {
|
if v1 != nil {
|
||||||
// v1 = hv1
|
// v1 = hv1
|
||||||
body = append(body, Nod(OAS, v1, hv1))
|
body = append(body, nod(OAS, v1, hv1))
|
||||||
}
|
}
|
||||||
|
|
||||||
// hv2 := ha[hv1]
|
// hv2 := ha[hv1]
|
||||||
nind := Nod(OINDEX, ha, hv1)
|
nind := nod(OINDEX, ha, hv1)
|
||||||
nind.Bounded = true
|
nind.Bounded = true
|
||||||
body = append(body, Nod(OAS, hv2, conv(nind, runetype)))
|
body = append(body, nod(OAS, hv2, conv(nind, runetype)))
|
||||||
|
|
||||||
// if hv2 < utf8.RuneSelf
|
// if hv2 < utf8.RuneSelf
|
||||||
nif := Nod(OIF, nil, nil)
|
nif := nod(OIF, nil, nil)
|
||||||
nif.Left = Nod(OLT, nind, nodintconst(utf8.RuneSelf))
|
nif.Left = nod(OLT, nind, nodintconst(utf8.RuneSelf))
|
||||||
|
|
||||||
// hv1++
|
// hv1++
|
||||||
nif.Nbody.Set1(Nod(OAS, hv1, Nod(OADD, hv1, nodintconst(1))))
|
nif.Nbody.Set1(nod(OAS, hv1, nod(OADD, hv1, nodintconst(1))))
|
||||||
|
|
||||||
// } else {
|
// } else {
|
||||||
eif := Nod(OAS2, nil, nil)
|
eif := nod(OAS2, nil, nil)
|
||||||
nif.Rlist.Set1(eif)
|
nif.Rlist.Set1(eif)
|
||||||
|
|
||||||
// hv2, hv1 = charntorune(ha, hv1)
|
// hv2, hv1 = charntorune(ha, hv1)
|
||||||
|
|
@ -343,7 +343,7 @@ func walkrange(n *Node) {
|
||||||
|
|
||||||
if v2 != nil {
|
if v2 != nil {
|
||||||
// v2 = hv2
|
// v2 = hv2
|
||||||
body = append(body, Nod(OAS, v2, hv2))
|
body = append(body, nod(OAS, v2, hv2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -403,25 +403,25 @@ func memclrrange(n, v1, v2, a *Node) bool {
|
||||||
n.Op = OIF
|
n.Op = OIF
|
||||||
|
|
||||||
n.Nbody.Set(nil)
|
n.Nbody.Set(nil)
|
||||||
n.Left = Nod(ONE, Nod(OLEN, a, nil), nodintconst(0))
|
n.Left = nod(ONE, nod(OLEN, a, nil), nodintconst(0))
|
||||||
|
|
||||||
// hp = &a[0]
|
// hp = &a[0]
|
||||||
hp := temp(ptrto(Types[TUINT8]))
|
hp := temp(ptrto(Types[TUINT8]))
|
||||||
|
|
||||||
tmp := Nod(OINDEX, a, nodintconst(0))
|
tmp := nod(OINDEX, a, nodintconst(0))
|
||||||
tmp.Bounded = true
|
tmp.Bounded = true
|
||||||
tmp = Nod(OADDR, tmp, nil)
|
tmp = nod(OADDR, tmp, nil)
|
||||||
tmp = Nod(OCONVNOP, tmp, nil)
|
tmp = nod(OCONVNOP, tmp, nil)
|
||||||
tmp.Type = ptrto(Types[TUINT8])
|
tmp.Type = ptrto(Types[TUINT8])
|
||||||
n.Nbody.Append(Nod(OAS, hp, tmp))
|
n.Nbody.Append(nod(OAS, hp, tmp))
|
||||||
|
|
||||||
// hn = len(a) * sizeof(elem(a))
|
// hn = len(a) * sizeof(elem(a))
|
||||||
hn := temp(Types[TUINTPTR])
|
hn := temp(Types[TUINTPTR])
|
||||||
|
|
||||||
tmp = Nod(OLEN, a, nil)
|
tmp = nod(OLEN, a, nil)
|
||||||
tmp = Nod(OMUL, tmp, nodintconst(elemsize))
|
tmp = nod(OMUL, tmp, nodintconst(elemsize))
|
||||||
tmp = conv(tmp, Types[TUINTPTR])
|
tmp = conv(tmp, Types[TUINTPTR])
|
||||||
n.Nbody.Append(Nod(OAS, hn, tmp))
|
n.Nbody.Append(nod(OAS, hn, tmp))
|
||||||
|
|
||||||
// memclr(hp, hn)
|
// memclr(hp, hn)
|
||||||
fn := mkcall("memclr", nil, nil, hp, hn)
|
fn := mkcall("memclr", nil, nil, hp, hn)
|
||||||
|
|
@ -429,7 +429,7 @@ func memclrrange(n, v1, v2, a *Node) bool {
|
||||||
n.Nbody.Append(fn)
|
n.Nbody.Append(fn)
|
||||||
|
|
||||||
// i = len(a) - 1
|
// i = len(a) - 1
|
||||||
v1 = Nod(OAS, v1, Nod(OSUB, Nod(OLEN, a, nil), nodintconst(1)))
|
v1 = nod(OAS, v1, nod(OSUB, nod(OLEN, a, nil), nodintconst(1)))
|
||||||
|
|
||||||
n.Nbody.Append(v1)
|
n.Nbody.Append(v1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -257,14 +257,14 @@ func hiter(t *Type) *Type {
|
||||||
func methodfunc(f *Type, receiver *Type) *Type {
|
func methodfunc(f *Type, receiver *Type) *Type {
|
||||||
var in []*Node
|
var in []*Node
|
||||||
if receiver != nil {
|
if receiver != nil {
|
||||||
d := Nod(ODCLFIELD, nil, nil)
|
d := nod(ODCLFIELD, nil, nil)
|
||||||
d.Type = receiver
|
d.Type = receiver
|
||||||
in = append(in, d)
|
in = append(in, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
var d *Node
|
var d *Node
|
||||||
for _, t := range f.Params().Fields().Slice() {
|
for _, t := range f.Params().Fields().Slice() {
|
||||||
d = Nod(ODCLFIELD, nil, nil)
|
d = nod(ODCLFIELD, nil, nil)
|
||||||
d.Type = t.Type
|
d.Type = t.Type
|
||||||
d.Isddd = t.Isddd
|
d.Isddd = t.Isddd
|
||||||
in = append(in, d)
|
in = append(in, d)
|
||||||
|
|
@ -272,7 +272,7 @@ func methodfunc(f *Type, receiver *Type) *Type {
|
||||||
|
|
||||||
var out []*Node
|
var out []*Node
|
||||||
for _, t := range f.Results().Fields().Slice() {
|
for _, t := range f.Results().Fields().Slice() {
|
||||||
d = Nod(ODCLFIELD, nil, nil)
|
d = nod(ODCLFIELD, nil, nil)
|
||||||
d.Type = t.Type
|
d.Type = t.Type
|
||||||
out = append(out, d)
|
out = append(out, d)
|
||||||
}
|
}
|
||||||
|
|
@ -971,7 +971,7 @@ func typenamesym(t *Type) *Sym {
|
||||||
|
|
||||||
func typename(t *Type) *Node {
|
func typename(t *Type) *Node {
|
||||||
s := typenamesym(t)
|
s := typenamesym(t)
|
||||||
n := Nod(OADDR, s.Def, nil)
|
n := nod(OADDR, s.Def, nil)
|
||||||
n.Type = ptrto(s.Def.Type)
|
n.Type = ptrto(s.Def.Type)
|
||||||
n.Addable = true
|
n.Addable = true
|
||||||
n.Ullman = 2
|
n.Ullman = 2
|
||||||
|
|
@ -994,7 +994,7 @@ func itabname(t, itype *Type) *Node {
|
||||||
itabs = append(itabs, itabEntry{t: t, itype: itype, sym: s})
|
itabs = append(itabs, itabEntry{t: t, itype: itype, sym: s})
|
||||||
}
|
}
|
||||||
|
|
||||||
n := Nod(OADDR, s.Def, nil)
|
n := nod(OADDR, s.Def, nil)
|
||||||
n.Type = ptrto(s.Def.Type)
|
n.Type = ptrto(s.Def.Type)
|
||||||
n.Addable = true
|
n.Addable = true
|
||||||
n.Ullman = 2
|
n.Ullman = 2
|
||||||
|
|
@ -1467,7 +1467,7 @@ func dumptypestructs() {
|
||||||
// The latter is the type of an auto-generated wrapper.
|
// The latter is the type of an auto-generated wrapper.
|
||||||
dtypesym(ptrto(errortype))
|
dtypesym(ptrto(errortype))
|
||||||
|
|
||||||
dtypesym(functype(nil, []*Node{Nod(ODCLFIELD, nil, typenod(errortype))}, []*Node{Nod(ODCLFIELD, nil, typenod(Types[TSTRING]))}))
|
dtypesym(functype(nil, []*Node{nod(ODCLFIELD, nil, typenod(errortype))}, []*Node{nod(ODCLFIELD, nil, typenod(Types[TSTRING]))}))
|
||||||
|
|
||||||
// add paths for runtime and main, which 6l imports implicitly.
|
// add paths for runtime and main, which 6l imports implicitly.
|
||||||
dimportpath(Runtimepkg)
|
dimportpath(Runtimepkg)
|
||||||
|
|
@ -1769,7 +1769,7 @@ func zeroaddr(size int64) *Node {
|
||||||
x.Typecheck = 1
|
x.Typecheck = 1
|
||||||
s.Def = x
|
s.Def = x
|
||||||
}
|
}
|
||||||
z := Nod(OADDR, s.Def, nil)
|
z := nod(OADDR, s.Def, nil)
|
||||||
z.Type = ptrto(Types[TUINT8])
|
z.Type = ptrto(Types[TUINT8])
|
||||||
z.Addable = true
|
z.Addable = true
|
||||||
z.Typecheck = 1
|
z.Typecheck = 1
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ func typecheckselect(sel *Node) {
|
||||||
|
|
||||||
// convert <-c into OSELRECV(N, <-c)
|
// convert <-c into OSELRECV(N, <-c)
|
||||||
case ORECV:
|
case ORECV:
|
||||||
n = Nod(OSELRECV, nil, n)
|
n = nod(OSELRECV, nil, n)
|
||||||
|
|
||||||
n.Typecheck = 1
|
n.Typecheck = 1
|
||||||
ncase.Left = n
|
ncase.Left = n
|
||||||
|
|
@ -152,9 +152,9 @@ func walkselect(sel *Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ch == nil { block() }; n;
|
// if ch == nil { block() }; n;
|
||||||
a := Nod(OIF, nil, nil)
|
a := nod(OIF, nil, nil)
|
||||||
|
|
||||||
a.Left = Nod(OEQ, ch, nodnil())
|
a.Left = nod(OEQ, ch, nodnil())
|
||||||
var ln Nodes
|
var ln Nodes
|
||||||
ln.Set(l)
|
ln.Set(l)
|
||||||
a.Nbody.Set1(mkcall("block", nil, &ln))
|
a.Nbody.Set1(mkcall("block", nil, &ln))
|
||||||
|
|
@ -179,7 +179,7 @@ func walkselect(sel *Node) {
|
||||||
}
|
}
|
||||||
switch n.Op {
|
switch n.Op {
|
||||||
case OSEND:
|
case OSEND:
|
||||||
n.Right = Nod(OADDR, n.Right, nil)
|
n.Right = nod(OADDR, n.Right, nil)
|
||||||
n.Right = typecheck(n.Right, Erv)
|
n.Right = typecheck(n.Right, Erv)
|
||||||
|
|
||||||
case OSELRECV, OSELRECV2:
|
case OSELRECV, OSELRECV2:
|
||||||
|
|
@ -187,14 +187,14 @@ func walkselect(sel *Node) {
|
||||||
n.Op = OSELRECV
|
n.Op = OSELRECV
|
||||||
}
|
}
|
||||||
if n.Op == OSELRECV2 {
|
if n.Op == OSELRECV2 {
|
||||||
n.List.SetIndex(0, Nod(OADDR, n.List.First(), nil))
|
n.List.SetIndex(0, nod(OADDR, n.List.First(), nil))
|
||||||
n.List.SetIndex(0, typecheck(n.List.Index(0), Erv))
|
n.List.SetIndex(0, typecheck(n.List.Index(0), Erv))
|
||||||
}
|
}
|
||||||
|
|
||||||
if n.Left == nil {
|
if n.Left == nil {
|
||||||
n.Left = nodnil()
|
n.Left = nodnil()
|
||||||
} else {
|
} else {
|
||||||
n.Left = Nod(OADDR, n.Left, nil)
|
n.Left = nod(OADDR, n.Left, nil)
|
||||||
n.Left = typecheck(n.Left, Erv)
|
n.Left = typecheck(n.Left, Erv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -214,7 +214,7 @@ func walkselect(sel *Node) {
|
||||||
|
|
||||||
n := cas.Left
|
n := cas.Left
|
||||||
setlineno(n)
|
setlineno(n)
|
||||||
r := Nod(OIF, nil, nil)
|
r := nod(OIF, nil, nil)
|
||||||
r.Ninit.Set(cas.Ninit.Slice())
|
r.Ninit.Set(cas.Ninit.Slice())
|
||||||
switch n.Op {
|
switch n.Op {
|
||||||
default:
|
default:
|
||||||
|
|
@ -228,7 +228,7 @@ func walkselect(sel *Node) {
|
||||||
|
|
||||||
// if c != nil && selectnbrecv(&v, c) { body } else { default body }
|
// if c != nil && selectnbrecv(&v, c) { body } else { default body }
|
||||||
case OSELRECV:
|
case OSELRECV:
|
||||||
r = Nod(OIF, nil, nil)
|
r = nod(OIF, nil, nil)
|
||||||
|
|
||||||
r.Ninit.Set(cas.Ninit.Slice())
|
r.Ninit.Set(cas.Ninit.Slice())
|
||||||
ch := n.Right.Left
|
ch := n.Right.Left
|
||||||
|
|
@ -236,7 +236,7 @@ func walkselect(sel *Node) {
|
||||||
|
|
||||||
// if c != nil && selectnbrecv2(&v, c) { body } else { default body }
|
// if c != nil && selectnbrecv2(&v, c) { body } else { default body }
|
||||||
case OSELRECV2:
|
case OSELRECV2:
|
||||||
r = Nod(OIF, nil, nil)
|
r = nod(OIF, nil, nil)
|
||||||
|
|
||||||
r.Ninit.Set(cas.Ninit.Slice())
|
r.Ninit.Set(cas.Ninit.Slice())
|
||||||
ch := n.Right.Left
|
ch := n.Right.Left
|
||||||
|
|
@ -257,10 +257,10 @@ func walkselect(sel *Node) {
|
||||||
setlineno(sel)
|
setlineno(sel)
|
||||||
|
|
||||||
selv = temp(selecttype(int32(sel.Xoffset)))
|
selv = temp(selecttype(int32(sel.Xoffset)))
|
||||||
r = Nod(OAS, selv, nil)
|
r = nod(OAS, selv, nil)
|
||||||
r = typecheck(r, Etop)
|
r = typecheck(r, Etop)
|
||||||
init = append(init, r)
|
init = append(init, r)
|
||||||
var_ = conv(conv(Nod(OADDR, selv, nil), Types[TUNSAFEPTR]), ptrto(Types[TUINT8]))
|
var_ = conv(conv(nod(OADDR, selv, nil), Types[TUNSAFEPTR]), ptrto(Types[TUINT8]))
|
||||||
r = mkcall("newselect", nil, nil, var_, nodintconst(selv.Type.Width), nodintconst(sel.Xoffset))
|
r = mkcall("newselect", nil, nil, var_, nodintconst(selv.Type.Width), nodintconst(sel.Xoffset))
|
||||||
r = typecheck(r, Etop)
|
r = typecheck(r, Etop)
|
||||||
init = append(init, r)
|
init = append(init, r)
|
||||||
|
|
@ -268,7 +268,7 @@ func walkselect(sel *Node) {
|
||||||
for _, cas := range sel.List.Slice() {
|
for _, cas := range sel.List.Slice() {
|
||||||
setlineno(cas)
|
setlineno(cas)
|
||||||
n = cas.Left
|
n = cas.Left
|
||||||
r = Nod(OIF, nil, nil)
|
r = nod(OIF, nil, nil)
|
||||||
r.Ninit.Set(cas.Ninit.Slice())
|
r.Ninit.Set(cas.Ninit.Slice())
|
||||||
cas.Ninit.Set(nil)
|
cas.Ninit.Set(nil)
|
||||||
if n != nil {
|
if n != nil {
|
||||||
|
|
@ -299,10 +299,10 @@ func walkselect(sel *Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// selv is no longer alive after use.
|
// selv is no longer alive after use.
|
||||||
r.Nbody.Append(Nod(OVARKILL, selv, nil))
|
r.Nbody.Append(nod(OVARKILL, selv, nil))
|
||||||
|
|
||||||
r.Nbody.AppendNodes(&cas.Nbody)
|
r.Nbody.AppendNodes(&cas.Nbody)
|
||||||
r.Nbody.Append(Nod(OBREAK, nil, nil))
|
r.Nbody.Append(nod(OBREAK, nil, nil))
|
||||||
init = append(init, r)
|
init = append(init, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -323,29 +323,29 @@ func selecttype(size int32) *Type {
|
||||||
// TODO(dvyukov): it's possible to generate Scase only once
|
// TODO(dvyukov): it's possible to generate Scase only once
|
||||||
// and then cache; and also cache Select per size.
|
// and then cache; and also cache Select per size.
|
||||||
|
|
||||||
scase := Nod(OTSTRUCT, nil, nil)
|
scase := nod(OTSTRUCT, nil, nil)
|
||||||
scase.List.Append(Nod(ODCLFIELD, newname(lookup("elem")), typenod(ptrto(Types[TUINT8]))))
|
scase.List.Append(nod(ODCLFIELD, newname(lookup("elem")), typenod(ptrto(Types[TUINT8]))))
|
||||||
scase.List.Append(Nod(ODCLFIELD, newname(lookup("chan")), typenod(ptrto(Types[TUINT8]))))
|
scase.List.Append(nod(ODCLFIELD, newname(lookup("chan")), typenod(ptrto(Types[TUINT8]))))
|
||||||
scase.List.Append(Nod(ODCLFIELD, newname(lookup("pc")), typenod(Types[TUINTPTR])))
|
scase.List.Append(nod(ODCLFIELD, newname(lookup("pc")), typenod(Types[TUINTPTR])))
|
||||||
scase.List.Append(Nod(ODCLFIELD, newname(lookup("kind")), typenod(Types[TUINT16])))
|
scase.List.Append(nod(ODCLFIELD, newname(lookup("kind")), typenod(Types[TUINT16])))
|
||||||
scase.List.Append(Nod(ODCLFIELD, newname(lookup("so")), typenod(Types[TUINT16])))
|
scase.List.Append(nod(ODCLFIELD, newname(lookup("so")), typenod(Types[TUINT16])))
|
||||||
scase.List.Append(Nod(ODCLFIELD, newname(lookup("receivedp")), typenod(ptrto(Types[TUINT8]))))
|
scase.List.Append(nod(ODCLFIELD, newname(lookup("receivedp")), typenod(ptrto(Types[TUINT8]))))
|
||||||
scase.List.Append(Nod(ODCLFIELD, newname(lookup("releasetime")), typenod(Types[TUINT64])))
|
scase.List.Append(nod(ODCLFIELD, newname(lookup("releasetime")), typenod(Types[TUINT64])))
|
||||||
scase = typecheck(scase, Etype)
|
scase = typecheck(scase, Etype)
|
||||||
scase.Type.Noalg = true
|
scase.Type.Noalg = true
|
||||||
scase.Type.Local = true
|
scase.Type.Local = true
|
||||||
|
|
||||||
sel := Nod(OTSTRUCT, nil, nil)
|
sel := nod(OTSTRUCT, nil, nil)
|
||||||
sel.List.Append(Nod(ODCLFIELD, newname(lookup("tcase")), typenod(Types[TUINT16])))
|
sel.List.Append(nod(ODCLFIELD, newname(lookup("tcase")), typenod(Types[TUINT16])))
|
||||||
sel.List.Append(Nod(ODCLFIELD, newname(lookup("ncase")), typenod(Types[TUINT16])))
|
sel.List.Append(nod(ODCLFIELD, newname(lookup("ncase")), typenod(Types[TUINT16])))
|
||||||
sel.List.Append(Nod(ODCLFIELD, newname(lookup("pollorder")), typenod(ptrto(Types[TUINT8]))))
|
sel.List.Append(nod(ODCLFIELD, newname(lookup("pollorder")), typenod(ptrto(Types[TUINT8]))))
|
||||||
sel.List.Append(Nod(ODCLFIELD, newname(lookup("lockorder")), typenod(ptrto(Types[TUINT8]))))
|
sel.List.Append(nod(ODCLFIELD, newname(lookup("lockorder")), typenod(ptrto(Types[TUINT8]))))
|
||||||
arr := Nod(OTARRAY, nodintconst(int64(size)), scase)
|
arr := nod(OTARRAY, nodintconst(int64(size)), scase)
|
||||||
sel.List.Append(Nod(ODCLFIELD, newname(lookup("scase")), arr))
|
sel.List.Append(nod(ODCLFIELD, newname(lookup("scase")), arr))
|
||||||
arr = Nod(OTARRAY, nodintconst(int64(size)), typenod(Types[TUINT16]))
|
arr = nod(OTARRAY, nodintconst(int64(size)), typenod(Types[TUINT16]))
|
||||||
sel.List.Append(Nod(ODCLFIELD, newname(lookup("lockorderarr")), arr))
|
sel.List.Append(nod(ODCLFIELD, newname(lookup("lockorderarr")), arr))
|
||||||
arr = Nod(OTARRAY, nodintconst(int64(size)), typenod(Types[TUINT16]))
|
arr = nod(OTARRAY, nodintconst(int64(size)), typenod(Types[TUINT16]))
|
||||||
sel.List.Append(Nod(ODCLFIELD, newname(lookup("pollorderarr")), arr))
|
sel.List.Append(nod(ODCLFIELD, newname(lookup("pollorderarr")), arr))
|
||||||
sel = typecheck(sel, Etype)
|
sel = typecheck(sel, Etype)
|
||||||
sel.Type.Noalg = true
|
sel.Type.Noalg = true
|
||||||
sel.Type.Local = true
|
sel.Type.Local = true
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ func staticcopy(l *Node, r *Node, out *[]*Node) bool {
|
||||||
if staticcopy(l, r, out) {
|
if staticcopy(l, r, out) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
*out = append(*out, Nod(OAS, l, r))
|
*out = append(*out, nod(OAS, l, r))
|
||||||
return true
|
return true
|
||||||
|
|
||||||
case OLITERAL:
|
case OLITERAL:
|
||||||
|
|
@ -316,7 +316,7 @@ func staticcopy(l *Node, r *Node, out *[]*Node) bool {
|
||||||
switch r.Left.Op {
|
switch r.Left.Op {
|
||||||
case OARRAYLIT, OSLICELIT, OSTRUCTLIT, OMAPLIT:
|
case OARRAYLIT, OSLICELIT, OSTRUCTLIT, OMAPLIT:
|
||||||
// copy pointer
|
// copy pointer
|
||||||
gdata(l, Nod(OADDR, inittemps[r], nil), int(l.Type.Width))
|
gdata(l, nod(OADDR, inittemps[r], nil), int(l.Type.Width))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,7 +326,7 @@ func staticcopy(l *Node, r *Node, out *[]*Node) bool {
|
||||||
|
|
||||||
n := *l
|
n := *l
|
||||||
n.Xoffset = l.Xoffset + int64(array_array)
|
n.Xoffset = l.Xoffset + int64(array_array)
|
||||||
gdata(&n, Nod(OADDR, a, nil), Widthptr)
|
gdata(&n, nod(OADDR, a, nil), Widthptr)
|
||||||
n.Xoffset = l.Xoffset + int64(array_nel)
|
n.Xoffset = l.Xoffset + int64(array_nel)
|
||||||
gdata(&n, r.Right, Widthint)
|
gdata(&n, r.Right, Widthint)
|
||||||
n.Xoffset = l.Xoffset + int64(array_cap)
|
n.Xoffset = l.Xoffset + int64(array_cap)
|
||||||
|
|
@ -344,20 +344,20 @@ func staticcopy(l *Node, r *Node, out *[]*Node) bool {
|
||||||
if e.Expr.Op == OLITERAL {
|
if e.Expr.Op == OLITERAL {
|
||||||
gdata(&n, e.Expr, int(n.Type.Width))
|
gdata(&n, e.Expr, int(n.Type.Width))
|
||||||
} else {
|
} else {
|
||||||
ll := Nod(OXXX, nil, nil)
|
ll := nod(OXXX, nil, nil)
|
||||||
*ll = n
|
*ll = n
|
||||||
ll.Orig = ll // completely separate copy
|
ll.Orig = ll // completely separate copy
|
||||||
if !staticassign(ll, e.Expr, out) {
|
if !staticassign(ll, e.Expr, out) {
|
||||||
// Requires computation, but we're
|
// Requires computation, but we're
|
||||||
// copying someone else's computation.
|
// copying someone else's computation.
|
||||||
rr := Nod(OXXX, nil, nil)
|
rr := nod(OXXX, nil, nil)
|
||||||
|
|
||||||
*rr = *orig
|
*rr = *orig
|
||||||
rr.Orig = rr // completely separate copy
|
rr.Orig = rr // completely separate copy
|
||||||
rr.Type = ll.Type
|
rr.Type = ll.Type
|
||||||
rr.Xoffset += e.Xoffset
|
rr.Xoffset += e.Xoffset
|
||||||
setlineno(rr)
|
setlineno(rr)
|
||||||
*out = append(*out, Nod(OAS, ll, rr))
|
*out = append(*out, nod(OAS, ll, rr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -401,11 +401,11 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
|
||||||
a := staticname(r.Left.Type)
|
a := staticname(r.Left.Type)
|
||||||
|
|
||||||
inittemps[r] = a
|
inittemps[r] = a
|
||||||
gdata(l, Nod(OADDR, a, nil), int(l.Type.Width))
|
gdata(l, nod(OADDR, a, nil), int(l.Type.Width))
|
||||||
|
|
||||||
// Init underlying literal.
|
// Init underlying literal.
|
||||||
if !staticassign(a, r.Left, out) {
|
if !staticassign(a, r.Left, out) {
|
||||||
*out = append(*out, Nod(OAS, a, r.Left))
|
*out = append(*out, nod(OAS, a, r.Left))
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
@ -427,7 +427,7 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
|
||||||
inittemps[r] = a
|
inittemps[r] = a
|
||||||
n := *l
|
n := *l
|
||||||
n.Xoffset = l.Xoffset + int64(array_array)
|
n.Xoffset = l.Xoffset + int64(array_array)
|
||||||
gdata(&n, Nod(OADDR, a, nil), Widthptr)
|
gdata(&n, nod(OADDR, a, nil), Widthptr)
|
||||||
n.Xoffset = l.Xoffset + int64(array_nel)
|
n.Xoffset = l.Xoffset + int64(array_nel)
|
||||||
gdata(&n, r.Right, Widthint)
|
gdata(&n, r.Right, Widthint)
|
||||||
n.Xoffset = l.Xoffset + int64(array_cap)
|
n.Xoffset = l.Xoffset + int64(array_cap)
|
||||||
|
|
@ -450,11 +450,11 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
|
||||||
gdata(&n, e.Expr, int(n.Type.Width))
|
gdata(&n, e.Expr, int(n.Type.Width))
|
||||||
} else {
|
} else {
|
||||||
setlineno(e.Expr)
|
setlineno(e.Expr)
|
||||||
a := Nod(OXXX, nil, nil)
|
a := nod(OXXX, nil, nil)
|
||||||
*a = n
|
*a = n
|
||||||
a.Orig = a // completely separate copy
|
a.Orig = a // completely separate copy
|
||||||
if !staticassign(a, e.Expr, out) {
|
if !staticassign(a, e.Expr, out) {
|
||||||
*out = append(*out, Nod(OAS, a, e.Expr))
|
*out = append(*out, nod(OAS, a, e.Expr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -519,20 +519,20 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
|
||||||
// Copy val directly into n.
|
// Copy val directly into n.
|
||||||
n.Type = val.Type
|
n.Type = val.Type
|
||||||
setlineno(val)
|
setlineno(val)
|
||||||
a := Nod(OXXX, nil, nil)
|
a := nod(OXXX, nil, nil)
|
||||||
*a = n
|
*a = n
|
||||||
a.Orig = a
|
a.Orig = a
|
||||||
if !staticassign(a, val, out) {
|
if !staticassign(a, val, out) {
|
||||||
*out = append(*out, Nod(OAS, a, val))
|
*out = append(*out, nod(OAS, a, val))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Construct temp to hold val, write pointer to temp into n.
|
// Construct temp to hold val, write pointer to temp into n.
|
||||||
a := staticname(val.Type)
|
a := staticname(val.Type)
|
||||||
inittemps[val] = a
|
inittemps[val] = a
|
||||||
if !staticassign(a, val, out) {
|
if !staticassign(a, val, out) {
|
||||||
*out = append(*out, Nod(OAS, a, val))
|
*out = append(*out, nod(OAS, a, val))
|
||||||
}
|
}
|
||||||
ptr := Nod(OADDR, a, nil)
|
ptr := nod(OADDR, a, nil)
|
||||||
n.Type = ptrto(val.Type)
|
n.Type = ptrto(val.Type)
|
||||||
gdata(&n, ptr, Widthptr)
|
gdata(&n, ptr, Widthptr)
|
||||||
}
|
}
|
||||||
|
|
@ -587,7 +587,7 @@ func (n *Node) isSimpleName() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func litas(l *Node, r *Node, init *Nodes) {
|
func litas(l *Node, r *Node, init *Nodes) {
|
||||||
a := Nod(OAS, l, r)
|
a := nod(OAS, l, r)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = walkexpr(a, init)
|
a = walkexpr(a, init)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
|
|
@ -692,7 +692,7 @@ func fixedlit(ctxt initContext, kind initKind, n *Node, var_ *Node, init *Nodes)
|
||||||
var indexnode func(*Node) *Node
|
var indexnode func(*Node) *Node
|
||||||
switch n.Op {
|
switch n.Op {
|
||||||
case OARRAYLIT, OSLICELIT:
|
case OARRAYLIT, OSLICELIT:
|
||||||
indexnode = func(index *Node) *Node { return Nod(OINDEX, var_, index) }
|
indexnode = func(index *Node) *Node { return nod(OINDEX, var_, index) }
|
||||||
case OSTRUCTLIT:
|
case OSTRUCTLIT:
|
||||||
indexnode = func(index *Node) *Node { return nodSym(ODOT, var_, index.Sym) }
|
indexnode = func(index *Node) *Node { return nodSym(ODOT, var_, index.Sym) }
|
||||||
default:
|
default:
|
||||||
|
|
@ -730,7 +730,7 @@ func fixedlit(ctxt initContext, kind initKind, n *Node, var_ *Node, init *Nodes)
|
||||||
|
|
||||||
// build list of assignments: var[index] = expr
|
// build list of assignments: var[index] = expr
|
||||||
setlineno(value)
|
setlineno(value)
|
||||||
a := Nod(OAS, indexnode(index), value)
|
a := nod(OAS, indexnode(index), value)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
switch kind {
|
switch kind {
|
||||||
case initKindStatic:
|
case initKindStatic:
|
||||||
|
|
@ -763,9 +763,9 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
|
||||||
fixedlit(ctxt, initKindDynamic, n, vstat, init)
|
fixedlit(ctxt, initKindDynamic, n, vstat, init)
|
||||||
|
|
||||||
// copy static to slice
|
// copy static to slice
|
||||||
a := Nod(OSLICE, vstat, nil)
|
a := nod(OSLICE, vstat, nil)
|
||||||
|
|
||||||
a = Nod(OAS, var_, a)
|
a = nod(OAS, var_, a)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a.IsStatic = true
|
a.IsStatic = true
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
|
|
@ -814,37 +814,37 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
|
||||||
x.Type = t
|
x.Type = t
|
||||||
|
|
||||||
if vstat == nil {
|
if vstat == nil {
|
||||||
a = Nod(OAS, x, nil)
|
a = nod(OAS, x, nil)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
init.Append(a) // zero new temp
|
init.Append(a) // zero new temp
|
||||||
}
|
}
|
||||||
|
|
||||||
a = Nod(OADDR, x, nil)
|
a = nod(OADDR, x, nil)
|
||||||
} else if n.Esc == EscNone {
|
} else if n.Esc == EscNone {
|
||||||
a = temp(t)
|
a = temp(t)
|
||||||
if vstat == nil {
|
if vstat == nil {
|
||||||
a = Nod(OAS, temp(t), nil)
|
a = nod(OAS, temp(t), nil)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
init.Append(a) // zero new temp
|
init.Append(a) // zero new temp
|
||||||
a = a.Left
|
a = a.Left
|
||||||
}
|
}
|
||||||
|
|
||||||
a = Nod(OADDR, a, nil)
|
a = nod(OADDR, a, nil)
|
||||||
} else {
|
} else {
|
||||||
a = Nod(ONEW, nil, nil)
|
a = nod(ONEW, nil, nil)
|
||||||
a.List.Set1(typenod(t))
|
a.List.Set1(typenod(t))
|
||||||
}
|
}
|
||||||
|
|
||||||
a = Nod(OAS, vauto, a)
|
a = nod(OAS, vauto, a)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = walkexpr(a, init)
|
a = walkexpr(a, init)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
|
|
||||||
if vstat != nil {
|
if vstat != nil {
|
||||||
// copy static to heap (4)
|
// copy static to heap (4)
|
||||||
a = Nod(OIND, vauto, nil)
|
a = nod(OIND, vauto, nil)
|
||||||
|
|
||||||
a = Nod(OAS, a, vstat)
|
a = nod(OAS, a, vstat)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = walkexpr(a, init)
|
a = walkexpr(a, init)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
|
|
@ -857,7 +857,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
|
||||||
}
|
}
|
||||||
index := r.Left
|
index := r.Left
|
||||||
value := r.Right
|
value := r.Right
|
||||||
a := Nod(OINDEX, vauto, index)
|
a := nod(OINDEX, vauto, index)
|
||||||
a.Bounded = true
|
a.Bounded = true
|
||||||
|
|
||||||
// TODO need to check bounds?
|
// TODO need to check bounds?
|
||||||
|
|
@ -877,7 +877,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
|
||||||
|
|
||||||
// build list of vauto[c] = expr
|
// build list of vauto[c] = expr
|
||||||
setlineno(value)
|
setlineno(value)
|
||||||
a = Nod(OAS, a, value)
|
a = nod(OAS, a, value)
|
||||||
|
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = orderstmtinplace(a)
|
a = orderstmtinplace(a)
|
||||||
|
|
@ -886,7 +886,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// make slice out of heap (6)
|
// make slice out of heap (6)
|
||||||
a = Nod(OAS, var_, Nod(OSLICE, vauto, nil))
|
a = nod(OAS, var_, nod(OSLICE, vauto, nil))
|
||||||
|
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = orderstmtinplace(a)
|
a = orderstmtinplace(a)
|
||||||
|
|
@ -898,7 +898,7 @@ func maplit(n *Node, m *Node, init *Nodes) {
|
||||||
// make the map var
|
// make the map var
|
||||||
nerr := nerrors
|
nerr := nerrors
|
||||||
|
|
||||||
a := Nod(OMAKE, nil, nil)
|
a := nod(OMAKE, nil, nil)
|
||||||
a.List.Set2(typenod(n.Type), nodintconst(int64(len(n.List.Slice()))))
|
a.List.Set2(typenod(n.Type), nodintconst(int64(len(n.List.Slice()))))
|
||||||
litas(m, a, init)
|
litas(m, a, init)
|
||||||
|
|
||||||
|
|
@ -942,8 +942,8 @@ func maplit(n *Node, m *Node, init *Nodes) {
|
||||||
if isliteral(index) && isliteral(value) {
|
if isliteral(index) && isliteral(value) {
|
||||||
// build vstatk[b] = index
|
// build vstatk[b] = index
|
||||||
setlineno(index)
|
setlineno(index)
|
||||||
lhs := Nod(OINDEX, vstatk, nodintconst(b))
|
lhs := nod(OINDEX, vstatk, nodintconst(b))
|
||||||
as := Nod(OAS, lhs, index)
|
as := nod(OAS, lhs, index)
|
||||||
as = typecheck(as, Etop)
|
as = typecheck(as, Etop)
|
||||||
as = walkexpr(as, init)
|
as = walkexpr(as, init)
|
||||||
as.IsStatic = true
|
as.IsStatic = true
|
||||||
|
|
@ -951,8 +951,8 @@ func maplit(n *Node, m *Node, init *Nodes) {
|
||||||
|
|
||||||
// build vstatv[b] = value
|
// build vstatv[b] = value
|
||||||
setlineno(value)
|
setlineno(value)
|
||||||
lhs = Nod(OINDEX, vstatv, nodintconst(b))
|
lhs = nod(OINDEX, vstatv, nodintconst(b))
|
||||||
as = Nod(OAS, lhs, value)
|
as = nod(OAS, lhs, value)
|
||||||
as = typecheck(as, Etop)
|
as = typecheck(as, Etop)
|
||||||
as = walkexpr(as, init)
|
as = walkexpr(as, init)
|
||||||
as.IsStatic = true
|
as.IsStatic = true
|
||||||
|
|
@ -967,19 +967,19 @@ func maplit(n *Node, m *Node, init *Nodes) {
|
||||||
// map[vstatk[i]] = vstatv[i]
|
// map[vstatk[i]] = vstatv[i]
|
||||||
// }
|
// }
|
||||||
i := temp(Types[TINT])
|
i := temp(Types[TINT])
|
||||||
rhs := Nod(OINDEX, vstatv, i)
|
rhs := nod(OINDEX, vstatv, i)
|
||||||
rhs.Bounded = true
|
rhs.Bounded = true
|
||||||
|
|
||||||
kidx := Nod(OINDEX, vstatk, i)
|
kidx := nod(OINDEX, vstatk, i)
|
||||||
kidx.Bounded = true
|
kidx.Bounded = true
|
||||||
lhs := Nod(OINDEX, m, kidx)
|
lhs := nod(OINDEX, m, kidx)
|
||||||
|
|
||||||
zero := Nod(OAS, i, nodintconst(0))
|
zero := nod(OAS, i, nodintconst(0))
|
||||||
cond := Nod(OLT, i, nodintconst(tk.NumElem()))
|
cond := nod(OLT, i, nodintconst(tk.NumElem()))
|
||||||
incr := Nod(OAS, i, Nod(OADD, i, nodintconst(1)))
|
incr := nod(OAS, i, nod(OADD, i, nodintconst(1)))
|
||||||
body := Nod(OAS, lhs, rhs)
|
body := nod(OAS, lhs, rhs)
|
||||||
|
|
||||||
loop := Nod(OFOR, cond, incr)
|
loop := nod(OFOR, cond, incr)
|
||||||
loop.Nbody.Set1(body)
|
loop.Nbody.Set1(body)
|
||||||
loop.Ninit.Set1(zero)
|
loop.Ninit.Set1(zero)
|
||||||
|
|
||||||
|
|
@ -1009,19 +1009,19 @@ func maplit(n *Node, m *Node, init *Nodes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setlineno(index)
|
setlineno(index)
|
||||||
a = Nod(OAS, key, index)
|
a = nod(OAS, key, index)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = walkstmt(a)
|
a = walkstmt(a)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
|
|
||||||
setlineno(value)
|
setlineno(value)
|
||||||
a = Nod(OAS, val, value)
|
a = nod(OAS, val, value)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = walkstmt(a)
|
a = walkstmt(a)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
|
|
||||||
setlineno(val)
|
setlineno(val)
|
||||||
a = Nod(OAS, Nod(OINDEX, m, key), val)
|
a = nod(OAS, nod(OINDEX, m, key), val)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = walkstmt(a)
|
a = walkstmt(a)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
|
|
@ -1032,10 +1032,10 @@ func maplit(n *Node, m *Node, init *Nodes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if key != nil {
|
if key != nil {
|
||||||
a = Nod(OVARKILL, key, nil)
|
a = nod(OVARKILL, key, nil)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
a = Nod(OVARKILL, val, nil)
|
a = nod(OVARKILL, val, nil)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
}
|
}
|
||||||
|
|
@ -1054,22 +1054,22 @@ func anylit(n *Node, var_ *Node, init *Nodes) {
|
||||||
|
|
||||||
var r *Node
|
var r *Node
|
||||||
if n.Right != nil {
|
if n.Right != nil {
|
||||||
r = Nod(OADDR, n.Right, nil)
|
r = nod(OADDR, n.Right, nil)
|
||||||
r = typecheck(r, Erv)
|
r = typecheck(r, Erv)
|
||||||
} else {
|
} else {
|
||||||
r = Nod(ONEW, nil, nil)
|
r = nod(ONEW, nil, nil)
|
||||||
r.Typecheck = 1
|
r.Typecheck = 1
|
||||||
r.Type = t
|
r.Type = t
|
||||||
r.Esc = n.Esc
|
r.Esc = n.Esc
|
||||||
}
|
}
|
||||||
|
|
||||||
r = walkexpr(r, init)
|
r = walkexpr(r, init)
|
||||||
a := Nod(OAS, var_, r)
|
a := nod(OAS, var_, r)
|
||||||
|
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
|
|
||||||
var_ = Nod(OIND, var_, nil)
|
var_ = nod(OIND, var_, nil)
|
||||||
var_ = typecheck(var_, Erv|Easgn)
|
var_ = typecheck(var_, Erv|Easgn)
|
||||||
anylit(n.Left, var_, init)
|
anylit(n.Left, var_, init)
|
||||||
|
|
||||||
|
|
@ -1090,7 +1090,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) {
|
||||||
fixedlit(ctxt, initKindStatic, n, vstat, init)
|
fixedlit(ctxt, initKindStatic, n, vstat, init)
|
||||||
|
|
||||||
// copy static to var
|
// copy static to var
|
||||||
a := Nod(OAS, var_, vstat)
|
a := nod(OAS, var_, vstat)
|
||||||
|
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = walkexpr(a, init)
|
a = walkexpr(a, init)
|
||||||
|
|
@ -1109,7 +1109,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) {
|
||||||
}
|
}
|
||||||
// initialization of an array or struct with unspecified components (missing fields or arrays)
|
// initialization of an array or struct with unspecified components (missing fields or arrays)
|
||||||
if var_.isSimpleName() || int64(n.List.Len()) < components {
|
if var_.isSimpleName() || int64(n.List.Len()) < components {
|
||||||
a := Nod(OAS, var_, nil)
|
a := nod(OAS, var_, nil)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = walkexpr(a, init)
|
a = walkexpr(a, init)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
|
|
|
||||||
|
|
@ -4721,7 +4721,7 @@ func (e *ssaExport) SplitStruct(name ssa.LocalSlot, i int) ssa.LocalSlot {
|
||||||
func (e *ssaExport) namedAuto(name string, typ ssa.Type) ssa.GCNode {
|
func (e *ssaExport) namedAuto(name string, typ ssa.Type) ssa.GCNode {
|
||||||
t := typ.(*Type)
|
t := typ.(*Type)
|
||||||
s := &Sym{Name: name, Pkg: localpkg}
|
s := &Sym{Name: name, Pkg: localpkg}
|
||||||
n := Nod(ONAME, nil, nil)
|
n := nod(ONAME, nil, nil)
|
||||||
s.Def = n
|
s.Def = n
|
||||||
s.Def.Used = true
|
s.Def.Used = true
|
||||||
n.Sym = s
|
n.Sym = s
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,7 @@ func importdot(opkg *Pkg, pack *Node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Nod(op Op, nleft *Node, nright *Node) *Node {
|
func nod(op Op, nleft *Node, nright *Node) *Node {
|
||||||
n := new(Node)
|
n := new(Node)
|
||||||
n.Op = op
|
n.Op = op
|
||||||
n.Left = nleft
|
n.Left = nleft
|
||||||
|
|
@ -384,7 +384,7 @@ func Nod(op Op, nleft *Node, nright *Node) *Node {
|
||||||
// nodSym makes a Node with Op op and with the Left field set to left
|
// nodSym makes a Node with Op op and with the Left field set to left
|
||||||
// and the Sym field set to sym. This is for ODOT and friends.
|
// and the Sym field set to sym. This is for ODOT and friends.
|
||||||
func nodSym(op Op, left *Node, sym *Sym) *Node {
|
func nodSym(op Op, left *Node, sym *Sym) *Node {
|
||||||
n := Nod(op, left, nil)
|
n := nod(op, left, nil)
|
||||||
n.Sym = sym
|
n.Sym = sym
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
@ -393,7 +393,7 @@ func saveorignode(n *Node) {
|
||||||
if n.Orig != nil {
|
if n.Orig != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
norig := Nod(n.Op, nil, nil)
|
norig := nod(n.Op, nil, nil)
|
||||||
*norig = *n
|
*norig = *n
|
||||||
n.Orig = norig
|
n.Orig = norig
|
||||||
}
|
}
|
||||||
|
|
@ -428,7 +428,7 @@ func (x methcmp) Less(i, j int) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func nodintconst(v int64) *Node {
|
func nodintconst(v int64) *Node {
|
||||||
c := Nod(OLITERAL, nil, nil)
|
c := nod(OLITERAL, nil, nil)
|
||||||
c.Addable = true
|
c.Addable = true
|
||||||
c.SetVal(Val{new(Mpint)})
|
c.SetVal(Val{new(Mpint)})
|
||||||
c.Val().U.(*Mpint).SetInt64(v)
|
c.Val().U.(*Mpint).SetInt64(v)
|
||||||
|
|
@ -438,7 +438,7 @@ func nodintconst(v int64) *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
func nodfltconst(v *Mpflt) *Node {
|
func nodfltconst(v *Mpflt) *Node {
|
||||||
c := Nod(OLITERAL, nil, nil)
|
c := nod(OLITERAL, nil, nil)
|
||||||
c.Addable = true
|
c.Addable = true
|
||||||
c.SetVal(Val{newMpflt()})
|
c.SetVal(Val{newMpflt()})
|
||||||
c.Val().U.(*Mpflt).Set(v)
|
c.Val().U.(*Mpflt).Set(v)
|
||||||
|
|
@ -1000,7 +1000,7 @@ func assignconvfn(n *Node, t *Type, context func() string) *Node {
|
||||||
// if the next step is non-bool (like interface{}).
|
// if the next step is non-bool (like interface{}).
|
||||||
if n.Type == idealbool && !t.IsBoolean() {
|
if n.Type == idealbool && !t.IsBoolean() {
|
||||||
if n.Op == ONAME || n.Op == OLITERAL {
|
if n.Op == ONAME || n.Op == OLITERAL {
|
||||||
r := Nod(OCONVNOP, n, nil)
|
r := nod(OCONVNOP, n, nil)
|
||||||
r.Type = Types[TBOOL]
|
r.Type = Types[TBOOL]
|
||||||
r.Typecheck = 1
|
r.Typecheck = 1
|
||||||
r.Implicit = true
|
r.Implicit = true
|
||||||
|
|
@ -1019,7 +1019,7 @@ func assignconvfn(n *Node, t *Type, context func() string) *Node {
|
||||||
op = OCONV
|
op = OCONV
|
||||||
}
|
}
|
||||||
|
|
||||||
r := Nod(op, n, nil)
|
r := nod(op, n, nil)
|
||||||
r.Type = t
|
r.Type = t
|
||||||
r.Typecheck = 1
|
r.Typecheck = 1
|
||||||
r.Implicit = true
|
r.Implicit = true
|
||||||
|
|
@ -1064,7 +1064,7 @@ func (n *Node) SetSliceBounds(low, high, max *Node) {
|
||||||
Fatalf("SetSliceBounds %v given three bounds", n.Op)
|
Fatalf("SetSliceBounds %v given three bounds", n.Op)
|
||||||
}
|
}
|
||||||
if n.Right == nil {
|
if n.Right == nil {
|
||||||
n.Right = Nod(OKEY, low, high)
|
n.Right = nod(OKEY, low, high)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
n.Right.Left = low
|
n.Right.Left = low
|
||||||
|
|
@ -1072,7 +1072,7 @@ func (n *Node) SetSliceBounds(low, high, max *Node) {
|
||||||
return
|
return
|
||||||
case OSLICE3, OSLICE3ARR:
|
case OSLICE3, OSLICE3ARR:
|
||||||
if n.Right == nil {
|
if n.Right == nil {
|
||||||
n.Right = Nod(OKEY, low, Nod(OKEY, high, max))
|
n.Right = nod(OKEY, low, nod(OKEY, high, max))
|
||||||
}
|
}
|
||||||
n.Right.Left = low
|
n.Right.Left = low
|
||||||
n.Right.Right.Left = high
|
n.Right.Right.Left = high
|
||||||
|
|
@ -1334,7 +1334,7 @@ func safeexpr(n *Node, init *Nodes) *Node {
|
||||||
if l == n.Left {
|
if l == n.Left {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
r := Nod(OXXX, nil, nil)
|
r := nod(OXXX, nil, nil)
|
||||||
*r = *n
|
*r = *n
|
||||||
r.Left = l
|
r.Left = l
|
||||||
r = typecheck(r, Erv)
|
r = typecheck(r, Erv)
|
||||||
|
|
@ -1346,7 +1346,7 @@ func safeexpr(n *Node, init *Nodes) *Node {
|
||||||
if l == n.Left {
|
if l == n.Left {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
a := Nod(OXXX, nil, nil)
|
a := nod(OXXX, nil, nil)
|
||||||
*a = *n
|
*a = *n
|
||||||
a.Left = l
|
a.Left = l
|
||||||
a = walkexpr(a, init)
|
a = walkexpr(a, init)
|
||||||
|
|
@ -1358,7 +1358,7 @@ func safeexpr(n *Node, init *Nodes) *Node {
|
||||||
if l == n.Left && r == n.Right {
|
if l == n.Left && r == n.Right {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
a := Nod(OXXX, nil, nil)
|
a := nod(OXXX, nil, nil)
|
||||||
*a = *n
|
*a = *n
|
||||||
a.Left = l
|
a.Left = l
|
||||||
a.Right = r
|
a.Right = r
|
||||||
|
|
@ -1380,7 +1380,7 @@ func safeexpr(n *Node, init *Nodes) *Node {
|
||||||
|
|
||||||
func copyexpr(n *Node, t *Type, init *Nodes) *Node {
|
func copyexpr(n *Node, t *Type, init *Nodes) *Node {
|
||||||
l := temp(t)
|
l := temp(t)
|
||||||
a := Nod(OAS, l, n)
|
a := nod(OAS, l, n)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
a = walkexpr(a, init)
|
a = walkexpr(a, init)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
|
|
@ -1706,7 +1706,7 @@ func structargs(tl *Type, mustname bool) []*Node {
|
||||||
} else if t.Sym != nil {
|
} else if t.Sym != nil {
|
||||||
n = newname(t.Sym)
|
n = newname(t.Sym)
|
||||||
}
|
}
|
||||||
a := Nod(ODCLFIELD, n, typenod(t.Type))
|
a := nod(ODCLFIELD, n, typenod(t.Type))
|
||||||
a.Isddd = t.Isddd
|
a.Isddd = t.Isddd
|
||||||
if n != nil {
|
if n != nil {
|
||||||
n.Isddd = t.Isddd
|
n.Isddd = t.Isddd
|
||||||
|
|
@ -1758,12 +1758,12 @@ func genwrapper(rcvr *Type, method *Field, newnam *Sym, iface int) {
|
||||||
dclcontext = PEXTERN
|
dclcontext = PEXTERN
|
||||||
markdcl()
|
markdcl()
|
||||||
|
|
||||||
this := Nod(ODCLFIELD, newname(lookup(".this")), typenod(rcvr))
|
this := nod(ODCLFIELD, newname(lookup(".this")), typenod(rcvr))
|
||||||
this.Left.Name.Param.Ntype = this.Right
|
this.Left.Name.Param.Ntype = this.Right
|
||||||
in := structargs(method.Type.Params(), true)
|
in := structargs(method.Type.Params(), true)
|
||||||
out := structargs(method.Type.Results(), false)
|
out := structargs(method.Type.Results(), false)
|
||||||
|
|
||||||
t := Nod(OTFUNC, nil, nil)
|
t := nod(OTFUNC, nil, nil)
|
||||||
l := []*Node{this}
|
l := []*Node{this}
|
||||||
if iface != 0 && rcvr.Width < Types[Tptr].Width {
|
if iface != 0 && rcvr.Width < Types[Tptr].Width {
|
||||||
// Building method for interface table and receiver
|
// Building method for interface table and receiver
|
||||||
|
|
@ -1772,14 +1772,14 @@ func genwrapper(rcvr *Type, method *Field, newnam *Sym, iface int) {
|
||||||
// Add a dummy padding argument after the
|
// Add a dummy padding argument after the
|
||||||
// receiver to make up the difference.
|
// receiver to make up the difference.
|
||||||
tpad := typArray(Types[TUINT8], Types[Tptr].Width-rcvr.Width)
|
tpad := typArray(Types[TUINT8], Types[Tptr].Width-rcvr.Width)
|
||||||
pad := Nod(ODCLFIELD, newname(lookup(".pad")), typenod(tpad))
|
pad := nod(ODCLFIELD, newname(lookup(".pad")), typenod(tpad))
|
||||||
l = append(l, pad)
|
l = append(l, pad)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.List.Set(append(l, in...))
|
t.List.Set(append(l, in...))
|
||||||
t.Rlist.Set(out)
|
t.Rlist.Set(out)
|
||||||
|
|
||||||
fn := Nod(ODCLFUNC, nil, nil)
|
fn := nod(ODCLFUNC, nil, nil)
|
||||||
fn.Func.Nname = newname(newnam)
|
fn.Func.Nname = newname(newnam)
|
||||||
fn.Func.Nname.Name.Defn = fn
|
fn.Func.Nname.Name.Defn = fn
|
||||||
fn.Func.Nname.Name.Param.Ntype = t
|
fn.Func.Nname.Name.Param.Ntype = t
|
||||||
|
|
@ -1800,9 +1800,9 @@ func genwrapper(rcvr *Type, method *Field, newnam *Sym, iface int) {
|
||||||
// generate nil pointer check for better error
|
// generate nil pointer check for better error
|
||||||
if rcvr.IsPtr() && rcvr.Elem() == methodrcvr {
|
if rcvr.IsPtr() && rcvr.Elem() == methodrcvr {
|
||||||
// generating wrapper from *T to T.
|
// generating wrapper from *T to T.
|
||||||
n := Nod(OIF, nil, nil)
|
n := nod(OIF, nil, nil)
|
||||||
|
|
||||||
n.Left = Nod(OEQ, this.Left, nodnil())
|
n.Left = nod(OEQ, this.Left, nodnil())
|
||||||
|
|
||||||
// these strings are already in the reflect tables,
|
// these strings are already in the reflect tables,
|
||||||
// so no space cost to use them here.
|
// so no space cost to use them here.
|
||||||
|
|
@ -1815,7 +1815,7 @@ func genwrapper(rcvr *Type, method *Field, newnam *Sym, iface int) {
|
||||||
l = append(l, nodlit(v))
|
l = append(l, nodlit(v))
|
||||||
v.U = method.Sym.Name
|
v.U = method.Sym.Name
|
||||||
l = append(l, nodlit(v)) // method name
|
l = append(l, nodlit(v)) // method name
|
||||||
call := Nod(OCALL, syslook("panicwrap"), nil)
|
call := nod(OCALL, syslook("panicwrap"), nil)
|
||||||
call.List.Set(l)
|
call.List.Set(l)
|
||||||
n.Nbody.Set1(call)
|
n.Nbody.Set1(call)
|
||||||
fn.Nbody.Append(n)
|
fn.Nbody.Append(n)
|
||||||
|
|
@ -1835,21 +1835,21 @@ func genwrapper(rcvr *Type, method *Field, newnam *Sym, iface int) {
|
||||||
dot = dot.Left // skip final .M
|
dot = dot.Left // skip final .M
|
||||||
// TODO(mdempsky): Remove dependency on dotlist.
|
// TODO(mdempsky): Remove dependency on dotlist.
|
||||||
if !dotlist[0].field.Type.IsPtr() {
|
if !dotlist[0].field.Type.IsPtr() {
|
||||||
dot = Nod(OADDR, dot, nil)
|
dot = nod(OADDR, dot, nil)
|
||||||
}
|
}
|
||||||
as := Nod(OAS, this.Left, Nod(OCONVNOP, dot, nil))
|
as := nod(OAS, this.Left, nod(OCONVNOP, dot, nil))
|
||||||
as.Right.Type = rcvr
|
as.Right.Type = rcvr
|
||||||
fn.Nbody.Append(as)
|
fn.Nbody.Append(as)
|
||||||
n := Nod(ORETJMP, nil, nil)
|
n := nod(ORETJMP, nil, nil)
|
||||||
n.Left = newname(methodsym(method.Sym, methodrcvr, 0))
|
n.Left = newname(methodsym(method.Sym, methodrcvr, 0))
|
||||||
fn.Nbody.Append(n)
|
fn.Nbody.Append(n)
|
||||||
} else {
|
} else {
|
||||||
fn.Func.Wrapper = true // ignore frame for panic+recover matching
|
fn.Func.Wrapper = true // ignore frame for panic+recover matching
|
||||||
call := Nod(OCALL, dot, nil)
|
call := nod(OCALL, dot, nil)
|
||||||
call.List.Set(args)
|
call.List.Set(args)
|
||||||
call.Isddd = isddd
|
call.Isddd = isddd
|
||||||
if method.Type.Results().NumFields() > 0 {
|
if method.Type.Results().NumFields() > 0 {
|
||||||
n := Nod(ORETURN, nil, nil)
|
n := nod(ORETURN, nil, nil)
|
||||||
n.List.Set1(call)
|
n.List.Set1(call)
|
||||||
call = n
|
call = n
|
||||||
}
|
}
|
||||||
|
|
@ -1885,11 +1885,11 @@ func hashmem(t *Type) *Node {
|
||||||
|
|
||||||
n := newname(sym)
|
n := newname(sym)
|
||||||
n.Class = PFUNC
|
n.Class = PFUNC
|
||||||
tfn := Nod(OTFUNC, nil, nil)
|
tfn := nod(OTFUNC, nil, nil)
|
||||||
tfn.List.Append(Nod(ODCLFIELD, nil, typenod(ptrto(t))))
|
tfn.List.Append(nod(ODCLFIELD, nil, typenod(ptrto(t))))
|
||||||
tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
|
tfn.List.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
|
||||||
tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
|
tfn.List.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
|
||||||
tfn.Rlist.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
|
tfn.Rlist.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
|
||||||
tfn = typecheck(tfn, Etype)
|
tfn = typecheck(tfn, Etype)
|
||||||
n.Type = tfn.Type
|
n.Type = tfn.Type
|
||||||
return n
|
return n
|
||||||
|
|
@ -2031,7 +2031,7 @@ func listtreecopy(l []*Node, lineno int32) []*Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
func liststmt(l []*Node) *Node {
|
func liststmt(l []*Node) *Node {
|
||||||
n := Nod(OBLOCK, nil, nil)
|
n := nod(OBLOCK, nil, nil)
|
||||||
n.List.Set(l)
|
n.List.Set(l)
|
||||||
if len(l) != 0 {
|
if len(l) != 0 {
|
||||||
n.Lineno = l[0].Lineno
|
n.Lineno = l[0].Lineno
|
||||||
|
|
@ -2137,7 +2137,7 @@ func addinit(n *Node, init []*Node) *Node {
|
||||||
// There may be multiple refs to this node;
|
// There may be multiple refs to this node;
|
||||||
// introduce OCONVNOP to hold init list.
|
// introduce OCONVNOP to hold init list.
|
||||||
case ONAME, OLITERAL:
|
case ONAME, OLITERAL:
|
||||||
n = Nod(OCONVNOP, n, nil)
|
n = nod(OCONVNOP, n, nil)
|
||||||
n.Type = n.Left.Type
|
n.Type = n.Left.Type
|
||||||
n.Typecheck = 1
|
n.Typecheck = 1
|
||||||
}
|
}
|
||||||
|
|
@ -2198,11 +2198,11 @@ func isbadimport(path string) bool {
|
||||||
func checknil(x *Node, init *Nodes) {
|
func checknil(x *Node, init *Nodes) {
|
||||||
x = walkexpr(x, nil) // caller has not done this yet
|
x = walkexpr(x, nil) // caller has not done this yet
|
||||||
if x.Type.IsInterface() {
|
if x.Type.IsInterface() {
|
||||||
x = Nod(OITAB, x, nil)
|
x = nod(OITAB, x, nil)
|
||||||
x = typecheck(x, Erv)
|
x = typecheck(x, Erv)
|
||||||
}
|
}
|
||||||
|
|
||||||
n := Nod(OCHECKNIL, x, nil)
|
n := nod(OCHECKNIL, x, nil)
|
||||||
n.Typecheck = 1
|
n.Typecheck = 1
|
||||||
init.Append(n)
|
init.Append(n)
|
||||||
}
|
}
|
||||||
|
|
@ -2254,7 +2254,7 @@ func ifaceData(n *Node, t *Type) *Node {
|
||||||
ptr.Type = ptrto(t)
|
ptr.Type = ptrto(t)
|
||||||
ptr.Bounded = true
|
ptr.Bounded = true
|
||||||
ptr.Typecheck = 1
|
ptr.Typecheck = 1
|
||||||
ind := Nod(OIND, ptr, nil)
|
ind := nod(OIND, ptr, nil)
|
||||||
ind.Type = t
|
ind.Type = t
|
||||||
ind.Typecheck = 1
|
ind.Typecheck = 1
|
||||||
return ind
|
return ind
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ func (s *exprSwitch) walk(sw *Node) {
|
||||||
s.exprname = cond
|
s.exprname = cond
|
||||||
} else {
|
} else {
|
||||||
s.exprname = temp(cond.Type)
|
s.exprname = temp(cond.Type)
|
||||||
cas = []*Node{Nod(OAS, s.exprname, cond)}
|
cas = []*Node{nod(OAS, s.exprname, cond)}
|
||||||
typecheckslice(cas, Etop)
|
typecheckslice(cas, Etop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -295,26 +295,26 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node {
|
||||||
n := c.node
|
n := c.node
|
||||||
lno := setlineno(n)
|
lno := setlineno(n)
|
||||||
|
|
||||||
a := Nod(OIF, nil, nil)
|
a := nod(OIF, nil, nil)
|
||||||
if rng := n.List.Slice(); rng != nil {
|
if rng := n.List.Slice(); rng != nil {
|
||||||
// Integer range.
|
// Integer range.
|
||||||
// exprname is a temp or a constant,
|
// exprname is a temp or a constant,
|
||||||
// so it is safe to evaluate twice.
|
// so it is safe to evaluate twice.
|
||||||
// In most cases, this conjunction will be
|
// In most cases, this conjunction will be
|
||||||
// rewritten by walkinrange into a single comparison.
|
// rewritten by walkinrange into a single comparison.
|
||||||
low := Nod(OGE, s.exprname, rng[0])
|
low := nod(OGE, s.exprname, rng[0])
|
||||||
high := Nod(OLE, s.exprname, rng[1])
|
high := nod(OLE, s.exprname, rng[1])
|
||||||
a.Left = Nod(OANDAND, low, high)
|
a.Left = nod(OANDAND, low, high)
|
||||||
a.Left = typecheck(a.Left, Erv)
|
a.Left = typecheck(a.Left, Erv)
|
||||||
a.Left = walkexpr(a.Left, nil) // give walk the opportunity to optimize the range check
|
a.Left = walkexpr(a.Left, nil) // give walk the opportunity to optimize the range check
|
||||||
} else if (s.kind != switchKindTrue && s.kind != switchKindFalse) || assignop(n.Left.Type, s.exprname.Type, nil) == OCONVIFACE || assignop(s.exprname.Type, n.Left.Type, nil) == OCONVIFACE {
|
} else if (s.kind != switchKindTrue && s.kind != switchKindFalse) || assignop(n.Left.Type, s.exprname.Type, nil) == OCONVIFACE || assignop(s.exprname.Type, n.Left.Type, nil) == OCONVIFACE {
|
||||||
a.Left = Nod(OEQ, s.exprname, n.Left) // if name == val
|
a.Left = nod(OEQ, s.exprname, n.Left) // if name == val
|
||||||
a.Left = typecheck(a.Left, Erv)
|
a.Left = typecheck(a.Left, Erv)
|
||||||
} else if s.kind == switchKindTrue {
|
} else if s.kind == switchKindTrue {
|
||||||
a.Left = n.Left // if val
|
a.Left = n.Left // if val
|
||||||
} else {
|
} else {
|
||||||
// s.kind == switchKindFalse
|
// s.kind == switchKindFalse
|
||||||
a.Left = Nod(ONOT, n.Left, nil) // if !val
|
a.Left = nod(ONOT, n.Left, nil) // if !val
|
||||||
a.Left = typecheck(a.Left, Erv)
|
a.Left = typecheck(a.Left, Erv)
|
||||||
}
|
}
|
||||||
a.Nbody.Set1(n.Right) // goto l
|
a.Nbody.Set1(n.Right) // goto l
|
||||||
|
|
@ -327,7 +327,7 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node {
|
||||||
|
|
||||||
// find the middle and recur
|
// find the middle and recur
|
||||||
half := len(cc) / 2
|
half := len(cc) / 2
|
||||||
a := Nod(OIF, nil, nil)
|
a := nod(OIF, nil, nil)
|
||||||
n := cc[half-1].node
|
n := cc[half-1].node
|
||||||
var mid *Node
|
var mid *Node
|
||||||
if rng := n.List.Slice(); rng != nil {
|
if rng := n.List.Slice(); rng != nil {
|
||||||
|
|
@ -335,12 +335,12 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node {
|
||||||
} else {
|
} else {
|
||||||
mid = n.Left
|
mid = n.Left
|
||||||
}
|
}
|
||||||
le := Nod(OLE, s.exprname, mid)
|
le := nod(OLE, s.exprname, mid)
|
||||||
if Isconst(mid, CTSTR) {
|
if Isconst(mid, CTSTR) {
|
||||||
// Search by length and then by value; see caseClauseByConstVal.
|
// Search by length and then by value; see caseClauseByConstVal.
|
||||||
lenlt := Nod(OLT, Nod(OLEN, s.exprname, nil), Nod(OLEN, mid, nil))
|
lenlt := nod(OLT, nod(OLEN, s.exprname, nil), nod(OLEN, mid, nil))
|
||||||
leneq := Nod(OEQ, Nod(OLEN, s.exprname, nil), Nod(OLEN, mid, nil))
|
leneq := nod(OEQ, nod(OLEN, s.exprname, nil), nod(OLEN, mid, nil))
|
||||||
a.Left = Nod(OOROR, lenlt, Nod(OANDAND, leneq, le))
|
a.Left = nod(OOROR, lenlt, nod(OANDAND, leneq, le))
|
||||||
} else {
|
} else {
|
||||||
a.Left = le
|
a.Left = le
|
||||||
}
|
}
|
||||||
|
|
@ -363,7 +363,7 @@ func casebody(sw *Node, typeswvar *Node) {
|
||||||
var cas []*Node // cases
|
var cas []*Node // cases
|
||||||
var stat []*Node // statements
|
var stat []*Node // statements
|
||||||
var def *Node // defaults
|
var def *Node // defaults
|
||||||
br := Nod(OBREAK, nil, nil)
|
br := nod(OBREAK, nil, nil)
|
||||||
|
|
||||||
for i, n := range sw.List.Slice() {
|
for i, n := range sw.List.Slice() {
|
||||||
setlineno(n)
|
setlineno(n)
|
||||||
|
|
@ -373,7 +373,7 @@ func casebody(sw *Node, typeswvar *Node) {
|
||||||
n.Op = OCASE
|
n.Op = OCASE
|
||||||
needvar := n.List.Len() != 1 || n.List.First().Op == OLITERAL
|
needvar := n.List.Len() != 1 || n.List.First().Op == OLITERAL
|
||||||
|
|
||||||
jmp := Nod(OGOTO, autolabel(".s"), nil)
|
jmp := nod(OGOTO, autolabel(".s"), nil)
|
||||||
switch n.List.Len() {
|
switch n.List.Len() {
|
||||||
case 0:
|
case 0:
|
||||||
// default
|
// default
|
||||||
|
|
@ -394,7 +394,7 @@ func casebody(sw *Node, typeswvar *Node) {
|
||||||
if typeswvar != nil || sw.Left.Type.IsInterface() || !n.List.First().Type.IsInteger() || n.List.Len() < integerRangeMin {
|
if typeswvar != nil || sw.Left.Type.IsInterface() || !n.List.First().Type.IsInteger() || n.List.Len() < integerRangeMin {
|
||||||
// Can't use integer ranges. Expand each case into a separate node.
|
// Can't use integer ranges. Expand each case into a separate node.
|
||||||
for _, n1 := range n.List.Slice() {
|
for _, n1 := range n.List.Slice() {
|
||||||
cas = append(cas, Nod(OCASE, n1, jmp))
|
cas = append(cas, nod(OCASE, n1, jmp))
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -417,13 +417,13 @@ func casebody(sw *Node, typeswvar *Node) {
|
||||||
}
|
}
|
||||||
if end-beg >= integerRangeMin {
|
if end-beg >= integerRangeMin {
|
||||||
// Record range in List.
|
// Record range in List.
|
||||||
c := Nod(OCASE, nil, jmp)
|
c := nod(OCASE, nil, jmp)
|
||||||
c.List.Set2(search[beg], search[end-1])
|
c.List.Set2(search[beg], search[end-1])
|
||||||
cas = append(cas, c)
|
cas = append(cas, c)
|
||||||
} else {
|
} else {
|
||||||
// Not large enough for range; record separately.
|
// Not large enough for range; record separately.
|
||||||
for _, n := range search[beg:end] {
|
for _, n := range search[beg:end] {
|
||||||
cas = append(cas, Nod(OCASE, n, jmp))
|
cas = append(cas, nod(OCASE, n, jmp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
beg = end
|
beg = end
|
||||||
|
|
@ -433,16 +433,16 @@ func casebody(sw *Node, typeswvar *Node) {
|
||||||
// Advance to next constant, adding individual non-constant
|
// Advance to next constant, adding individual non-constant
|
||||||
// or as-yet-unhandled constant cases as we go.
|
// or as-yet-unhandled constant cases as we go.
|
||||||
for ; j < len(s) && (j < run || !Isconst(s[j], CTINT)); j++ {
|
for ; j < len(s) && (j < run || !Isconst(s[j], CTINT)); j++ {
|
||||||
cas = append(cas, Nod(OCASE, s[j], jmp))
|
cas = append(cas, nod(OCASE, s[j], jmp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stat = append(stat, Nod(OLABEL, jmp.Left, nil))
|
stat = append(stat, nod(OLABEL, jmp.Left, nil))
|
||||||
if typeswvar != nil && needvar && n.Rlist.Len() != 0 {
|
if typeswvar != nil && needvar && n.Rlist.Len() != 0 {
|
||||||
l := []*Node{
|
l := []*Node{
|
||||||
Nod(ODCL, n.Rlist.First(), nil),
|
nod(ODCL, n.Rlist.First(), nil),
|
||||||
Nod(OAS, n.Rlist.First(), typeswvar),
|
nod(OAS, n.Rlist.First(), typeswvar),
|
||||||
}
|
}
|
||||||
typecheckslice(l, Etop)
|
typecheckslice(l, Etop)
|
||||||
stat = append(stat, l...)
|
stat = append(stat, l...)
|
||||||
|
|
@ -502,7 +502,7 @@ func (s *exprSwitch) genCaseClauses(clauses []*Node) caseClauses {
|
||||||
}
|
}
|
||||||
|
|
||||||
if cc.defjmp == nil {
|
if cc.defjmp == nil {
|
||||||
cc.defjmp = Nod(OBREAK, nil, nil)
|
cc.defjmp = nod(OBREAK, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// diagnose duplicate cases
|
// diagnose duplicate cases
|
||||||
|
|
@ -542,7 +542,7 @@ func (s *typeSwitch) genCaseClauses(clauses []*Node) caseClauses {
|
||||||
}
|
}
|
||||||
|
|
||||||
if cc.defjmp == nil {
|
if cc.defjmp == nil {
|
||||||
cc.defjmp = Nod(OBREAK, nil, nil)
|
cc.defjmp = nod(OBREAK, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// diagnose duplicate cases
|
// diagnose duplicate cases
|
||||||
|
|
@ -689,7 +689,7 @@ func (s *typeSwitch) walk(sw *Node) {
|
||||||
// predeclare temporary variables and the boolean var
|
// predeclare temporary variables and the boolean var
|
||||||
s.facename = temp(cond.Right.Type)
|
s.facename = temp(cond.Right.Type)
|
||||||
|
|
||||||
a := Nod(OAS, s.facename, cond.Right)
|
a := nod(OAS, s.facename, cond.Right)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
cas = append(cas, a)
|
cas = append(cas, a)
|
||||||
|
|
||||||
|
|
@ -714,21 +714,21 @@ func (s *typeSwitch) walk(sw *Node) {
|
||||||
// Use a similar strategy for non-empty interfaces.
|
// Use a similar strategy for non-empty interfaces.
|
||||||
|
|
||||||
// Get interface descriptor word.
|
// Get interface descriptor word.
|
||||||
typ := Nod(OITAB, s.facename, nil)
|
typ := nod(OITAB, s.facename, nil)
|
||||||
|
|
||||||
// Check for nil first.
|
// Check for nil first.
|
||||||
i := Nod(OIF, nil, nil)
|
i := nod(OIF, nil, nil)
|
||||||
i.Left = Nod(OEQ, typ, nodnil())
|
i.Left = nod(OEQ, typ, nodnil())
|
||||||
if clauses.niljmp != nil {
|
if clauses.niljmp != nil {
|
||||||
// Do explicit nil case right here.
|
// Do explicit nil case right here.
|
||||||
i.Nbody.Set1(clauses.niljmp)
|
i.Nbody.Set1(clauses.niljmp)
|
||||||
} else {
|
} else {
|
||||||
// Jump to default case.
|
// Jump to default case.
|
||||||
lbl := autolabel(".s")
|
lbl := autolabel(".s")
|
||||||
i.Nbody.Set1(Nod(OGOTO, lbl, nil))
|
i.Nbody.Set1(nod(OGOTO, lbl, nil))
|
||||||
// Wrap default case with label.
|
// Wrap default case with label.
|
||||||
blk := Nod(OBLOCK, nil, nil)
|
blk := nod(OBLOCK, nil, nil)
|
||||||
blk.List.Set([]*Node{Nod(OLABEL, lbl, nil), def})
|
blk.List.Set([]*Node{nod(OLABEL, lbl, nil), def})
|
||||||
def = blk
|
def = blk
|
||||||
}
|
}
|
||||||
i.Left = typecheck(i.Left, Erv)
|
i.Left = typecheck(i.Left, Erv)
|
||||||
|
|
@ -744,7 +744,7 @@ func (s *typeSwitch) walk(sw *Node) {
|
||||||
h.Typecheck = 1
|
h.Typecheck = 1
|
||||||
h.Xoffset = int64(2 * Widthptr) // offset of hash in runtime._type
|
h.Xoffset = int64(2 * Widthptr) // offset of hash in runtime._type
|
||||||
h.Bounded = true // guaranteed not to fault
|
h.Bounded = true // guaranteed not to fault
|
||||||
a = Nod(OAS, s.hashname, h)
|
a = nod(OAS, s.hashname, h)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
cas = append(cas, a)
|
cas = append(cas, a)
|
||||||
|
|
||||||
|
|
@ -816,21 +816,21 @@ func (s *typeSwitch) typeone(t *Node) *Node {
|
||||||
nblank = typecheck(nblank, Erv|Easgn)
|
nblank = typecheck(nblank, Erv|Easgn)
|
||||||
} else {
|
} else {
|
||||||
name = t.Rlist.First()
|
name = t.Rlist.First()
|
||||||
init = []*Node{Nod(ODCL, name, nil)}
|
init = []*Node{nod(ODCL, name, nil)}
|
||||||
a := Nod(OAS, name, nil)
|
a := nod(OAS, name, nil)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
init = append(init, a)
|
init = append(init, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
a := Nod(OAS2, nil, nil)
|
a := nod(OAS2, nil, nil)
|
||||||
a.List.Set([]*Node{name, s.okname}) // name, ok =
|
a.List.Set([]*Node{name, s.okname}) // name, ok =
|
||||||
b := Nod(ODOTTYPE, s.facename, nil)
|
b := nod(ODOTTYPE, s.facename, nil)
|
||||||
b.Type = t.Left.Type // interface.(type)
|
b.Type = t.Left.Type // interface.(type)
|
||||||
a.Rlist.Set1(b)
|
a.Rlist.Set1(b)
|
||||||
a = typecheck(a, Etop)
|
a = typecheck(a, Etop)
|
||||||
init = append(init, a)
|
init = append(init, a)
|
||||||
|
|
||||||
c := Nod(OIF, nil, nil)
|
c := nod(OIF, nil, nil)
|
||||||
c.Left = s.okname
|
c.Left = s.okname
|
||||||
c.Nbody.Set1(t.Right) // if ok { goto l }
|
c.Nbody.Set1(t.Right) // if ok { goto l }
|
||||||
|
|
||||||
|
|
@ -846,8 +846,8 @@ func (s *typeSwitch) walkCases(cc []caseClause) *Node {
|
||||||
if !c.isconst {
|
if !c.isconst {
|
||||||
Fatalf("typeSwitch walkCases")
|
Fatalf("typeSwitch walkCases")
|
||||||
}
|
}
|
||||||
a := Nod(OIF, nil, nil)
|
a := nod(OIF, nil, nil)
|
||||||
a.Left = Nod(OEQ, s.hashname, nodintconst(int64(c.hash)))
|
a.Left = nod(OEQ, s.hashname, nodintconst(int64(c.hash)))
|
||||||
a.Left = typecheck(a.Left, Erv)
|
a.Left = typecheck(a.Left, Erv)
|
||||||
a.Nbody.Set1(n.Right)
|
a.Nbody.Set1(n.Right)
|
||||||
cas = append(cas, a)
|
cas = append(cas, a)
|
||||||
|
|
@ -857,8 +857,8 @@ func (s *typeSwitch) walkCases(cc []caseClause) *Node {
|
||||||
|
|
||||||
// find the middle and recur
|
// find the middle and recur
|
||||||
half := len(cc) / 2
|
half := len(cc) / 2
|
||||||
a := Nod(OIF, nil, nil)
|
a := nod(OIF, nil, nil)
|
||||||
a.Left = Nod(OLE, s.hashname, nodintconst(int64(cc[half-1].hash)))
|
a.Left = nod(OLE, s.hashname, nodintconst(int64(cc[half-1].hash)))
|
||||||
a.Left = typecheck(a.Left, Erv)
|
a.Left = typecheck(a.Left, Erv)
|
||||||
a.Nbody.Set1(s.walkCases(cc[:half]))
|
a.Nbody.Set1(s.walkCases(cc[:half]))
|
||||||
a.Rlist.Set1(s.walkCases(cc[half:]))
|
a.Rlist.Set1(s.walkCases(cc[half:]))
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ func TestCaseClauseByConstVal(t *testing.T) {
|
||||||
{nodlit(Val{"abc"}), nodlit(Val{"xyz"})},
|
{nodlit(Val{"abc"}), nodlit(Val{"xyz"})},
|
||||||
}
|
}
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
a := caseClause{node: Nod(OXXX, test.a, nil)}
|
a := caseClause{node: nod(OXXX, test.a, nil)}
|
||||||
b := caseClause{node: Nod(OXXX, test.b, nil)}
|
b := caseClause{node: nod(OXXX, test.b, nil)}
|
||||||
s := caseClauseByConstVal{a, b}
|
s := caseClauseByConstVal{a, b}
|
||||||
if less := s.Less(0, 1); !less {
|
if less := s.Less(0, 1); !less {
|
||||||
t.Errorf("%d: caseClauseByConstVal(%v, %v) = false", i, test.a, test.b)
|
t.Errorf("%d: caseClauseByConstVal(%v, %v) = false", i, test.a, test.b)
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ type Type struct {
|
||||||
methods Fields
|
methods Fields
|
||||||
allMethods Fields
|
allMethods Fields
|
||||||
|
|
||||||
Nod *Node // canonical OTYPE node
|
nod *Node // canonical OTYPE node
|
||||||
Orig *Type // original type (type literal or predefined type)
|
Orig *Type // original type (type literal or predefined type)
|
||||||
|
|
||||||
Sym *Sym // symbol containing name, for named types
|
Sym *Sym // symbol containing name, for named types
|
||||||
|
|
|
||||||
|
|
@ -618,7 +618,7 @@ OpSwitch:
|
||||||
|
|
||||||
dowidth(l.Type)
|
dowidth(l.Type)
|
||||||
if r.Type.IsInterface() == l.Type.IsInterface() || l.Type.Width >= 1<<16 {
|
if r.Type.IsInterface() == l.Type.IsInterface() || l.Type.Width >= 1<<16 {
|
||||||
l = Nod(aop, l, nil)
|
l = nod(aop, l, nil)
|
||||||
l.Type = r.Type
|
l.Type = r.Type
|
||||||
l.Typecheck = 1
|
l.Typecheck = 1
|
||||||
n.Left = l
|
n.Left = l
|
||||||
|
|
@ -640,7 +640,7 @@ OpSwitch:
|
||||||
|
|
||||||
dowidth(r.Type)
|
dowidth(r.Type)
|
||||||
if r.Type.IsInterface() == l.Type.IsInterface() || r.Type.Width >= 1<<16 {
|
if r.Type.IsInterface() == l.Type.IsInterface() || r.Type.Width >= 1<<16 {
|
||||||
r = Nod(aop, r, nil)
|
r = nod(aop, r, nil)
|
||||||
r.Type = l.Type
|
r.Type = l.Type
|
||||||
r.Typecheck = 1
|
r.Typecheck = 1
|
||||||
n.Right = r
|
n.Right = r
|
||||||
|
|
@ -1128,7 +1128,7 @@ OpSwitch:
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
n.Left = Nod(OADDR, n.Left, nil)
|
n.Left = nod(OADDR, n.Left, nil)
|
||||||
n.Left.Implicit = true
|
n.Left.Implicit = true
|
||||||
n.Left = typecheck(n.Left, Erv)
|
n.Left = typecheck(n.Left, Erv)
|
||||||
l = n.Left
|
l = n.Left
|
||||||
|
|
@ -1697,7 +1697,7 @@ OpSwitch:
|
||||||
switch n.Op {
|
switch n.Op {
|
||||||
case OCONVNOP:
|
case OCONVNOP:
|
||||||
if n.Left.Op == OLITERAL {
|
if n.Left.Op == OLITERAL {
|
||||||
r := Nod(OXXX, nil, nil)
|
r := nod(OXXX, nil, nil)
|
||||||
n.Op = OCONV
|
n.Op = OCONV
|
||||||
n.Orig = r
|
n.Orig = r
|
||||||
*r = *n
|
*r = *n
|
||||||
|
|
@ -2260,7 +2260,7 @@ func implicitstar(n *Node) *Node {
|
||||||
if !t.IsArray() {
|
if !t.IsArray() {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
n = Nod(OIND, n, nil)
|
n = nod(OIND, n, nil)
|
||||||
n.Implicit = true
|
n.Implicit = true
|
||||||
n = typecheck(n, Erv)
|
n = typecheck(n, Erv)
|
||||||
return n
|
return n
|
||||||
|
|
@ -2440,7 +2440,7 @@ func lookdot(n *Node, t *Type, dostrcmp int) *Field {
|
||||||
}
|
}
|
||||||
if t.IsInterface() {
|
if t.IsInterface() {
|
||||||
if n.Left.Type.IsPtr() {
|
if n.Left.Type.IsPtr() {
|
||||||
n.Left = Nod(OIND, n.Left, nil) // implicitstar
|
n.Left = nod(OIND, n.Left, nil) // implicitstar
|
||||||
n.Left.Implicit = true
|
n.Left.Implicit = true
|
||||||
n.Left = typecheck(n.Left, Erv)
|
n.Left = typecheck(n.Left, Erv)
|
||||||
}
|
}
|
||||||
|
|
@ -2462,11 +2462,11 @@ func lookdot(n *Node, t *Type, dostrcmp int) *Field {
|
||||||
if !eqtype(rcvr, tt) {
|
if !eqtype(rcvr, tt) {
|
||||||
if rcvr.Etype == Tptr && eqtype(rcvr.Elem(), tt) {
|
if rcvr.Etype == Tptr && eqtype(rcvr.Elem(), tt) {
|
||||||
checklvalue(n.Left, "call pointer method on")
|
checklvalue(n.Left, "call pointer method on")
|
||||||
n.Left = Nod(OADDR, n.Left, nil)
|
n.Left = nod(OADDR, n.Left, nil)
|
||||||
n.Left.Implicit = true
|
n.Left.Implicit = true
|
||||||
n.Left = typecheck(n.Left, Etype|Erv)
|
n.Left = typecheck(n.Left, Etype|Erv)
|
||||||
} else if tt.Etype == Tptr && rcvr.Etype != Tptr && eqtype(tt.Elem(), rcvr) {
|
} else if tt.Etype == Tptr && rcvr.Etype != Tptr && eqtype(tt.Elem(), rcvr) {
|
||||||
n.Left = Nod(OIND, n.Left, nil)
|
n.Left = nod(OIND, n.Left, nil)
|
||||||
n.Left.Implicit = true
|
n.Left.Implicit = true
|
||||||
n.Left = typecheck(n.Left, Etype|Erv)
|
n.Left = typecheck(n.Left, Etype|Erv)
|
||||||
} else if tt.Etype == Tptr && tt.Elem().Etype == Tptr && eqtype(derefall(tt), derefall(rcvr)) {
|
} else if tt.Etype == Tptr && tt.Elem().Etype == Tptr && eqtype(derefall(tt), derefall(rcvr)) {
|
||||||
|
|
@ -2476,7 +2476,7 @@ func lookdot(n *Node, t *Type, dostrcmp int) *Field {
|
||||||
if rcvr.Etype == Tptr && tt.Elem().Etype != Tptr {
|
if rcvr.Etype == Tptr && tt.Elem().Etype != Tptr {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
n.Left = Nod(OIND, n.Left, nil)
|
n.Left = nod(OIND, n.Left, nil)
|
||||||
n.Left.Implicit = true
|
n.Left.Implicit = true
|
||||||
n.Left = typecheck(n.Left, Etype|Erv)
|
n.Left = typecheck(n.Left, Etype|Erv)
|
||||||
tt = tt.Elem()
|
tt = tt.Elem()
|
||||||
|
|
@ -2849,7 +2849,7 @@ func typecheckcomplit(n *Node) *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save original node (including n->right)
|
// Save original node (including n->right)
|
||||||
norig := Nod(n.Op, nil, nil)
|
norig := nod(n.Op, nil, nil)
|
||||||
|
|
||||||
*norig = *n
|
*norig = *n
|
||||||
|
|
||||||
|
|
@ -2905,7 +2905,7 @@ func typecheckcomplit(n *Node) *Node {
|
||||||
l := n2
|
l := n2
|
||||||
setlineno(l)
|
setlineno(l)
|
||||||
if l.Op != OKEY {
|
if l.Op != OKEY {
|
||||||
l = Nod(OKEY, nodintconst(int64(i)), l)
|
l = nod(OKEY, nodintconst(int64(i)), l)
|
||||||
l.Left.Type = Types[TINT]
|
l.Left.Type = Types[TINT]
|
||||||
l.Left.Typecheck = 1
|
l.Left.Typecheck = 1
|
||||||
n.List.SetIndex(i2, l)
|
n.List.SetIndex(i2, l)
|
||||||
|
|
@ -3009,7 +3009,7 @@ func typecheckcomplit(n *Node) *Node {
|
||||||
}
|
}
|
||||||
// No pushtype allowed here. Must name fields for that.
|
// No pushtype allowed here. Must name fields for that.
|
||||||
n1 = assignconv(n1, f.Type, "field value")
|
n1 = assignconv(n1, f.Type, "field value")
|
||||||
n1 = Nod(OKEY, newname(f.Sym), n1)
|
n1 = nod(OKEY, newname(f.Sym), n1)
|
||||||
n1.Left.Type = structkey
|
n1.Left.Type = structkey
|
||||||
n1.Left.Xoffset = f.Offset
|
n1.Left.Xoffset = f.Offset
|
||||||
n1.Left.Typecheck = 1
|
n1.Left.Typecheck = 1
|
||||||
|
|
@ -3089,7 +3089,7 @@ func typecheckcomplit(n *Node) *Node {
|
||||||
|
|
||||||
n.Orig = norig
|
n.Orig = norig
|
||||||
if n.Type.IsPtr() {
|
if n.Type.IsPtr() {
|
||||||
n = Nod(OPTRLIT, n, nil)
|
n = nod(OPTRLIT, n, nil)
|
||||||
n.Typecheck = 1
|
n.Typecheck = 1
|
||||||
n.Type = n.Left.Type
|
n.Type = n.Left.Type
|
||||||
n.Left.Type = t
|
n.Left.Type = t
|
||||||
|
|
@ -3416,18 +3416,18 @@ func stringtoarraylit(n *Node) *Node {
|
||||||
if n.Type.Elem().Etype == TUINT8 {
|
if n.Type.Elem().Etype == TUINT8 {
|
||||||
// []byte
|
// []byte
|
||||||
for i := 0; i < len(s); i++ {
|
for i := 0; i < len(s); i++ {
|
||||||
l = append(l, Nod(OKEY, nodintconst(int64(i)), nodintconst(int64(s[0]))))
|
l = append(l, nod(OKEY, nodintconst(int64(i)), nodintconst(int64(s[0]))))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// []rune
|
// []rune
|
||||||
i := 0
|
i := 0
|
||||||
for _, r := range s {
|
for _, r := range s {
|
||||||
l = append(l, Nod(OKEY, nodintconst(int64(i)), nodintconst(int64(r))))
|
l = append(l, nod(OKEY, nodintconst(int64(i)), nodintconst(int64(r))))
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nn := Nod(OCOMPLIT, nil, typenod(n.Type))
|
nn := nod(OCOMPLIT, nil, typenod(n.Type))
|
||||||
nn.List.Set(l)
|
nn.List.Set(l)
|
||||||
nn = typecheck(nn, Erv)
|
nn = typecheck(nn, Erv)
|
||||||
return nn
|
return nn
|
||||||
|
|
@ -3444,7 +3444,7 @@ func domethod(n *Node) {
|
||||||
// type check failed; leave empty func
|
// type check failed; leave empty func
|
||||||
// TODO(mdempsky): Fix Type rekinding.
|
// TODO(mdempsky): Fix Type rekinding.
|
||||||
n.Type.Etype = TFUNC
|
n.Type.Etype = TFUNC
|
||||||
n.Type.Nod = nil
|
n.Type.nod = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3464,7 +3464,7 @@ func domethod(n *Node) {
|
||||||
|
|
||||||
// TODO(mdempsky): Fix Type rekinding.
|
// TODO(mdempsky): Fix Type rekinding.
|
||||||
*n.Type = *nt.Type
|
*n.Type = *nt.Type
|
||||||
n.Type.Nod = nil
|
n.Type.nod = nil
|
||||||
checkwidth(n.Type)
|
checkwidth(n.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3497,7 +3497,7 @@ func copytype(n *Node, t *Type) {
|
||||||
}
|
}
|
||||||
t.methods = Fields{}
|
t.methods = Fields{}
|
||||||
t.allMethods = Fields{}
|
t.allMethods = Fields{}
|
||||||
t.Nod = nil
|
t.nod = nil
|
||||||
t.Deferwidth = false
|
t.Deferwidth = false
|
||||||
|
|
||||||
// Update nodes waiting on this type.
|
// Update nodes waiting on this type.
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ func lexinit() {
|
||||||
for _, s := range builtinFuncs {
|
for _, s := range builtinFuncs {
|
||||||
// TODO(marvin): Fix Node.EType type union.
|
// TODO(marvin): Fix Node.EType type union.
|
||||||
s2 := Pkglookup(s.name, builtinpkg)
|
s2 := Pkglookup(s.name, builtinpkg)
|
||||||
s2.Def = Nod(ONAME, nil, nil)
|
s2.Def = nod(ONAME, nil, nil)
|
||||||
s2.Def.Sym = s2
|
s2.Def.Sym = s2
|
||||||
s2.Def.Etype = EType(s.op)
|
s2.Def.Etype = EType(s.op)
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +116,7 @@ func lexinit() {
|
||||||
|
|
||||||
s = lookup("_")
|
s = lookup("_")
|
||||||
s.Block = -100
|
s.Block = -100
|
||||||
s.Def = Nod(ONAME, nil, nil)
|
s.Def = nod(ONAME, nil, nil)
|
||||||
s.Def.Sym = s
|
s.Def.Sym = s
|
||||||
Types[TBLANK] = typ(TBLANK)
|
Types[TBLANK] = typ(TBLANK)
|
||||||
s.Def.Type = Types[TBLANK]
|
s.Def.Type = Types[TBLANK]
|
||||||
|
|
@ -124,7 +124,7 @@ func lexinit() {
|
||||||
|
|
||||||
s = Pkglookup("_", builtinpkg)
|
s = Pkglookup("_", builtinpkg)
|
||||||
s.Block = -100
|
s.Block = -100
|
||||||
s.Def = Nod(ONAME, nil, nil)
|
s.Def = nod(ONAME, nil, nil)
|
||||||
s.Def.Sym = s
|
s.Def.Sym = s
|
||||||
Types[TBLANK] = typ(TBLANK)
|
Types[TBLANK] = typ(TBLANK)
|
||||||
s.Def.Type = Types[TBLANK]
|
s.Def.Type = Types[TBLANK]
|
||||||
|
|
@ -138,7 +138,7 @@ func lexinit() {
|
||||||
s.Def.Name = new(Name)
|
s.Def.Name = new(Name)
|
||||||
|
|
||||||
s = Pkglookup("iota", builtinpkg)
|
s = Pkglookup("iota", builtinpkg)
|
||||||
s.Def = Nod(OIOTA, nil, nil)
|
s.Def = nod(OIOTA, nil, nil)
|
||||||
s.Def.Sym = s
|
s.Def.Sym = s
|
||||||
s.Def.Name = new(Name)
|
s.Def.Name = new(Name)
|
||||||
}
|
}
|
||||||
|
|
@ -457,7 +457,7 @@ func finishUniverse() {
|
||||||
s1.Block = s.Block
|
s1.Block = s.Block
|
||||||
}
|
}
|
||||||
|
|
||||||
nodfp = Nod(ONAME, nil, nil)
|
nodfp = nod(ONAME, nil, nil)
|
||||||
nodfp.Type = Types[TINT32]
|
nodfp.Type = Types[TINT32]
|
||||||
nodfp.Xoffset = 0
|
nodfp.Xoffset = 0
|
||||||
nodfp.Class = PPARAM
|
nodfp.Class = PPARAM
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ ret:
|
||||||
var val Val
|
var val Val
|
||||||
val.U = new(Mpint)
|
val.U = new(Mpint)
|
||||||
val.U.(*Mpint).SetInt64(v)
|
val.U.(*Mpint).SetInt64(v)
|
||||||
n := Nod(OLITERAL, nil, nil)
|
n := nod(OLITERAL, nil, nil)
|
||||||
n.Orig = nn
|
n.Orig = nn
|
||||||
n.SetVal(val)
|
n.SetVal(val)
|
||||||
n.Type = Types[TUINTPTR]
|
n.Type = Types[TUINTPTR]
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1854,7 +1854,7 @@ func (p *parser) commClause() *CommClause {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(gri) find a better solution
|
// TODO(gri) find a better solution
|
||||||
var missing_stmt Stmt = new(EmptyStmt) // = Nod(OXXX, nil, nil)
|
var missing_stmt Stmt = new(EmptyStmt) // = nod(OXXX, nil, nil)
|
||||||
|
|
||||||
// Statement =
|
// Statement =
|
||||||
// Declaration | LabeledStmt | SimpleStmt |
|
// Declaration | LabeledStmt | SimpleStmt |
|
||||||
|
|
@ -1921,7 +1921,7 @@ func (p *parser) stmt() Stmt {
|
||||||
s.Tok = _Fallthrough
|
s.Tok = _Fallthrough
|
||||||
return s
|
return s
|
||||||
// // will be converted to OFALL
|
// // will be converted to OFALL
|
||||||
// stmt := Nod(OXFALL, nil, nil)
|
// stmt := nod(OXFALL, nil, nil)
|
||||||
// stmt.Xoffset = int64(block)
|
// stmt.Xoffset = int64(block)
|
||||||
// return stmt
|
// return stmt
|
||||||
|
|
||||||
|
|
@ -1946,7 +1946,7 @@ func (p *parser) stmt() Stmt {
|
||||||
s.Tok = _Goto
|
s.Tok = _Goto
|
||||||
s.Label = p.name()
|
s.Label = p.name()
|
||||||
return s
|
return s
|
||||||
// stmt := Nod(OGOTO, p.new_name(p.name()), nil)
|
// stmt := nod(OGOTO, p.new_name(p.name()), nil)
|
||||||
// stmt.Sym = dclstack // context, for goto restrictions
|
// stmt.Sym = dclstack // context, for goto restrictions
|
||||||
// return stmt
|
// return stmt
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue