From d67825ea3f441523e2814b831d397d95c0dc46a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 9 Feb 2025 21:59:12 +0100 Subject: Provide imported definitions at run-time --- src/Test/Builtins.hs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/Test/Builtins.hs') diff --git a/src/Test/Builtins.hs b/src/Test/Builtins.hs index a676a35..29e54af 100644 --- a/src/Test/Builtins.hs +++ b/src/Test/Builtins.hs @@ -9,22 +9,24 @@ import Data.Text (Text) import Process (Process) import Test -builtins :: [ ( VarName, SomeVarValue ) ] +builtins :: [ ( FqVarName, SomeVarValue ) ] builtins = - [ ( VarName "send", builtinSend ) - , ( VarName "flush", builtinFlush ) - , ( VarName "guard", builtinGuard ) - , ( VarName "wait", builtinWait ) + [ fq "send" builtinSend + , fq "flush" builtinFlush + , fq "guard" builtinGuard + , fq "wait" builtinWait ] + where + fq name impl = ( GlobalVarName (ModuleName [ "$" ]) (VarName name), impl ) getArg :: ExprType a => FunctionArguments SomeVarValue -> Maybe ArgumentKeyword -> a getArg args = fromMaybe (error "parameter mismatch") . getArgMb args getArgMb :: ExprType a => FunctionArguments SomeVarValue -> Maybe ArgumentKeyword -> Maybe a getArgMb (FunctionArguments args) kw = do - fromSomeVarValue SourceLineBuiltin (VarName "") =<< M.lookup kw args + fromSomeVarValue SourceLineBuiltin (LocalVarName (VarName "")) =<< M.lookup kw args -getArgVars :: FunctionArguments SomeVarValue -> Maybe ArgumentKeyword -> [ (( VarName, [ Text ] ), SomeVarValue ) ] +getArgVars :: FunctionArguments SomeVarValue -> Maybe ArgumentKeyword -> [ (( FqVarName, [ Text ] ), SomeVarValue ) ] getArgVars (FunctionArguments args) kw = do maybe [] svvVariables $ M.lookup kw args -- cgit v1.2.3