Return object as INTEGER or REAL constant.
(obj, kind=4)
| 947 | |
| 948 | |
| 949 | def as_number(obj, kind=4): |
| 950 | """Return object as INTEGER or REAL constant. |
| 951 | """ |
| 952 | if isinstance(obj, int): |
| 953 | return Expr(Op.INTEGER, (obj, kind)) |
| 954 | if isinstance(obj, float): |
| 955 | return Expr(Op.REAL, (obj, kind)) |
| 956 | if isinstance(obj, Expr): |
| 957 | if obj.op in (Op.INTEGER, Op.REAL): |
| 958 | return obj |
| 959 | raise OpError(f'cannot convert {obj} to INTEGER or REAL constant') |
| 960 | |
| 961 | |
| 962 | def as_integer(obj, kind=4): |
searching dependent graphs…