Skip to content

Commit

Permalink
compute local vars num
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Feb 9, 2024
1 parent 8b2cb05 commit a3efba0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Juvix/Compiler/Reg/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ module Juvix.Compiler.Reg.Interpreter
where

import Control.Monad.ST
import Data.HashMap.Strict qualified as HashMap
import Data.Vector qualified as Vec
import Data.Vector.Mutable qualified as MV
import Juvix.Compiler.Reg.Data.InfoTable
import Juvix.Compiler.Reg.Error
import Juvix.Compiler.Reg.Extra
import Juvix.Compiler.Reg.Interpreter.Base
import Juvix.Compiler.Reg.Interpreter.Error
import Juvix.Compiler.Reg.Pretty
Expand All @@ -27,14 +29,16 @@ runFunction hout infoTable args0 info0 = do
Left err -> throw err
Right v -> return v
where
localVarsNum :: HashMap Symbol Int
localVarsNum = HashMap.map (computeLocalVarsNum . (^. functionCode)) (infoTable ^. infoFunctions)

goFun :: [Val] -> FunctionInfo -> ST s Val
goFun args info = do
tmps <- MV.replicate localsNum Nothing
go (Vec.fromList args) tmps (info ^. functionCode)
where
-- TODO: count exact
localsNum :: Int
localsNum = 128
localsNum = fromJust $ HashMap.lookup (info ^. functionSymbol) localVarsNum

go :: Args -> Vars s -> Code -> ST s Val
go args tmps = \case
Expand Down
1 change: 0 additions & 1 deletion test/Reg/Run/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ regRunAssertion' = regRunAssertionParam' runAssertion

regRunAssertionParam' :: (Handle -> Symbol -> InfoTable -> IO ()) -> InfoTable -> Path Abs File -> (String -> IO ()) -> Assertion
regRunAssertionParam' interpretFun tab expectedFile step = do
step "Validate"
case tab ^. infoMainFunction of
Just sym -> do
withTempDir'
Expand Down

0 comments on commit a3efba0

Please sign in to comment.