add bool stack return and fix adapter

This commit is contained in:
2025-01-04 16:20:00 +03:00
parent 7f259c8a07
commit e220ff39fc
2 changed files with 15 additions and 10 deletions
+5 -5
View File
@@ -28,7 +28,7 @@ contract Push3IntAdapter {
view
returns (uint256)
{
// CodeTag.SUBLIST is typically enum = 3, but
// 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.
@@ -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,7 +96,7 @@ 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");
@@ -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");
@@ -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];
}
}
}