t0 := t
check := false
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
check = true
if gc.Isconst(nl, gc.CTINT) && nl.Int() != -(1<<uint64(t.Width*8-1)) {
check = false
}
if t.Width < 4 {
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
t = gc.Types[gc.TINT32]
} else {
t = gc.Types[gc.TUINT32]
var olddx gc.Node
var dx gc.Node
savex(x86.REG_DX, &dx, &olddx, res, t)
- if !gc.Issigned[t.Etype] {
+ if !t.IsSigned() {
gc.Nodconst(&n4, t, 0)
gmove(&n4, &dx)
} else {
gc.Nodconst(&n3, tcount, nl.Type.Width*8)
gins(optoas(gc.OCMP, tcount), &n1, &n3)
p1 := gc.Gbranch(optoas(gc.OLT, tcount), nil, +1)
- if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
+ if op == gc.ORSH && nl.Type.IsSigned() {
gc.Nodconst(&n3, gc.Types[gc.TUINT32], nl.Type.Width*8-1)
gins(a, &n3, &n2)
} else {
// perform full-width multiplication.
t := gc.Types[gc.TUINT64]
- if gc.Issigned[nl.Type.Etype] {
+ if nl.Type.IsSigned() {
t = gc.Types[gc.TINT64]
}
var n1 gc.Node
}
func ginscmp(op gc.Op, t *gc.Type, n1, n2 *gc.Node, likely int) *obj.Prog {
- if gc.Isint[t.Etype] && n1.Op == gc.OLITERAL && gc.Smallintconst(n1) && n2.Op != gc.OLITERAL {
+ if t.IsInteger() && n1.Op == gc.OLITERAL && gc.Smallintconst(n1) && n2.Op != gc.OLITERAL {
// Reverse comparison to place constant last.
op = gc.Brrev(op)
n1, n2 = n2, n1
gc.Cgen(n1, &g1)
gmove(&g1, &r1)
}
- if n2.Op == gc.OLITERAL && gc.Isint[t.Etype] && gc.Smallintconst(n2) {
+ if n2.Op == gc.OLITERAL && t.IsInteger() && gc.Smallintconst(n2) {
r2 = *n2
} else {
gc.Regalloc(&r2, t, n2)
case gc.TINT32,
gc.TUINT32:
var p *obj.Prog
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
p = gins(arm.AMULL, &n2, nil)
} else {
p = gins(arm.AMULLU, &n2, nil)
if sc == 0 {
} else // nothing to do
if sc >= uint64(nl.Type.Width*8) {
- if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
+ if op == gc.ORSH && nl.Type.IsSigned() {
gshift(arm.AMOVW, &n1, arm.SHIFT_AR, int32(w), &n1)
} else {
gins(arm.AEOR, &n1, &n1)
}
} else {
- if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
+ if op == gc.ORSH && nl.Type.IsSigned() {
gshift(arm.AMOVW, &n1, arm.SHIFT_AR, int32(sc), &n1)
} else if op == gc.ORSH {
gshift(arm.AMOVW, &n1, arm.SHIFT_LR, int32(sc), &n1) // OLSH
if op == gc.ORSH {
var p1 *obj.Prog
var p2 *obj.Prog
- if gc.Issigned[nl.Type.Etype] {
+ if nl.Type.IsSigned() {
p1 = gshift(arm.AMOVW, &n2, arm.SHIFT_AR, int32(w)-1, &n2)
p2 = gregshift(arm.AMOVW, &n2, arm.SHIFT_AR, &n1, &n2)
} else {
}
func ginscmp(op gc.Op, t *gc.Type, n1, n2 *gc.Node, likely int) *obj.Prog {
- if gc.Isint[t.Etype] && n1.Op == gc.OLITERAL && n1.Int() == 0 && n2.Op != gc.OLITERAL {
+ if t.IsInteger() && n1.Op == gc.OLITERAL && n1.Int() == 0 && n2.Op != gc.OLITERAL {
op = gc.Brrev(op)
n1, n2 = n2, n1
}
gc.Regalloc(&g1, n1.Type, &r1)
gc.Cgen(n1, &g1)
gmove(&g1, &r1)
- if gc.Isint[t.Etype] && n2.Op == gc.OLITERAL && n2.Int() == 0 {
+ if t.IsInteger() && n2.Op == gc.OLITERAL && n2.Int() == 0 {
gins(arm.ACMP, &r1, n2)
} else {
gc.Regalloc(&r2, t, n2)
t0 := t
check := false
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
check = true
if gc.Isconst(nl, gc.CTINT) && nl.Int() != -(1<<uint64(t.Width*8-1)) {
check = false
}
if t.Width < 8 {
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
t = gc.Types[gc.TINT64]
} else {
t = gc.Types[gc.TUINT64]
case gc.TINT64,
gc.TUINT64:
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
gins(arm64.ASMULH, &n2, &n1)
} else {
gins(arm64.AUMULH, &n2, &n1)
gc.Nodconst(&n3, tcount, nl.Type.Width*8)
gcmp(optoas(gc.OCMP, tcount), &n1, &n3)
p1 := gc.Gbranch(optoas(gc.OLT, tcount), nil, +1)
- if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
+ if op == gc.ORSH && nl.Type.IsSigned() {
gc.Nodconst(&n3, gc.Types[gc.TUINT32], nl.Type.Width*8-1)
gins(a, &n3, &n2)
} else {
}
func ginscmp(op gc.Op, t *gc.Type, n1, n2 *gc.Node, likely int) *obj.Prog {
- if gc.Isint[t.Etype] && n1.Op == gc.OLITERAL && n2.Op != gc.OLITERAL {
+ if t.IsInteger() && n1.Op == gc.OLITERAL && n2.Op != gc.OLITERAL {
// Reverse comparison to place constant last.
op = gc.Brrev(op)
n1, n2 = n2, n1
gc.Regalloc(&g1, n1.Type, &r1)
gc.Cgen(n1, &g1)
gmove(&g1, &r1)
- if gc.Isint[t.Etype] && gc.Isconst(n2, gc.CTINT) {
+ if t.IsInteger() && gc.Isconst(n2, gc.CTINT) {
ginscon2(optoas(gc.OCMP, t), &r1, n2.Int())
} else {
gc.Regalloc(&r2, t, n2)
func basetypeName(t *Type) string {
s := t.Sym
- if s == nil && Isptr[t.Etype] {
+ if s == nil && t.IsPtr() {
s = t.Elem().Sym // deref
}
if s != nil {
} else {
// anonymous field - typ must be T or *T and T must be a type name
s := typ.Sym
- if s == nil && Isptr[typ.Etype] {
+ if s == nil && typ.IsPtr() {
s = typ.Type.Sym // deref
}
pkg := importpkg
case floatTag:
f := newMpflt()
p.float(f)
- if typ == idealint || Isint[typ.Etype] {
+ if typ == idealint || typ.IsInteger() {
// uncommon case: large int encoded as float
u := new(Mpint)
u.SetFloat(f)
f = false
}
- if !Iscomplex[n.Type.Etype] && Ctxt.Arch.Regsize == 8 && !wb {
+ if !n.Type.IsComplex() && Ctxt.Arch.Regsize == 8 && !wb {
a := Thearch.Optoas(OAS, res.Type)
var addr obj.Addr
if Thearch.Sudoaddable(a, res, &addr) {
if Ctxt.Arch.Thechar == '5' { // TODO(rsc): Maybe more often?
// if both are addressable, move
if n.Addable && res.Addable {
- if Is64(n.Type) || Is64(res.Type) || n.Op == OREGISTER || res.Op == OREGISTER || Iscomplex[n.Type.Etype] || Iscomplex[res.Type.Etype] {
+ if Is64(n.Type) || Is64(res.Type) || n.Op == OREGISTER || res.Op == OREGISTER || n.Type.IsComplex() || res.Type.IsComplex() {
Thearch.Gmove(n, res)
} else {
var n1 Node
}
// if n is sudoaddable generate addr and move
- if Ctxt.Arch.Thechar == '5' && !Is64(n.Type) && !Is64(res.Type) && !Iscomplex[n.Type.Etype] && !Iscomplex[res.Type.Etype] {
+ if Ctxt.Arch.Thechar == '5' && !Is64(n.Type) && !Is64(res.Type) && !n.Type.IsComplex() && !res.Type.IsComplex() {
a := Thearch.Optoas(OAS, n.Type)
var addr obj.Addr
if Thearch.Sudoaddable(a, n, &addr) {
}
}
- if Thearch.Cgen_float != nil && nl != nil && Isfloat[n.Type.Etype] && Isfloat[nl.Type.Etype] {
+ if Thearch.Cgen_float != nil && nl != nil && n.Type.IsFloat() && nl.Type.IsFloat() {
Thearch.Cgen_float(n, res)
return
}
- if !Iscomplex[n.Type.Etype] && Ctxt.Arch.Regsize == 8 {
+ if !n.Type.IsComplex() && Ctxt.Arch.Regsize == 8 {
a := Thearch.Optoas(OAS, n.Type)
var addr obj.Addr
if Thearch.Sudoaddable(a, n, &addr) {
return
case OMINUS:
- if Isfloat[nl.Type.Etype] {
+ if nl.Type.IsFloat() {
nr = Nodintconst(-1)
nr = convlit(nr, n.Type)
a = Thearch.Optoas(OMUL, nl.Type)
Regalloc(&n1, nl.Type, res)
Thearch.Gmove(nl, &n1)
} else {
- if n.Type.Width > int64(Widthptr) || Is64(nl.Type) || Isfloat[nl.Type.Etype] {
+ if n.Type.Width > int64(Widthptr) || Is64(nl.Type) || nl.Type.IsFloat() {
Tempname(&n1, nl.Type)
} else {
Regalloc(&n1, nl.Type, res)
}
Cgen(nl, &n1)
}
- if n.Type.Width > int64(Widthptr) || Is64(n.Type) || Isfloat[n.Type.Etype] {
+ if n.Type.Width > int64(Widthptr) || Is64(n.Type) || n.Type.IsFloat() {
Tempname(&n2, n.Type)
} else {
Regalloc(&n2, n.Type, nil)
cgen_callret(n, res)
case OMOD, ODIV:
- if Isfloat[n.Type.Etype] || Thearch.Dodiv == nil {
+ if n.Type.IsFloat() || Thearch.Dodiv == nil {
a = Thearch.Optoas(n.Op, nl.Type)
goto abop
}
Tempname(n1, n.Type)
Cgen(n, n1)
- if n.Type.Width <= int64(Widthptr) || Isfloat[n.Type.Etype] {
+ if n.Type.Width <= int64(Widthptr) || n.Type.IsFloat() {
n2 := *n1
Regalloc(n1, n.Type, rg)
Thearch.Gmove(&n2, n1)
// i is in register n1, extend to 32 bits.
t := Types[TUINT32]
- if Issigned[n1.Type.Etype] {
+ if n1.Type.IsSigned() {
t = Types[TINT32]
}
// type of the index
t := Types[TUINT64]
- if Issigned[n1.Type.Etype] {
+ if n1.Type.IsSigned() {
t = Types[TINT64]
}
// Could do the same for slice except that we need
// to use the real index for the bounds checking.
case OINDEX:
- if n.Left.Type.IsArray() || (Isptr[n.Left.Type.Etype] && n.Left.Left.Type.IsArray()) {
+ if n.Left.Type.IsArray() || (n.Left.Type.IsPtr() && n.Left.Left.Type.IsArray()) {
if Isconst(n.Right, CTINT) {
// Compute &a.
- if !Isptr[n.Left.Type.Etype] {
+ if !n.Left.Type.IsPtr() {
Igen(n.Left, a, res)
} else {
var n1 Node
Genlist(n.Ninit)
}
- if Thearch.Bgen_float != nil && n.Left != nil && Isfloat[n.Left.Type.Etype] {
+ if Thearch.Bgen_float != nil && n.Left != nil && n.Left.Type.IsFloat() {
if genval {
bvgenjump(n, res, wantTrue, false)
return
op := n.Op
if !wantTrue {
- if Isfloat[nr.Type.Etype] {
+ if nr.Type.IsFloat() {
// Brcom is not valid on floats when NaN is involved.
ll := n.Ninit // avoid re-genning Ninit
n.Ninit.Set(nil)
return
}
- if Iscomplex[nl.Type.Etype] {
+ if nl.Type.IsComplex() {
complexbool(op, nl, nr, res, wantTrue, likely, to)
return
}
l, r := nl, nr
// On x86, only < and <= work right with NaN; reverse if needed
- if Ctxt.Arch.Thechar == '6' && Isfloat[nl.Type.Etype] && (op == OGT || op == OGE) {
+ if Ctxt.Arch.Thechar == '6' && nl.Type.IsFloat() && (op == OGT || op == OGE) {
l, r = r, l
op = Brrev(op)
}
// Handle floating point special cases.
// Note that 8g has Bgen_float and is handled above.
- if Isfloat[nl.Type.Etype] {
+ if nl.Type.IsFloat() {
switch Ctxt.Arch.Thechar {
case '5':
if genval {
case ODOT:
t := n.Left.Type
- if Isptr[t.Etype] {
+ if t.IsPtr() {
break
}
off := stkof(n.Left)
case OCALLMETH, OCALLINTER, OCALLFUNC:
t := n.Left.Type
- if Isptr[t.Etype] {
+ if t.IsPtr() {
t = t.Elem()
}
// res = &return value from call.
func cgen_aret(n *Node, res *Node) {
t := n.Left.Type
- if Isptr[t.Etype] {
+ if t.IsPtr() {
t = t.Elem()
}
p = fmt.Sprintf("(%v).(%v)-fm", Tconv(rcvrtype, FmtLeft|FmtShort), Sconv(meth, FmtLeft))
}
basetype := rcvrtype
- if Isptr[rcvrtype.Etype] {
+ if rcvrtype.IsPtr() {
basetype = basetype.Elem()
}
if !basetype.IsInterface() && basetype.Sym == nil {
ptr.Xoffset = 0
xfunc.Func.Dcl = append(xfunc.Func.Dcl, ptr)
var body []*Node
- if Isptr[rcvrtype.Etype] || rcvrtype.IsInterface() {
+ if rcvrtype.IsPtr() || rcvrtype.IsInterface() {
ptr.Name.Param.Ntype = typenod(rcvrtype)
body = append(body, Nod(OAS, ptr, cv))
} else {
if t != nil && t.Etype == TIDEAL && n.Val().Ctype() != CTINT {
n.SetVal(toint(n.Val()))
}
- if t != nil && !Isint[t.Etype] {
+ if t != nil && !t.IsInteger() {
Yyerror("invalid operation: %v (shift of type %v)", n, t)
t = nil
}
func doesoverflow(v Val, t *Type) bool {
switch v.Ctype() {
case CTINT, CTRUNE:
- if !Isint[t.Etype] {
+ if !t.IsInteger() {
Fatalf("overflow: %v integer constant", t)
}
if v.U.(*Mpint).Cmp(Minintval[t.Etype]) < 0 || v.U.(*Mpint).Cmp(Maxintval[t.Etype]) > 0 {
}
case CTFLT:
- if !Isfloat[t.Etype] {
+ if !t.IsFloat() {
Fatalf("overflow: %v floating-point constant", t)
}
if v.U.(*Mpflt).Cmp(minfltval[t.Etype]) <= 0 || v.U.(*Mpflt).Cmp(maxfltval[t.Etype]) >= 0 {
}
case CTCPLX:
- if !Iscomplex[t.Etype] {
+ if !t.IsComplex() {
Fatalf("overflow: %v complex constant", t)
}
if v.U.(*Mpcplx).Real.Cmp(minfltval[t.Etype]) <= 0 || v.U.(*Mpcplx).Real.Cmp(maxfltval[t.Etype]) >= 0 || v.U.(*Mpcplx).Imag.Cmp(minfltval[t.Etype]) <= 0 || v.U.(*Mpcplx).Imag.Cmp(maxfltval[t.Etype]) >= 0 {
nr = defaultlit(nr, Types[TUINT])
n.Right = nr
- if nr.Type != nil && (Issigned[nr.Type.Etype] || !Isint[nr.Type.Etype]) {
+ if nr.Type != nil && (nr.Type.IsSigned() || !nr.Type.IsInteger()) {
goto illegal
}
if nl.Val().Ctype() != CTRUNE {
// in the case of an untyped non-constant value, like 1<<i.
v1 := n.Val()
if t != nil {
- if Isint[t.Etype] {
+ if t.IsInteger() {
t1 = t
v1 = toint(n.Val())
- } else if Isfloat[t.Etype] {
+ } else if t.IsFloat() {
t1 = t
v1 = toflt(n.Val())
- } else if Iscomplex[t.Etype] {
+ } else if t.IsComplex() {
t1 = t
v1 = tocplx(n.Val())
}
// function calls or channel receive operations.
t := l.Type
- if t != nil && Isptr[t.Etype] {
+ if t != nil && t.IsPtr() {
t = t.Elem()
}
if t != nil && t.IsArray() && !hascallchan(l) {
n.SetVal(Val{fval})
n.Type = t
- if !Isfloat[t.Etype] {
+ if !t.IsFloat() {
Fatalf("nodfconst: bad type %v", t)
}
}
func Complexop(n *Node, res *Node) bool {
if n != nil && n.Type != nil {
- if Iscomplex[n.Type.Etype] {
+ if n.Type.IsComplex() {
goto maybe
}
}
if res != nil && res.Type != nil {
- if Iscomplex[res.Type.Etype] {
+ if res.Type.IsComplex() {
goto maybe
}
}
return
}
- if t.Sym == nil && Isptr[t.Etype] {
+ if t.Sym == nil && t.IsPtr() {
t = t.Elem()
if t.IsInterface() {
Yyerror("embedded type cannot be a pointer to interface")
}
}
- if Isptr[t.Etype] {
+ if t.IsPtr() {
Yyerror("embedded type cannot be a pointer")
} else if t.Etype == TFORW && t.Embedlineno == 0 {
t.Embedlineno = lineno
return false
}
t := rcvr.Type
- if !Isptr[t.Etype] {
+ if !t.IsPtr() {
return false
}
t = t.Elem()
goto bad
}
s = t.Sym
- if s == nil && Isptr[t.Etype] {
+ if s == nil && t.IsPtr() {
t = t.Elem()
if t == nil {
goto bad
}
if (spkg == nil || nsym.Pkg != spkg) && !exportname(nsym.Name) {
- if t0.Sym == nil && Isptr[t0.Etype] {
+ if t0.Sym == nil && t0.IsPtr() {
p = fmt.Sprintf("(%v).%s.%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
} else {
p = fmt.Sprintf("%v.%s.%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Pkg.Prefix, nsym.Name, suffix)
}
} else {
- if t0.Sym == nil && Isptr[t0.Etype] {
+ if t0.Sym == nil && t0.IsPtr() {
p = fmt.Sprintf("(%v).%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Name, suffix)
} else {
p = fmt.Sprintf("%v.%s%s", Tconv(t0, FmtLeft|FmtShort), nsym.Name, suffix)
return
}
if t != nil {
- if Isptr[t.Etype] {
+ if t.IsPtr() {
if t.Sym != nil {
Yyerror("invalid receiver type %v (%v is a pointer type)", pa, t)
return
return
}
- if Isptr[t.Etype] {
+ if t.IsPtr() {
Yyerror("invalid receiver type %v (%v is a pointer type)", pa, t)
return
}
// it is also a dereference, because it is implicitly
// dereferenced (see #12588)
if n.Type.IsArray() &&
- !(Isptr[n.Right.Type.Etype] && Eqtype(n.Right.Type.Elem(), n.Type)) {
+ !(n.Right.Type.IsPtr() && Eqtype(n.Right.Type.Elem(), n.Type)) {
escassignNilWhy(e, n.List.Second(), n.Right, "range")
} else {
escassignDereference(e, n.List.Second(), n.Right, e.stepAssign(nil, n.List.Second(), n.Right, "range-deref"))
t := n.Left.Type
if t != Types[t.Etype] && t != idealbool && t != idealstring {
- if Isptr[t.Etype] {
+ if t.IsPtr() {
t = t.Elem()
}
if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
case OLITERAL:
t := n.Type
if t != Types[n.Type.Etype] && t != idealbool && t != idealstring {
- if Isptr[t.Etype] {
+ if t.IsPtr() {
t = t.Elem()
}
if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
if n.Type != nil && n.Type.Etype != TIDEAL && n.Type.Etype != TNIL && n.Type != idealbool && n.Type != idealstring {
// Need parens when type begins with what might
// be misinterpreted as a unary operator: * or <-.
- if Isptr[n.Type.Etype] || (n.Type.IsChan() && n.Type.Chan == Crecv) {
+ if n.Type.IsPtr() || (n.Type.IsChan() && n.Type.Chan == Crecv) {
return fmt.Sprintf("(%v)(%v)", n.Type, Vconv(n.Val(), 0))
} else {
return fmt.Sprintf("%v(%v)", n.Type, Vconv(n.Val(), 0))
// but for export, this should be rendered as (*pkg.T).meth.
// These nodes have the special property that they are names with a left OTYPE and a right ONAME.
if fmtmode == FExp && n.Left != nil && n.Left.Op == OTYPE && n.Right != nil && n.Right.Op == ONAME {
- if Isptr[n.Left.Type.Etype] {
+ if n.Left.Type.IsPtr() {
return fmt.Sprintf("(%v).%v", n.Left.Type, Sconv(n.Right.Sym, FmtShort|FmtByte))
} else {
return fmt.Sprintf("%v.%v", n.Left.Type, Sconv(n.Right.Sym, FmtShort|FmtByte))
return fmt.Sprintf("%v { %v }", n.Type, n.Name.Param.Closure.Nbody)
case OCOMPLIT:
- ptrlit := n.Right != nil && n.Right.Implicit && n.Right.Type != nil && Isptr[n.Right.Type.Etype]
+ ptrlit := n.Right != nil && n.Right.Implicit && n.Right.Type != nil && n.Right.Type.IsPtr()
if fmtmode == FErr {
if n.Right != nil && n.Right.Type != nil && !n.Implicit {
if ptrlit {
nodl.Type = t
nodl.Xoffset = lbase + offset
nodr.Type = t
- if Isfloat[t.Etype] {
+ if t.IsFloat() {
// TODO(rsc): Cache zero register like we do for integers?
Clearslim(&nodl)
} else {
var Simtype [NTYPE]EType
var (
- Isptr [NTYPE]bool
isforw [NTYPE]bool
Isint [NTYPE]bool
Isfloat [NTYPE]bool
Iscomplex [NTYPE]bool
- Issigned [NTYPE]bool
issimple [NTYPE]bool
)
// method
rcvr := fn.Type.Recv().Type
- if Isptr[rcvr.Etype] {
+ if rcvr.IsPtr() {
rcvr = rcvr.Elem()
}
if rcvr.Sym == nil {
}
if t.Note != nil && *t.Note == unsafeUintptrTag {
xp := n.List.Addr(i)
- for (*xp).Op == OCONVNOP && !Isptr[(*xp).Type.Etype] {
+ for (*xp).Op == OCONVNOP && !(*xp).Type.IsPtr() {
xp = &(*xp).Left
}
x := *xp
- if Isptr[x.Type.Etype] {
+ if x.Type.IsPtr() {
x = ordercopyexpr(x, x.Type, order, 0)
x.Name.Keepalive = true
*xp = x
ss.SetVal(s3)
} else {
s := s2.Sym
- if s == nil && Isptr[s2.Etype] {
+ if s == nil && s2.IsPtr() {
s = s2.Elem().Sym
}
pkg := importpkg
}
// Ideally we wouldn't see any integer types here, but we do.
- if n.Type == nil || (!Isptr[n.Type.Etype] && !Isint[n.Type.Etype] && n.Type.Etype != TUNSAFEPTR) {
+ if n.Type == nil || (!n.Type.IsPtr() && !n.Type.IsInteger() && n.Type.Etype != TUNSAFEPTR) {
Dump("checknil", n)
Fatalf("bad checknil")
}
}
}
- if Isptr[t.Etype] && t.Elem().IsArray() {
+ if t.IsPtr() && t.Elem().IsArray() {
t = t.Elem()
}
n.Type = t
// method does not apply.
this := f.Type.Recv().Type
- if Isptr[this.Etype] && this.Elem() == t {
+ if this.IsPtr() && this.Elem() == t {
continue
}
- if Isptr[this.Etype] && !Isptr[t.Etype] && f.Embedded != 2 && !isifacemethod(f.Type) {
+ if this.IsPtr() && !t.IsPtr() && f.Embedded != 2 && !isifacemethod(f.Type) {
continue
}
}
tptr := Ptrto(t)
- if !Isptr[t.Etype] && (t.Sym != nil || methods(tptr) != nil) {
+ if !t.IsPtr() && (t.Sym != nil || methods(tptr) != nil) {
sptr := dtypesym(tptr)
r := obj.Addrel(Linksym(s))
r.Off = 0
}
func typenamesym(t *Type) *Sym {
- if t == nil || (Isptr[t.Etype] && t.Elem() == nil) || isideal(t) {
+ if t == nil || (t.IsPtr() && t.Elem() == nil) || isideal(t) {
Fatalf("typename %v", t)
}
s := typesym(t)
}
func itabname(t, itype *Type) *Node {
- if t == nil || (Isptr[t.Etype] && t.Elem() == nil) || isideal(t) {
+ if t == nil || (t.IsPtr() && t.Elem() == nil) || isideal(t) {
Fatalf("itabname %v", t)
}
s := Pkglookup(Tconv(t, FmtLeft)+","+Tconv(itype, FmtLeft), itabpkg)
// emit the type structures for int, float, etc.
tbase := t
- if Isptr[t.Etype] && t.Sym == nil && t.Elem().Sym != nil {
+ if t.IsPtr() && t.Sym == nil && t.Elem().Sym != nil {
tbase = t.Elem()
}
dupok := 0
Fatalf("anylit: not lit")
case OPTRLIT:
- if !Isptr[t.Etype] {
+ if !t.IsPtr() {
Fatalf("anylit: not ptr")
}
n.Val().U.(*Mpint).SetInt64(v)
n.Type = t
- if Isfloat[t.Etype] {
+ if t.IsFloat() {
Fatalf("nodconst: bad type %v", t)
}
}
if t == nil {
return false
}
- if !Isptr[t.Etype] {
+ if !t.IsPtr() {
return false
}
t = t.Elem()
}
// strip away pointer if it's there
- if Isptr[t.Etype] {
+ if t.IsPtr() {
if t.Sym != nil {
return nil
}
// 3. src and dst are unnamed pointer types
// and their base types have identical underlying types.
- if Isptr[src.Etype] && Isptr[dst.Etype] && src.Sym == nil && dst.Sym == nil {
+ if src.IsPtr() && dst.IsPtr() && src.Sym == nil && dst.Sym == nil {
if Eqtype(src.Elem().Orig, dst.Elem().Orig) {
return OCONVNOP
}
}
// 4. src and dst are both integer or floating point types.
- if (Isint[src.Etype] || Isfloat[src.Etype]) && (Isint[dst.Etype] || Isfloat[dst.Etype]) {
+ if (src.IsInteger() || src.IsFloat()) && (dst.IsInteger() || dst.IsFloat()) {
if Simtype[src.Etype] == Simtype[dst.Etype] {
return OCONVNOP
}
}
// 5. src and dst are both complex types.
- if Iscomplex[src.Etype] && Iscomplex[dst.Etype] {
+ if src.IsComplex() && dst.IsComplex() {
if Simtype[src.Etype] == Simtype[dst.Etype] {
return OCONVNOP
}
// 6. src is an integer or has type []byte or []rune
// and dst is a string type.
- if Isint[src.Etype] && dst.IsString() {
+ if src.IsInteger() && dst.IsString() {
return ORUNESTR
}
}
// 8. src is a pointer or uintptr and dst is unsafe.Pointer.
- if (Isptr[src.Etype] || src.Etype == TUINTPTR) && dst.Etype == TUNSAFEPTR {
+ if (src.IsPtr() || src.Etype == TUINTPTR) && dst.Etype == TUNSAFEPTR {
return OCONVNOP
}
// 9. src is unsafe.Pointer and dst is a pointer or uintptr.
- if src.Etype == TUNSAFEPTR && (Isptr[dst.Etype] || dst.Etype == TUINTPTR) {
+ if src.Etype == TUNSAFEPTR && (dst.IsPtr() || dst.Etype == TUINTPTR) {
return OCONVNOP
}
}
// common mistake: *struct and *interface.
- if tl != nil && tr != nil && Isptr[tl.Etype] && Isptr[tr.Etype] {
+ if tl != nil && tr != nil && tl.IsPtr() && tr.IsPtr() {
if tl.Elem().IsStruct() && tr.Elem().IsInterface() {
fmt_ += "\n\t(*struct vs *interface)"
} else if tl.Elem().IsInterface() && tr.Elem().IsStruct() {
// (if save is not nil).
func lookdot0(s *Sym, t *Type, save **Field, ignorecase bool) int {
u := t
- if Isptr[u.Etype] {
+ if u.IsPtr() {
u = u.Elem()
}
}
u = t
- if Isptr[u.Etype] {
+ if u.IsPtr() {
u = u.Elem()
}
if !u.IsStruct() && !u.IsInterface() {
func expand0(t *Type, followptr bool) {
u := t
- if Isptr[u.Etype] {
+ if u.IsPtr() {
followptr = true
u = u.Elem()
}
}
u := t
- if Isptr[u.Etype] {
+ if u.IsPtr() {
followptr = true
u = u.Elem()
}
methodrcvr := method.Type.Recv().Type
// generate nil pointer check for better error
- if Isptr[rcvr.Etype] && rcvr.Elem() == methodrcvr {
+ if rcvr.IsPtr() && rcvr.Elem() == methodrcvr {
// generating wrapper from *T to T.
n := Nod(OIF, nil, nil)
dot := adddot(NodSym(OXDOT, this.Left, method.Sym))
// generate call
- if !instrumenting && Isptr[rcvr.Etype] && Isptr[methodrcvr.Etype] && method.Embedded != 0 && !isifacemethod(method.Type) {
+ if !instrumenting && rcvr.IsPtr() && methodrcvr.IsPtr() && method.Embedded != 0 && !isifacemethod(method.Type) {
// generate tail call: adjust pointer receiver and jump to embedded method.
dot = dot.Left // skip final .M
// TODO(mdempsky): Remove dependency on dotlist.
- if !Isptr[dotlist[0].field.Type.Etype] {
+ if !dotlist[0].field.Type.IsPtr() {
dot = Nod(OADDR, dot, nil)
}
as := Nod(OAS, this.Left, Nod(OCONVNOP, dot, nil))
testdclstack()
// wrappers where T is anonymous (struct or interface) can be duplicated.
- if rcvr.IsStruct() || rcvr.IsInterface() || Isptr[rcvr.Etype] && rcvr.Elem().IsStruct() {
+ if rcvr.IsStruct() || rcvr.IsInterface() || rcvr.IsPtr() && rcvr.Elem().IsStruct() {
fn.Func.Dupok = true
}
fn = typecheck(fn, Etop)
}
for _, d := range path {
- if Isptr[d.field.Type.Etype] {
+ if d.field.Type.IsPtr() {
*followptr = true
break
}
// the method does not exist for value types.
rcvr := tm.Type.Recv().Type
- if Isptr[rcvr.Etype] && !Isptr[t0.Etype] && !followptr && !isifacemethod(tm.Type) {
+ if rcvr.IsPtr() && !t0.IsPtr() && !followptr && !isifacemethod(tm.Type) {
if false && Debug['r'] != 0 {
Yyerror("interface pointer mismatch")
}
if n == nil || n.Op != OLITERAL || n.Type == nil {
return -1
}
- if !Isint[n.Type.Etype] {
+ if !n.Type.IsInteger() {
return -1
}
b = b << 1
}
- if !Issigned[n.Type.Etype] {
+ if !n.Type.IsSigned() {
return -1
}
v = toint(l.Val())
default:
- if l.Type != nil && Isint[l.Type.Etype] && l.Op != OLITERAL {
+ if l.Type != nil && l.Type.IsInteger() && l.Op != OLITERAL {
Yyerror("non-constant array bound %v", l)
} else {
Yyerror("invalid array bound %v", l)
break OpSwitch
}
- if !Isptr[t.Etype] {
+ if !t.IsPtr() {
if top&(Erv|Etop) != 0 {
Yyerror("invalid indirect of %v", Nconv(n.Left, FmtLong))
n.Type = nil
r = defaultlit(r, Types[TUINT])
n.Right = r
t := r.Type
- if !Isint[t.Etype] || Issigned[t.Etype] {
+ if !t.IsInteger() || t.IsSigned() {
Yyerror("invalid operation: %v (shift count type %v, must be unsigned integer)", n, r.Type)
n.Type = nil
return n
}
t = l.Type
- if t != nil && t.Etype != TIDEAL && !Isint[t.Etype] {
+ if t != nil && t.Etype != TIDEAL && !t.IsInteger() {
Yyerror("invalid operation: %v (shift of type %v)", n, t)
n.Type = nil
return n
break OpSwitch
}
- if Isptr[t.Etype] && !t.Elem().IsInterface() {
+ if t.IsPtr() && !t.Elem().IsInterface() {
t = t.Elem()
if t == nil {
n.Type = nil
case isnilinter(t):
Yyerror("%v undefined (type %v is interface with no methods)", n, n.Left.Type)
- case Isptr[t.Etype] && t.Elem().IsInterface():
+ case t.IsPtr() && t.Elem().IsInterface():
// Pointer to interface is almost always a mistake.
Yyerror("%v undefined (type %v is pointer to interface, not interface)", n, n.Left.Type)
}
}
- if n.Right.Type != nil && !Isint[n.Right.Type.Etype] {
+ if n.Right.Type != nil && !n.Right.Type.IsInteger() {
Yyerror("non-integer %s index %v", why, n.Right)
break
}
if Istype(t, TSTRING) {
n.Type = t
n.Op = OSLICESTR
- } else if Isptr[t.Etype] && t.Elem().IsArray() {
+ } else if t.IsPtr() && t.Elem().IsArray() {
tp = t.Elem()
n.Type = typSlice(tp.Elem())
dowidth(n.Type)
}
var tp *Type
- if Isptr[t.Etype] && t.Elem().IsArray() {
+ if t.IsPtr() && t.Elem().IsArray() {
tp = t.Elem()
n.Type = typSlice(tp.Elem())
dowidth(n.Type)
}
case OREAL, OIMAG:
- if !Iscomplex[t.Etype] {
+ if !t.IsComplex() {
goto badcall1
}
if Isconst(l, CTCPLX) {
if t == nil {
return false
}
- if !Isint[t.Etype] {
+ if !t.IsInteger() {
Yyerror("invalid slice index %v (type %v)", r, t)
return false
}
func implicitstar(n *Node) *Node {
// insert implicit * if needed for fixed array
t := n.Type
- if t == nil || !Isptr[t.Etype] {
+ if t == nil || !t.IsPtr() {
return n
}
t = t.Elem()
if r != nil {
if errnode != nil {
Yyerror("ambiguous selector %v", errnode)
- } else if Isptr[t.Etype] {
+ } else if t.IsPtr() {
Yyerror("ambiguous selector (%v).%v", t, s)
} else {
Yyerror("ambiguous selector %v.%v", t, s)
}
// disallow T.m if m requires *T receiver
- if Isptr[f2.Type.Recv().Type.Etype] && !Isptr[t.Etype] && f2.Embedded != 2 && !isifacemethod(f2.Type) {
+ if f2.Type.Recv().Type.IsPtr() && !t.IsPtr() && f2.Embedded != 2 && !isifacemethod(f2.Type) {
Yyerror("invalid method expression %v (needs pointer receiver: (*%v).%v)", n, t, Sconv(f2.Sym, FmtShort))
return false
}
dotField[typeSym{t.Orig, s}] = f1
}
if t.IsInterface() {
- if Isptr[n.Left.Type.Etype] {
+ if n.Left.Type.IsPtr() {
n.Left = Nod(OIND, n.Left, nil) // implicitstar
n.Left.Implicit = true
n.Left = typecheck(n.Left, Erv)
pll = ll
ll = ll.Left
}
- if pll.Implicit && Isptr[ll.Type.Etype] && ll.Type.Sym != nil && ll.Type.Sym.Def != nil && ll.Type.Sym.Def.Op == OTYPE {
+ if pll.Implicit && ll.Type.IsPtr() && ll.Type.Sym != nil && ll.Type.Sym.Def != nil && ll.Type.Sym.Def.Op == OTYPE {
// It is invalid to automatically dereference a named pointer type when selecting a method.
// Make n->left == ll to clarify error message.
n.Left = ll
nerr := nerrors
n.Type = t
- if Isptr[t.Etype] {
+ if t.IsPtr() {
// For better or worse, we don't allow pointers as the composite literal type,
// except when using the &T syntax, which sets implicit on the OIND.
if !n.Right.Implicit {
}
n.Orig = norig
- if Isptr[n.Type.Etype] {
+ if n.Type.IsPtr() {
n = Nod(OPTRLIT, n, nil)
n.Typecheck = 1
n.Type = n.Left.Type
if embedlineno != 0 {
lineno = embedlineno
- if Isptr[t.Etype] {
+ if t.IsPtr() {
Yyerror("embedded type cannot be a pointer")
}
}
}
}
- if !Isint[n.Type.Etype] && n.Type.Etype != TIDEAL {
+ if !n.Type.IsInteger() && n.Type.Etype != TIDEAL {
Yyerror("non-integer %s argument in make(%v) - %v", arg, t, n.Type)
return false
}
Iscomplex[TCOMPLEX64] = true
Iscomplex[TCOMPLEX128] = true
- Isptr[TPTR32] = true
- Isptr[TPTR64] = true
-
isforw[TFORW] = true
- Issigned[TINT] = true
- Issigned[TINT8] = true
- Issigned[TINT16] = true
- Issigned[TINT32] = true
- Issigned[TINT64] = true
-
// initialize okfor
for et := EType(0); et < NTYPE; et++ {
if Isint[et] || et == TIDEAL {
// delayed until now to preserve side effects.
t := n.Left.Type
- if Isptr[t.Etype] {
+ if t.IsPtr() {
t = t.Elem()
}
if t.IsArray() {
case OCONV, OCONVNOP:
if Thearch.Thechar == '5' {
- if Isfloat[n.Left.Type.Etype] {
+ if n.Left.Type.IsFloat() {
if n.Type.Etype == TINT64 {
n = mkcall("float64toint64", n.Type, init, conv(n.Left, Types[TFLOAT64]))
break
}
}
- if Isfloat[n.Type.Etype] {
+ if n.Type.IsFloat() {
if n.Left.Type.Etype == TINT64 {
n = mkcall("int64tofloat64", n.Type, init, conv(n.Left, Types[TINT64]))
break
break
}
t := n.Left.Type
- if t != nil && Isptr[t.Etype] {
+ if t != nil && t.IsPtr() {
t = t.Elem()
}
if t.IsArray() {
on = syslook("printiface")
}
on = substArgTypes(on, n.Type) // any-1
- } else if Isptr[et] || et == TCHAN || et == TMAP || et == TFUNC || et == TUNSAFEPTR {
+ } else if n.Type.IsPtr() || et == TCHAN || et == TMAP || et == TFUNC || et == TUNSAFEPTR {
on = syslook("printpointer")
on = substArgTypes(on, n.Type) // any-1
} else if n.Type.IsSlice() {
l := n.Left
r := n.Right
- if (n.Op != OOR && n.Op != OXOR) || (l.Op != OLSH && l.Op != ORSH) || (r.Op != OLSH && r.Op != ORSH) || n.Type == nil || Issigned[n.Type.Etype] || l.Op == r.Op {
+ if (n.Op != OOR && n.Op != OXOR) || (l.Op != OLSH && l.Op != ORSH) || (r.Op != OLSH && r.Op != ORSH) || n.Type == nil || n.Type.IsSigned() || l.Op == r.Op {
return n
}
// The result of walkmul MUST be assigned back to n, e.g.
// n.Left = walkmul(n.Left, init)
func walkmul(n *Node, init *Nodes) *Node {
- if !Isint[n.Type.Etype] {
+ if !n.Type.IsInteger() {
return n
}
var m Magic
m.W = w
- if Issigned[nl.Type.Etype] {
+ if nl.Type.IsSigned() {
m.Sd = nr.Val().U.(*Mpint).Int64()
Smagic(&m)
} else {
}
default:
- if Issigned[n.Type.Etype] {
+ if n.Type.IsSigned() {
if n.Op == OMOD {
// signed modulo 2^pow is like ANDing
// with the last pow bits, but if nl < 0,
// return 1 if integer n must be in range [0, max), 0 otherwise
func bounded(n *Node, max int64) bool {
- if n.Type == nil || !Isint[n.Type.Etype] {
+ if n.Type == nil || !n.Type.IsInteger() {
return false
}
- sign := Issigned[n.Type.Etype]
+ sign := n.Type.IsSigned()
bits := int32(8 * n.Type.Width)
if Smallintconst(n) {
}
t := n.Left.Type
- if Isptr[t.Etype] {
+ if t.IsPtr() {
t = t.Elem()
}
field := dotField[typeSym{t.Orig, n.Sym}]
}
outer := n.Left.Type
- if Isptr[outer.Etype] {
+ if outer.IsPtr() {
outer = outer.Elem()
}
if outer.Sym == nil {
t0 := t
if t.Width < 8 {
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
t = gc.Types[gc.TINT64]
} else {
t = gc.Types[gc.TUINT64]
case gc.TINT64,
gc.TUINT64:
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
gins3(mips.AMULV, &n2, &n1, nil)
} else {
gins3(mips.AMULVU, &n2, &n1, nil)
gc.Nodconst(&n3, tcount, nl.Type.Width*8)
gins3(mips.ASGTU, &n3, &n1, &rtmp)
p1 := ginsbranch(mips.ABNE, nil, &rtmp, nil, 0)
- if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
+ if op == gc.ORSH && nl.Type.IsSigned() {
gc.Nodconst(&n3, gc.Types[gc.TUINT32], nl.Type.Width*8-1)
gins(a, &n3, &n2)
} else {
}
func ginscmp(op gc.Op, t *gc.Type, n1, n2 *gc.Node, likely int) *obj.Prog {
- if !gc.Isfloat[t.Etype] && (op == gc.OLT || op == gc.OGE) {
+ if !t.IsFloat() && (op == gc.OLT || op == gc.OGE) {
// swap nodes to fit SGT instruction
n1, n2 = n2, n1
}
- if gc.Isfloat[t.Etype] && (op == gc.OLT || op == gc.OLE) {
+ if t.IsFloat() && (op == gc.OLT || op == gc.OLE) {
// swap nodes to fit CMPGT, CMPGE instructions and reverse relation
n1, n2 = n2, n1
if op == gc.OLT {
t0 := t
check := false
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
check = true
if gc.Isconst(nl, gc.CTINT) && nl.Int() != -(1<<uint64(t.Width*8-1)) {
check = false
}
if t.Width < 8 {
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
t = gc.Types[gc.TINT64]
} else {
t = gc.Types[gc.TUINT64]
case gc.TINT64,
gc.TUINT64:
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
gins(ppc64.AMULHD, &n2, &n1)
} else {
gins(ppc64.AMULHDU, &n2, &n1)
gc.Nodconst(&n3, tcount, nl.Type.Width*8)
gins(optoas(gc.OCMP, tcount), &n1, &n3)
p1 := gc.Gbranch(optoas(gc.OLT, tcount), nil, +1)
- if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
+ if op == gc.ORSH && nl.Type.IsSigned() {
gc.Nodconst(&n3, gc.Types[gc.TUINT32], nl.Type.Width*8-1)
gins(a, &n3, &n2)
} else {
}
func ginscmp(op gc.Op, t *gc.Type, n1, n2 *gc.Node, likely int) *obj.Prog {
- if gc.Isint[t.Etype] && n1.Op == gc.OLITERAL && n2.Op != gc.OLITERAL {
+ if t.IsInteger() && n1.Op == gc.OLITERAL && n2.Op != gc.OLITERAL {
// Reverse comparison to place constant last.
op = gc.Brrev(op)
n1, n2 = n2, n1
gc.Regalloc(&g1, n1.Type, &r1)
gc.Cgen(n1, &g1)
gmove(&g1, &r1)
- if gc.Isint[t.Etype] && gc.Isconst(n2, gc.CTINT) {
+ if t.IsInteger() && gc.Isconst(n2, gc.CTINT) {
ginscon2(optoas(gc.OCMP, t), &r1, n2.Int())
} else {
gc.Regalloc(&r2, t, n2)
t0 := t
check := false
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
check = true
if gc.Isconst(nl, gc.CTINT) && nl.Int() != -1<<uint64(t.Width*8-1) {
check = false
}
if t.Width < 4 {
- if gc.Issigned[t.Etype] {
+ if t.IsSigned() {
t = gc.Types[gc.TINT32]
} else {
t = gc.Types[gc.TUINT32]
gc.Patch(p1, gc.Pc)
}
- if !gc.Issigned[t.Etype] {
+ if !t.IsSigned() {
var nz gc.Node
gc.Nodconst(&nz, t, 0)
gmove(&nz, dx)
}
var t *gc.Type
- if gc.Issigned[nl.Type.Etype] {
+ if nl.Type.IsSigned() {
t = gc.Types[gc.TINT32]
} else {
t = gc.Types[gc.TUINT32]
p1 = gc.Gbranch(optoas(gc.OLT, gc.Types[gc.TUINT32]), nil, +1)
}
- if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
+ if op == gc.ORSH && nl.Type.IsSigned() {
gins(a, ncon(uint32(w)-1), &n2)
} else {
gmove(ncon(0), &n2)
// copy from byte to full registers
t := gc.Types[gc.TUINT32]
- if gc.Issigned[nl.Type.Etype] {
+ if nl.Type.IsSigned() {
t = gc.Types[gc.TINT32]
}
}
func ginscmp(op gc.Op, t *gc.Type, n1, n2 *gc.Node, likely int) *obj.Prog {
- if gc.Isint[t.Etype] || t.Etype == gc.Tptr {
+ if t.IsInteger() || t.Etype == gc.Tptr {
if (n1.Op == gc.OLITERAL || n1.Op == gc.OADDR && n1.Left.Op == gc.ONAME) && n2.Op != gc.OLITERAL {
// Reverse comparison to place constant (including address constant) last.
op = gc.Brrev(op)
gc.Cgen(n1, &g1)
gmove(&g1, &r1)
}
- if n2.Op == gc.OLITERAL && gc.Isint[t.Etype] || n2.Op == gc.OADDR && n2.Left.Op == gc.ONAME && n2.Left.Class == gc.PEXTERN {
+ if n2.Op == gc.OLITERAL && t.IsInteger() || n2.Op == gc.OADDR && n2.Left.Op == gc.ONAME && n2.Left.Class == gc.PEXTERN {
r2 = *n2
} else {
gc.Regalloc(&r2, t, n2)