-
Notifications
You must be signed in to change notification settings - Fork 58
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
Support MemRepTuple
in the Nockma backend
#2586
Conversation
094d951
to
7d2d4d6
Compare
3385e7e
to
3453cd3
Compare
@@ -46,6 +46,7 @@ data ConstructorInfo = ConstructorInfo | |||
_constructorTag :: Tag, | |||
_constructorType :: Type, | |||
_constructorArgNames :: [Maybe Text], | |||
_constructorArgsNum :: Int, |
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.
_constructorArgsNum
is always equal to length (typeArgs _constructorType)
, I guess? There should be a comment that this field is only a "cache" for this value.
mkConstructorInfo ci@Asm.ConstructorInfo {..} = | ||
ConstructorInfo | ||
{ _constructorInfoArity = fromIntegral _constructorArgsNum, | ||
_constructorInfoMemRep = nockmaMemRep (memRep ci (getInductiveInfo (ci ^. Asm.constructorInductive))) |
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.
This is fine, but ultimately it would be good to have a (parameterised) transformation on JuvixTree which calculates the representations. It can only be used with the Nockma pipeline until the C code generation supports the representations, but later it could be re-used.
We can represent Anoma types like resource as Juvix records.
The Nockma encoding of types uses Nockma 'tuples' where each component of the tuple holds a value of a field. So for Juvix->Anoma integration it is convenient to compile values of record types as Nockma tuples.
We already have the concept of representing constructors of inductive types that have only one non-zero-field constructor in the compiler, see
MemRepTuple
.In this PR, as part of the Nockma step, we mark constructors that satisfy the requirements of the
MemRepTuple
translation as such. Then we use a tuple encoding for those constructors.