mirror of
https://github.com/github/semantic.git
synced 2024-12-23 14:54:16 +03:00
Assignment eval now uses continutation, does envLookup
This commit is contained in:
parent
9f4eed9aef
commit
b821c4009c
@ -4,6 +4,7 @@ module Data.Syntax.Statement where
|
|||||||
import Abstract.Eval
|
import Abstract.Eval
|
||||||
import Abstract.Value
|
import Abstract.Value
|
||||||
import Abstract.FreeVariables
|
import Abstract.FreeVariables
|
||||||
|
import Abstract.Environment
|
||||||
import Abstract.Store
|
import Abstract.Store
|
||||||
import Algorithm
|
import Algorithm
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
@ -74,13 +75,16 @@ instance ( Monad m
|
|||||||
, Semigroup (Cell l (Value s a l))
|
, Semigroup (Cell l (Value s a l))
|
||||||
, MonadAddress l m
|
, MonadAddress l m
|
||||||
, MonadStore l (Value s a l) m
|
, MonadStore l (Value s a l) m
|
||||||
, FreeVariables1 s) => Eval l (Value s a l) m s a Assignment where
|
, MonadEnv l (Value s a l) m
|
||||||
eval ev Assignment{..} = do
|
, FreeVariables1 s)
|
||||||
|
=> Eval l (Value s a l) m s a Assignment where
|
||||||
|
eval ev yield Assignment{..} = do
|
||||||
let [var] = toList (freeVariables assignmentTarget)
|
let [var] = toList (freeVariables assignmentTarget)
|
||||||
v <- ev assignmentValue
|
v <- ev pure assignmentValue
|
||||||
a <- alloc @l var
|
env <- askEnv @l @(Value s a l)
|
||||||
|
a <- maybe (alloc @l var) pure (envLookup var env)
|
||||||
assign a v
|
assign a v
|
||||||
pure v
|
localEnv (envInsert var a) (yield v)
|
||||||
|
|
||||||
-- Returns
|
-- Returns
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user