From fa44bd5c81bf6cbc357abe613e9fdf5c3a0f81dd Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 16 Jan 2022 01:58:58 +0530 Subject: ccwl: Do not expand to syntax values. Macros should not normally expand to syntax values as constant literals. We now do more work at the macro-expansion phase so that this is not necessary. * ccwl/ccwl.scm (collect-steps): In the returned objects, put syntax to reference function object instead of the function object itself. (key->output): Return syntax to construct an object instead of the object itself. (workflow): Do not expand to syntax values as constant literals. --- ccwl/ccwl.scm | 54 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index b6a2920..903f161 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -405,7 +405,7 @@ represented by objects." (key (output-id output) step-id)) (function-outputs function-object))) (list (make-step step-id - function-object + #'function (map (match-lambda ((arg . value) (cons (keyword->symbol arg) @@ -422,34 +422,44 @@ represented by objects." (x (error "Unrecognized syntax:" (syntax->datum #'x))))) (define (key->output key steps) - "Return the object corresponding to KEY, a object, in -STEPS, a list of objects. If no such object is found, -return #f." + "Return syntax to construct an object corresponding to KEY, +a object, in STEPS, a list of objects. If no such + object is found, return #f." (and-let* ((step-with-output (find (lambda (step) (eq? (step-id step) (key-step key))) - steps)) - (output (find (lambda (output) - (eq? (output-id output) - (key-cwl-id key))) - (step-out step-with-output)))) - (set-output-source output (cwl-key-address key)))) + steps))) + (with-syntax ((key-cwl-id (datum->syntax #f (key-cwl-id key)))) + #`(set-output-source (find (lambda (output) + (eq? (output-id output) + 'key-cwl-id)) + (function-outputs + #,(step-run step-with-output))) + #,(cwl-key-address key))))) (define-syntax workflow (lambda (x) (syntax-case x () ((_ (inputs ...) tree) - #`(let ((input-objects (list #,@(map input #'(inputs ...)))) - (output-keys steps (collect-steps #'tree (map (compose key input-spec-id) - #'(inputs ...))))) - ;; TODO: Error out on duplicated step IDs. - ;; TODO: Implement escape hatch #:other in workflow syntax. - (make-workflow steps - input-objects - ;; Find the output object for each output - ;; key. Filter out global workflow inputs. - (filter-map (cut key->output <> steps) - output-keys) - '()))) + (let ((output-keys steps (collect-steps + #'tree (map (compose key input-spec-id) + #'(inputs ...))))) + ;; TODO: Error out on duplicated step IDs. + ;; TODO: Implement escape hatch #:other in workflow syntax. + #`(make-workflow + (list #,@(map (lambda (step) + #`(make-step + #,(with-syntax ((id (datum->syntax #f (step-id step)))) + #''id) + #,(step-run step) + #,(with-syntax ((in (datum->syntax #f (step-in step)))) + #''in))) + steps)) + (list #,@(map input #'(inputs ...))) + ;; Find the output object for each output + ;; key. Filter out global workflow inputs. + (list #,@(filter-map (cut key->output <> steps) + output-keys)) + '()))) (x (error "Unrecognized workflow syntax [expected (workflow (input ...) tree)]:" (syntax->datum #'x)))))) -- cgit v1.2.3