Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions std/dispatch.solc
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ forall name payability args rets fn
=> instance Method(name,payability,args,rets,fn):Selector {
function compute(prx : Proxy(Method(name,payability,args,rets,fn))) -> bytes4 {
// let hash : word = keccakLit(sigStr(prx));
let hash = keccakLit(sigStr(Proxy:Proxy(name)) + "(" + sigStr(Proxy:Proxy(args)) + ")");
let res : word;
assembly { res := shr(224, hash) }

return bytes4(res);
let hash = keccakLit(sigStr(Proxy:Proxy(name)) + "(" + sigStr(Proxy:Proxy(args)) + ")");
return bytes4(bshrWord(224, hash));
}
}

Expand Down
64 changes: 61 additions & 3 deletions std/std.solc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ export {
bytes,
bytes4(*),
bytes32(*),
bandWord,
borWord,
bxorWord,
bnotWord,
bshlWord,
bshrWord,
calldata(*),
concatLit,
eqWord,
Expand Down Expand Up @@ -411,6 +417,60 @@ function subWord(l: word, r: word) -> word {
return rw;
}

// Bitwise AND
function bandWord(x: word, y: word) -> word {
let res: word;
assembly {
res := and(x, y)
}
return res;
}

// Bitwise OR
function borWord(x: word) -> word {
let res: word;
assembly {
res := or(x)
}
return res;
}

// Bitwise XOR
function bxorWord(x: word) -> word {
let res: word;
assembly {
res := xor(x)
}
return res;
}

// Bitwise NOT
function bnotWord(x: word) -> word {
let res: word;
assembly {
res := not(x)
}
return res;
}

// Bitwise SHL
function bshlWord(x: word, y: word) -> word {
let res: word;
assembly {
res := shl(x, y)
}
return res;
}

// Bitwise SHR
function bshrWord(x: word, y: word) -> word {
let res: word;
assembly {
res := shr(x, y)
}
return res;
}

instance word:Eq {
function eq(x:word, y:word) -> bool {
return eqWord(x, y);
Expand Down Expand Up @@ -1123,9 +1183,7 @@ instance bool:ABIEncode {
}

function round_up_to_mul_of_32(value:word) -> word {
let result : word;
assembly { result := and(add(value, 31), not(31)) }
return result;
return bandWord(value + 31, bnotWord(31));
}

function encodeIntoFromBytesLike(srcPtr:word, basePtr:word, offset:word, tail:word) -> word {
Expand Down
Loading