From 7ade83a3671f61ee5dcaa9cece260d536621de83 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 26 Nov 2018 13:06:01 -0500 Subject: [PATCH] objectMembers Co-Authored-By: Rob Rix --- test/SpecHelpers.hs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/test/SpecHelpers.hs b/test/SpecHelpers.hs index c08672046..30e746a4c 100644 --- a/test/SpecHelpers.hs +++ b/test/SpecHelpers.hs @@ -15,6 +15,7 @@ module SpecHelpers , LogQueue , StatQueue , lookupDeclaration +, objectMembers ) where import Control.Abstract hiding (lookupDeclaration) @@ -151,16 +152,22 @@ testEvaluating type Val term = Value term Precise --- deNamespace :: Heap Precise Precise (Value term Precise) --- -> Value term Precise --- -> Maybe (Name, [Name]) --- deNamespace heap ns@(Namespace name _ _) = (,) name . Env.allNames <$> namespaceScope heap ns --- deNamespace _ _ = Nothing +objectMembers :: Heap Precise Precise (Value term Precise) + -> ScopeGraph Precise + -> Value term Precise + -> Maybe [Name] +objectMembers heap scopeGraph (Object frame) = frameNames heap scopeGraph frame +objectMembers _ _ _ = Nothing + +frameNames :: Heap Precise Precise (Value term Precise) + -> ScopeGraph Precise + -> Precise + -> Maybe [ Name ] +frameNames heap scopeGraph frame = do + scopeAddress <- Heap.scopeLookup frame heap + scope <- ScopeGraph.lookupScope scopeAddress scopeGraph + pure (unDeclaration <$> ScopeGraph.declarationNames scope scopeGraph) --- namespaceScope :: Heap Precise Precise (Value term Precise) --- -> Value term Precise --- -> Maybe (Environment Precise) --- namespaceScope heap ns@(Namespace _ _ _) -- = either (const Nothing) (snd . snd) -- . run -- . runFresh