1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 13:34:31 +03:00

Evaluate Module and Program using Imperative.

This commit is contained in:
Rob Rix 2018-03-13 12:04:48 -04:00
parent f709237e37
commit 6f10d8aa83
2 changed files with 2 additions and 16 deletions

View File

@ -124,14 +124,7 @@ instance Ord1 Program where liftCompare = genericLiftCompare
instance Show1 Program where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable Program where
eval (Program xs) = eval' xs
where
eval' [] = unit >>= interface
eval' [x] = subtermValue x >>= interface
eval' (x:xs) = do
_ <- subtermValue x
env <- getGlobalEnv
localEnv (envUnion env) (eval' xs)
eval (Program xs) = runImperative $ foldMap (Imperative . subtermValue) xs
-- | An accessibility modifier, e.g. private, public, protected, etc.
newtype AccessibilityModifier a = AccessibilityModifier ByteString

View File

@ -161,14 +161,7 @@ instance Show1 Module where liftShowsPrec = genericLiftShowsPrec
-- We need to ensure that all input files have aggregated their content into
-- a coherent module before we begin evaluating a module.
instance Evaluatable Module where
eval (Module _ xs) = eval' xs
where
eval' [] = unit >>= interface
eval' [x] = subtermValue x >>= interface
eval' (x:xs) = do
_ <- subtermValue x
env <- getGlobalEnv
localEnv (envUnion env) (eval' xs)
eval (Module _ xs) = runImperative $ foldMap (Imperative . subtermValue) xs
-- | A decorator in Python
data Decorator a = Decorator { decoratorIdentifier :: !a, decoratorParamaters :: ![a], decoratorBody :: !a }