From 8caee1226dcc9566649358f6af1f177e7341c76c Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 10 Dec 2018 09:53:12 -0500 Subject: [PATCH] Evaluate Statement.Assignment using ref. --- src/Data/Syntax/Statement.hs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/Data/Syntax/Statement.hs b/src/Data/Syntax/Statement.hs index a0e467166..61a1c5b97 100644 --- a/src/Data/Syntax/Statement.hs +++ b/src/Data/Syntax/Statement.hs @@ -173,26 +173,23 @@ instance Ord1 Assignment where liftCompare = genericLiftCompare instance Show1 Assignment where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Assignment where - eval eval _ Assignment{..} = do - lhs <- eval assignmentTarget + eval eval ref Assignment{..} = do + lhs <- ref assignmentTarget rhs <- eval assignmentValue - case lhs of - Rval val -> throwEvalError (DerefError val) - LvalMember lhsSlot -> do - case declaredName assignmentValue of - Just rhsName -> do - assocScope <- associatedScope (Declaration rhsName) - case assocScope of - Just assocScope' -> do - objectScope <- newScope (Map.singleton Import [ assocScope' ]) - putSlotDeclarationScope lhsSlot (Just objectScope) -- TODO: not sure if this is right - Nothing -> - pure () + case declaredName assignmentValue of + Just rhsName -> do + assocScope <- associatedScope (Declaration rhsName) + case assocScope of + Just assocScope' -> do + objectScope <- newScope (Map.singleton Import [ assocScope' ]) + putSlotDeclarationScope lhs (Just objectScope) -- TODO: not sure if this is right Nothing -> pure () - assign lhsSlot =<< Abstract.value rhs - pure (LvalMember lhsSlot) + Nothing -> + pure () + assign lhs =<< Abstract.value rhs + pure (LvalMember lhs) instance Tokenize Assignment where -- Should we be using 'assignmentContext' in here?