CSPM-Interpreter 0.2.0.0 → 0.3.0.0
raw patch · 6 files changed
+28/−23 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- CSPM.Interpreter.Types: initialEnvirionment :: IO Env
+ CSPM.Interpreter: runInterpreterP :: LModule -> UniqueIdent -> (Process, Env)
- CSPM.Interpreter: runInterpreter :: LModule -> UniqueIdent -> IO (Process, Env)
+ CSPM.Interpreter: runInterpreter :: LModule -> UniqueIdent -> (Value, Env)
Files
- CSPM-Interpreter.cabal +1/−1
- src/CSPM/Interpreter.hs +18/−9
- src/CSPM/Interpreter/CoreInstances.hs +2/−2
- src/CSPM/Interpreter/Renaming.hs +4/−4
- src/CSPM/Interpreter/Test/CLI.hs +3/−4
- src/CSPM/Interpreter/Types.hs +0/−3
CSPM-Interpreter.cabal view
@@ -1,5 +1,5 @@ Name: CSPM-Interpreter-Version: 0.2.0.0+Version: 0.3.0.0 Synopsis: An interpreter for CSPM Description:
src/CSPM/Interpreter.hs view
@@ -19,6 +19,7 @@ ,getAllEvents ,prepareAST ,runInterpreter+ ,runInterpreterP ,module CSPM.Interpreter.Types ,module CSPM.Interpreter.Bindings ,module CSPM.Interpreter.CoreInstances@@ -38,15 +39,23 @@ import Data.IntMap as IntMap -- | Run the interpreter for a given module and top-level identifier.-runInterpreter :: AST.LModule -> AST.UniqueIdent -> IO (Process,Env)-runInterpreter ast entry = do- initEnv <- initialEnvirionment- let- env = processDeclList (hs "TopLevelEnvirionment") initEnv+runInterpreter :: AST.LModule -> AST.UniqueIdent -> (Value,Env)+runInterpreter ast entry+ = (getLetBindings env IntMap.! AST.uniqueIdentId entry+ ,env)+ where + env = processDeclList (hs "TopLevelEnvirionment") emptyEnvirionment $ AST.moduleDecls $ unLabel ast- val :: Value- val = (IntMap.!) (getLetBindings env) $ AST.uniqueIdentId entry- case val of- VProcess x -> return (x,env)++-- | Run the interpreter for a given module and top-level identifier.+-- Cast result to a process+runInterpreterP :: AST.LModule -> AST.UniqueIdent -> (Process,Env)+runInterpreterP ast entry = case val of+ VProcess x -> (x,env) _ -> throwTypingError "entrypoint is not a CSPM-process" (Just $ AST.bindingLoc entry) $ Just val+ where+ env = processDeclList (hs "TopLevelEnvirionment") emptyEnvirionment+ $ AST.moduleDecls $ unLabel ast+ val :: Value+ val = (IntMap.!) (getLetBindings env) $ AST.uniqueIdentId entry
src/CSPM/Interpreter/CoreInstances.hs view
@@ -75,8 +75,8 @@ isInRenamingRange _ty e rel = Set.member e $ renamingRange rel getRenamingDomain _ty = Set.toList . renamingDomain getRenamingRange _ty = Set.toList . renamingRange- imageRenaming _ty = Renaming.imageRenaming2- preImageRenaming _ty = Renaming.imageRenaming1+ imageRenaming _ty = Renaming.imageRenaming+ preImageRenaming _ty = Renaming.preImageRenaming singleEventToClosureSet _ty = ClosureSet.singleEventToClosureSet instance BF INT where
src/CSPM/Interpreter/Renaming.hs view
@@ -83,12 +83,12 @@ {- sets have actually no advantage because we convert to lists anyway -} -imageRenaming1 :: RenamingRelation -> Event -> [Event]-imageRenaming1 relation prefix+imageRenaming :: RenamingRelation -> Event -> [Event]+imageRenaming relation prefix = List.map snd $ List.filter (\(x,_) -> x == prefix) $ Set.toList $ renamingPairs relation -imageRenaming2 :: RenamingRelation -> Event -> [Event]-imageRenaming2 relation prefix+preImageRenaming :: RenamingRelation -> Event -> [Event]+preImageRenaming relation prefix = List.map fst $ List.filter (\(_,x) -> x == prefix) $ Set.toList $ renamingPairs relation isInRelation :: RenamingRelation -> Event -> Event -> Bool
src/CSPM/Interpreter/Test/CLI.hs view
@@ -40,7 +40,7 @@ import CSPM.Interpreter.Eval import qualified CSPM.Interpreter.Types as Types import CSPM.Interpreter.Types- (Value,initialEnvirionment,getLetBindings)+ (Value,emptyEnvirionment,getLetBindings) import CSPM.Interpreter.PrepareAST (prepareAST) import CSPM.Interpreter.Hash import CSPM.Interpreter.CoreInstances ()@@ -77,7 +77,7 @@ srcPlain <- case context of Just path -> readFile path Nothing -> return ""- let fileName = maybe "expression" id context+ let fileName = fromMaybe "expression" context {- this is a hack: we simply append the expression to be evaluated at the end of the sourcefile and parse both together in one go@@ -105,13 +105,12 @@ -- putStrLn $ "total : " ++ showTime(time_have_ast - startTime) time_start_execute <- getCPUTime- initEnv <- initialEnvirionment let entry :: AST.UniqueIdent entry = fromJust $ Map.lookup "test__entry" $ (\(x,_,_) -> x) renaming astP :: LModule astP = compilePattern astNew- env = processDeclList (hs "TopLevelEnvirionment") initEnv+ env = processDeclList (hs "TopLevelEnvirionment") emptyEnvirionment $ AST.moduleDecls $ unLabel astP val :: Value val = (IntMap.!) (getLetBindings env) $ AST.uniqueIdentId entry
src/CSPM/Interpreter/Types.hs view
@@ -145,9 +145,6 @@ ,letDigests :: IntMap Digest } -initialEnvirionment :: IO Env-initialEnvirionment = return emptyEnvirionment- emptyEnvirionment :: Env emptyEnvirionment = Env { argBindings = IntMap.empty