Skip to content

Commit

Permalink
Merge pull request #5542 from unisonweb/topic/calling-conventions
Browse files Browse the repository at this point in the history
Change interpreter calling conventions to be more direct
  • Loading branch information
dolio authored Jan 15, 2025
2 parents b182c6b + 85feecc commit 0a98cc9
Show file tree
Hide file tree
Showing 7 changed files with 1,185 additions and 1,476 deletions.
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

0 comments on commit 0a98cc9

Please sign in to comment.