Merge pull request #1 from Fireboltofdeath/luau-fixes

Luau fixes
This commit is contained in:
Rerumu 2021-10-17 15:07:13 -04:00 committed by GitHub
commit 07489fe8cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 24 deletions

View File

@ -34,7 +34,7 @@ local function unsign_i64(x)
return x return x
end end
local function rip_u64(x) return math.floor(x / 0x100000000), bit.tobit(x % 0x100000000) end local function rip_u64(x) return math.floor(x / 0x100000000), x % 0x100000000 end
local function merge_u64(hi, lo) return hi * 0x100000000 + lo end local function merge_u64(hi, lo) return hi * 0x100000000 + lo end
@ -74,23 +74,23 @@ function ge.u64(lhs, rhs) return unsign_i64(lhs) >= unsign_i64(rhs) and 1 or 0 e
function gt.u64(lhs, rhs) return unsign_i64(lhs) > unsign_i64(rhs) and 1 or 0 end function gt.u64(lhs, rhs) return unsign_i64(lhs) > unsign_i64(rhs) and 1 or 0 end
band.i32 = bit.band band.i32 = bit32.band
bor.i32 = bit.bor bor.i32 = bit32.bor
bxor.i32 = bit.bxor bxor.i32 = bit32.bxor
bnot.i32 = bit.bnot bnot.i32 = bit32.bnot
band.i64 = bit.band band.i64 = bit32.band
bor.i64 = bit.bor bor.i64 = bit32.bor
bxor.i64 = bit.bxor bxor.i64 = bit32.bxor
bnot.i64 = bit.bnot bnot.i64 = bit32.bnot
shl.u32 = bit.lshift shl.u32 = bit32.lshift
shr.u32 = bit.rshift shr.u32 = bit32.rshift
shl.i32 = bit.lshift shl.i32 = bit32.lshift
shr.i32 = bit.rshift shr.i32 = bit32.rshift
shl.u64 = bit.lshift shl.u64 = bit32.lshift
shr.u64 = bit.rshift shr.u64 = bit32.rshift
shl.i64 = bit.lshift shl.i64 = bit32.lshift
shr.i64 = bit.rshift shr.i64 = bit32.rshift
extend.i32_u64 = no_op extend.i32_u64 = no_op
@ -105,7 +105,7 @@ end
function load.i32_u8(memory, addr) function load.i32_u8(memory, addr)
local value = load.i32(memory, addr) local value = load.i32(memory, addr)
return bit.band(value, 0xFF) return bit32.band(value, 0xFF)
end end
function load.i64(memory, addr) function load.i64(memory, addr)
@ -126,10 +126,10 @@ end
function store.i32_n8(memory, addr, value) function store.i32_n8(memory, addr, value)
if addr % 4 ~= 0 then error('unaligned write') end if addr % 4 ~= 0 then error('unaligned write') end
local old = bit.band(memory.data[addr / 4] or 0, 0xFFFFFF00) local old = bit32.band(memory.data[addr / 4] or 0, 0xFFFFFF00)
local new = bit.band(value, 0xFF) local new = bit32.band(value, 0xFF)
memory.data[addr / 4] = bit.bor(old, new) memory.data[addr / 4] = bit32.bor(old, new)
end end
function store.i64(memory, addr, value) function store.i64(memory, addr, value)

View File

@ -36,7 +36,7 @@ pub struct LuaJIT;
impl Edition for LuaJIT { impl Edition for LuaJIT {
fn runtime(&self) -> &'static str { fn runtime(&self) -> &'static str {
"luajit" "'luajit'"
} }
fn start_block(&self, w: Writer) -> Result<()> { fn start_block(&self, w: Writer) -> Result<()> {
@ -86,7 +86,7 @@ pub struct Luau;
impl Edition for Luau { impl Edition for Luau {
fn runtime(&self) -> &'static str { fn runtime(&self) -> &'static str {
"luau" "script.Runtime"
} }
fn start_block(&self, w: Writer) -> Result<()> { fn start_block(&self, w: Writer) -> Result<()> {

View File

@ -246,7 +246,7 @@ fn gen_nil_array(name: &str, len: usize, w: Writer) -> Result<()> {
} }
pub fn translate(spec: &dyn Edition, m: &Module, w: Writer) -> Result<()> { pub fn translate(spec: &dyn Edition, m: &Module, w: Writer) -> Result<()> {
writeln!(w, "local runtime = require('{}')", spec.runtime())?; writeln!(w, "local runtime = require({})", spec.runtime())?;
writeln!(w, "{}", RUNTIME_DATA)?; writeln!(w, "{}", RUNTIME_DATA)?;
gen_nil_array("FUNC_LIST", m.in_arity.len(), w)?; gen_nil_array("FUNC_LIST", m.in_arity.len(), w)?;