Boolean stack implementation #18

Open
navelbuffle wants to merge 17 commits from boolean-stack into offchain-start
Showing only changes of commit d38937095e - Show all commits
+10
View File
@@ -108,11 +108,21 @@ contract Push3Interpreter {
return makeDescriptor(CodeTag.INT_LITERAL, 0, 0, masked); return makeDescriptor(CodeTag.INT_LITERAL, 0, 0, masked);
} }
function makeBoolLiteral(bool val) internal pure returns (uint256) {
uint256 masked;
if (val) masked = uint256(1);
return makeDescriptor(CodeTag.BOOL_LITERAL, 0, 0, masked);
}
function extractInt32(uint256 desc) internal pure returns (int32) { function extractInt32(uint256 desc) internal pure returns (int32) {
// read the low 32 bits // read the low 32 bits
return int32(uint32(getLow184(desc))); return int32(uint32(getLow184(desc)));
} }
function extractBool(uint256 desc) internal pure returns (bool) {
return desc & 1 == 1;
}
// ----------------------------------------------------- // -----------------------------------------------------
// 3. HELPER READS // 3. HELPER READS
// ----------------------------------------------------- // -----------------------------------------------------