1
1
mirror of https://github.com/github/semantic.git synced 2024-12-15 01:51:39 +03:00

Merge branch 'heap-frames' of https://github.com/github/semantic into heap-frames

This commit is contained in:
joshvera 2018-12-06 10:44:43 -05:00
commit 1ddd78b9de
2 changed files with 21 additions and 14 deletions

View File

@ -50,10 +50,8 @@ data Value term address
deriving (Eq, Ord, Show, Generic, NFData)
instance Ord address => ValueRoots address (Value term address) where
valueRoots v
| Closure _ _ _ _ _ _ _ <- v = undefined -- Env.addresses env
| otherwise = mempty
instance ValueRoots address (Value term address) where
valueRoots _ = lowerBound
instance ( FreeVariables term

View File

@ -31,12 +31,8 @@ instance Show1 Function where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable Function where
eval _ Function{..} = do
name <- maybeM (throwEvalError NoNameError) (declaredName functionName)
-- TODO: Should we declare the name of the function within `function`?
span <- ask @Span
currentScope' <- currentScope
let lexicalEdges = Map.singleton Lexical [ currentScope' ]
associatedScope <- newScope lexicalEdges
declare (Declaration name) span (Just associatedScope)
associatedScope <- declareFunction name span
params <- withScope associatedScope . for functionParameters $ \paramNode -> do
param <- maybeM (throwEvalError NoNameError) (declaredName paramNode)
@ -46,6 +42,23 @@ instance Evaluatable Function where
v <- function name params functionBody associatedScope
v <$ (value v >>= assign addr)
declareFunction :: ( Carrier sig m
, Member (State (ScopeGraph address)) sig
, Member (Allocator address) sig
, Member (Reader (address, address)) sig
, Member Fresh sig
, Ord address
)
=> Name
-> Span
-> Evaluator term address value m address
declareFunction name span = do
currentScope' <- currentScope
let lexicalEdges = Map.singleton Lexical [ currentScope' ]
associatedScope <- newScope lexicalEdges
declare (Declaration name) span (Just associatedScope)
pure associatedScope
instance Tokenize Function where
tokenize Function{..} = within' Scope.Function $ do
functionName
@ -74,12 +87,8 @@ instance Diffable Method where
instance Evaluatable Method where
eval _ Method{..} = do
name <- maybeM (throwEvalError NoNameError) (declaredName methodName)
-- TODO: Should we declare the name of the function within `function`?
span <- ask @Span
currentScope' <- currentScope
let lexicalEdges = Map.singleton Lexical [ currentScope' ]
associatedScope <- newScope lexicalEdges
declare (Declaration name) span (Just associatedScope)
associatedScope <- declareFunction name span
params <- withScope associatedScope $ do
let self = Name.name "__self"