mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Tighten some more ast.TypeExpr methods
This commit is contained in:
1 parent
6c6a647cab
commit
6656b6e5e9
2 files changed
+21
-13
No files matched your search
+9
-7
@@ -670,11 +670,11 @@ func (n *TypeExpr) Pointee() *TypeExpr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *TypeExpr) IsBool() bool {
|
func (n *TypeExpr) IsBool() bool {
|
||||||
return n.id0 == 0 && n.id2 == t.IDBool
|
return n.id0 == 0 && n.id1 == t.IDBase && n.id2 == t.IDBool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *TypeExpr) IsIdeal() bool {
|
func (n *TypeExpr) IsIdeal() bool {
|
||||||
return n.id0 == 0 && n.id2 == t.IDDoubleZ
|
return n.id0 == 0 && n.id1 == t.IDBase && n.id2 == t.IDDoubleZ
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *TypeExpr) IsNumType() bool {
|
func (n *TypeExpr) IsNumType() bool {
|
||||||
@@ -682,7 +682,7 @@ func (n *TypeExpr) IsNumType() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *TypeExpr) IsNumTypeOrIdeal() bool {
|
func (n *TypeExpr) IsNumTypeOrIdeal() bool {
|
||||||
return n.id0 == 0 && n.id1 == t.IDBase && (n.id2.IsNumType() || n.id2 == t.IDDoubleZ)
|
return n.id0 == 0 && n.id1 == t.IDBase && n.id2.IsNumTypeOrIdeal()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *TypeExpr) IsRefined() bool {
|
func (n *TypeExpr) IsRefined() bool {
|
||||||
@@ -698,7 +698,7 @@ func (n *TypeExpr) IsSliceType() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *TypeExpr) IsUnsignedInteger() bool {
|
func (n *TypeExpr) IsUnsignedInteger() bool {
|
||||||
return n.id0 == 0 &&
|
return n.id0 == 0 && n.id1 == t.IDBase &&
|
||||||
(n.id2 == t.IDU8 || n.id2 == t.IDU16 || n.id2 == t.IDU32 || n.id2 == t.IDU64)
|
(n.id2 == t.IDU8 || n.id2 == t.IDU16 || n.id2 == t.IDU32 || n.id2 == t.IDU64)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -706,9 +706,11 @@ func (n *TypeExpr) HasPointers() bool {
|
|||||||
for ; n != nil; n = n.Inner() {
|
for ; n != nil; n = n.Inner() {
|
||||||
switch n.id0 {
|
switch n.id0 {
|
||||||
case 0:
|
case 0:
|
||||||
switch n.id2 {
|
if n.id1 == t.IDBase {
|
||||||
case t.IDIOReader, t.IDIOWriter:
|
switch n.id2 {
|
||||||
return true
|
case t.IDIOReader, t.IDIOWriter:
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case t.IDPtr, t.IDNptr, t.IDSlice:
|
case t.IDPtr, t.IDNptr, t.IDSlice:
|
||||||
return true
|
return true
|
||||||
|
|||||||
+12
-6
@@ -104,8 +104,9 @@ func (x ID) IsClose() bool { return x < ID(len(isClose)) && isClose[x] }
|
|||||||
func (x ID) IsTightLeft() bool { return x < ID(len(isTightLeft)) && isTightLeft[x] }
|
func (x ID) IsTightLeft() bool { return x < ID(len(isTightLeft)) && isTightLeft[x] }
|
||||||
func (x ID) IsTightRight() bool { return x < ID(len(isTightRight)) && isTightRight[x] }
|
func (x ID) IsTightRight() bool { return x < ID(len(isTightRight)) && isTightRight[x] }
|
||||||
|
|
||||||
func (x ID) IsAssign() bool { return minAssign <= x && x <= maxAssign }
|
func (x ID) IsAssign() bool { return minAssign <= x && x <= maxAssign }
|
||||||
func (x ID) IsNumType() bool { return minNumType <= x && x <= maxNumType }
|
func (x ID) IsNumType() bool { return minNumType <= x && x <= maxNumType }
|
||||||
|
func (x ID) IsNumTypeOrIdeal() bool { return minNumTypeOrIdeal <= x && x <= maxNumTypeOrIdeal }
|
||||||
|
|
||||||
func (x ID) IsImplicitSemicolon(m *Map) bool {
|
func (x ID) IsImplicitSemicolon(m *Map) bool {
|
||||||
return x.IsLiteral(m) || x.IsIdent(m) ||
|
return x.IsLiteral(m) || x.IsIdent(m) ||
|
||||||
@@ -336,10 +337,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
minBuiltInIdent = 0x98
|
minBuiltInIdent = 0x98
|
||||||
minNumType = 0x98
|
minNumTypeOrIdeal = 0x98
|
||||||
maxNumType = 0x9F
|
minNumType = 0x98
|
||||||
maxBuiltInIdent = 0xFF
|
maxNumType = 0x9F
|
||||||
|
maxNumTypeOrIdeal = 0xA0
|
||||||
|
maxBuiltInIdent = 0xFF
|
||||||
|
|
||||||
IDI8 = ID(0x98)
|
IDI8 = ID(0x98)
|
||||||
IDI16 = ID(0x99)
|
IDI16 = ID(0x99)
|
||||||
@@ -350,7 +353,10 @@ const (
|
|||||||
IDU32 = ID(0x9E)
|
IDU32 = ID(0x9E)
|
||||||
IDU64 = ID(0x9F)
|
IDU64 = ID(0x9F)
|
||||||
|
|
||||||
|
// It is important that IDDoubleZ is right next to the IDI8..IDU64 block.
|
||||||
|
// See the ID.IsNumTypeOrIdeal method.
|
||||||
IDDoubleZ = ID(0xA0)
|
IDDoubleZ = ID(0xA0)
|
||||||
|
|
||||||
IDDiamond = ID(0xA1)
|
IDDiamond = ID(0xA1)
|
||||||
|
|
||||||
IDUnderscore = ID(0xA2)
|
IDUnderscore = ID(0xA2)
|
||||||
|
|||||||
Reference in new issue
Block a user