Renamed ModuleName to ModuleLocator, since that's more accurate of a name.
This commit is contained in:
parent
246549465e
commit
042f52f45c
14
compiler.rkt
14
compiler.rkt
|
@ -359,7 +359,7 @@
|
||||||
`(,(make-AssignImmediateStatement target (make-Const (void))))))))
|
`(,(make-AssignImmediateStatement target (make-Const (void))))))))
|
||||||
|
|
||||||
|
|
||||||
(: compile-module-invoke (ModuleName -> InstructionSequence))
|
(: compile-module-invoke (ModuleLocator -> InstructionSequence))
|
||||||
;; Generates code that will invoke a module (if it hasn't been invoked yet)
|
;; Generates code that will invoke a module (if it hasn't been invoked yet)
|
||||||
;; FIXME: assumes the module has already been linked. We should error out
|
;; FIXME: assumes the module has already been linked. We should error out
|
||||||
;; if the module hasn't been linked yet.
|
;; if the module hasn't been linked yet.
|
||||||
|
@ -381,7 +381,7 @@
|
||||||
;; linked yet.
|
;; linked yet.
|
||||||
,(make-DebugPrint (make-Const
|
,(make-DebugPrint (make-Const
|
||||||
(format "DEBUG: the module ~a hasn't been linked in!!!"
|
(format "DEBUG: the module ~a hasn't been linked in!!!"
|
||||||
(ModuleName-name a-module-name))))
|
(ModuleLocator-name a-module-name))))
|
||||||
,(make-GotoStatement (make-Label already-loaded))
|
,(make-GotoStatement (make-Label already-loaded))
|
||||||
,linked
|
,linked
|
||||||
,(make-TestAndBranchStatement (make-TestTrue
|
,(make-TestAndBranchStatement (make-TestTrue
|
||||||
|
@ -397,12 +397,12 @@
|
||||||
,already-loaded)))]))
|
,already-loaded)))]))
|
||||||
|
|
||||||
|
|
||||||
(: kernel-module-name? (ModuleName -> Boolean))
|
(: kernel-module-name? (ModuleLocator -> Boolean))
|
||||||
;; Produces true if the module is hardcoded.
|
;; Produces true if the module is hardcoded.
|
||||||
(define (kernel-module-name? name)
|
(define (kernel-module-name? name)
|
||||||
(or (and (eq? (ModuleName-name name) '#%kernel)
|
(or (and (eq? (ModuleLocator-name name) '#%kernel)
|
||||||
(eq? (ModuleName-real-path name) '#%kernel))
|
(eq? (ModuleLocator-real-path name) '#%kernel))
|
||||||
(eq? (ModuleName-name name) 'whalesong/lang/kernel)))
|
(eq? (ModuleLocator-name name) 'whalesong/lang/kernel)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -977,7 +977,7 @@
|
||||||
(default)]
|
(default)]
|
||||||
[(ModuleVariable? op-knowledge)
|
[(ModuleVariable? op-knowledge)
|
||||||
(cond
|
(cond
|
||||||
[(symbol=? (ModuleName-name
|
[(symbol=? (ModuleLocator-name
|
||||||
(ModuleVariable-module-name op-knowledge))
|
(ModuleVariable-module-name op-knowledge))
|
||||||
'#%kernel)
|
'#%kernel)
|
||||||
(let ([op (ModuleVariable-name op-knowledge)])
|
(let ([op (ModuleVariable-name op-knowledge)])
|
||||||
|
|
|
@ -34,9 +34,9 @@
|
||||||
|
|
||||||
|
|
||||||
(define-struct: Module ([name : Symbol]
|
(define-struct: Module ([name : Symbol]
|
||||||
[path : ModuleName]
|
[path : ModuleLocator]
|
||||||
[prefix : Prefix]
|
[prefix : Prefix]
|
||||||
[requires : (Listof ModuleName)]
|
[requires : (Listof ModuleLocator)]
|
||||||
[code : Expression])
|
[code : Expression])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@
|
||||||
(define-struct: VariableReference ([toplevel : ToplevelRef]) #:transparent)
|
(define-struct: VariableReference ([toplevel : ToplevelRef]) #:transparent)
|
||||||
|
|
||||||
|
|
||||||
(define-struct: Require ([path : ModuleName]) #:transparent)
|
(define-struct: Require ([path : ModuleLocator]) #:transparent)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,16 +11,16 @@
|
||||||
expression-module-path)
|
expression-module-path)
|
||||||
|
|
||||||
|
|
||||||
(: get-dependencies (Expression -> (Listof ModuleName)))
|
(: get-dependencies (Expression -> (Listof ModuleLocator)))
|
||||||
(define (get-dependencies expr)
|
(define (get-dependencies expr)
|
||||||
(let ([deps ((inst new-set ModuleName))])
|
(let ([deps ((inst new-set ModuleLocator))])
|
||||||
(let: visit : 'ok ([expr : Expression expr])
|
(let: visit : 'ok ([expr : Expression expr])
|
||||||
(cond
|
(cond
|
||||||
[(Top? expr)
|
[(Top? expr)
|
||||||
(visit (Top-code expr))
|
(visit (Top-code expr))
|
||||||
'ok]
|
'ok]
|
||||||
[(Module? expr)
|
[(Module? expr)
|
||||||
(for-each (lambda: ([mn : ModuleName])
|
(for-each (lambda: ([mn : ModuleLocator])
|
||||||
(set-insert! deps mn))
|
(set-insert! deps mn))
|
||||||
(Module-requires expr))
|
(Module-requires expr))
|
||||||
'ok]
|
'ok]
|
||||||
|
@ -29,8 +29,8 @@
|
||||||
(set->list deps)))
|
(set->list deps)))
|
||||||
|
|
||||||
|
|
||||||
(: expression-module-path (Expression -> (U False ModuleName)))
|
(: expression-module-path (Expression -> (U False ModuleLocator)))
|
||||||
;; Given a toplevel expression of a module, returns its self-declared ModuleName.
|
;; Given a toplevel expression of a module, returns its self-declared ModuleLocator.
|
||||||
;; If we can't find one, return false.
|
;; If we can't find one, return false.
|
||||||
(define (expression-module-path expr)
|
(define (expression-module-path expr)
|
||||||
(cond
|
(cond
|
||||||
|
|
|
@ -95,15 +95,15 @@
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
;; Produces the entry point of the module.
|
;; Produces the entry point of the module.
|
||||||
(define-struct: ModuleEntry ([name : ModuleName])
|
(define-struct: ModuleEntry ([name : ModuleLocator])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
;; Produces true if the module has already been invoked
|
;; Produces true if the module has already been invoked
|
||||||
(define-struct: IsModuleInvoked ([name : ModuleName])
|
(define-struct: IsModuleInvoked ([name : ModuleLocator])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
;; Produces true if the module has been loaded into the machine
|
;; Produces true if the module has been loaded into the machine
|
||||||
(define-struct: IsModuleLinked ([name : ModuleName])
|
(define-struct: IsModuleLinked ([name : ModuleLocator])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@
|
||||||
|
|
||||||
;; Installs a module record into the machine
|
;; Installs a module record into the machine
|
||||||
(define-struct: InstallModuleEntry! ([name : Symbol]
|
(define-struct: InstallModuleEntry! ([name : Symbol]
|
||||||
[path : ModuleName]
|
[path : ModuleLocator]
|
||||||
[entry-point : Symbol])
|
[entry-point : Symbol])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
|
|
|
@ -279,19 +279,19 @@
|
||||||
(: assemble-module-entry (ModuleEntry -> String))
|
(: assemble-module-entry (ModuleEntry -> String))
|
||||||
(define (assemble-module-entry entry)
|
(define (assemble-module-entry entry)
|
||||||
(format "MACHINE.modules[~s].label"
|
(format "MACHINE.modules[~s].label"
|
||||||
(symbol->string (ModuleName-name (ModuleEntry-name entry)))))
|
(symbol->string (ModuleLocator-name (ModuleEntry-name entry)))))
|
||||||
|
|
||||||
|
|
||||||
(: assemble-is-module-invoked (IsModuleInvoked -> String))
|
(: assemble-is-module-invoked (IsModuleInvoked -> String))
|
||||||
(define (assemble-is-module-invoked entry)
|
(define (assemble-is-module-invoked entry)
|
||||||
(format "MACHINE.modules[~s].label"
|
(format "MACHINE.modules[~s].label"
|
||||||
(symbol->string (ModuleName-name (IsModuleInvoked-name entry)))))
|
(symbol->string (ModuleLocator-name (IsModuleInvoked-name entry)))))
|
||||||
|
|
||||||
|
|
||||||
(: assemble-is-module-linked (IsModuleLinked -> String))
|
(: assemble-is-module-linked (IsModuleLinked -> String))
|
||||||
(define (assemble-is-module-linked entry)
|
(define (assemble-is-module-linked entry)
|
||||||
(format "(MACHINE.modules[~s] !== undefined)"
|
(format "(MACHINE.modules[~s] !== undefined)"
|
||||||
(symbol->string (ModuleName-name (IsModuleLinked-name entry)))))
|
(symbol->string (ModuleLocator-name (IsModuleLinked-name entry)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,6 @@
|
||||||
|
|
||||||
[(InstallModuleEntry!? op)
|
[(InstallModuleEntry!? op)
|
||||||
(format "MACHINE.modules[~s]=new RUNTIME.ModuleRecord(~s, ~a);"
|
(format "MACHINE.modules[~s]=new RUNTIME.ModuleRecord(~s, ~a);"
|
||||||
(symbol->string (ModuleName-name (InstallModuleEntry!-path op)))
|
(symbol->string (ModuleLocator-name (InstallModuleEntry!-path op)))
|
||||||
(symbol->string (InstallModuleEntry!-name op))
|
(symbol->string (InstallModuleEntry!-name op))
|
||||||
(assemble-label (make-Label (InstallModuleEntry!-entry-point op))))]))
|
(assemble-label (make-Label (InstallModuleEntry!-entry-point op))))]))
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
|
|
||||||
;; A ModuleName is an identifier for a Module.
|
;; A ModuleLocator is an identifier for a Module.
|
||||||
(define-struct: ModuleName ([name : Symbol]
|
(define-struct: ModuleLocator ([name : Symbol]
|
||||||
[real-path : (U Symbol Path)])
|
[real-path : (U Symbol Path)])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
|
|
||||||
(define-struct: ModuleVariable ([name : Symbol]
|
(define-struct: ModuleVariable ([name : Symbol]
|
||||||
[module-name : ModuleName])
|
[module-name : ModuleLocator])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,9 @@
|
||||||
[else
|
[else
|
||||||
(let* ([dependent-module-names (get-dependencies ast)]
|
(let* ([dependent-module-names (get-dependencies ast)]
|
||||||
[paths
|
[paths
|
||||||
(foldl (lambda: ([mp : ModuleName]
|
(foldl (lambda: ([mp : ModuleLocator]
|
||||||
[acc : (Listof Source)])
|
[acc : (Listof Source)])
|
||||||
(let ([rp [ModuleName-real-path mp]])
|
(let ([rp [ModuleLocator-real-path mp]])
|
||||||
|
|
||||||
(cond [(and (path? rp)
|
(cond [(and (path? rp)
|
||||||
(should-follow? rp)
|
(should-follow? rp)
|
||||||
|
|
|
@ -157,18 +157,18 @@
|
||||||
|
|
||||||
;; maybe-fix-module-name: expression -> expression
|
;; maybe-fix-module-name: expression -> expression
|
||||||
;; When we're compiling a module directly from memory, it doesn't have a file path.
|
;; When we're compiling a module directly from memory, it doesn't have a file path.
|
||||||
;; We rewrite the ModuleName to its given name.
|
;; We rewrite the ModuleLocator to its given name.
|
||||||
(define (maybe-fix-module-name exp)
|
(define (maybe-fix-module-name exp)
|
||||||
(match exp
|
(match exp
|
||||||
[(struct Top (top-prefix
|
[(struct Top (top-prefix
|
||||||
(struct Module ((and name (? symbol?))
|
(struct Module ((and name (? symbol?))
|
||||||
(struct ModuleName ('self 'self))
|
(struct ModuleLocator ('self 'self))
|
||||||
module-prefix
|
module-prefix
|
||||||
module-requires
|
module-requires
|
||||||
module-code))))
|
module-code))))
|
||||||
(make-Top top-prefix
|
(make-Top top-prefix
|
||||||
(make-Module name
|
(make-Module name
|
||||||
(make-ModuleName name name) (current-module-path)
|
(make-ModuleLocator name name) (current-module-path)
|
||||||
module-prefix
|
module-prefix
|
||||||
module-requires
|
module-requires
|
||||||
module-code))]
|
module-code))]
|
||||||
|
@ -218,12 +218,12 @@
|
||||||
(define (wrap-module-name resolved-path-name)
|
(define (wrap-module-name resolved-path-name)
|
||||||
(cond
|
(cond
|
||||||
[(symbol? resolved-path-name)
|
[(symbol? resolved-path-name)
|
||||||
(make-ModuleName resolved-path-name resolved-path-name)]
|
(make-ModuleLocator resolved-path-name resolved-path-name)]
|
||||||
[(path? resolved-path-name)
|
[(path? resolved-path-name)
|
||||||
(let ([rewritten-path (rewrite-path resolved-path-name)])
|
(let ([rewritten-path (rewrite-path resolved-path-name)])
|
||||||
(cond
|
(cond
|
||||||
[(symbol? rewritten-path)
|
[(symbol? rewritten-path)
|
||||||
(make-ModuleName (rewrite-path resolved-path-name)
|
(make-ModuleLocator (rewrite-path resolved-path-name)
|
||||||
(normalize-path resolved-path-name))]
|
(normalize-path resolved-path-name))]
|
||||||
[else
|
[else
|
||||||
(error 'wrap-module-name "Unable to resolve module path ~s."
|
(error 'wrap-module-name "Unable to resolve module path ~s."
|
||||||
|
@ -287,12 +287,12 @@
|
||||||
(let ([resolved-path ((current-module-path-resolver) path (current-module-path))])
|
(let ([resolved-path ((current-module-path-resolver) path (current-module-path))])
|
||||||
(cond
|
(cond
|
||||||
[(symbol? resolved-path)
|
[(symbol? resolved-path)
|
||||||
(make-Require (make-ModuleName resolved-path resolved-path))]
|
(make-Require (make-ModuleLocator resolved-path resolved-path))]
|
||||||
[(path? resolved-path)
|
[(path? resolved-path)
|
||||||
(let ([rewritten-path (rewrite-path resolved-path)])
|
(let ([rewritten-path (rewrite-path resolved-path)])
|
||||||
(cond
|
(cond
|
||||||
[(symbol? rewritten-path)
|
[(symbol? rewritten-path)
|
||||||
(make-Require (make-ModuleName rewritten-path
|
(make-Require (make-ModuleLocator rewritten-path
|
||||||
(normalize-path resolved-path)))]
|
(normalize-path resolved-path)))]
|
||||||
[else
|
[else
|
||||||
(printf "Internal error: I don't know how to handle the require for ~s" require-statement)
|
(printf "Internal error: I don't know how to handle the require for ~s" require-statement)
|
||||||
|
@ -304,7 +304,7 @@
|
||||||
(printf "Internal error: I don't know how to handle the require for ~s" require-statement)
|
(printf "Internal error: I don't know how to handle the require for ~s" require-statement)
|
||||||
(error 'parse-req)]))])))
|
(error 'parse-req)]))])))
|
||||||
|
|
||||||
;; parse-req-reqs: (stx -> (listof ModuleName))
|
;; parse-req-reqs: (stx -> (listof ModuleLocator))
|
||||||
(define (parse-req-reqs reqs)
|
(define (parse-req-reqs reqs)
|
||||||
(match reqs
|
(match reqs
|
||||||
[(struct stx (encoded))
|
[(struct stx (encoded))
|
||||||
|
@ -371,7 +371,7 @@
|
||||||
(cond
|
(cond
|
||||||
[(symbol? self-path)
|
[(symbol? self-path)
|
||||||
(make-Module name
|
(make-Module name
|
||||||
(make-ModuleName self-path self-path)
|
(make-ModuleLocator self-path self-path)
|
||||||
(parse-prefix prefix)
|
(parse-prefix prefix)
|
||||||
(parse-mod-requires self-modidx requires)
|
(parse-mod-requires self-modidx requires)
|
||||||
(parse-mod-body body))]
|
(parse-mod-body body))]
|
||||||
|
@ -380,7 +380,7 @@
|
||||||
(cond
|
(cond
|
||||||
[(symbol? rewritten-path)
|
[(symbol? rewritten-path)
|
||||||
(make-Module name
|
(make-Module name
|
||||||
(make-ModuleName rewritten-path
|
(make-ModuleLocator rewritten-path
|
||||||
(normalize-path self-path))
|
(normalize-path self-path))
|
||||||
(parse-prefix prefix)
|
(parse-prefix prefix)
|
||||||
(parse-mod-requires self-modidx requires)
|
(parse-mod-requires self-modidx requires)
|
||||||
|
@ -389,7 +389,7 @@
|
||||||
(error 'parse-mod "Internal error: unable to resolve module path ~s" self-path)]))]))]))
|
(error 'parse-mod "Internal error: unable to resolve module path ~s" self-path)]))]))]))
|
||||||
|
|
||||||
|
|
||||||
;; parse-mod-requires: module-path-index (listof (pair (U Integer #f) (listof module-path-index))) -> (listof ModuleName)
|
;; parse-mod-requires: module-path-index (listof (pair (U Integer #f) (listof module-path-index))) -> (listof ModuleLocator)
|
||||||
(define (parse-mod-requires enclosing-module-path-index requires)
|
(define (parse-mod-requires enclosing-module-path-index requires)
|
||||||
;; We only care about phase 0 --- the runtime.
|
;; We only care about phase 0 --- the runtime.
|
||||||
(let ([resolver (current-module-path-index-resolver)])
|
(let ([resolver (current-module-path-index-resolver)])
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
[(current-language)
|
[(current-language)
|
||||||
=> (lambda (lang)
|
=> (lambda (lang)
|
||||||
(if (member sym lang)
|
(if (member sym lang)
|
||||||
(make-ModuleVariable sym (make-ModuleName '#%kernel '#%kernel))
|
(make-ModuleVariable sym (make-ModuleLocator '#%kernel '#%kernel))
|
||||||
#f))]
|
#f))]
|
||||||
[else
|
[else
|
||||||
#f]))
|
#f]))
|
||||||
|
|
|
@ -458,12 +458,12 @@
|
||||||
|
|
||||||
[(InstallModuleEntry!? op)
|
[(InstallModuleEntry!? op)
|
||||||
(printf "installing module ~s\n"
|
(printf "installing module ~s\n"
|
||||||
(ModuleName-name
|
(ModuleLocator-name
|
||||||
(InstallModuleEntry!-path op)))
|
(InstallModuleEntry!-path op)))
|
||||||
(hash-set! (machine-modules m)
|
(hash-set! (machine-modules m)
|
||||||
(ModuleName-name (InstallModuleEntry!-path op))
|
(ModuleLocator-name (InstallModuleEntry!-path op))
|
||||||
(make-module-record (InstallModuleEntry!-name op)
|
(make-module-record (InstallModuleEntry!-name op)
|
||||||
(ModuleName-name
|
(ModuleLocator-name
|
||||||
(InstallModuleEntry!-path op))
|
(InstallModuleEntry!-path op))
|
||||||
(InstallModuleEntry!-entry-point op)
|
(InstallModuleEntry!-entry-point op)
|
||||||
#f
|
#f
|
||||||
|
@ -856,17 +856,17 @@
|
||||||
|
|
||||||
[(ModuleEntry? an-oparg)
|
[(ModuleEntry? an-oparg)
|
||||||
(let ([a-module (hash-ref (machine-modules m)
|
(let ([a-module (hash-ref (machine-modules m)
|
||||||
(ModuleName-name (ModuleEntry-name an-oparg)))])
|
(ModuleLocator-name (ModuleEntry-name an-oparg)))])
|
||||||
(module-record-label a-module))]
|
(module-record-label a-module))]
|
||||||
|
|
||||||
[(IsModuleInvoked? an-oparg)
|
[(IsModuleInvoked? an-oparg)
|
||||||
(let ([a-module (hash-ref (machine-modules m)
|
(let ([a-module (hash-ref (machine-modules m)
|
||||||
(ModuleName-name (IsModuleInvoked-name an-oparg)))])
|
(ModuleLocator-name (IsModuleInvoked-name an-oparg)))])
|
||||||
(module-record-invoked? a-module))]
|
(module-record-invoked? a-module))]
|
||||||
|
|
||||||
[(IsModuleLinked? an-oparg)
|
[(IsModuleLinked? an-oparg)
|
||||||
(hash-has-key? (machine-modules m)
|
(hash-has-key? (machine-modules m)
|
||||||
(ModuleName-name (IsModuleLinked-name an-oparg)))]
|
(ModuleLocator-name (IsModuleLinked-name an-oparg)))]
|
||||||
|
|
||||||
[(VariableReference? an-oparg)
|
[(VariableReference? an-oparg)
|
||||||
(let ([t (VariableReference-toplevel an-oparg)])
|
(let ([t (VariableReference-toplevel an-oparg)])
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
|
|
||||||
|
|
||||||
(define (module-name< x y)
|
(define (module-name< x y)
|
||||||
(string<? (symbol->string (ModuleName-name x))
|
(string<? (symbol->string (ModuleLocator-name x))
|
||||||
(symbol->string (ModuleName-name y))))
|
(symbol->string (ModuleLocator-name y))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,10 +61,10 @@
|
||||||
module-name<)
|
module-name<)
|
||||||
|
|
||||||
(sort
|
(sort
|
||||||
(list (make-ModuleName 'collects/racket/base.rkt
|
(list (make-ModuleLocator 'collects/racket/base.rkt
|
||||||
(normalize-path (build-path collects-dir "racket" "base.rkt")))
|
(normalize-path (build-path collects-dir "racket" "base.rkt")))
|
||||||
(make-ModuleName 'collects/racket/math.rkt
|
(make-ModuleLocator 'collects/racket/math.rkt
|
||||||
(normalize-path (build-path collects-dir "racket" "math.rkt")))
|
(normalize-path (build-path collects-dir "racket" "math.rkt")))
|
||||||
(make-ModuleName 'whalesong/get-module-bytecode.rkt
|
(make-ModuleLocator 'whalesong/get-module-bytecode.rkt
|
||||||
(normalize-path (build-path compiler-path "get-module-bytecode.rkt"))))
|
(normalize-path (build-path compiler-path "get-module-bytecode.rkt"))))
|
||||||
module-name<)))
|
module-name<)))
|
|
@ -340,7 +340,7 @@
|
||||||
42))
|
42))
|
||||||
[(struct Top ((struct Prefix (list))
|
[(struct Top ((struct Prefix (list))
|
||||||
(struct Module ((? symbol?)
|
(struct Module ((? symbol?)
|
||||||
(? ModuleName?)
|
(? ModuleLocator?)
|
||||||
(? Prefix?) ;; the prefix will include a reference to print-values.
|
(? Prefix?) ;; the prefix will include a reference to print-values.
|
||||||
_ ;; requires
|
_ ;; requires
|
||||||
(struct Splice ((list (struct ApplyValues
|
(struct Splice ((list (struct ApplyValues
|
||||||
|
@ -354,7 +354,7 @@
|
||||||
(define x "x")))
|
(define x "x")))
|
||||||
[(struct Top ((struct Prefix ((? list?)))
|
[(struct Top ((struct Prefix ((? list?)))
|
||||||
(struct Module ((? symbol?)
|
(struct Module ((? symbol?)
|
||||||
(? ModuleName?)
|
(? ModuleLocator?)
|
||||||
(? Prefix?) ;; the prefix will include a reference to print-values.
|
(? Prefix?) ;; the prefix will include a reference to print-values.
|
||||||
_ ;; requires
|
_ ;; requires
|
||||||
(struct Splice ((list (struct DefValues
|
(struct Splice ((list (struct DefValues
|
||||||
|
@ -409,7 +409,7 @@
|
||||||
(match (run-my-parse #'(module foo racket/base))
|
(match (run-my-parse #'(module foo racket/base))
|
||||||
[(struct Top ((? Prefix?)
|
[(struct Top ((? Prefix?)
|
||||||
(struct Module ('foo
|
(struct Module ('foo
|
||||||
(struct ModuleName
|
(struct ModuleLocator
|
||||||
('whalesong/tests/foo.rkt
|
('whalesong/tests/foo.rkt
|
||||||
(? (lambda (p)
|
(? (lambda (p)
|
||||||
(and (path? p)
|
(and (path? p)
|
||||||
|
@ -418,7 +418,7 @@
|
||||||
(build-path this-test-path "foo.rkt"))))))))
|
(build-path this-test-path "foo.rkt"))))))))
|
||||||
|
|
||||||
(struct Prefix (list))
|
(struct Prefix (list))
|
||||||
(list (struct ModuleName ('collects/racket/base.rkt
|
(list (struct ModuleLocator ('collects/racket/base.rkt
|
||||||
_)))
|
_)))
|
||||||
(struct Splice ('()))))))
|
(struct Splice ('()))))))
|
||||||
#t]
|
#t]
|
||||||
|
@ -434,9 +434,9 @@
|
||||||
(#%provide f))))
|
(#%provide f))))
|
||||||
[(struct Top ((struct Prefix ((list '#f)))
|
[(struct Top ((struct Prefix ((list '#f)))
|
||||||
(struct Module ('foo
|
(struct Module ('foo
|
||||||
(struct ModuleName ('self _ #;(build-path "root/foo/bar.rkt")))
|
(struct ModuleLocator ('self _ #;(build-path "root/foo/bar.rkt")))
|
||||||
(struct Prefix ((list 'f)))
|
(struct Prefix ((list 'f)))
|
||||||
(list (struct ModuleName ('#%kernel '#%kernel)))
|
(list (struct ModuleLocator ('#%kernel '#%kernel)))
|
||||||
(struct Splice ((list (struct DefValues ((list (struct ToplevelRef (0 0)))
|
(struct Splice ((list (struct DefValues ((list (struct ToplevelRef (0 0)))
|
||||||
(struct Constant ('ok)))))))))))
|
(struct Constant ('ok)))))))))))
|
||||||
'#t]))
|
'#t]))
|
||||||
|
|
|
@ -211,7 +211,7 @@
|
||||||
'lamEntry2)))
|
'lamEntry2)))
|
||||||
|
|
||||||
(test (parse '(+ x x))
|
(test (parse '(+ x x))
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable '+ (make-ModuleName '#%kernel '#%kernel))
|
(make-Top (make-Prefix `(,(make-ModuleVariable '+ (make-ModuleLocator '#%kernel '#%kernel))
|
||||||
x))
|
x))
|
||||||
(make-App (make-ToplevelRef 2 0)
|
(make-App (make-ToplevelRef 2 0)
|
||||||
(list (make-ToplevelRef 2 1)
|
(list (make-ToplevelRef 2 1)
|
||||||
|
@ -219,7 +219,7 @@
|
||||||
|
|
||||||
|
|
||||||
(test (parse '(lambda (x) (+ x x)))
|
(test (parse '(lambda (x) (+ x x)))
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable '+ (make-ModuleName '#%kernel '#%kernel))))
|
(make-Top (make-Prefix `(,(make-ModuleVariable '+ (make-ModuleLocator '#%kernel '#%kernel))))
|
||||||
(make-Lam 'unknown 1 #f
|
(make-Lam 'unknown 1 #f
|
||||||
(make-App (make-ToplevelRef 2 0)
|
(make-App (make-ToplevelRef 2 0)
|
||||||
(list (make-LocalRef 3 #f)
|
(list (make-LocalRef 3 #f)
|
||||||
|
@ -229,8 +229,8 @@
|
||||||
|
|
||||||
(test (parse '(lambda (x)
|
(test (parse '(lambda (x)
|
||||||
(+ (* x x) x)))
|
(+ (* x x) x)))
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable '* (make-ModuleName '#%kernel '#%kernel))
|
(make-Top (make-Prefix `(,(make-ModuleVariable '* (make-ModuleLocator '#%kernel '#%kernel))
|
||||||
,(make-ModuleVariable '+ (make-ModuleName '#%kernel '#%kernel))))
|
,(make-ModuleVariable '+ (make-ModuleLocator '#%kernel '#%kernel))))
|
||||||
(make-Lam 'unknown 1 #f
|
(make-Lam 'unknown 1 #f
|
||||||
;; stack layout: [???, ???, prefix, x]
|
;; stack layout: [???, ???, prefix, x]
|
||||||
(make-App (make-ToplevelRef 2 1)
|
(make-App (make-ToplevelRef 2 1)
|
||||||
|
@ -289,7 +289,7 @@
|
||||||
(test (parse '(let* ([x 3]
|
(test (parse '(let* ([x 3]
|
||||||
[x (add1 x)])
|
[x (add1 x)])
|
||||||
(add1 x)))
|
(add1 x)))
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable 'add1 (make-ModuleName '#%kernel '#%kernel))))
|
(make-Top (make-Prefix `(,(make-ModuleVariable 'add1 (make-ModuleLocator '#%kernel '#%kernel))))
|
||||||
|
|
||||||
;; stack layout: [prefix]
|
;; stack layout: [prefix]
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@
|
||||||
(test (parse '(let ([x 0])
|
(test (parse '(let ([x 0])
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(set! x (add1 x)))))
|
(set! x (add1 x)))))
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable 'add1 (make-ModuleName '#%kernel '#%kernel))))
|
(make-Top (make-Prefix `(,(make-ModuleVariable 'add1 (make-ModuleLocator '#%kernel '#%kernel))))
|
||||||
(make-Let1 (make-Constant 0)
|
(make-Let1 (make-Constant 0)
|
||||||
(make-BoxEnv 0
|
(make-BoxEnv 0
|
||||||
(make-Lam 'unknown 0 #f
|
(make-Lam 'unknown 0 #f
|
||||||
|
@ -437,7 +437,7 @@
|
||||||
[y 1])
|
[y 1])
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(set! x (add1 x)))))
|
(set! x (add1 x)))))
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable 'add1 (make-ModuleName '#%kernel '#%kernel))))
|
(make-Top (make-Prefix `(,(make-ModuleVariable 'add1 (make-ModuleLocator '#%kernel '#%kernel))))
|
||||||
(make-LetVoid 2
|
(make-LetVoid 2
|
||||||
(make-Seq (list
|
(make-Seq (list
|
||||||
(make-InstallValue 1 0 (make-Constant 0) #t)
|
(make-InstallValue 1 0 (make-Constant 0) #t)
|
||||||
|
@ -465,7 +465,7 @@
|
||||||
(reset!)
|
(reset!)
|
||||||
(list a b)))
|
(list a b)))
|
||||||
(make-Top
|
(make-Top
|
||||||
(make-Prefix `(a b ,(make-ModuleVariable 'list (make-ModuleName '#%kernel '#%kernel)) reset!))
|
(make-Prefix `(a b ,(make-ModuleVariable 'list (make-ModuleLocator '#%kernel '#%kernel)) reset!))
|
||||||
(make-Splice
|
(make-Splice
|
||||||
(list
|
(list
|
||||||
(make-ToplevelSet 0 0 (make-Constant '(hello)))
|
(make-ToplevelSet 0 0 (make-Constant '(hello)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user