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:
parent
8ff61d8299
commit
4913b252b8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user