From 8d671b99e476d076d1a5c061e9d82954d10c9f5c Mon Sep 17 00:00:00 2001 From: Rerumu Date: Sat, 21 May 2022 04:18:29 -0400 Subject: [PATCH] Expand runtimes a bit more --- codegen-luajit/runtime/runtime.lua | 18 ++++++++++++++++++ codegen-luau/runtime/runtime.lua | 14 ++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/codegen-luajit/runtime/runtime.lua b/codegen-luajit/runtime/runtime.lua index 235dfdf..660fe27 100644 --- a/codegen-luajit/runtime/runtime.lua +++ b/codegen-luajit/runtime/runtime.lua @@ -24,6 +24,7 @@ do local sub = {} local mul = {} local div = {} + local neg = {} local to_signed = bit.tobit @@ -60,10 +61,15 @@ do return (i64(u64(lhs) / u64(rhs))) end + function neg.num(num) + return -num + end + module.add = add module.sub = sub module.mul = mul module.div = div + module.neg = neg end do @@ -200,6 +206,8 @@ do local trunc = {} local extend = {} local convert = {} + local promote = {} + local demote = {} local reinterpret = {} -- This would surely be an issue in a multi-thread environment... @@ -267,6 +275,14 @@ do return (to_number(u64(num))) end + function demote.f32_f64(num) + return num + end + + function promote.f64_f32(num) + return num + end + function reinterpret.i32_f32(num) RE_INSTANCE.f32 = num @@ -295,6 +311,8 @@ do module.trunc = trunc module.extend = extend module.convert = convert + module.demote = demote + module.promote = promote module.reinterpret = reinterpret end diff --git a/codegen-luau/runtime/runtime.lua b/codegen-luau/runtime/runtime.lua index 9a17354..ab30319 100644 --- a/codegen-luau/runtime/runtime.lua +++ b/codegen-luau/runtime/runtime.lua @@ -36,6 +36,7 @@ do local sub = {} local mul = {} local div = {} + local neg = {} local assert = assert @@ -76,10 +77,15 @@ do div.u64 = I64.divide_unsigned + function neg.num(num) + return -num + end + module.add = add module.sub = sub module.mul = mul module.div = div + module.neg = neg end do @@ -228,6 +234,8 @@ do local trunc = {} local extend = {} local convert = {} + local demote = {} + local promote = {} local reinterpret = {} local math_ceil = math.ceil @@ -323,6 +331,10 @@ do convert.f64_u64 = num_into_u64 + demote.f32_f64 = no_op + + promote.f64_f32 = no_op + function reinterpret.i32_f32(num) local packed = string_pack("f", num) @@ -353,6 +365,8 @@ do module.trunc = trunc module.extend = extend module.convert = convert + module.demote = demote + module.promote = promote module.reinterpret = reinterpret end