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

Define a helper for declaring functions/methods.

This commit is contained in:
Rob Rix 2018-12-06 10:19:22 -05:00
parent 8ff61d8299
commit 4913b252b8

View File

@ -46,6 +46,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