Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First optimizations #111

Merged
merged 3 commits into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions qi-lib/flow/core/compiler.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
racket/match
(only-in racket/list make-list)
"syntax.rkt"
"../aux-syntax.rkt")
"../aux-syntax.rkt"
macro-debugger/emit)
"impl.rkt"
(only-in racket/list make-list)
racket/function
Expand Down Expand Up @@ -169,11 +170,18 @@
#'(thread _0 ... fused _1 ...)]
[_ this-syntax]))

;; Applies f repeatedly to the init-val terminating the loop if the
;; result of f is #f or the new syntax object is eq? to the previous
;; (possibly initial) one.
;;
;; Caveats:
;; * the syntax object is not inspected, only eq? is used
;; * comparison is performed only between consecutive steps (does not handle cyclic occurences)
(define ((fix f) init-val)
;; may need to be modified to handle #f as a special terminator
(let ([new-val (f init-val)])
(if (eq? new-val init-val)
new-val
(if (or (not new-val)
(eq? new-val init-val))
init-val
((fix f) new-val))))

(define (deforest-pass stx)
Expand Down Expand Up @@ -270,8 +278,12 @@
;; TODO: use syntax-parse and match ~> specifically.
;; Since macros are expanded "outside in," presumably
;; it will naturally wrap the outermost ~>
(wrap-with-scopes #`(qi0->racket #,(rewrite-all-bindings stx))
(bound-identifiers stx))))
(let ([stx1 (wrap-with-scopes #`(qi0->racket #,(rewrite-all-bindings stx))
(bound-identifiers stx))])
(emit-local-step stx stx1 #:id #'process-bindings)
stx1))

)

(define-syntax (qi0->racket stx)
;; this is a macro so it receives the entire expression
Expand Down
Loading