@@ -1135,7 +1135,7 @@ def as_int(e):
1135
1135
if t .is_endian :
1136
1136
(fun , funtype ) = t .get_load_fun ()
1137
1137
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 ):
1139
1139
e = mkCast (e .site , e , target_type )
1140
1140
return e
1141
1141
else :
@@ -1203,7 +1203,7 @@ def mkIfExpr(site, cond, texpr, fexpr):
1203
1203
# Normally handled by expr_conditional; this only happens
1204
1204
# in DMLC-internal mkIfExpr calls
1205
1205
(result , rtype ) = (texpr , ttype ) if cond .value else (fexpr , ftype )
1206
- assert rtype .cmp (utype ) == 0
1206
+ assert rtype .eq (utype )
1207
1207
return result
1208
1208
return IfExpr (site , cond , texpr , fexpr , utype )
1209
1209
else :
@@ -1225,8 +1225,8 @@ def mkIfExpr(site, cond, texpr, fexpr):
1225
1225
if (isinstance (ttype , (TPtr , TArray ))
1226
1226
and isinstance (ftype , (TPtr , TArray ))
1227
1227
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 )))):
1230
1230
# if any branch is void, then the union is too
1231
1231
base = (ftype if ftype .base .void else ttype ).base .clone ()
1232
1232
# if any branch is const *, then the union is too
@@ -1235,8 +1235,7 @@ def mkIfExpr(site, cond, texpr, fexpr):
1235
1235
or shallow_const (ttype .base )
1236
1236
or shallow_const (ftype .base ))
1237
1237
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 )):
1240
1239
utype = ttype
1241
1240
else :
1242
1241
raise EBINOP (site , ':' , texpr , fexpr )
@@ -1401,8 +1400,8 @@ def make(cls, site, lh, rh):
1401
1400
if ((lhtype .is_arith and rhtype .is_arith )
1402
1401
or (isinstance (lhtype , (TPtr , TArray ))
1403
1402
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 )))):
1406
1405
return cls .make_simple (site , lh , rh )
1407
1406
raise EILLCOMP (site , lh , lhtype , rh , rhtype )
1408
1407
@@ -1565,7 +1564,7 @@ def make(cls, site, lh, rh):
1565
1564
return mkBoolConstant (site , (lhc .node is rhc .node
1566
1565
and lhc_indices == rhc_indices ))
1567
1566
if (isinstance (lhc , HookRef ) and isinstance (rhc , HookRef )
1568
- and lhtype .cmp (rhtype ) == 0 ):
1567
+ and lhtype .eq (rhtype )):
1569
1568
lh_indices = [idx .value for idx in lhc .indices ]
1570
1569
rh_indices = [idx .value for idx in rhc .indices ]
1571
1570
return mkBoolConstant (site , (lhc .hook is rhc .hook
@@ -1607,9 +1606,9 @@ def make(cls, site, lh, rh):
1607
1606
if ((lhtype .is_arith and rhtype .is_arith )
1608
1607
or (isinstance (lhtype , (TPtr , TArray ))
1609
1608
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 )) ))
1613
1612
or (isinstance (lhtype , TBool ) and isinstance (rhtype , TBool ))):
1614
1613
return Equals (site , lh , rh )
1615
1614
@@ -1618,7 +1617,7 @@ def make(cls, site, lh, rh):
1618
1617
return IdentityEq (site , TraitObjIdentity (lh .site , lh ),
1619
1618
TraitObjIdentity (rh .site , rh ))
1620
1619
if (isinstance (lhtype , THook ) and isinstance (rhtype , THook )
1621
- and lhtype .cmp (rhtype ) == 0 ):
1620
+ and lhtype .eq (rhtype )):
1622
1621
return IdentityEq (site , lh , rh )
1623
1622
1624
1623
raise EILLCOMP (site , lh , lhtype , rh , rhtype )
@@ -2940,8 +2939,8 @@ def mkInterfaceMethodRef(site, iface_node, indices, method_name):
2940
2939
if (not isinstance (ftype , TPtr )
2941
2940
or not isinstance (ftype .base , TFunction )
2942
2941
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 ]))):
2945
2944
# non-method members are not accessible
2946
2945
raise EMEMBER (site , struct_name , method_name )
2947
2946
@@ -4826,18 +4825,13 @@ def mkCast(site, expr, new_type):
4826
4825
return Cast (site , expr , new_type )
4827
4826
if isinstance (real , (TVoid , TArray , TFunction )):
4828
4827
raise ECAST (site , expr , new_type )
4829
- if old_type .cmp (real ) == 0 :
4830
- if (old_type . is_int
4831
- and not old_type .is_endian
4832
- and dml . globals . compat_dml12_int ( expr . site ) ):
4828
+ if old_type .eq (real ):
4829
+ if (dml . globals . compat_dml12_int ( expr . site )
4830
+ and old_type .is_int
4831
+ and not old_type . is_endian ):
4833
4832
# 1.2 integer expressions often lie about their actual type,
4834
4833
# and require a "redundant" cast! Why yes, this IS horrid!
4835
4834
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 )
4841
4835
return mkRValue (expr )
4842
4836
if isinstance (real , (TStruct , TExternStruct , TVector , TTraitList )):
4843
4837
raise ECAST (site , expr , new_type )
0 commit comments