cs: repair prompt around top-level evaluation
This commit is contained in:
parent
593be62896
commit
eb3ba2052e
|
@ -120,7 +120,7 @@ otherwise.}
|
||||||
[name any/c #f]
|
[name any/c #f]
|
||||||
[import-keys #f #f]
|
[import-keys #f #f]
|
||||||
[get-import #f #f]
|
[get-import #f #f]
|
||||||
[options (listof (or/c 'serializable 'unsafe 'static 'no-prompt))
|
[options (listof (or/c 'serializable 'unsafe 'static 'use-prompt))
|
||||||
'(serializable)])
|
'(serializable)])
|
||||||
linklet?]
|
linklet?]
|
||||||
[(compile-linklet [form (or/c correlated? any/c)]
|
[(compile-linklet [form (or/c correlated? any/c)]
|
||||||
|
@ -129,7 +129,7 @@ otherwise.}
|
||||||
[get-import (or/c #f (any/c . -> . (values (or/c linklet? instance? #f)
|
[get-import (or/c #f (any/c . -> . (values (or/c linklet? instance? #f)
|
||||||
(or/c vector? #f))))
|
(or/c vector? #f))))
|
||||||
#f]
|
#f]
|
||||||
[options (listof (or/c 'serializable 'unsafe 'static 'no-prompt))
|
[options (listof (or/c 'serializable 'unsafe 'static 'use-prompt))
|
||||||
'(serializable)])
|
'(serializable)])
|
||||||
(values linklet? vector?)])]{
|
(values linklet? vector?)])]{
|
||||||
|
|
||||||
|
@ -192,9 +192,12 @@ at most once. Compilation with @racket['static] is intended to improve
|
||||||
the performance of references within the linklet to defined and
|
the performance of references within the linklet to defined and
|
||||||
imported variables.
|
imported variables.
|
||||||
|
|
||||||
If @racket['no-prompt] is included in @racket[options], then when the
|
If @racket['use-prompt] is included in @racket[options], then
|
||||||
resulting linklet is instantiated, the @racket[_use-prompt?] argument
|
instantiating resulting linklet always wraps a prompt around each
|
||||||
to @racket[instantiate-linklet] may be treated as @racket[#f].
|
definition and immediate expression in the linklet. Otherwise,
|
||||||
|
supplying @racket[#t] as the @racket[_use-prompt?] argument to
|
||||||
|
@racket[instantiate-linklet] may only wrap a prompt around the entire
|
||||||
|
instantiation.
|
||||||
|
|
||||||
The symbols in @racket[options] must be distinct, otherwise
|
The symbols in @racket[options] must be distinct, otherwise
|
||||||
@exnraise[exn:fail:contract].
|
@exnraise[exn:fail:contract].
|
||||||
|
@ -267,9 +270,13 @@ each export. If @racket[target-instance] is provided as
|
||||||
non-@racket[#f], its existing variables remain intact if they are not
|
non-@racket[#f], its existing variables remain intact if they are not
|
||||||
modified by a linklet definition.
|
modified by a linklet definition.
|
||||||
|
|
||||||
If @racket[use-prompt?] is true, then the evaluation each definition
|
If @racket[use-prompt?] is true, then a a @tech{prompt} is wrapped
|
||||||
and expression in the linklet is wrapped in a @tech{prompt} in the
|
around the linklet instantiation in same ways as an expression in a
|
||||||
same ways as an expression in a module body.}
|
module body. If the linklet contains multiple definitions or immediate
|
||||||
|
expressions, then a prompt may or may not be wrapped around each
|
||||||
|
definition or expression; supply @racket['use-prompt] to
|
||||||
|
@racket[compile-linklet] to ensure that a prompt is used around each
|
||||||
|
definition and expression.}
|
||||||
|
|
||||||
|
|
||||||
@defproc[(linklet-import-variables [linklet linklet?])
|
@defproc[(linklet-import-variables [linklet linklet?])
|
||||||
|
|
|
@ -563,18 +563,25 @@
|
||||||
;; Call the linklet:
|
;; Call the linklet:
|
||||||
(performance-region
|
(performance-region
|
||||||
'instantiate
|
'instantiate
|
||||||
(apply
|
((if use-prompt?
|
||||||
(if (eq? 'callable (linklet-preparation linklet))
|
;; For per-form prompts with in a module linklet,
|
||||||
(linklet-code linklet)
|
;; rely on 'use-prompt provided at compile time.
|
||||||
(eval-from-bytevector (linklet-code linklet) (linklet-format linklet)))
|
;; But this one is useful for top-level forms.
|
||||||
(make-variable-reference target-instance #f)
|
call-with-module-prompt
|
||||||
(append (apply append
|
(lambda (thunk) (thunk)))
|
||||||
(map (make-extract-variables target-instance)
|
(lambda ()
|
||||||
import-instances
|
(apply
|
||||||
(linklet-importss linklet)
|
(if (eq? 'callable (linklet-preparation linklet))
|
||||||
(linklet-importss-abi linklet)))
|
(linklet-code linklet)
|
||||||
(create-variables target-instance
|
(eval-from-bytevector (linklet-code linklet) (linklet-format linklet)))
|
||||||
(linklet-exports linklet)))))))]
|
(make-variable-reference target-instance #f)
|
||||||
|
(append (apply append
|
||||||
|
(map (make-extract-variables target-instance)
|
||||||
|
import-instances
|
||||||
|
(linklet-importss linklet)
|
||||||
|
(linklet-importss-abi linklet)))
|
||||||
|
(create-variables target-instance
|
||||||
|
(linklet-exports linklet)))))))))]
|
||||||
[else
|
[else
|
||||||
;; Make a fresh instance, recur, and return the instance
|
;; Make a fresh instance, recur, and return the instance
|
||||||
(let ([i (make-instance (linklet-name linklet))])
|
(let ([i (make-instance (linklet-name linklet))])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user