From 951ee169a2be6f98bb12e64c107aa66796240f6c Mon Sep 17 00:00:00 2001 From: Rerumu Date: Sat, 25 Jun 2022 03:52:03 -0400 Subject: [PATCH] Style touch ups --- codegen/luau/runtime/numeric.lua | 6 +++--- codegen/luau/runtime/runtime.lua | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/codegen/luau/runtime/numeric.lua b/codegen/luau/runtime/numeric.lua index 8734fac..ab85c9e 100644 --- a/codegen/luau/runtime/numeric.lua +++ b/codegen/luau/runtime/numeric.lua @@ -25,7 +25,7 @@ local math_pow = math.pow local table_freeze = table.freeze local from_u32, into_u32, from_u64, into_u64 -local num_add, num_subtract, num_multiply, num_divide_unsigned, num_negate, num_bit_not +local num_add, num_subtract, num_multiply, num_divide_unsigned, num_negate, num_not local num_is_negative, num_is_zero, num_is_equal, num_is_less_unsigned, num_is_greater_unsigned -- TODO: Eventually support Vector3 @@ -231,7 +231,7 @@ function Numeric.divide_signed(lhs, rhs) end function Numeric.negate(value) - return num_add(num_bit_not(value), K_ONE) + return num_add(num_not(value), K_ONE) end function Numeric.bit_and(lhs, rhs) @@ -393,7 +393,7 @@ num_subtract = Numeric.subtract num_multiply = Numeric.multiply num_divide_unsigned = Numeric.divide_unsigned num_negate = Numeric.negate -num_bit_not = Numeric.bit_not +num_not = Numeric.bit_not num_is_negative = Numeric.is_negative num_is_zero = Numeric.is_zero diff --git a/codegen/luau/runtime/runtime.lua b/codegen/luau/runtime/runtime.lua index a6c1034..6669381 100644 --- a/codegen/luau/runtime/runtime.lua +++ b/codegen/luau/runtime/runtime.lua @@ -44,11 +44,11 @@ do local assert = assert local math_abs = math.abs - local math_round = math.round local math_floor = math.floor + local math_round = math.round local math_sign = math.sign - local math_min = math.min local math_max = math.max + local math_min = math.min function add.i32(a, b) return to_u32(a + b) @@ -92,17 +92,19 @@ do end function min.num(a, b) - if b ~= b then + if b == b then + return math_min(a, b) + else return b end - return math_min(a, b) end function max.num(a, b) - if b ~= b then + if b == b then + return math_max(a, b) + else return b end - return math_max(a, b) end function copysign.num(lhs, rhs) @@ -117,7 +119,7 @@ do local result = math_round(num) if math_abs(num) % 1 == 0.5 and math_floor(math_abs(num) % 2) == 0 then - result -= math_sign(result) + result = result - math_sign(result) end return result @@ -332,7 +334,11 @@ do end function trunc.num(num) - return if num >= 0 then math.floor(num) else math.ceil(num) + if num >= 0 then + return math.floor(num) + else + return math.ceil(num) + end end trunc.u64_f32 = num_from_u64