static CiType FindCommonType(CiExpr expr1, CiExpr expr2)
{
CiType type1 = expr1.Type;
CiType type2 = expr2.Type;
if (type1.Equals(type2))
return type1;
if ((type1 == CiIntType.Value && type2 == CiByteType.Value)
|| (type1 == CiByteType.Value && type2 == CiIntType.Value))
return CiIntType.Value;
CiType type = type1.Ptr;
if (type != null)
return type; // stg, ptr || stg, null
type = type2.Ptr;
if (type != null)
return type; // ptr, stg || null, stg
if (type1 != CiType.Null)
return type1; // ptr, null
if (type2 != CiType.Null)
return type2; // null, ptr
throw new ResolveException("Incompatible types");
}