aboutsummaryrefslogtreecommitdiff
path: root/src/macros
diff options
context:
space:
mode:
authorArun Isaac2021-02-05 15:00:27 +0530
committerArun Isaac2021-02-05 15:00:27 +0530
commitc31a57815be4d3ef5f6fd28cc9a34b3be55bfe56 (patch)
treec1be91a98018535ea5fd934e1986c3d3e5ba0128 /src/macros
parent7352aa8150d0012d10be7b1aaa341be7c459a05a (diff)
downloadnsmc-c31a57815be4d3ef5f6fd28cc9a34b3be55bfe56.tar.gz
nsmc-c31a57815be4d3ef5f6fd28cc9a34b3be55bfe56.tar.lz
nsmc-c31a57815be4d3ef5f6fd28cc9a34b3be55bfe56.zip
Migrate C source to SC.
sph-sc is a scheme-like S-expression syntax for C. It elements much of the pain and repetition involved in writing C syntax. * src/extent-sampling.c, src/gaussian-nd-random.c, src/nd-random.c, src/oracles.c, src/utils.c: Delete files. * src/extent-sampling.sc, src/gaussian-nd-random.sc, src/macros/macros.sc, src/nd-random.sc, src/oracles.sc, src/utils.sc: New files. * CMakeLists.txt: Generate C source files from SC source files.
Diffstat (limited to 'src/macros')
-rw-r--r--src/macros/macros.sc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/macros/macros.sc b/src/macros/macros.sc
new file mode 100644
index 0000000..6ffc7ec
--- /dev/null
+++ b/src/macros/macros.sc
@@ -0,0 +1,12 @@
+(sc-define-syntax (for-i index limit body ...)
+ (for ((define index int 0)
+ (< index limit)
+ (set+ index 1))
+ body ...))
+
+(sc-define-syntax (with-alloc var type allocate free body ...)
+ (let* ()
+ (declare var type)
+ (set var allocate)
+ body ...
+ (free var)))