elm/libraries/Native/Bitwise.js

26 lines
797 B
JavaScript
Raw Normal View History

2013-10-29 18:50:55 +00:00
Elm.Native.Bitwise = {};
Elm.Native.Bitwise.make = function(elm) {
2013-10-29 17:47:37 +00:00
elm.Native = elm.Native || {};
2013-10-29 18:50:55 +00:00
elm.Native.Bitwise = elm.Native.Bitwise || {};
if (elm.Native.Bitwise.values) return elm.Native.Bitwise.values;
2013-10-29 17:47:37 +00:00
function and(a,b) { return a & b; }
function or (a,b) { return a | b; }
function xor(a,b) { return a ^ b; }
function not(a) { return ~a; }
function sll(a,offset) { return a << offset; }
function sra(a,offset) { return a >> offset; }
function srl(a,offset) { return a >>> offset; }
2013-10-29 18:50:55 +00:00
return elm.Native.Bitwise.values = {
2014-02-08 18:42:44 +00:00
and: F2(and),
or : F2(or ),
xor: F2(xor),
2013-10-29 17:47:37 +00:00
complement: not,
2014-02-08 18:42:44 +00:00
shiftLeft : F2(sll),
shiftRightArithmatic: F2(sra),
shiftRightLogical : F2(srl),
2013-10-29 17:47:37 +00:00
};
};