// for fninit and set lineno to NoPos here.
// TODO(gri) fix this once we switched permanently to the new
// position information.
- lineno = MakePos(p.file.Pos().Base(), uint(p.file.Lines), 0)
+ lineno = makePos(p.file.Pos().Base(), uint(p.file.Lines), 0)
clearImports()
}
yyerror("can only use //go:noescape with external func implementations")
}
f.Func.Pragma = pragma
- lineno = MakePos(fun.Pos().Base(), fun.EndLine, 0)
+ lineno = makePos(fun.Pos().Base(), fun.EndLine, 0)
f.Func.Endlineno = lineno
funcbody(f)
l[i] = p.wrapname(expr.ElemList[i], e)
}
n.List.Set(l)
- lineno = MakePos(expr.Pos().Base(), expr.EndLine, 0)
+ lineno = makePos(expr.Pos().Base(), expr.EndLine, 0)
return n
case *syntax.KeyValueExpr:
return p.nod(expr, OKEY, p.expr(expr.Key), p.wrapname(expr.Value, p.expr(expr.Value)))
case *syntax.FuncLit:
closurehdr(p.typeExpr(expr.Type))
body := p.stmts(expr.Body)
- lineno = MakePos(expr.Pos().Base(), expr.EndLine, 0)
+ lineno = makePos(expr.Pos().Base(), expr.EndLine, 0)
return p.setlineno(expr, closurebody(body))
case *syntax.ParenExpr:
return p.nod(expr, OPAREN, p.expr(expr.X), nil)
return c
}
-func Nodconst(n *Node, t *Type, v int64) {
+func nodconst(n *Node, t *Type, v int64) {
*n = Node{}
n.Op = OLITERAL
n.Addable = true
fmt.Printf("genwrapper rcvrtype=%v method=%v newnam=%v\n", rcvr, method, newnam)
}
- lineno = MakePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0)
+ lineno = makePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0)
dclcontext = PEXTERN
markdcl()
return true
}
-// even simpler simtype; get rid of ptr, bool.
-// assuming that the front end has rejected
-// all the invalid conversions (like ptr -> bool)
-func Simsimtype(t *Type) EType {
- if t == nil {
- return 0
- }
-
- et := simtype[t.Etype]
- switch et {
- case TPTR32:
- et = TUINT32
-
- case TPTR64:
- et = TUINT64
-
- case TBOOL:
- et = TUINT8
- }
-
- return et
-}
-
func listtreecopy(l []*Node, pos src.XPos) []*Node {
var out []*Node
for _, n := range l {
}
if t.IsArray() {
safeexpr(n.Left, init)
- Nodconst(n, n.Type, t.NumElem())
+ nodconst(n, n.Type, t.NumElem())
n.Typecheck = 1
}
case TUINT8, TUINT16, TUINT32:
var nc Node
- Nodconst(&nc, nl.Type, int64(m.Um))
+ nodconst(&nc, nl.Type, int64(m.Um))
n1 := nod(OHMUL, nl, &nc)
n1 = typecheck(n1, Erv)
if m.Ua != 0 {
// shift by m.s
var nc Node
- Nodconst(&nc, Types[TUINT], int64(m.S))
+ nodconst(&nc, Types[TUINT], int64(m.S))
n = conv(nod(ORSH, n2, &nc), nl.Type)
} else {
// n = n1 >> m.s
var nc Node
- Nodconst(&nc, Types[TUINT], int64(m.S))
+ nodconst(&nc, Types[TUINT], int64(m.S))
n = nod(ORSH, n1, &nc)
}
case TINT8, TINT16, TINT32:
var nc Node
- Nodconst(&nc, nl.Type, m.Sm)
+ nodconst(&nc, nl.Type, m.Sm)
n1 := nod(OHMUL, nl, &nc)
n1 = typecheck(n1, Erv)
if m.Sm < 0 {
// shift by m.s
var ns Node
- Nodconst(&ns, Types[TUINT], int64(m.S))
+ nodconst(&ns, Types[TUINT], int64(m.S))
n2 := conv(nod(ORSH, n1, &ns), nl.Type)
// add 1 iff n1 is negative.
var nneg Node
- Nodconst(&nneg, Types[TUINT], int64(w)-1)
+ nodconst(&nneg, Types[TUINT], int64(w)-1)
n3 := nod(ORSH, nl, &nneg) // n4 = -1 iff n1 is negative.
n = nod(OSUB, n2, n3)
case 0:
if n.Op == OMOD {
// nl % 1 is zero.
- Nodconst(n, n.Type, 0)
+ nodconst(n, n.Type, 0)
} else if s != 0 {
// divide by -1
n.Op = OMINUS
// nl & (2^pow-1) is (nl+1)%2^pow - 1.
var nc Node
- Nodconst(&nc, Types[simtype[TUINT]], int64(w)-1)
+ nodconst(&nc, Types[simtype[TUINT]], int64(w)-1)
n1 := nod(ORSH, nl, &nc) // n1 = -1 iff nl < 0.
if pow == 1 {
n1 = typecheck(n1, Erv)
n2 := nod(OSUB, nl, n1)
var nc Node
- Nodconst(&nc, nl.Type, 1)
+ nodconst(&nc, nl.Type, 1)
n3 := nod(OAND, n2, &nc)
n = nod(OADD, n3, n1)
} else {
// n = (nl+ε)&(nr-1) - ε where ε=2^pow-1 iff nl<0.
var nc Node
- Nodconst(&nc, nl.Type, (1<<uint(pow))-1)
+ nodconst(&nc, nl.Type, (1<<uint(pow))-1)
n2 := nod(OAND, n1, &nc) // n2 = 2^pow-1 iff nl<0.
n2 = typecheck(n2, Erv)
n2 = cheapexpr(n2, init)
// if nl < 0, we want to add 2^n-1 first.
var nc Node
- Nodconst(&nc, Types[simtype[TUINT]], int64(w)-1)
+ nodconst(&nc, Types[simtype[TUINT]], int64(w)-1)
n1 := nod(ORSH, nl, &nc) // n1 = -1 iff nl < 0.
if pow == 1 {
// nl+1 is nl-(-1)
// Do a logical right right on -1 to keep pow bits.
var nc Node
- Nodconst(&nc, Types[simtype[TUINT]], int64(w)-int64(pow))
+ nodconst(&nc, Types[simtype[TUINT]], int64(w)-int64(pow))
n2 := nod(ORSH, conv(n1, nl.Type.toUnsigned()), &nc)
n.Left = nod(OADD, nl, conv(n2, nl.Type))
}
n.Op = ORSH
var n2 Node
- Nodconst(&n2, Types[simtype[TUINT]], int64(pow))
+ nodconst(&n2, Types[simtype[TUINT]], int64(pow))
n.Right = &n2
n.Typecheck = 0
}
// n = nl & (nr-1)
n.Op = OAND
- Nodconst(&nc, nl.Type, nr.Int64()-1)
+ nodconst(&nc, nl.Type, nr.Int64()-1)
} else {
// n = nl >> pow
n.Op = ORSH
- Nodconst(&nc, Types[simtype[TUINT]], int64(pow))
+ nodconst(&nc, Types[simtype[TUINT]], int64(pow))
}
n.Typecheck = 0