Separate env-tree construction and usage
This commit is contained in:
parent
24cc24b0d7
commit
65fc5bec75
@ -5,12 +5,12 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
module AST.Scope
|
module AST.Scope
|
||||||
( HasLocalScope (..)
|
-- ( HasLocalScope (..)
|
||||||
, addLocalScopes
|
-- , addLocalScopes
|
||||||
, lookupEnv
|
-- , lookupEnv
|
||||||
, Kind (..)
|
-- , Kind (..)
|
||||||
, ScopedDecl (..)
|
-- , ScopedDecl (..)
|
||||||
)
|
-- )
|
||||||
where
|
where
|
||||||
|
|
||||||
import Control.Arrow (second)
|
import Control.Arrow (second)
|
||||||
@ -59,11 +59,15 @@ addLocalScopes
|
|||||||
-> Pascal (Product ([ScopedDecl] : xs))
|
-> Pascal (Product ([ScopedDecl] : xs))
|
||||||
addLocalScopes tree =
|
addLocalScopes tree =
|
||||||
fmap (\xs -> Cons (envAt envWithREfs $ getRange xs) xs) tree
|
fmap (\xs -> Cons (envAt envWithREfs $ getRange xs) xs) tree
|
||||||
|
where
|
||||||
|
envWithREfs = getEnvTree tree
|
||||||
|
|
||||||
|
getEnvTree tree = envWithREfs
|
||||||
where
|
where
|
||||||
envWithREfs = flip execState env do
|
envWithREfs = flip execState env do
|
||||||
flip traverseOnly tree \r (Name t) -> do
|
flip traverseOnly tree \r (Name t) -> do
|
||||||
modify $ addRef (getRange r) t
|
modify $ getRange r `addRef` t
|
||||||
return (Name t)
|
return $ Name t
|
||||||
|
|
||||||
env
|
env
|
||||||
= execCollectM
|
= execCollectM
|
||||||
|
Loading…
Reference in New Issue
Block a user