diff --git a/cyclone.scm b/cyclone.scm index b277aef6..7eef0bc1 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -547,10 +547,13 @@ (in-prog-raw (read-file in-file)) (program? (not (library? (car in-prog-raw)))) (in-prog - (if program? - in-prog-raw + (cond + (program? + (Cyc-add-feature! 'program) ;; Load special feature + in-prog-raw) + (else ;; Account for any cond-expand declarations in the library - (list (lib:cond-expand (car in-prog-raw) expander)))) + (list (lib:cond-expand (car in-prog-raw) expander))))) ;; TODO: expand in-prog, if a library, using lib:cond-expand. (OK, this works now) ;; TODO: will also need to do below in lib:get-all-import-deps, after reading each library (program:imports/code (if program? (import-reduction in-prog expander) '())) diff --git a/test-find-local-vars.scm b/test-find-local-vars.scm index c7a3e894..02d66d54 100644 --- a/test-find-local-vars.scm +++ b/test-find-local-vars.scm @@ -1,4 +1,10 @@ -(import (scheme base) (scheme write) (scheme cyclone ast) (scheme cyclone util) (scheme cyclone pretty-print)) +(cond-expand + (program + (import (scheme base) + (scheme write) + (scheme cyclone ast) + (scheme cyclone util) + (scheme cyclone pretty-print)))) ;; Local variable reduction: ;; Reduce given sexp by replacing certain lambda calls with a let containing @@ -122,40 +128,43 @@ (return (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))) - -(pretty-print - (ast:ast->pp-sexp - (opt:local-var-reduction (ast:sexp->ast sexp)))) +(cond-expand + (program + (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))) + + (pretty-print + (ast:ast->pp-sexp + (opt:local-var-reduction (ast:sexp->ast sexp)))) + ))