in the middle of fixing require for js-implemented modules
This commit is contained in:
parent
e0429d565a
commit
91c2460a23
|
@ -1,5 +1,5 @@
|
|||
#lang planet dyoo/whalesong
|
||||
(require (planet dyoo/whalesong/world))
|
||||
(require (planet dyoo/whalesong/image))
|
||||
|
||||
(display "hello again")
|
||||
(newline)
|
|
@ -10,6 +10,7 @@
|
|||
"../parser/path-rewriter.rkt"
|
||||
"../parser/parse-bytecode.rkt"
|
||||
racket/match
|
||||
racket/list
|
||||
(prefix-in query: "../lang/js/query.rkt")
|
||||
(planet dyoo/closure-compile:1:1)
|
||||
(prefix-in runtime: "get-runtime.rkt")
|
||||
|
@ -106,32 +107,65 @@
|
|||
(log-debug "~a requires ~a"
|
||||
(ModuleSource-path src)
|
||||
module-requires)
|
||||
(let ([module-body-text
|
||||
(format "
|
||||
if(--MACHINE.callsBeforeTrampoline<0) { throw arguments.callee; }
|
||||
var modrec = MACHINE.modules[~s];
|
||||
var exports = {};
|
||||
modrec.isInvoked = true;
|
||||
(function(MACHINE, RUNTIME, EXPORTS){~a})(MACHINE, plt.runtime, exports);
|
||||
~a
|
||||
return MACHINE.control.pop().label(MACHINE);"
|
||||
(symbol->string name)
|
||||
text
|
||||
(get-provided-name-code bytecode))])
|
||||
|
||||
(make-UninterpretedSource
|
||||
(format "
|
||||
MACHINE.modules[~s] =
|
||||
new plt.runtime.ModuleRecord(~s,
|
||||
function(MACHINE) {
|
||||
if(--MACHINE.callsBeforeTrampoline<0) { throw arguments.callee; }
|
||||
var modrec = MACHINE.modules[~s];
|
||||
var exports = {};
|
||||
modrec.isInvoked = true;
|
||||
(function(MACHINE, RUNTIME, EXPORTS){~a})(MACHINE, plt.runtime, exports);
|
||||
// FIXME: we need to inject the namespace with the values defined in exports.
|
||||
~a
|
||||
return MACHINE.control.pop().label(MACHINE);
|
||||
~a
|
||||
});
|
||||
"
|
||||
(symbol->string name)
|
||||
(symbol->string name)
|
||||
(symbol->string name)
|
||||
text
|
||||
(get-provided-name-code bytecode))))]
|
||||
(symbol->string name)
|
||||
(symbol->string name)
|
||||
(assemble-modinvokes module-requires module-body-text))
|
||||
|
||||
(map make-ModuleSource module-requires))))]
|
||||
|
||||
|
||||
[(SexpSource? src)
|
||||
(error 'get-javascript-implementation)]
|
||||
[(UninterpretedSource? src)
|
||||
(error 'get-javascript-implementation)]))
|
||||
|
||||
|
||||
|
||||
(define (assemble-modinvokes paths after)
|
||||
(cond
|
||||
[(empty? paths)
|
||||
after]
|
||||
[else
|
||||
(assemble-modinvoke (first paths)
|
||||
(assemble-modinvokes (rest paths) after))]))
|
||||
|
||||
|
||||
(define (assemble-modinvoke path after)
|
||||
(format "if (! MACHINE.modules[~s].isInvoked) {
|
||||
MACHINE.modules[~s].invoke(MACHINE,
|
||||
function() {
|
||||
~a
|
||||
},
|
||||
MACHINE.params.currentErrorHandler);
|
||||
} else {
|
||||
~a
|
||||
}
|
||||
"
|
||||
path
|
||||
path
|
||||
after
|
||||
after))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -223,6 +223,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// External invokation of a module.
|
||||
ModuleRecord.prototype.invoke = function(MACHINE, succ, fail) {
|
||||
MACHINE = MACHINE || plt.runtime.currentMachine;
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
#:transparent)
|
||||
(define-struct: SexpSource ([sexp : Any])
|
||||
#:transparent)
|
||||
(define-struct: UninterpretedSource ([datum : String])
|
||||
(define-struct: UninterpretedSource ([datum : String]
|
||||
[neighbors : (Listof Source)])
|
||||
#:transparent)
|
||||
|
||||
|
||||
|
|
|
@ -132,26 +132,30 @@
|
|||
(Source (U False Expression) -> (Listof Source)))
|
||||
(define (collect-new-dependencies this-source ast)
|
||||
(cond
|
||||
[(eq? ast #f)
|
||||
empty]
|
||||
[(not (should-follow-children? this-source))
|
||||
empty]
|
||||
[(UninterpretedSource? this-source)
|
||||
(UninterpretedSource-neighbors this-source)]
|
||||
[else
|
||||
(let* ([dependent-module-names (get-dependencies ast)]
|
||||
[paths
|
||||
(foldl (lambda: ([mp : ModuleLocator]
|
||||
[acc : (Listof Source)])
|
||||
(let ([rp [ModuleLocator-real-path mp]])
|
||||
(cond [((current-kernel-module-locator?)
|
||||
mp)
|
||||
acc]
|
||||
[(path? rp)
|
||||
(cons (make-ModuleSource rp) acc)]
|
||||
[else
|
||||
acc])))
|
||||
'()
|
||||
dependent-module-names)])
|
||||
paths)]))
|
||||
(cond
|
||||
[(eq? ast #f)
|
||||
empty]
|
||||
[(not (should-follow-children? this-source))
|
||||
empty]
|
||||
[else
|
||||
(let* ([dependent-module-names (get-dependencies ast)]
|
||||
[paths
|
||||
(foldl (lambda: ([mp : ModuleLocator]
|
||||
[acc : (Listof Source)])
|
||||
(let ([rp [ModuleLocator-real-path mp]])
|
||||
(cond [((current-kernel-module-locator?)
|
||||
mp)
|
||||
acc]
|
||||
[(path? rp)
|
||||
(cons (make-ModuleSource rp) acc)]
|
||||
[else
|
||||
acc])))
|
||||
'()
|
||||
dependent-module-names)])
|
||||
paths)])]))
|
||||
|
||||
(let: loop : Void ([sources : (Listof Source) sources])
|
||||
(cond
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"test-conform-browser.rkt"
|
||||
"test-earley-browser.rkt"
|
||||
"test-get-dependencies.rkt"
|
||||
"more-tests/run-more-tests.rkt")
|
||||
"run-more-tests.rkt")
|
||||
|
||||
|
||||
;; This test takes a bit too much time.
|
||||
|
|
Loading…
Reference in New Issue
Block a user