From ddd448ae86e5730d5cd297f44ec89ee3fa3c0006 Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 18 Jan 2025 01:25:47 -0700 Subject: use a scheme procedures+eval to manage and transform AST Removes records for a more-managable scheme-syntax approach. Modules+overriding allows for the IR itself to be represented and evaluated as scheme code during each transformation. --- src/modules/utils/assign-stack.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/modules/utils/assign-stack.scm (limited to 'src/modules/utils/assign-stack.scm') diff --git a/src/modules/utils/assign-stack.scm b/src/modules/utils/assign-stack.scm new file mode 100644 index 0000000..8037400 --- /dev/null +++ b/src/modules/utils/assign-stack.scm @@ -0,0 +1,15 @@ +(define-module (modules utils assign-stack) + #:export (make-location + get-frame-size)) + + +(define make-location) +(define get-frame-size) +(let ((dict (make-hash-table)) + (ptr 0)) + (set! make-location + (lambda (id) + (or (hash-ref dict id) + (begin (set! ptr (1+ ptr)) + (hash-set! dict id (get-frame-size)))))) + (set! get-frame-size (lambda () (* -4 ptr)))) -- cgit v1.2.3