Add f32 and f64 distinction

This commit is contained in:
Rerumu
2022-06-25 04:30:06 -04:00
parent 951ee169a2
commit 5b61f742f4
5 changed files with 160 additions and 89 deletions
+7 -3
View File
@@ -96,11 +96,11 @@ do
return (i64(u64(lhs) % u64(rhs)))
end
function neg.num(num)
function neg.f32(num)
return -num
end
function copysign.num(lhs, rhs)
function copysign.f32(lhs, rhs)
RE_INSTANCE.f64 = rhs
if RE_INSTANCE.b32 >= 0 then
@@ -110,7 +110,7 @@ do
end
end
function nearest.num(num)
function nearest.f32(num)
local result = round(num)
if math_abs(num) % 1 == 0.5 and temp_2 % 2 == 1 then
@@ -120,6 +120,10 @@ do
return result
end
neg.f64 = neg.f32
copysign.f64 = copysign.f32
nearest.f64 = nearest.f32
module.add = add
module.sub = sub
module.mul = mul
+10 -10
View File
@@ -7,10 +7,10 @@ pub trait AsSymbol {
impl AsSymbol for BinOpType {
fn as_symbol(&self) -> Option<&'static str> {
let result = match self {
Self::Add_I64 | Self::Add_FN => "+",
Self::Sub_I64 | Self::Sub_FN => "-",
Self::Mul_I64 | Self::Mul_FN => "*",
Self::DivS_I64 | Self::Div_FN => "/",
Self::Add_I64 | Self::Add_F32 | Self::Add_F64 => "+",
Self::Sub_I64 | Self::Sub_F32 | Self::Sub_F64 => "-",
Self::Mul_I64 | Self::Mul_F32 | Self::Mul_F64 => "*",
Self::DivS_I64 | Self::Div_F32 | Self::Div_F64 => "/",
Self::RemS_I64 => "%",
_ => return None,
};
@@ -22,12 +22,12 @@ impl AsSymbol for BinOpType {
impl AsSymbol for CmpOpType {
fn as_symbol(&self) -> Option<&'static str> {
let result = match self {
Self::Eq_I32 | Self::Eq_I64 | Self::Eq_FN => "==",
Self::Ne_I32 | Self::Ne_I64 | Self::Ne_FN => "~=",
Self::LtS_I32 | Self::LtS_I64 | Self::Lt_FN => "<",
Self::GtS_I32 | Self::GtS_I64 | Self::Gt_FN => ">",
Self::LeS_I32 | Self::LeS_I64 | Self::Le_FN => "<=",
Self::GeS_I32 | Self::GeS_I64 | Self::Ge_FN => ">=",
Self::Eq_I32 | Self::Eq_I64 | Self::Eq_F32 | Self::Eq_F64 => "==",
Self::Ne_I32 | Self::Ne_I64 | Self::Ne_F32 | Self::Ne_F64 => "~=",
Self::LtS_I32 | Self::LtS_I64 | Self::Lt_F32 | Self::Lt_F64 => "<",
Self::GtS_I32 | Self::GtS_I64 | Self::Gt_F32 | Self::Gt_F64 => ">",
Self::LeS_I32 | Self::LeS_I64 | Self::Le_F32 | Self::Le_F64 => "<=",
Self::GeS_I32 | Self::GeS_I64 | Self::Ge_F32 | Self::Ge_F64 => ">=",
_ => return None,
};