Added a special (program) feature

This commit is contained in:
Justin Ethier 2018-11-10 06:52:54 -05:00
parent 74e56aeb2f
commit 8cbcf82121
2 changed files with 53 additions and 41 deletions

View file

@ -547,10 +547,13 @@
(in-prog-raw (read-file in-file)) (in-prog-raw (read-file in-file))
(program? (not (library? (car in-prog-raw)))) (program? (not (library? (car in-prog-raw))))
(in-prog (in-prog
(if program? (cond
in-prog-raw (program?
(Cyc-add-feature! 'program) ;; Load special feature
in-prog-raw)
(else
;; Account for any cond-expand declarations in the library ;; 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: 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 ;; 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) '())) (program:imports/code (if program? (import-reduction in-prog expander) '()))

View file

@ -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: ;; Local variable reduction:
;; Reduce given sexp by replacing certain lambda calls with a let containing ;; Reduce given sexp by replacing certain lambda calls with a let containing
@ -122,7 +128,9 @@
(return (return
(scan sexp))))) (scan sexp)))))
(define sexp (cond-expand
(program
(define sexp
'(lambda '(lambda
(k$1073 i$88$682 first$89$683 row$90$684) (k$1073 i$88$682 first$89$683 row$90$684)
(if (Cyc-fast-eq (if (Cyc-fast-eq
@ -152,10 +160,11 @@
(cdr first$89$683) (cdr first$89$683)
(cdr row$90$684)))))))) (cdr row$90$684))))))))
;(pretty-print ;(pretty-print
; (ast:ast->pp-sexp ; (ast:ast->pp-sexp
; (ast:sexp->ast sexp))) ; (ast:sexp->ast sexp)))
(pretty-print (pretty-print
(ast:ast->pp-sexp (ast:ast->pp-sexp
(opt:local-var-reduction (ast:sexp->ast sexp)))) (opt:local-var-reduction (ast:sexp->ast sexp))))
))