add bool stack return and fix adapter
This commit is contained in:
@@ -28,7 +28,7 @@ contract Push3IntAdapter {
|
|||||||
view
|
view
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
// CodeTag.SUBLIST is typically enum = 3, but
|
// CodeTag.SUBLIST is typically enum = 4, but
|
||||||
// let's fetch it via
|
// let's fetch it via
|
||||||
// (uint8)Push3Interpreter.CodeTag.SUBLIST
|
// (uint8)Push3Interpreter.CodeTag.SUBLIST
|
||||||
// or we can directly pass 3 if we know the numeric value.
|
// or we can directly pass 3 if we know the numeric value.
|
||||||
@@ -70,7 +70,7 @@ contract Push3IntAdapter {
|
|||||||
initIntStack[0] = in1;
|
initIntStack[0] = in1;
|
||||||
|
|
||||||
// 4) Run
|
// 4) Run
|
||||||
(, , int256[] memory finalIntStack) =
|
(, , int256[] memory finalIntStack,) =
|
||||||
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
|
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
|
||||||
|
|
||||||
// 5) Return top of final int stack
|
// 5) Return top of final int stack
|
||||||
@@ -96,7 +96,7 @@ contract Push3IntAdapter {
|
|||||||
initIntStack[0] = in1;
|
initIntStack[0] = in1;
|
||||||
initIntStack[1] = in2;
|
initIntStack[1] = in2;
|
||||||
|
|
||||||
(, , int256[] memory finalIntStack) =
|
(, , int256[] memory finalIntStack,) =
|
||||||
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
|
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
|
||||||
|
|
||||||
require(finalIntStack.length > 0, "No integer output");
|
require(finalIntStack.length > 0, "No integer output");
|
||||||
@@ -121,7 +121,7 @@ contract Push3IntAdapter {
|
|||||||
int256[] memory initIntStack = new int256[](1);
|
int256[] memory initIntStack = new int256[](1);
|
||||||
initIntStack[0] = in1;
|
initIntStack[0] = in1;
|
||||||
|
|
||||||
(, , int256[] memory finalIntStack) =
|
(, , int256[] memory finalIntStack,) =
|
||||||
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
|
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
|
||||||
|
|
||||||
require(finalIntStack.length >= 2, "Not enough outputs");
|
require(finalIntStack.length >= 2, "Not enough outputs");
|
||||||
@@ -144,7 +144,7 @@ contract Push3IntAdapter {
|
|||||||
uint256[] memory initCodeStack = new uint256[](0);
|
uint256[] memory initCodeStack = new uint256[](0);
|
||||||
int256[] memory initIntStack = new int256[](0);
|
int256[] memory initIntStack = new int256[](0);
|
||||||
|
|
||||||
(, , int256[] memory finalIntStack) =
|
(, , int256[] memory finalIntStack,) =
|
||||||
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
|
interpreter.runInterpreter(code, initCodeStack, initExecStack, initIntStack);
|
||||||
|
|
||||||
return finalIntStack;
|
return finalIntStack;
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ contract Push3Interpreter {
|
|||||||
uint256[] calldata initCodeStack, // empty
|
uint256[] calldata initCodeStack, // empty
|
||||||
uint256[] calldata initExecStack, // descriptors
|
uint256[] calldata initExecStack, // descriptors
|
||||||
int256[] calldata initIntStack, // 32bit word
|
int256[] calldata initIntStack, // 32bit word
|
||||||
bool[] calldata initBoolStack
|
bool[] calldata initBoolStack // bool array
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
pure
|
pure
|
||||||
@@ -436,5 +436,10 @@ contract Push3Interpreter {
|
|||||||
for (uint256 i = 0; i < intTop; i++) {
|
for (uint256 i = 0; i < intTop; i++) {
|
||||||
finalIntStack[i] = intStack[i];
|
finalIntStack[i] = intStack[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finalBoolStack = new int256[](boolTop);
|
||||||
|
for (uint256 i = 0; i < boolTop; i++) {
|
||||||
|
finalBoolStack[i] = boolStack[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user