From de4c3e5f8af27d07ef5ad1532e4e0cb906361a56 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Fri, 16 Mar 2018 17:07:53 -0400 Subject: [PATCH] Take a stab at typechecking. --- src/Control/Abstract/Addressable.hs | 1 + src/Control/Abstract/Value.hs | 3 +++ src/Data/Abstract/Type.hs | 1 + 3 files changed, 5 insertions(+) diff --git a/src/Control/Abstract/Addressable.hs b/src/Control/Abstract/Addressable.hs index 47171c135..a2919363d 100644 --- a/src/Control/Abstract/Addressable.hs +++ b/src/Control/Abstract/Addressable.hs @@ -48,6 +48,7 @@ letrec name body = do instance (MonadFail m, LocationFor value ~ Precise, MonadHeap value m) => MonadAddressable Precise value m where deref = derefWith (maybeM uninitializedAddress . unLatest) alloc _ = do + -- Compute the next available address in the heap, then write an empty value into it. addr <- fmap (Address . Precise . heapSize) getHeap addr <$ modifyHeap (heapInit addr mempty) diff --git a/src/Control/Abstract/Value.hs b/src/Control/Abstract/Value.hs index e61384242..0c7b90914 100644 --- a/src/Control/Abstract/Value.hs +++ b/src/Control/Abstract/Value.hs @@ -261,6 +261,9 @@ instance (Alternative m, MonadEnvironment Type m, MonadFail m, MonadFresh m, Mon rational _ = pure Type.Rational multiple = pure . Type.Product array = pure . Type.Array + klass _ _ = pure Object + + objectEnvironment _ = pure mempty ifthenelse cond if' else' = unify cond Bool *> (if' <|> else') diff --git a/src/Data/Abstract/Type.hs b/src/Data/Abstract/Type.hs index 15fa96dbe..8da343b44 100644 --- a/src/Data/Abstract/Type.hs +++ b/src/Data/Abstract/Type.hs @@ -20,6 +20,7 @@ data Type | Var TName -- ^ A type variable. | Product [Type] -- ^ N-ary products. | Array [Type] -- ^ Arrays. Note that this is heterogenous. + | Object -- ^ Objects. Once we have some notion of inheritance we'll need to store a superclass. deriving (Eq, Ord, Show) -- TODO: À la carte representation of types.