diff options
author | bd <bdunahu@operationnull.com> | 2025-01-18 01:25:47 -0700 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-01-18 01:25:47 -0700 |
commit | ddd448ae86e5730d5cd297f44ec89ee3fa3c0006 (patch) | |
tree | 9eaa2c75b9b397fcef0fe9467d10f21cc1e07a0c /src/modules/generator/allocate.scm | |
parent | 1c216bd45a7d4fb529288192ecff46453309c485 (diff) |
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.
Diffstat (limited to 'src/modules/generator/allocate.scm')
-rw-r--r-- | src/modules/generator/allocate.scm | 16 |
1 files changed, 16 insertions, 0 deletions
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)) |