Boolean stack implementation #18

Open
navelbuffle wants to merge 17 commits from boolean-stack into offchain-start
2 changed files with 15 additions and 10 deletions
Showing only changes of commit e220ff39fc - Show all commits
+9 -9
View File
@@ -28,9 +28,9 @@ contract Push3IntAdapter {
view
returns (uint256)
{
// CodeTag.SUBLIST is typically enum = 3, but
// let's fetch it via
// (uint8)Push3Interpreter.CodeTag.SUBLIST
// CodeTag.SUBLIST is typically enum = 4, but
// let's fetch it via
// (uint8)Push3Interpreter.CodeTag.SUBLIST
// or we can directly pass 3 if we know the numeric value.
// We'll do:
@@ -70,7 +70,7 @@ contract Push3IntAdapter {
initIntStack[0] = in1;
// 4) Run
(, , int256[] memory finalIntStack) =
(, , int256[] memory finalIntStack,) =
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
// 5) Return top of final int stack
@@ -96,11 +96,11 @@ contract Push3IntAdapter {
initIntStack[0] = in1;
initIntStack[1] = in2;
(, , int256[] memory finalIntStack) =
(, , int256[] memory finalIntStack,) =
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
require(finalIntStack.length > 0, "No integer output");
out1 = finalIntStack[finalIntStack.length - 1];
}
@@ -121,7 +121,7 @@ contract Push3IntAdapter {
int256[] memory initIntStack = new int256[](1);
initIntStack[0] = in1;
(, , int256[] memory finalIntStack) =
(, , int256[] memory finalIntStack,) =
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
require(finalIntStack.length >= 2, "Not enough outputs");
@@ -130,7 +130,7 @@ contract Push3IntAdapter {
}
/**
* @notice Zero int input, returns entire final int stack
* @notice Zero int input, returns entire final int stack
*/
function run0InNOut(bytes calldata code)
external
@@ -144,7 +144,7 @@ contract Push3IntAdapter {
uint256[] memory initCodeStack = new uint256[](0);
int256[] memory initIntStack = new int256[](0);
(, , int256[] memory finalIntStack) =
(, , int256[] memory finalIntStack,) =
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
return finalIntStack;
+6 -1
View File
@@ -293,7 +293,7 @@ contract Push3Interpreter {
uint256[] calldata initCodeStack, // empty
uint256[] calldata initExecStack, // descriptors
int256[] calldata initIntStack, // 32bit word
bool[] calldata initBoolStack
bool[] calldata initBoolStack // bool array
)
external
pure
@@ -436,5 +436,10 @@ contract Push3Interpreter {
for (uint256 i = 0; i < intTop; i++) {
finalIntStack[i] = intStack[i];
}
finalBoolStack = new int256[](boolTop);
for (uint256 i = 0; i < boolTop; i++) {
finalBoolStack[i] = boolStack[i];
}
}
}