summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-02-27 22:12:33 -0500
committerDavid Thompson <dthompson2@worcester.edu>2023-06-08 08:14:41 -0400
commit6413818c676d3e230284bce14078ab5fdda52994 (patch)
treea857de478760ed09f72fd4d885ff1fe8fc429022
parentf6d7108b52110b6605ecf90d82e91c6ebb901ec7 (diff)
Add escape hatch for inserting Scheme values into Seagull code.
-rw-r--r--chickadee/graphics/seagull.scm12
1 files changed, 11 insertions, 1 deletions
diff --git a/chickadee/graphics/seagull.scm b/chickadee/graphics/seagull.scm
index 6ff764e..567522f 100644
--- a/chickadee/graphics/seagull.scm
+++ b/chickadee/graphics/seagull.scm
@@ -3275,6 +3275,14 @@
(reverse uniforms)
`(begin ,@body))))))
+;; Allow importing Scheme values into Seagull expressions with special
+;; '$' syntax, such as numeric constants or user-defined shader types.
+(define-syntax seagull-quasiquote
+ (syntax-rules ($)
+ ((_ ($ x)) x)
+ ((_ (x ...)) (list (seagull-quasiquote x) ...))
+ ((_ x) (quote x))))
+
;; Using syntax-case allows us to compile shaders to their fully typed
;; intermediate form at compile time, leaving only GLSL emission for
;; runtime.
@@ -3284,7 +3292,9 @@
((_ name stage body ...)
(let*-values (((inputs outputs uniforms body)
(partition-globals
- (syntax->datum #'(body ...)))))
+ (syntax->datum
+ (eval #'(seagull-quasiquote (body ...))
+ (current-module))))))
(define-values (compiled global-map max-id)
(compile-seagull #:stage (syntax->datum #'stage)
#:inputs inputs