1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 18:23:44 +03:00

Add BadLoads

This commit is contained in:
joshvera 2018-05-03 19:53:36 -04:00
parent 9f51129314
commit 9883948abd
2 changed files with 25 additions and 0 deletions

View File

@ -17,6 +17,7 @@ library
-- Analyses & term annotations
Analysis.Abstract.BadAddresses
, Analysis.Abstract.BadModuleResolutions
, Analysis.Abstract.BadLoads
, Analysis.Abstract.BadSyntax
, Analysis.Abstract.BadValues
, Analysis.Abstract.BadVariables

View File

@ -0,0 +1,24 @@
{-# LANGUAGE GADTs, GeneralizedNewtypeDeriving, TypeFamilies, TypeOperators, UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- For the Interpreter instances MonadEvaluator constraint
module Analysis.Abstract.BadLoads where
import Control.Abstract.Analysis
import Data.Abstract.Evaluatable
import Prologue
newtype BadLoads m (effects :: [* -> *]) a = BadLoads { runBadLoads :: m effects a }
deriving (Alternative, Applicative, Functor, Effectful, Monad)
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (BadLoads m)
deriving instance MonadAnalysis location term value effects m => MonadAnalysis location term value effects (BadLoads m)
instance ( Interpreter m effects
, MonadEvaluator location term value effects m
)
=> Interpreter (BadLoads m) (Resumable (LoadError term) ': effects) where
type Result (BadLoads m) (Resumable (LoadError term) ': effects) result = Result m effects result
interpret
= interpret
. runBadLoads
. raiseHandler (relay pure (\ (Resumable err) yield -> traceM ("LoadError:" <> show err) *> case err of
LoadError _ -> yield []))