Skip to content
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

Change interpreter calling conventions to be more direct #5542

Merged
merged 9 commits into from
Jan 15, 2025
24 changes: 24 additions & 0 deletions parser-typechecker/src/Unison/Builtin/Decls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ constructorId ref name = do
(_, _, dd) <- find (\(_, r, _) -> Reference.DerivedId r == ref) builtinDataDecls
fmap fromIntegral . elemIndex name $ DD.constructorNames dd

effectId :: Reference -> Text -> Maybe ConstructorId
effectId ref name = do
(_, _, ed) <- find (\(_, r, _) -> Reference.DerivedId r == ref) builtinEffectDecls
fmap fromIntegral . elemIndex name . DD.constructorNames $ DD.toDataDecl ed

noneId, someId, okConstructorId, failConstructorId, docBlobId, docLinkId, docSignatureId, docSourceId, docEvaluateId, docJoinId, linkTermId, linkTypeId, eitherRightId, eitherLeftId :: ConstructorId
isPropagatedConstructorId, isTestConstructorId, bufferModeNoBufferingId, bufferModeLineBufferingId, bufferModeBlockBufferingId, bufferModeSizedBlockBufferingId :: ConstructorId
seqViewEmpty, seqViewElem :: ConstructorId
Expand Down Expand Up @@ -153,6 +158,25 @@ bufferModeBlockBufferingId = Maybe.fromJust $ constructorId bufferModeRef "io2.B

bufferModeSizedBlockBufferingId = Maybe.fromJust $ constructorId bufferModeRef "io2.BufferMode.SizedBlockBuffering"

fileModeReadId, fileModeWriteId, fileModeAppendId, fileModeReadWriteId :: ConstructorId
fileModeReadId = Maybe.fromJust $ constructorId fileModeRef "io2.FileMode.Read"
fileModeWriteId = Maybe.fromJust $ constructorId fileModeRef "io2.FileMode.Write"
fileModeAppendId = Maybe.fromJust $ constructorId fileModeRef "io2.FileMode.Append"
fileModeReadWriteId = Maybe.fromJust $ constructorId fileModeRef "io2.FileMode.ReadWrite"

seekModeAbsoluteId, seekModeRelativeId, seekModeEndId :: ConstructorId
seekModeAbsoluteId = Maybe.fromJust $ constructorId seekModeRef "io2.SeekMode.AbsoluteSeek"
seekModeRelativeId = Maybe.fromJust $ constructorId seekModeRef "io2.SeekMode.RelativeSeek"
seekModeEndId = Maybe.fromJust $ constructorId seekModeRef "io2.SeekMode.SeekFromEnd"

stdInId, stdOutId, stdErrId :: ConstructorId
stdInId = Maybe.fromJust $ constructorId stdHandleRef "io2.StdHandle.StdIn"
stdOutId = Maybe.fromJust $ constructorId stdHandleRef "io2.StdHandle.StdOut"
stdErrId = Maybe.fromJust $ constructorId stdHandleRef "io2.StdHandle.StdErr"

exceptionRaiseId :: ConstructorId
exceptionRaiseId = Maybe.fromJust $ effectId exceptionRef "Exception.raise"

okConstructorReferent, failConstructorReferent :: Referent.Referent
okConstructorReferent = Referent.Con (ConstructorReference testResultRef okConstructorId) CT.Data
failConstructorReferent = Referent.Con (ConstructorReference testResultRef failConstructorId) CT.Data
Expand Down
Loading
Loading