Skip to content

Commit

Permalink
fix after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Dec 15, 2023
1 parent cf07146 commit b871ffb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
11 changes: 3 additions & 8 deletions src/Juvix/Compiler/Asm/Extra/Apply.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ makeLenses ''ApplyBuiltins
addApplyBuiltins :: InfoTable -> (ApplyBuiltins, InfoTable)
addApplyBuiltins tab = (blts, bs' ^. stateInfoTable)
where
nextSymbol = maximum (0 : HashMap.keys (tab ^. infoFunctions) ++ HashMap.keys (tab ^. infoInductives)) + 1
nextUserId = maximum (0 : mapMaybe getUserTag (HashMap.keys (tab ^. infoConstrs))) + 1
nextSymbolId = maximum (0 : map (^. symbolId) (HashMap.keys (tab ^. infoFunctions) ++ HashMap.keys (tab ^. infoInductives))) + 1
nextUserId = maximum (0 : mapMaybe getUserTagId (HashMap.keys (tab ^. infoConstrs))) + 1

bs :: BuilderState
bs =
BuilderState
{ _stateNextSymbol = nextSymbol,
{ _stateNextSymbolId = nextSymbolId,
_stateNextUserTag = nextUserId,
_stateInfoTable = tab,
_stateIdents = mempty
Expand All @@ -53,8 +53,3 @@ addApplyBuiltins tab = (blts, bs' ^. stateInfoTable)
f = case fromJust $ HashMap.lookup idt (bs' ^. stateIdents) of
IdentFun s -> s
_ -> impossible

getUserTag :: Tag -> Maybe Word
getUserTag = \case
BuiltinTag {} -> Nothing
UserTag x -> Just x
8 changes: 5 additions & 3 deletions src/Juvix/Compiler/Asm/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ runParser fileName input = (^. stateInfoTable) <$> runParser' emptyBuilderState
runParser' :: BuilderState -> FilePath -> Text -> Either MegaparsecError BuilderState
runParser' bs fileName input =
case run $
runInfoTableBuilder' bs $
evalTopNameIdGen defaultModuleId $
P.runParserT parseToplevel fileName input of
evalState @Index 0 $
evalState @LocalNameMap mempty $
runInfoTableBuilder' bs $
evalTopNameIdGen defaultModuleId $
P.runParserT parseToplevel fileName input of
(_, Left err) -> Left (MegaparsecError err)
(bs', Right ()) -> Right bs'

Expand Down
1 change: 1 addition & 0 deletions src/Juvix/Compiler/Core/Data/InfoTable/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ data ConstructorInfo' n = ConstructorInfo
_constructorTag :: Tag,
_constructorType :: n,
_constructorArgsNum :: Int,
_constructorArgNames :: [Maybe Text],
_constructorInductive :: Symbol,
_constructorFixity :: Maybe Fixity,
_constructorBuiltin :: Maybe BuiltinConstructor,
Expand Down

0 comments on commit b871ffb

Please sign in to comment.