From 5cfcf88a3772f5fcf96e9dda33e4e9c4980803bd Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 9 Nov 2018 17:13:09 -0500 Subject: [PATCH] Initial file --- test-find-local-vars.scm | 89 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 test-find-local-vars.scm diff --git a/test-find-local-vars.scm b/test-find-local-vars.scm new file mode 100644 index 00000000..3ef2edd0 --- /dev/null +++ b/test-find-local-vars.scm @@ -0,0 +1,89 @@ +(import (scheme base) (scheme write) (scheme cyclone ast) (scheme cyclone util) (scheme cyclone pretty-print)) + +(define (find-local-vars sexp) + (define (scan exp) + (cond + ((ast:lambda? exp) + (for-each + scan + (ast:lambda-body exp))) + ((quote? exp) exp) + ((const? exp) exp) + ((ref? exp) exp) + ((define? exp) + (for-each + scan + (define->exp exp))) + ((set!? exp) + (for-each + scan + (set!->exp exp))) + ((if? exp) + (scan (if->condition exp)) + (scan (if->then exp)) + (scan (if->else exp))) + ((app? exp) + (cond + ((ast:lambda? (car exp)) +;; TODO: want to find this: +;; ((lambda +;; (k$1080) +;; (if (Cyc-fast-eq +;; (car first$89$683) +;; (car row$90$684)) +;; (k$1080 if-equal$76$674) +;; (k$1080 if-different$77$675))) +;; (lambda +;; (r$1079) +;; (Cyc-seq +;; (vector-set! +;; vec$79$677 +;; i$88$682 +;; r$1079) +;; ((cell-get lp$80$87$681) +;; k$1073 +;; (Cyc-fast-plus i$88$682 1) +;; (cdr first$89$683) +;; (cdr row$90$684)))))))) + 'TODO) + (else + (map scan exp)))) + (else 'todo) + )) + (scan sexp)) + +(define sexp + '(lambda + (k$1073 i$88$682 first$89$683 row$90$684) + (if (Cyc-fast-eq + i$88$682 + number-of-cols$68$671) + (k$1073 + (Cyc-fast-eq + i$88$682 + number-of-cols$68$671)) + ((lambda + (k$1080) + (if (Cyc-fast-eq + (car first$89$683) + (car row$90$684)) + (k$1080 if-equal$76$674) + (k$1080 if-different$77$675))) + (lambda + (r$1079) + (Cyc-seq + (vector-set! + vec$79$677 + i$88$682 + r$1079) + ((cell-get lp$80$87$681) + k$1073 + (Cyc-fast-plus i$88$682 1) + (cdr first$89$683) + (cdr row$90$684)))))))) + +;(pretty-print +; (ast:ast->pp-sexp +; (ast:sexp->ast sexp))) + +(find-local-vars (ast:sexp->ast sexp))