1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 20:41:38 +03:00

Allow allocation in assignment again

This commit is contained in:
Timothy Clem 2018-04-12 14:22:55 -07:00
parent 01d3e7d547
commit 97a566e973

View File

@ -96,8 +96,15 @@ instance Show1 Assignment where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable Assignment where
eval Assignment{..} = do
lhs <- subtermValue assignmentTarget >>= scopedEnvironment
localEnv (mappend lhs) (subtermValue assignmentValue)
case freeVariables (subterm assignmentTarget) of
[name] -> do
v <- subtermValue assignmentValue
addr <- lookupOrAlloc name
assign addr v
modifyEnv (Env.insert name addr) $> v
_ -> do
lhs <- subtermValue assignmentTarget >>= scopedEnvironment
localEnv (mappend lhs) (subtermValue assignmentValue)
-- | Post increment operator (e.g. 1++ in Go, or i++ in C).
newtype PostIncrement a = PostIncrement a