@@ -1135,7 +1135,7 @@ def as_int(e):
11351135 if t .is_endian :
11361136 (fun , funtype ) = t .get_load_fun ()
11371137 e = dml .expr .Apply (e .site , mkLit (e .site , fun , funtype ), (e ,), funtype )
1138- if not compatible_types ( realtype (e .ctype ()), target_type ):
1138+ if not realtype (e .ctype ()). eq ( target_type ):
11391139 e = mkCast (e .site , e , target_type )
11401140 return e
11411141 else :
@@ -1203,7 +1203,7 @@ def mkIfExpr(site, cond, texpr, fexpr):
12031203 # Normally handled by expr_conditional; this only happens
12041204 # in DMLC-internal mkIfExpr calls
12051205 (result , rtype ) = (texpr , ttype ) if cond .value else (fexpr , ftype )
1206- assert rtype .cmp (utype ) == 0
1206+ assert rtype .eq (utype )
12071207 return result
12081208 return IfExpr (site , cond , texpr , fexpr , utype )
12091209 else :
@@ -1225,8 +1225,8 @@ def mkIfExpr(site, cond, texpr, fexpr):
12251225 if (isinstance (ttype , (TPtr , TArray ))
12261226 and isinstance (ftype , (TPtr , TArray ))
12271227 and (ttype .base .void or ftype .base .void
1228- or compatible_types ( safe_realtype_unconst (ttype .base ),
1229- safe_realtype_unconst (ftype .base )))):
1228+ or safe_realtype_unconst (ttype .base ). eq (
1229+ safe_realtype_unconst (ftype .base )))):
12301230 # if any branch is void, then the union is too
12311231 base = (ftype if ftype .base .void else ttype ).base .clone ()
12321232 # if any branch is const *, then the union is too
@@ -1235,8 +1235,7 @@ def mkIfExpr(site, cond, texpr, fexpr):
12351235 or shallow_const (ttype .base )
12361236 or shallow_const (ftype .base ))
12371237 utype = TPtr (base )
1238- elif compatible_types (safe_realtype_unconst (ttype ),
1239- safe_realtype_unconst (ftype )):
1238+ elif safe_realtype_unconst (ttype ).eq (safe_realtype_unconst (ftype )):
12401239 utype = ttype
12411240 else :
12421241 raise EBINOP (site , ':' , texpr , fexpr )
@@ -1401,8 +1400,8 @@ def make(cls, site, lh, rh):
14011400 if ((lhtype .is_arith and rhtype .is_arith )
14021401 or (isinstance (lhtype , (TPtr , TArray ))
14031402 and isinstance (rhtype , (TPtr , TArray ))
1404- and compatible_types ( safe_realtype_unconst (lhtype .base ),
1405- safe_realtype_unconst (rhtype .base )))):
1403+ and safe_realtype_unconst (lhtype .base ). eq (
1404+ safe_realtype_unconst (rhtype .base )))):
14061405 return cls .make_simple (site , lh , rh )
14071406 raise EILLCOMP (site , lh , lhtype , rh , rhtype )
14081407
@@ -1565,7 +1564,7 @@ def make(cls, site, lh, rh):
15651564 return mkBoolConstant (site , (lhc .node is rhc .node
15661565 and lhc_indices == rhc_indices ))
15671566 if (isinstance (lhc , HookRef ) and isinstance (rhc , HookRef )
1568- and lhtype .cmp (rhtype ) == 0 ):
1567+ and lhtype .eq (rhtype )):
15691568 lh_indices = [idx .value for idx in lhc .indices ]
15701569 rh_indices = [idx .value for idx in rhc .indices ]
15711570 return mkBoolConstant (site , (lhc .hook is rhc .hook
@@ -1607,9 +1606,9 @@ def make(cls, site, lh, rh):
16071606 if ((lhtype .is_arith and rhtype .is_arith )
16081607 or (isinstance (lhtype , (TPtr , TArray ))
16091608 and isinstance (rhtype , (TPtr , TArray ))
1610- and (compatible_types ( safe_realtype_unconst ( lhtype .base ),
1611- safe_realtype_unconst (rhtype .base ))
1612- or lhtype . base . void or rhtype .base . void ))
1609+ and (lhtype .base . void or rhtype . base . void
1610+ or safe_realtype_unconst (lhtype .base ). eq (
1611+ safe_realtype_unconst ( rhtype .base )) ))
16131612 or (isinstance (lhtype , TBool ) and isinstance (rhtype , TBool ))):
16141613 return Equals (site , lh , rh )
16151614
@@ -1618,7 +1617,7 @@ def make(cls, site, lh, rh):
16181617 return IdentityEq (site , TraitObjIdentity (lh .site , lh ),
16191618 TraitObjIdentity (rh .site , rh ))
16201619 if (isinstance (lhtype , THook ) and isinstance (rhtype , THook )
1621- and lhtype .cmp (rhtype ) == 0 ):
1620+ and lhtype .eq (rhtype )):
16221621 return IdentityEq (site , lh , rh )
16231622
16241623 raise EILLCOMP (site , lh , lhtype , rh , rhtype )
@@ -2940,8 +2939,8 @@ def mkInterfaceMethodRef(site, iface_node, indices, method_name):
29402939 if (not isinstance (ftype , TPtr )
29412940 or not isinstance (ftype .base , TFunction )
29422941 or not ftype .base .input_types
2943- or TPtr (safe_realtype_unconst (TNamed ('conf_object_t' ))).cmp (
2944- safe_realtype_unconst (ftype .base .input_types [0 ])) != 0 ):
2942+ or not TPtr (safe_realtype_unconst (TNamed ('conf_object_t' ))).eq (
2943+ safe_realtype_unconst (ftype .base .input_types [0 ]))):
29452944 # non-method members are not accessible
29462945 raise EMEMBER (site , struct_name , method_name )
29472946
@@ -4826,18 +4825,13 @@ def mkCast(site, expr, new_type):
48264825 return Cast (site , expr , new_type )
48274826 if isinstance (real , (TVoid , TArray , TFunction )):
48284827 raise ECAST (site , expr , new_type )
4829- if old_type .cmp (real ) == 0 :
4828+ if old_type .eq (real ):
48304829 if (old_type .is_int
48314830 and not old_type .is_endian
48324831 and dml .globals .compat_dml12_int (expr .site )):
48334832 # 1.2 integer expressions often lie about their actual type,
48344833 # and require a "redundant" cast! Why yes, this IS horrid!
48354834 return Cast (site , expr , new_type )
4836- if real .is_int and real .members is not None :
4837- # An integer type can be compatible with a bitfields without being
4838- # equal to it, as DMLC will treat bitfields differently. Leverage
4839- # Cast in this case
4840- return Cast (site , expr , new_type )
48414835 return mkRValue (expr )
48424836 if isinstance (real , (TStruct , TExternStruct , TVector , TTraitList )):
48434837 raise ECAST (site , expr , new_type )
0 commit comments