1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Add a defineClass convenience.

This commit is contained in:
Rob Rix 2018-06-18 10:27:12 -04:00
parent 4b0d8c2cd3
commit 7cd3afb2ba

View File

@ -5,6 +5,7 @@ import Control.Abstract.Environment
import Control.Abstract.Evaluator
import Control.Abstract.Heap
import Control.Abstract.Value
import qualified Data.Abstract.Environment as Env
import Data.Abstract.Name
import Data.Text (unpack)
import Prologue
@ -23,6 +24,23 @@ define name def = withCurrentCallStack callStack $ do
bind name addr
def >>= assign addr
defineClass :: ( AbstractValue address value effects
, HasCallStack
, Member (Allocator address value) effects
, Member (Env address) effects
, Member (Reader ModuleInfo) effects
, Member (Reader Span) effects
)
=> Name
-> [Name]
-> Evaluator address value effects a
-> Evaluator address value effects ()
defineClass name superclasses scope = define name $ do
env <- locally $ do
void $ scope
Env.head <$> getEnv
klass name (map (string . formatName) superclasses) env
lambda :: (AbstractFunction address value effects, Member Fresh effects)
=> (Name -> Evaluator address value effects address)
-> Evaluator address value effects value