mirror of
https://github.com/github/semantic.git
synced 2025-01-01 19:55:34 +03:00
Evaluate Statement.Assignment using ref.
This commit is contained in:
parent
0adaad3ba0
commit
8caee1226d
@ -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?
|
||||
|
Loading…
Reference in New Issue
Block a user