diff --git a/src/Control/Abstract/Evaluator.hs b/src/Control/Abstract/Evaluator.hs index d476ba9b7..f0a2eb287 100644 --- a/src/Control/Abstract/Evaluator.hs +++ b/src/Control/Abstract/Evaluator.hs @@ -43,10 +43,15 @@ newtype Evaluator location value effects a = Evaluator { runEvaluator :: Eff eff deriving instance Member NonDet effects => Alternative (Evaluator location value effects) +-- | 'ValueRef' is the type subterms evaluate to and can represent either values directly ('Rval'), or references to values (lvals - such as local variables or object members) data ValueRef value where + -- Represents a value: Rval :: value -> ValueRef value + -- Represents a local variable. No environment is attached - it's assumed that LvalLocal will be evaluated in the same scope it was constructed: LvalLocal :: Name -> ValueRef value + -- Represents an object member: LvalMember :: value -> Name -> ValueRef value + deriving (Eq, Ord, Show) -- Effects diff --git a/src/Data/Abstract/Evaluatable.hs b/src/Data/Abstract/Evaluatable.hs index c364b62c3..319af322b 100644 --- a/src/Data/Abstract/Evaluatable.hs +++ b/src/Data/Abstract/Evaluatable.hs @@ -138,6 +138,7 @@ deriving instance Show (Unspecialized a b) instance Show1 (Unspecialized a) where liftShowsPrec _ _ = showsPrec +-- | Evaluates a 'Value' returning the referenced value value :: ( Addressable location effects , AbstractValue location value effects , Members '[ Reader (Environment location value) @@ -154,6 +155,7 @@ value (LvalLocal var) = variable var value (LvalMember obj prop) = evaluateInScopedEnv (pure obj) (variable prop) value (Rval val) = pure val +-- | Evaluates a 'Subterm' to its rval subtermValue :: ( Addressable location effects , AbstractValue location value effects , Members '[ Reader (Environment location value)