py2llvm: support conversion of fractions to float

This commit is contained in:
Sebastien Bourdeauducq 2015-02-18 09:56:07 -07:00
parent d484b3a548
commit ec84726858
1 changed files with 9 additions and 0 deletions

View File

@ -153,6 +153,15 @@ class VFraction(VGeneric):
r.auto_store(builder, builder.sdiv(a, b))
return r.o_intx(target_bits, builder)
def o_float(self, builder):
r = VFloat()
if builder is not None:
a, b = self._nd(builder)
af = builder.sitofp(a, r.get_llvm_type())
bf = builder.sitofp(b, r.get_llvm_type())
r.auto_store(builder, builder.fdiv(af, bf))
return r
def _o_eq_inv(self, other, builder, ne):
if not isinstance(other, (VInt, VFraction)):
return NotImplemented