retabbing, dumping a 'local', no longer using parenthesized module form
This commit is contained in:
parent
53db721ee9
commit
2cebd8f4cb
|
@ -762,375 +762,371 @@
|
||||||
; highlight-placeholder --- and a list of sexps which go in the holes
|
; highlight-placeholder --- and a list of sexps which go in the holes
|
||||||
|
|
||||||
(define (reconstruct-current mark-list break-kind returned-value-list render-settings)
|
(define (reconstruct-current mark-list break-kind returned-value-list render-settings)
|
||||||
(local
|
|
||||||
(
|
; ;; ;;; ;;; ;;; ; ;; ; ; ;; ; ;; ;;; ; ;;
|
||||||
|
;; ; ; ; ; ; ;; ; ; ;; ; ;; ; ; ; ;;
|
||||||
; ;; ;;; ;;; ;;; ; ;; ; ; ;; ; ;; ;;; ; ;;
|
; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
|
||||||
;; ; ; ; ; ; ;; ; ; ;; ; ;; ; ; ; ;;
|
; ;;;;; ; ; ; ; ; ;;;;; ; ; ; ; ; ;;;;; ;
|
||||||
; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
|
; ; ; ; ; ; ; ; ; ; ; ; ; ;
|
||||||
; ;;;;; ; ; ; ; ; ;;;;; ; ; ; ; ; ;;;;; ;
|
; ; ; ; ; ; ; ; ; ; ; ; ; ;
|
||||||
; ; ; ; ; ; ; ; ; ; ; ; ; ;
|
; ;;;; ;;; ;;; ; ; ; ; ; ; ; ;;;; ;
|
||||||
; ; ; ; ; ; ; ; ; ; ; ; ; ;
|
|
||||||
; ;;;; ;;; ;;; ; ; ; ; ; ; ; ;;;; ;
|
|
||||||
|
(define (recon-inner mark-list so-far)
|
||||||
|
(let* ([recon-source-current-marks
|
||||||
(define (recon-inner mark-list so-far)
|
(lambda (expr)
|
||||||
(let* ([recon-source-current-marks
|
(recon-source-expr expr mark-list null null render-settings))]
|
||||||
(lambda (expr)
|
[top-mark (car mark-list)]
|
||||||
(recon-source-expr expr mark-list null null render-settings))]
|
[exp (mark-source top-mark)]
|
||||||
[top-mark (car mark-list)]
|
[iota (lambda (x) (build-list x (lambda (x) x)))]
|
||||||
[exp (mark-source top-mark)]
|
|
||||||
[iota (lambda (x) (build-list x (lambda (x) x)))]
|
[recon-let
|
||||||
|
(lambda ()
|
||||||
[recon-let
|
(with-syntax ([(label ((vars rhs) ...) . bodies) exp])
|
||||||
(lambda ()
|
(match-let*
|
||||||
(with-syntax ([(label ((vars rhs) ...) . bodies) exp])
|
([binding-sets (map syntax->list (syntax->list #'(vars ...)))]
|
||||||
(match-let*
|
[binding-list (apply append binding-sets)]
|
||||||
([binding-sets (map syntax->list (syntax->list #'(vars ...)))]
|
[glumps
|
||||||
[binding-list (apply append binding-sets)]
|
(map (lambda (binding-set rhs)
|
||||||
[glumps
|
(make-let-glump
|
||||||
(map (lambda (binding-set rhs)
|
(map (lambda (binding)
|
||||||
(make-let-glump
|
(stepper-syntax-property binding
|
||||||
(map (lambda (binding)
|
'stepper-lifted-name
|
||||||
(stepper-syntax-property binding
|
(binding-lifted-name mark-list binding)))
|
||||||
'stepper-lifted-name
|
binding-set)
|
||||||
(binding-lifted-name mark-list binding)))
|
rhs
|
||||||
binding-set)
|
(map (lambda (arg-binding)
|
||||||
rhs
|
(lookup-binding mark-list arg-binding))
|
||||||
(map (lambda (arg-binding)
|
binding-set)))
|
||||||
(lookup-binding mark-list arg-binding))
|
binding-sets
|
||||||
binding-set)))
|
(syntax->list #`(rhs ...)))]
|
||||||
binding-sets
|
[num-defns-done (lookup-binding mark-list let-counter)]
|
||||||
(syntax->list #`(rhs ...)))]
|
[(vector done-glumps not-done-glumps)
|
||||||
[num-defns-done (lookup-binding mark-list let-counter)]
|
(n-split-list num-defns-done glumps)]
|
||||||
[(vector done-glumps not-done-glumps)
|
[recon-lifted
|
||||||
(n-split-list num-defns-done glumps)]
|
(lambda (names expr)
|
||||||
[recon-lifted
|
#`(#,names #,expr))]
|
||||||
(lambda (names expr)
|
[before-bindings
|
||||||
#`(#,names #,expr))]
|
(map
|
||||||
[before-bindings
|
(lambda (glump)
|
||||||
(map
|
(let* ([name-set (let-glump-name-set glump)]
|
||||||
(lambda (glump)
|
[rhs-val-set (map (lambda (val)
|
||||||
(let* ([name-set (let-glump-name-set glump)]
|
(if (> (length name-set) 0)
|
||||||
[rhs-val-set (map (lambda (val)
|
(recon-value val render-settings (car name-set))
|
||||||
(if (> (length name-set) 0)
|
(recon-value val render-settings)))
|
||||||
(recon-value val render-settings (car name-set))
|
(let-glump-val-set glump))])
|
||||||
(recon-value val render-settings)))
|
(if (= (length rhs-val-set) 1)
|
||||||
(let-glump-val-set glump))])
|
#`(#,name-set #,@rhs-val-set)
|
||||||
(if (= (length rhs-val-set) 1)
|
#`(#,name-set (values #,rhs-val-set)))))
|
||||||
#`(#,name-set #,@rhs-val-set)
|
done-glumps)]
|
||||||
#`(#,name-set (values #,rhs-val-set)))))
|
[reconstruct-remaining-def
|
||||||
done-glumps)]
|
(lambda (glump)
|
||||||
[reconstruct-remaining-def
|
(let ([rhs-source (let-glump-exp glump)]
|
||||||
(lambda (glump)
|
[rhs-name-set (let-glump-name-set glump)])
|
||||||
(let ([rhs-source (let-glump-exp glump)]
|
(recon-lifted rhs-name-set
|
||||||
[rhs-name-set (let-glump-name-set glump)])
|
(recon-source-current-marks rhs-source))))]
|
||||||
(recon-lifted rhs-name-set
|
[after-bindings
|
||||||
(recon-source-current-marks rhs-source))))]
|
(if (pair? not-done-glumps)
|
||||||
[after-bindings
|
(if (eq? so-far nothing-so-far)
|
||||||
(if (pair? not-done-glumps)
|
(map reconstruct-remaining-def not-done-glumps)
|
||||||
(if (eq? so-far nothing-so-far)
|
(cons (recon-lifted (let-glump-name-set (car not-done-glumps)) so-far)
|
||||||
(map reconstruct-remaining-def not-done-glumps)
|
(map reconstruct-remaining-def (cdr not-done-glumps))))
|
||||||
(cons (recon-lifted (let-glump-name-set (car not-done-glumps)) so-far)
|
null)]
|
||||||
(map reconstruct-remaining-def (cdr not-done-glumps))))
|
[recon-bindings (append before-bindings after-bindings)]
|
||||||
null)]
|
;; JBC: deleted a bunch of dead code here referring to a never-set "stepper-offset" index...
|
||||||
[recon-bindings (append before-bindings after-bindings)]
|
;; frightening.
|
||||||
;; JBC: deleted a bunch of dead code here referring to a never-set "stepper-offset" index...
|
[rectified-bodies
|
||||||
;; frightening.
|
(for/list ([body (in-list (syntax->list #'bodies))])
|
||||||
[rectified-bodies
|
(recon-source-expr body mark-list binding-list binding-list render-settings))])
|
||||||
(for/list ([body (in-list (syntax->list #'bodies))])
|
(attach-info #`(label #,recon-bindings #,@rectified-bodies) exp))))])
|
||||||
(recon-source-expr body mark-list binding-list binding-list render-settings))])
|
|
||||||
(attach-info #`(label #,recon-bindings #,@rectified-bodies) exp))))])
|
; STC: cache any running promises in the top mark
|
||||||
|
; Means that promise is being evaluated.
|
||||||
; STC: cache any running promises in the top mark
|
; NOTE: This wont wind running promises nested in another promise.
|
||||||
; Means that promise is being evaluated.
|
; Those wont be detected until the outer promise is being
|
||||||
; NOTE: This wont wind running promises nested in another promise.
|
; reconed, so we cant handle it until then.
|
||||||
; Those wont be detected until the outer promise is being
|
(let ([maybe-running-promise
|
||||||
; reconed, so we cant handle it until then.
|
(findf (λ (f) (and (promise? f) (nested-promise-running? f)))
|
||||||
(let ([maybe-running-promise
|
(map mark-binding-value (mark-bindings top-mark)))])
|
||||||
(findf (λ (f) (and (promise? f) (nested-promise-running? f)))
|
(when (and maybe-running-promise
|
||||||
(map mark-binding-value (mark-bindings top-mark)))])
|
(not (hash-has-key? partially-evaluated-promises-table
|
||||||
(when (and maybe-running-promise
|
maybe-running-promise))
|
||||||
(not (hash-has-key? partially-evaluated-promises-table
|
(not (eq? so-far nothing-so-far)))
|
||||||
maybe-running-promise))
|
(hash-set! partially-evaluated-promises-table
|
||||||
(not (eq? so-far nothing-so-far)))
|
maybe-running-promise so-far)))
|
||||||
(hash-set! partially-evaluated-promises-table
|
|
||||||
maybe-running-promise so-far)))
|
(if (stepper-syntax-property exp 'stepper-fake-exp)
|
||||||
|
|
||||||
(if (stepper-syntax-property exp 'stepper-fake-exp)
|
(kernel:kernel-syntax-case
|
||||||
|
exp #f
|
||||||
(kernel:kernel-syntax-case exp #f
|
[(begin . bodies)
|
||||||
[(begin . bodies)
|
(if (eq? so-far nothing-so-far)
|
||||||
(if (eq? so-far nothing-so-far)
|
(error 'recon-inner "breakpoint before a begin reduction should have a result value in exp: ~a" (syntax->datum exp))
|
||||||
(error 'recon-inner "breakpoint before a begin reduction should have a result value in exp: ~a" (syntax->datum exp))
|
#`(begin #,so-far #,@(map recon-source-current-marks (cdr (syntax->list #'bodies)))))]
|
||||||
#`(begin #,so-far #,@(map recon-source-current-marks (cdr (syntax->list #'bodies)))))]
|
[(begin0 first-body . rest-bodies)
|
||||||
[(begin0 first-body . rest-bodies)
|
(if (eq? so-far nothing-so-far)
|
||||||
(if (eq? so-far nothing-so-far)
|
(error 'recon-inner "breakpoint before a begin0 reduction should have a result value in exp: ~a" (syntax->datum exp))
|
||||||
(error 'recon-inner "breakpoint before a begin0 reduction should have a result value in exp: ~a" (syntax->datum exp))
|
#`(begin0 #,(recon-value (lookup-binding mark-list begin0-temp) render-settings)
|
||||||
#`(begin0 #,(recon-value (lookup-binding mark-list begin0-temp) render-settings)
|
#,so-far
|
||||||
#,so-far
|
#,@(map recon-source-current-marks (syntax->list #`rest-bodies))))]
|
||||||
#,@(map recon-source-current-marks (syntax->list #`rest-bodies))))]
|
[else
|
||||||
[else
|
(error 'recon-inner "unexpected fake-exp expression: ~a" (syntax->datum exp))])
|
||||||
(error 'recon-inner "unexpected fake-exp expression: ~a" (syntax->datum exp))])
|
|
||||||
|
(kernel:kernel-syntax-case
|
||||||
(kernel:kernel-syntax-case exp #f
|
exp #f
|
||||||
; variable references
|
; variable references
|
||||||
[id
|
[id
|
||||||
(identifier? (syntax id))
|
(identifier? (syntax id))
|
||||||
(if (eq? so-far nothing-so-far)
|
(if (eq? so-far nothing-so-far)
|
||||||
(recon-source-current-marks exp)
|
(recon-source-current-marks exp)
|
||||||
(error 'recon-inner "variable reference given as context: ~a" exp))]
|
(error 'recon-inner "variable reference given as context: ~a" exp))]
|
||||||
|
|
||||||
[(#%top . id)
|
[(#%top . id)
|
||||||
(if (eq? so-far nothing-so-far)
|
(if (eq? so-far nothing-so-far)
|
||||||
(recon-source-current-marks exp)
|
(recon-source-current-marks exp)
|
||||||
(error 'recon-inner "variable reference given as context: ~a" exp))]
|
(error 'recon-inner "variable reference given as context: ~a" exp))]
|
||||||
|
|
||||||
; applications
|
; applications
|
||||||
[(#%plain-app . terms)
|
[(#%plain-app . terms)
|
||||||
(attach-info
|
(attach-info
|
||||||
(match-let*
|
(match-let*
|
||||||
([sub-exprs (syntax->list (syntax terms))]
|
([sub-exprs (syntax->list (syntax terms))]
|
||||||
[arg-temps (build-list (length sub-exprs) get-arg-var)]
|
[arg-temps (build-list (length sub-exprs) get-arg-var)]
|
||||||
[arg-vals (map (lambda (arg-temp)
|
[arg-vals (map (lambda (arg-temp)
|
||||||
(lookup-binding mark-list arg-temp))
|
(lookup-binding mark-list arg-temp))
|
||||||
arg-temps)]
|
arg-temps)]
|
||||||
[(vector evaluated unevaluated) (split-list (lambda (x) (eq? (cadr x) *unevaluated*))
|
[(vector evaluated unevaluated) (split-list (lambda (x) (eq? (cadr x) *unevaluated*))
|
||||||
(zip sub-exprs arg-vals))]
|
(zip sub-exprs arg-vals))]
|
||||||
[rectified-evaluated (map (lx (recon-value _ render-settings #f so-far))
|
[rectified-evaluated (map (lx (recon-value _ render-settings #f so-far))
|
||||||
(map cadr evaluated))])
|
(map cadr evaluated))])
|
||||||
(case (mark-label (car mark-list))
|
(case (mark-label (car mark-list))
|
||||||
((not-yet-called)
|
((not-yet-called)
|
||||||
(if (null? unevaluated)
|
(if (null? unevaluated)
|
||||||
#`(#%plain-app . #,rectified-evaluated)
|
#`(#%plain-app . #,rectified-evaluated)
|
||||||
#`(#%plain-app
|
#`(#%plain-app
|
||||||
#,@rectified-evaluated
|
#,@rectified-evaluated
|
||||||
#,so-far
|
#,so-far
|
||||||
#,@(map recon-source-current-marks (cdr (map car unevaluated))))))
|
#,@(map recon-source-current-marks (cdr (map car unevaluated))))))
|
||||||
((called) ; unevaluated = null
|
((called) ; unevaluated = null
|
||||||
(stepper-syntax-property
|
(stepper-syntax-property
|
||||||
(if (eq? so-far nothing-so-far)
|
(if (eq? so-far nothing-so-far)
|
||||||
(datum->syntax #'here `(,#'#%plain-app ...)) ; in unannotated code ... can this occur?
|
(datum->syntax #'here `(,#'#%plain-app ...)) ; in unannotated code ... can this occur?
|
||||||
; dont show ellipses for force (and other lazy fns)
|
; dont show ellipses for force (and other lazy fns)
|
||||||
; object-name is good enough here, so dont need to add another "special val"
|
; object-name is good enough here, so dont need to add another "special val"
|
||||||
(let ([obj-name (object-name (car arg-vals))])
|
(let ([obj-name (object-name (car arg-vals))])
|
||||||
(cond [(ormap
|
(cond [(ormap
|
||||||
(lx (eq? obj-name _))
|
(lx (eq? obj-name _))
|
||||||
'(force ! !! !list !!list
|
'(force ! !! !list !!list
|
||||||
caar cadr cdar cddr caaar caadr cadar caddr cdaar cdadr cddar
|
caar cadr cdar cddr caaar caadr cadar caddr cdaar cdadr cddar
|
||||||
cdddr caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
|
cdddr caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
|
||||||
cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
|
cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
|
||||||
first second third fourth fifth sixth seventh eighth take
|
first second third fourth fifth sixth seventh eighth take
|
||||||
eq? eqv? equal? list? length list-ref list-tail append reverse
|
eq? eqv? equal? list? length list-ref list-tail append reverse
|
||||||
empty? assoc assq assv cons? remove remq remv member memq memv))
|
empty? assoc assq assv cons? remove remq remv member memq memv))
|
||||||
#`(#%plain-app . #,rectified-evaluated)]
|
#`(#%plain-app . #,rectified-evaluated)]
|
||||||
[else
|
[else
|
||||||
(datum->syntax #'here `(,#'#%plain-app ... ,so-far ...))])))
|
(datum->syntax #'here `(,#'#%plain-app ... ,so-far ...))])))
|
||||||
'stepper-args-of-call
|
'stepper-args-of-call
|
||||||
rectified-evaluated))
|
rectified-evaluated))
|
||||||
(else
|
(else
|
||||||
(error 'recon-inner "bad label (~v) in application mark in expr: ~a" (mark-label (car mark-list)) exp))))
|
(error 'recon-inner "bad label (~v) in application mark in expr: ~a" (mark-label (car mark-list)) exp))))
|
||||||
exp)]
|
exp)]
|
||||||
|
|
||||||
; define-struct
|
; define-struct
|
||||||
;
|
;
|
||||||
; [(z:struct-form? expr)
|
; [(z:struct-form? expr)
|
||||||
; (if (comes-from-define-struct? expr)
|
; (if (comes-from-define-struct? expr)
|
||||||
; so-far
|
; so-far
|
||||||
; (let ([super-expr (z:struct-form-super expr)]
|
; (let ([super-expr (z:struct-form-super expr)]
|
||||||
; [raw-type (utils:read->raw (z:struct-form-type expr))]
|
; [raw-type (utils:read->raw (z:struct-form-type expr))]
|
||||||
; [raw-fields (map utils:read->raw (z:struct-form-fields expr))])
|
; [raw-fields (map utils:read->raw (z:struct-form-fields expr))])
|
||||||
; (if super-expr
|
; (if super-expr
|
||||||
; `(struct (,raw-type ,so-far)
|
; `(struct (,raw-type ,so-far)
|
||||||
; ,raw-fields)
|
; ,raw-fields)
|
||||||
; `(struct ,raw-type ,raw-fields))))]
|
; `(struct ,raw-type ,raw-fields))))]
|
||||||
|
|
||||||
; if
|
; if
|
||||||
[(if test then else)
|
[(if test then else)
|
||||||
(begin
|
(begin
|
||||||
(when (eq? so-far nothing-so-far)
|
(when (eq? so-far nothing-so-far)
|
||||||
(error 'reconstruct "breakpoint before an if reduction should have a result value"))
|
(error 'reconstruct "breakpoint before an if reduction should have a result value"))
|
||||||
(attach-info
|
(attach-info
|
||||||
#`(if #,so-far
|
#`(if #,so-far
|
||||||
#,(recon-source-current-marks (syntax then))
|
#,(recon-source-current-marks (syntax then))
|
||||||
#,(recon-source-current-marks (syntax else)))
|
#,(recon-source-current-marks (syntax else)))
|
||||||
exp))]
|
exp))]
|
||||||
|
|
||||||
; one-armed if
|
; one-armed if
|
||||||
|
|
||||||
[(if test then)
|
[(if test then)
|
||||||
(begin
|
(begin
|
||||||
(when (eq? so-far nothing-so-far)
|
(when (eq? so-far nothing-so-far)
|
||||||
(error 'reconstruct "breakpoint before an if reduction should have a result value"))
|
(error 'reconstruct "breakpoint before an if reduction should have a result value"))
|
||||||
(attach-info
|
(attach-info
|
||||||
#`(if #,so-far #,(recon-source-current-marks (syntax then)))
|
#`(if #,so-far #,(recon-source-current-marks (syntax then)))
|
||||||
exp))]
|
exp))]
|
||||||
|
|
||||||
; quote : there is no break on a quote.
|
; quote : there is no break on a quote.
|
||||||
|
|
||||||
;; advanced-begin : okay, here comes advanced-begin.
|
;; advanced-begin : okay, here comes advanced-begin.
|
||||||
|
|
||||||
[(begin . terms)
|
[(begin . terms)
|
||||||
;; even in advanced, begin expands into a let-values.
|
;; even in advanced, begin expands into a let-values.
|
||||||
(error 'reconstruct/inner "begin in non-teaching-languages not implemented in reconstruct")]
|
(error 'reconstruct/inner "begin in non-teaching-languages not implemented in reconstruct")]
|
||||||
|
|
||||||
; begin : in the current expansion of begin, there are only two-element begin's, one-element begins, and
|
; begin : in the current expansion of begin, there are only two-element begin's, one-element begins, and
|
||||||
;; zero-element begins; these arise as the expansion of ... ?
|
;; zero-element begins; these arise as the expansion of ... ?
|
||||||
|
|
||||||
;; these are all dead code, right?
|
;; these are all dead code, right?
|
||||||
|
|
||||||
#;[(begin stx-a stx-b)
|
#;[(begin stx-a stx-b)
|
||||||
(attach-info
|
(attach-info
|
||||||
(if (eq? so-far nothing-so-far)
|
(if (eq? so-far nothing-so-far)
|
||||||
#`(begin #,(recon-source-current-marks #`stx-a) #,(recon-source-current-marks #`stx-b))
|
#`(begin #,(recon-source-current-marks #`stx-a) #,(recon-source-current-marks #`stx-b))
|
||||||
#`(begin #,so-far #,(recon-source-current-marks #`stx-b))))]
|
#`(begin #,so-far #,(recon-source-current-marks #`stx-b))))]
|
||||||
|
|
||||||
#;[(begin clause)
|
#;[(begin clause)
|
||||||
(attach-info
|
(attach-info
|
||||||
(if (eq? so-far nothing-so-far)
|
(if (eq? so-far nothing-so-far)
|
||||||
#`(begin #,(recon-source-current-marks (syntax clause)))
|
#`(begin #,(recon-source-current-marks (syntax clause)))
|
||||||
(error
|
(error
|
||||||
'recon-inner
|
'recon-inner
|
||||||
"stepper:reconstruct: one-clause begin appeared as context: ~a" (syntax->datum exp)))
|
"stepper:reconstruct: one-clause begin appeared as context: ~a" (syntax->datum exp)))
|
||||||
exp)]
|
exp)]
|
||||||
|
|
||||||
#;[(begin)
|
#;[(begin)
|
||||||
(attach-info
|
(attach-info
|
||||||
(if (eq? so-far nothing-so-far)
|
(if (eq? so-far nothing-so-far)
|
||||||
#`(begin)
|
#`(begin)
|
||||||
(error
|
(error
|
||||||
'recon-inner
|
'recon-inner
|
||||||
"stepper-reconstruct: zero-clause begin appeared as context: ~a" (syntax->datum exp))))]
|
"stepper-reconstruct: zero-clause begin appeared as context: ~a" (syntax->datum exp))))]
|
||||||
|
|
||||||
; begin0 :
|
; begin0 :
|
||||||
;; one-body begin0: perhaps this will turn out to be a special case of the
|
;; one-body begin0: perhaps this will turn out to be a special case of the
|
||||||
;; many-body case.
|
;; many-body case.
|
||||||
[(begin0 body)
|
[(begin0 body)
|
||||||
(if (eq? so-far nothing-so-far)
|
(if (eq? so-far nothing-so-far)
|
||||||
(recon-source-current-marks exp)
|
(recon-source-current-marks exp)
|
||||||
(error 'recon-inner "one-body begin0 given as context: ~a" exp))]
|
(error 'recon-inner "one-body begin0 given as context: ~a" exp))]
|
||||||
|
|
||||||
;; the only time begin0 shows up other than in a fake-exp is when the first
|
;; the only time begin0 shows up other than in a fake-exp is when the first
|
||||||
;; term is being evaluated
|
;; term is being evaluated
|
||||||
[(begin0 first-body . rest-bodies)
|
[(begin0 first-body . rest-bodies)
|
||||||
(if (eq? so-far nothing-so-far)
|
(if (eq? so-far nothing-so-far)
|
||||||
(error 'foo "not implemented")
|
(error 'foo "not implemented")
|
||||||
;; don't know what goes hereyet
|
;; don't know what goes hereyet
|
||||||
#`(begin0 #,so-far #,@(map recon-source-current-marks (syntax->list #`rest-bodies))))]
|
#`(begin0 #,so-far #,@(map recon-source-current-marks (syntax->list #`rest-bodies))))]
|
||||||
|
|
||||||
; let-values
|
; let-values
|
||||||
|
|
||||||
[(let-values . rest) (recon-let)]
|
[(let-values . rest) (recon-let)]
|
||||||
|
|
||||||
[(letrec-values . rest) (recon-let)]
|
[(letrec-values . rest) (recon-let)]
|
||||||
|
|
||||||
[(set! var rhs)
|
[(set! var rhs)
|
||||||
(begin
|
(begin
|
||||||
(when (eq? so-far nothing-so-far)
|
(when (eq? so-far nothing-so-far)
|
||||||
(error 'reconstruct "breakpoint before an if reduction should have a result value"))
|
(error 'reconstruct "breakpoint before an if reduction should have a result value"))
|
||||||
(attach-info
|
(attach-info
|
||||||
(let ([rendered-var (reconstruct-set!-var mark-list #`var)])
|
(let ([rendered-var (reconstruct-set!-var mark-list #`var)])
|
||||||
#`(set! #,rendered-var #,so-far))
|
#`(set! #,rendered-var #,so-far))
|
||||||
exp))]
|
exp))]
|
||||||
|
|
||||||
; lambda : there is no break on a lambda
|
; lambda : there is no break on a lambda
|
||||||
|
|
||||||
[else
|
[else
|
||||||
(error
|
(error
|
||||||
'recon-inner
|
'recon-inner
|
||||||
"stepper:reconstruct: unknown object to reconstruct: ~a" (syntax->datum exp))]))))
|
"stepper:reconstruct: unknown object to reconstruct: ~a" (syntax->datum exp))]))))
|
||||||
|
|
||||||
; the main recursive reconstruction loop is in recon:
|
; the main recursive reconstruction loop is in recon:
|
||||||
; recon : (syntax mark-list boolean -> syntax)
|
; recon : (syntax mark-list boolean -> syntax)
|
||||||
|
|
||||||
(define (recon so-far mark-list first)
|
(define (recon so-far mark-list first)
|
||||||
(cond [(null? mark-list) ; now taken to indicate a callback:
|
(cond [(null? mark-list) ; now taken to indicate a callback:
|
||||||
(unless (eq? so-far nothing-so-far)
|
(unless (eq? so-far nothing-so-far)
|
||||||
(set! last-so-far so-far))
|
(set! last-so-far so-far))
|
||||||
so-far
|
so-far
|
||||||
;(error `recon "expcted a top-level mark at the end of the mark list.")
|
;(error `recon "expcted a top-level mark at the end of the mark list.")
|
||||||
]
|
]
|
||||||
|
[else
|
||||||
|
(case (mark-label (car mark-list))
|
||||||
|
[(top-level)
|
||||||
|
(if (null? (cdr mark-list))
|
||||||
|
(reconstruct-top-level (mark-source (car mark-list)) so-far)
|
||||||
|
(error 'recon "top-level-define mark found at non-end of mark list"))]
|
||||||
[else
|
[else
|
||||||
(case (mark-label (car mark-list))
|
(let ([reconstructed (recon-inner mark-list so-far)])
|
||||||
[(top-level)
|
(recon
|
||||||
(if (null? (cdr mark-list))
|
(if first
|
||||||
(reconstruct-top-level (mark-source (car mark-list)) so-far)
|
(mark-as-highlight reconstructed)
|
||||||
(error 'recon "top-level-define mark found at non-end of mark list"))]
|
reconstructed)
|
||||||
[else
|
(cdr mark-list)
|
||||||
(let ([reconstructed (recon-inner mark-list so-far)])
|
#f))])]))
|
||||||
(recon
|
|
||||||
(if first
|
; uncomment to see all breaks coming in:
|
||||||
(mark-as-highlight reconstructed)
|
#;(define _ (printf "break-kind: ~a\ninnermost source: ~a\nreturned-value-list: ~a\n"
|
||||||
reconstructed)
|
break-kind
|
||||||
(cdr mark-list)
|
(and (pair? mark-list)
|
||||||
#f))])]))
|
(syntax->datum (mark-source (car mark-list))))
|
||||||
|
returned-value-list))
|
||||||
; uncomment to see all breaks coming in:
|
|
||||||
#;(define _ (printf "break-kind: ~a\ninnermost source: ~a\nreturned-value-list: ~a\n"
|
(define answer
|
||||||
break-kind
|
(begin
|
||||||
(and (pair? mark-list)
|
; STC: reset partial-eval-promise table on each call to recon
|
||||||
(syntax->datum (mark-source (car mark-list))))
|
(set! partially-evaluated-promises-table (make-weak-hash))
|
||||||
returned-value-list))
|
(set! last-so-far null)
|
||||||
|
|
||||||
(define answer
|
(case break-kind
|
||||||
(begin
|
((left-side)
|
||||||
; STC: reset partial-eval-promise table on each call to recon
|
(let* ([innermost
|
||||||
(set! partially-evaluated-promises-table (make-weak-hash))
|
(if returned-value-list ; is it a normal-break/values?
|
||||||
(set! last-so-far null)
|
(begin
|
||||||
|
(unless (and (pair? returned-value-list)
|
||||||
(case break-kind
|
(null? (cdr returned-value-list)))
|
||||||
((left-side)
|
(error 'reconstruct
|
||||||
(let* ([innermost
|
"context expected one value, given ~v"
|
||||||
(if returned-value-list ; is it a normal-break/values?
|
returned-value-list))
|
||||||
(begin
|
(recon-value (car returned-value-list) render-settings))
|
||||||
(unless (and (pair? returned-value-list)
|
nothing-so-far)])
|
||||||
(null? (cdr returned-value-list)))
|
(recon innermost mark-list #t)))
|
||||||
(error 'reconstruct
|
((right-side)
|
||||||
"context expected one value, given ~v"
|
(let* ([innermost
|
||||||
returned-value-list))
|
(if returned-value-list ; is it an expr -> value reduction?
|
||||||
(recon-value (car returned-value-list) render-settings))
|
(begin
|
||||||
nothing-so-far)])
|
(unless (and (pair? returned-value-list)
|
||||||
(recon innermost mark-list #t)))
|
(null? (cdr returned-value-list)))
|
||||||
((right-side)
|
(error 'reconstruct
|
||||||
(let* ([innermost
|
"context expected one value, given ~v"
|
||||||
(if returned-value-list ; is it an expr -> value reduction?
|
returned-value-list))
|
||||||
(begin
|
(recon-value (car returned-value-list) render-settings))
|
||||||
(unless (and (pair? returned-value-list)
|
(recon-source-expr (mark-source (car mark-list))
|
||||||
(null? (cdr returned-value-list)))
|
mark-list null null render-settings))])
|
||||||
(error 'reconstruct
|
(recon (mark-as-highlight innermost) (cdr mark-list) #f)))
|
||||||
"context expected one value, given ~v"
|
((double-break)
|
||||||
returned-value-list))
|
(let* ([source-expr (mark-source (car mark-list))]
|
||||||
(recon-value (car returned-value-list) render-settings))
|
[innermost-before
|
||||||
(recon-source-expr (mark-source (car mark-list))
|
(mark-as-highlight
|
||||||
mark-list null null render-settings))])
|
(recon-source-expr source-expr mark-list null null render-settings))]
|
||||||
(recon (mark-as-highlight innermost) (cdr mark-list) #f)))
|
[newly-lifted-bindings
|
||||||
((double-break)
|
(syntax-case source-expr (letrec-values)
|
||||||
(let* ([source-expr (mark-source (car mark-list))]
|
[(letrec-values ([vars . rest] ...) . bodies)
|
||||||
[innermost-before
|
(apply append (map syntax->list (syntax->list #`(vars ...))))]
|
||||||
(mark-as-highlight
|
[(let-values ([vars . rest] ...) . bodies)
|
||||||
(recon-source-expr source-expr mark-list null null render-settings))]
|
(apply append (map syntax->list (syntax->list #`(vars ...))))]
|
||||||
[newly-lifted-bindings
|
[else (error
|
||||||
(syntax-case source-expr (letrec-values)
|
'reconstruct
|
||||||
[(letrec-values ([vars . rest] ...) . bodies)
|
"expected a let-values as source for a double-break, got: ~.s"
|
||||||
(apply append (map syntax->list (syntax->list #`(vars ...))))]
|
(syntax->datum source-expr))])]
|
||||||
[(let-values ([vars . rest] ...) . bodies)
|
[innermost-after
|
||||||
(apply append (map syntax->list (syntax->list #`(vars ...))))]
|
(mark-as-highlight
|
||||||
[else (error
|
(recon-source-expr
|
||||||
'reconstruct
|
(mark-source (car mark-list))
|
||||||
"expected a let-values as source for a double-break, got: ~.s"
|
mark-list null newly-lifted-bindings render-settings))])
|
||||||
(syntax->datum source-expr))])]
|
(list (recon innermost-before (cdr mark-list) #f)
|
||||||
[innermost-after
|
(recon innermost-after (cdr mark-list) #f)))))))
|
||||||
(mark-as-highlight
|
|
||||||
(recon-source-expr
|
|
||||||
(mark-source (car mark-list))
|
|
||||||
mark-list null newly-lifted-bindings render-settings))])
|
|
||||||
(list (recon innermost-before (cdr mark-list) #f)
|
|
||||||
(recon innermost-after (cdr mark-list) #f)))))))
|
|
||||||
)
|
|
||||||
|
|
||||||
answer
|
|
||||||
))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
answer
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user