mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Implement bit operations.
This commit is contained in:
parent
10879bcae6
commit
06adbc2c59
@ -1537,6 +1537,15 @@ string IRGeneratorForStatements::binaryOperation(
|
||||
case Token::Mod:
|
||||
fun = m_utils.checkedIntModFunction(*type);
|
||||
break;
|
||||
case Token::BitOr:
|
||||
fun = "or";
|
||||
break;
|
||||
case Token::BitXor:
|
||||
fun = "xor";
|
||||
break;
|
||||
case Token::BitAnd:
|
||||
fun = "and";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
19
test/libsolidity/semanticTests/expressions/bit_operators.sol
Normal file
19
test/libsolidity/semanticTests/expressions/bit_operators.sol
Normal file
@ -0,0 +1,19 @@
|
||||
contract test {
|
||||
uint8 x;
|
||||
uint v;
|
||||
function f() public returns (uint x, uint y, uint z) {
|
||||
uint16 a;
|
||||
uint32 b;
|
||||
assembly {
|
||||
a := 0x0f0f0f0f0f
|
||||
b := 0xff0fff0fff
|
||||
}
|
||||
x = a & b;
|
||||
y = a | b;
|
||||
z = a ^ b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 3855, 268374015, 268370160
|
Loading…
Reference in New Issue
Block a user