mirror of
https://github.com/Reuh/candran.git
synced 2025-10-27 17:59:30 +00:00
40 lines
1.4 KiB
Text
40 lines
1.4 KiB
Text
UNPACK = (list, i, j)
|
|
return "unpack(" .. list .. (i and (", " .. i .. (j and (", " .. j) or "")) or "") .. ")"
|
|
end
|
|
APPEND = (t, toAppend)
|
|
return "do" .. indent() .. "local a, p = { " .. toAppend .. " }, #" .. t .. "+1" .. newline() .. "for i=1, #a do" .. indent() .. t .. "[p] = a[i]" .. newline() .. "p = p + 1" .. unindent() .. "end" .. unindent() .. "end"
|
|
end
|
|
|
|
tags._opid.idiv = (left, right)
|
|
return "math.floor(" .. lua(left) .. " / " .. lua(right) .. ")"
|
|
end
|
|
tags._opid.band = (left, right)
|
|
addRequire("bit", "band", "band")
|
|
return var("band") .. "(" .. lua(left) .. ", " .. lua(right) .. ")"
|
|
end
|
|
tags._opid.bor = (left, right)
|
|
addRequire("bit", "bor", "bor")
|
|
return var("bor") .. "(" .. lua(left) .. ", " .. lua(right) .. ")"
|
|
end
|
|
tags._opid.bxor = (left, right)
|
|
addRequire("bit", "bxor", "bxor")
|
|
return var("bxor") .. "(" .. lua(left) .. ", " .. lua(right) .. ")"
|
|
end
|
|
tags._opid.shl = (left, right)
|
|
addRequire("bit", "lshift", "lshift")
|
|
return var("lshift") .. "(" .. lua(left) .. ", " .. lua(right) .. ")"
|
|
end
|
|
tags._opid.shr = (left, right)
|
|
addRequire("bit", "rshift", "rshift")
|
|
return var("rshift") .. "(" .. lua(left) .. ", " .. lua(right) .. ")"
|
|
end
|
|
tags._opid.bnot = (right)
|
|
addRequire("bit", "bnot", "bnot")
|
|
return var("bnot") .. "(" .. lua(right) .. ")"
|
|
end
|
|
|
|
#local patch = output
|
|
#output = ""
|
|
#import("compiler.lua53", { patch = patch, loadPackage = false })
|
|
|
|
return lua53
|