From 495bdf7812f4f793eb1fad03d75d40e97d1aa745 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 17 May 2021 02:17:24 +0530 Subject: Abstract out command variable reflection. * ccwl/ccwl.scm (command-variable, command-syntax->object): New functions. (workflow-steps): Use command-variable and command-syntax->object. --- ccwl/ccwl.scm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index 1d370fa..1469471 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -294,6 +294,15 @@ ;; Global input/output (symbol->string (key-name key)))) +(define (command-variable command-syntax) + "Return the corresponding module variable if command described by +COMMAND-SYNTAX is a valid defined ccwl command. Else, return #f." + (module-variable (current-module) + (syntax->datum command-syntax))) + +(define (command-syntax->object command-syntax) + (variable-ref (command-variable command-syntax))) + (define (workflow-steps x input-keys) "Traverse ccwl source X and return list of steps. INPUT-KEYS is a list of supplied input objects." @@ -315,12 +324,10 @@ list of supplied input objects." ;; messages. (begin ;; Test for undefined command. - (unless (module-variable (current-module) - (syntax->datum #'command)) + (unless (command-variable #'command) (error "Undefined ccwl command:" (syntax->datum #'command))) (let ((input-key-symbols (map key-name input-keys)) - (command-object (module-ref (current-module) - (syntax->datum #'command))) + (command-object (command-syntax->object #'command)) (step-id (syntax->datum #'step-id))) ;; Test for missing required parameters. ;; TODO: Filter out optional parameters. -- cgit v1.2.3