Skip to content

Commit

Permalink
changes for review
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz authored and jonaprieto committed Apr 14, 2023
1 parent ada6f9a commit 6fd4521
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
21 changes: 12 additions & 9 deletions src/Juvix/Compiler/Asm/Translation/FromCore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,24 @@ genCode infoTable fi =
goBuiltinApp isTail tempSize refs (Core.BuiltinApp {..}) =
case _builtinAppOp of
OpSeq ->
case _builtinAppArgs of
[arg1, arg2] ->
DL.append
(go False tempSize refs arg1)
( DL.cons
(mkInstr Pop)
(go isTail tempSize refs arg2)
)
_ -> impossible
goSeq isTail tempSize refs _builtinAppArgs
_ ->
snocReturn isTail $
DL.append
(DL.concat (map (go False tempSize refs) (reverse _builtinAppArgs)))
(genOp _builtinAppOp)

goSeq :: Bool -> Int -> BinderList Value -> [Core.Node] -> Code'
goSeq isTail tempSize refs = \case
[arg1, arg2] ->
DL.append
(go False tempSize refs arg1)
( DL.cons
(mkInstr Pop)
(go isTail tempSize refs arg2)
)
_ -> impossible

goConstr :: Bool -> Int -> BinderList Value -> Core.Constr -> Code'
goConstr isTail tempSize refs = \case
Core.Constr _ (Core.BuiltinTag Core.TagTrue) _ ->
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Builtins/Bool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ registerIf f = do
true_ <- toExpression <$> getBuiltinName (getLoc f) BuiltinBoolTrue
false_ <- toExpression <$> getBuiltinName (getLoc f) BuiltinBoolFalse
let if_ = f ^. funDefName
u = ExpressionUniverse (Universe {_universeLevel = Nothing, _universeLoc = error "Universe with no location"})
u = ExpressionUniverse smallUniverseNoLoc
vart <- freshVar "t"
vare <- freshVar "e"
hole <- freshHole
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Builtins/Control.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Juvix.Prelude

registerSeq :: (Members '[Builtins, NameIdGen] r) => FunctionDef -> Sem r ()
registerSeq f = do
let u = ExpressionUniverse (Universe {_universeLevel = Nothing, _universeLoc = error "Universe with no location"})
let u = ExpressionUniverse smallUniverseNoLoc
a <- freshVar "a"
b <- freshVar "b"
let seq = f ^. funDefName
Expand Down
4 changes: 2 additions & 2 deletions src/Juvix/Compiler/Builtins/Debug.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Juvix.Prelude
registerTrace :: (Members '[Builtins, NameIdGen] r) => AxiomDef -> Sem r ()
registerTrace f = do
let ftype = f ^. axiomType
u = ExpressionUniverse (Universe {_universeLevel = Nothing, _universeLoc = error "Universe with no location"})
u = ExpressionUniverse smallUniverseNoLoc
a <- freshVar "a"
let freeVars = HashSet.fromList [a]
unless
Expand All @@ -19,7 +19,7 @@ registerTrace f = do
registerFail :: (Members '[Builtins, NameIdGen] r) => AxiomDef -> Sem r ()
registerFail f = do
let ftype = f ^. axiomType
u = ExpressionUniverse (Universe {_universeLevel = Nothing, _universeLoc = error "Universe with no location"})
u = ExpressionUniverse smallUniverseNoLoc
a <- freshVar "a"
let freeVars = HashSet.fromList [a]
string_ <- getBuiltinName (getLoc f) BuiltinString
Expand Down
3 changes: 3 additions & 0 deletions src/Juvix/Data/Universe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ smallUniverse = Universe (Just smallLevel)
isSmallUniverse :: Universe -> Bool
isSmallUniverse = (== smallLevel) . getUniverseLevel

smallUniverseNoLoc :: Universe
smallUniverseNoLoc = smallUniverse (error "Universe with no location")

instance HasAtomicity Universe where
atomicity u = case u ^. universeLevel of
Nothing -> Atom
Expand Down

0 comments on commit 6fd4521

Please sign in to comment.