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/generator/allocate.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/modules/generator/allocate.scm (limited to 'src/modules/generator/allocate.scm') diff --git a/src/modules/generator/allocate.scm b/src/modules/generator/allocate.scm new file mode 100644 index 0000000..193cadb --- /dev/null +++ b/src/modules/generator/allocate.scm @@ -0,0 +1,16 @@ +(define-module (modules generator allocate) + #:use-module (modules utils assign-stack) + #:export (expansion->allocate)) + + +(define (expansion->allocate ast) + (define (allocate n) + (cond + ((null? n) n) + ((eq? (car n) 'tmp) + (list 'stack (make-location (cadr n)))) + ((list? (car n)) + (cons (allocate (car n)) (allocate (cdr n)))) + (#t + (cons (car n) (allocate (cdr n)))))) + (allocate ast)) -- cgit v1.2.3