blob: 3f42335b16d5064efb985e79cbe240e81decf6df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
module Test.Builtins (
builtins,
) where
import Data.Map qualified as M
import Data.Typeable
import Test
builtins :: [ ( VarName, SomeVarValue ) ]
builtins =
[ ( VarName "guard", builtinGuard )
, ( VarName "wait", builtinWait )
]
getArg :: Typeable a => FunctionArguments SomeExpr -> Maybe ArgumentKeyword -> a
getArg (FunctionArguments args) kw =
case M.lookup kw args of
Just (SomeExpr expr) | Just expr' <- cast expr -> expr'
_ -> error "parameter mismatch"
builtinGuard :: SomeVarValue
builtinGuard = SomeVarValue (FunctionArguments $ M.singleton Nothing (SomeArgumentType (NoDefault @Bool))) $
\sline args -> TestBlock [ Guard sline (getArg args Nothing) ]
builtinWait :: SomeVarValue
builtinWait = SomeVarValue mempty $ const . const $ TestBlock [ Wait ]
|