-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[6.0] Box.getReg implementation #1015
Conversation
@@ -367,7 +367,7 @@ class ErgoTreeSpecification extends SigmaDslTesting with ContractsTestkit { | |||
MInfo(4, BytesWithoutRefMethod), | |||
MInfo(5, IdMethod), | |||
MInfo(6, creationInfoMethod), | |||
MInfo(7, getRegMethod), | |||
MInfo(7, getRegMethodV5), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to version this test as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
FuncValue( | ||
Array((1, SBox)), | ||
OptionGet(ExtractRegisterAs(ValUse(1, SBox), ErgoBox.R0, SOption(SLong))) | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea behind getReg was to have "computable" index, not just constant.
For example the index can come from Context variable and thus the concrete register will not be fixed in the ErgoTree. This will allow code like:
val x = box.getReg[Int](getVar[Int](varId).get).get
So I suggest to add additional test with variable register passed as function argument and have a series of cases in verifyCases.
"{ (x: (Box, Int)) => x._1.getReg[Long](x._2).get }"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ (x: (Box, Int)) => x._1.getReg[Long](x._2).get }
is way different from box.getReg[Int](getVar[Int](varId).get).get
,
so I've made a test in BasicOpsSpecification
which is checking exactly context variable usage:
{
val x = SELF.getReg[Long](getVar[Int](1).get).get
x == SELF.value
}
and so the new test can also be used for reference for people asked for computable index.
@aslesarenko comments addressed, please make another pass! |
In this PR, Box.getReg to get register contents by index is implemented
Example:
close #416