lang/ast: add TypeExpr.IsXxx methods

This commit is contained in:
Nigel Tao committed 2023-10-04 17:09:59 +11:00
1 parent 2f5108978d
commit 6f79c182ea
2 files changed
+18

No files matched your search

+12
View File
@@ -917,6 +917,10 @@ func (n *TypeExpr) IsCPUArchType() bool {
return n.id0 == 0 && n.id1 == t.IDBase && n.id2.IsBuiltInCPUArch()
}
func (n *TypeExpr) IsEmptyStruct() bool {
return n.id0 == 0 && n.id1 == t.IDBase && n.id2 == t.IDEmptyStruct
}
func (n *TypeExpr) IsEtcUtilityType() bool {
return n.id0 == 0 && n.id1 == t.IDBase && n.id2.IsEtcUtility()
}
@@ -953,6 +957,14 @@ func (n *TypeExpr) IsNumTypeOrIdeal() bool {
return n.id0 == 0 && n.id1 == t.IDBase && n.id2.IsNumTypeOrIdeal()
}
func (n *TypeExpr) IsRangeType() bool {
return n.id0 == 0 && n.id1 == t.IDBase && n.id2.IsRangeType()
}
func (n *TypeExpr) IsRectType() bool {
return n.id0 == 0 && n.id1 == t.IDBase && n.id2.IsRectType()
}
func (n *TypeExpr) IsRefined() bool {
return n.id0 == 0 && n.id1 == t.IDBase && n.id2.IsNumType() && (n.lhs != nil || n.mhs != nil)
}