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

Do not duplicate nockma stdlib in the nockma backend #3005

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Juvix/Compiler/Nockma/Language.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ data AtomHint
| AtomHintNil
| AtomHintVoid
| AtomHintFunctionsPlaceholder
| AtomHintStdlibPlaceholder
| AtomHintString
deriving stock (Show, Eq, Lift, Generic)

Expand Down
1 change: 1 addition & 0 deletions src/Juvix/Compiler/Nockma/Pretty/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ instance forall a. (PrettyCode a, NockNatural a) => PrettyCode (Atom a) where
AtomHintNil -> return (annotate (AnnKind KNameConstructor) Str.nil)
AtomHintVoid -> return (annotate (AnnKind KNameAxiom) Str.void)
AtomHintFunctionsPlaceholder -> return (annotate (AnnKind KNameAxiom) Str.functionsPlaceholder)
AtomHintStdlibPlaceholder -> return (annotate (AnnKind KNameAxiom) Str.stdlibPlaceholder)
AtomHintString -> atomToText atm >>= ppCode

instance PrettyCode Text where
Expand Down
17 changes: 15 additions & 2 deletions src/Juvix/Compiler/Nockma/Translation/FromTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ compile = \case
FunctionsLibrary -> OpQuote # functionsLibraryPlaceHolder
RawCode -> opAddress "allocClosureFunPath" (fpath <> closurePath RawCode)
TempStack -> remakeList []
StandardLibrary -> OpQuote # stdlib
StandardLibrary -> OpQuote # stdlibPlaceHolder
ClosureTotalArgsNum -> nockNatLiteral farity
ClosureArgsNum -> nockIntegralLiteral (length args)
ClosureArgs -> remakeList args
Expand Down Expand Up @@ -958,7 +958,7 @@ runCompilerWith opts constrs moduleFuns mainFun = makeAnomaFun
FunctionsLibrary -> ("functionsLibrary-" <> funName) @ functionsLibraryPlaceHolder
RawCode -> ("rawCode-" <> funName) @ c
TempStack -> ("tempStack-" <> funName) @ nockNilHere
StandardLibrary -> ("stdlib-" <> funName) @ stdlib
StandardLibrary -> ("stdlib-" <> funName) @ stdlibPlaceHolder
ClosureTotalArgsNum -> ("closureTotalArgsNum-" <> funName) @ nockNilHere
ClosureArgsNum -> ("closureArgsNum-" <> funName) @ nockNilHere
ClosureArgs -> ("closureArgs-" <> funName) @ nockNilHere
Expand Down Expand Up @@ -1001,6 +1001,19 @@ runCompilerWith opts constrs moduleFuns mainFun = makeAnomaFun
{ _anomaClosure = mainClosure
}

stdlibPlaceHolder :: Term Natural
stdlibPlaceHolder =
TermAtom
Atom
{ _atomInfo =
AtomInfo
{ _atomInfoLoc = Irrelevant Nothing,
_atomInfoTag = Nothing,
_atomInfoHint = Just AtomHintStdlibPlaceholder
},
_atom = 0 :: Natural
}

functionsLibraryPlaceHolder :: Term Natural
functionsLibraryPlaceHolder =
TermAtom
Expand Down
3 changes: 3 additions & 0 deletions src/Juvix/Extra/Strings.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,9 @@ version = "version"
functionsPlaceholder :: (IsString s) => s
functionsPlaceholder = "functionsLibrary_placeholder"

stdlibPlaceholder :: (IsString s) => s
stdlibPlaceholder = "stdlib_placeholder"

theFunctionsLibrary :: (IsString s) => s
theFunctionsLibrary = "the_functionsLibrary"

Expand Down
Loading