File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -7,15 +7,19 @@ The bit operations are only done
77This means we can ignore the differences between bit libraries.
88]]
99
10- -- Lua 5.3 has built-in bit operators, wrap them in a function.
11- if _VERSION == " Lua 5.3" then
10+ -- Lua 5.1 didn't have `load` or bitwise operators, just let it fall through.
11+ if _VERSION ~= " Lua 5.1" then
12+ -- Lua 5.3+ has built-in bit operators, wrap them in a function.
1213 -- Use debug.getinfo to get correct file+line numbers for loaded snippet
1314 local info = debug.getinfo (1 , " Sl" )
14- return assert (load ((" \n " ):rep (info .currentline + 1 ).. [[ return {
15+ local has_bitwise , bitwise = pcall (load ((" \n " ):rep (info .currentline + 1 ).. [[ return {
1516 band = function(a, b) return a & b end;
1617 bor = function(a, b) return a | b end;
1718 bxor = function(a, b) return a ~ b end;
18- }]] , info .source ))()
19+ }]] , info .source ))
20+ if has_bitwise then
21+ return bitwise
22+ end
1923end
2024
2125-- The "bit" library that comes with luajit
You can’t perform that action at this time.
0 commit comments