still in the middle of tracing down weirdness with the module loading.
This commit is contained in:
parent
2b51e06c76
commit
3030cf9f00
|
@ -278,13 +278,13 @@
|
||||||
(make-TestAndJump (make-TestTrue (make-ModulePredicate a-module-name 'linked?))
|
(make-TestAndJump (make-TestTrue (make-ModulePredicate a-module-name 'linked?))
|
||||||
linked)
|
linked)
|
||||||
;; TODO: try to link dynamically, using plt.runtime.currentModuleLoader.
|
;; TODO: try to link dynamically, using plt.runtime.currentModuleLoader.
|
||||||
(make-Perform (make-LinkModule! a-module-name))
|
(make-Perform (make-LinkModule! a-module-name linked))
|
||||||
;; If that fails, finally raise an exception here that says that the module hasn't been
|
;; If that fails, finally raise an exception here that says that the module hasn't been
|
||||||
;; 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!!!"
|
||||||
(ModuleLocator-name a-module-name))))
|
; (ModuleLocator-name a-module-name))))
|
||||||
(make-Goto (make-Label (LinkedLabel-label on-return)))
|
;(make-Goto (make-Label (LinkedLabel-label on-return)))
|
||||||
linked
|
linked
|
||||||
(make-TestAndJump (make-TestTrue
|
(make-TestAndJump (make-TestTrue
|
||||||
(make-ModulePredicate a-module-name 'invoked?))
|
(make-ModulePredicate a-module-name 'invoked?))
|
||||||
|
|
|
@ -474,7 +474,10 @@
|
||||||
|
|
||||||
|
|
||||||
;; Use the dynamic module loader to link the module into the runtime.
|
;; Use the dynamic module loader to link the module into the runtime.
|
||||||
(define-struct: LinkModule! ([path : ModuleLocator]))
|
;; After successful linkage, jump into label.
|
||||||
|
(define-struct: LinkModule! ([path : ModuleLocator]
|
||||||
|
[label : Symbol]))
|
||||||
|
|
||||||
|
|
||||||
;; Installs a module record into the machine
|
;; Installs a module record into the machine
|
||||||
(define-struct: InstallModuleEntry! ([name : Symbol]
|
(define-struct: InstallModuleEntry! ([name : Symbol]
|
||||||
|
|
|
@ -151,6 +151,20 @@
|
||||||
(format "RT.raiseUnimplementedPrimitiveError(M,~s);"
|
(format "RT.raiseUnimplementedPrimitiveError(M,~s);"
|
||||||
(symbol->string (RaiseUnimplementedPrimitiveError!-name op)))]
|
(symbol->string (RaiseUnimplementedPrimitiveError!-name op)))]
|
||||||
|
|
||||||
|
[(LinkModule!? op)
|
||||||
|
(format "RT.PAUSE(
|
||||||
|
function(restart){
|
||||||
|
RT.currentModuleLoader(M,~s,
|
||||||
|
function(){
|
||||||
|
restart(function(M){ ~a(M); });
|
||||||
|
},
|
||||||
|
function(){
|
||||||
|
RT.raiseModuleLoadingError(M,~s);
|
||||||
|
});
|
||||||
|
});"
|
||||||
|
(symbol->string (ModuleLocator-name (LinkModule!-path op)))
|
||||||
|
(assemble-label (make-Label (LinkModule!-label op)))
|
||||||
|
(symbol->string (ModuleLocator-name (LinkModule!-path op))))]
|
||||||
|
|
||||||
[(InstallModuleEntry!? op)
|
[(InstallModuleEntry!? op)
|
||||||
(format "M.modules[~s]=new RT.ModuleRecord(~s,~a);"
|
(format "M.modules[~s]=new RT.ModuleRecord(~s,~a);"
|
||||||
|
|
|
@ -31,11 +31,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(: assemble/write-invoke ((Listof Statement) Output-Port -> Void))
|
(: assemble/write-invoke ((Listof Statement) #;Boolean Output-Port -> Void))
|
||||||
;; Writes out the JavaScript code that represents the anonymous invocation expression.
|
;; Writes out the JavaScript code that represents the anonymous invocation expression.
|
||||||
;; What's emitted is a function expression that, when invoked, runs the
|
;; What's emitted is a function expression that, when invoked, runs the
|
||||||
;; statements.
|
;; statements.
|
||||||
(define (assemble/write-invoke stmts op)
|
(define (assemble/write-invoke stmts #;without-trampoline? op)
|
||||||
(parameterize ([current-interned-symbol-table ((inst make-hash Symbol Symbol))]
|
(parameterize ([current-interned-symbol-table ((inst make-hash Symbol Symbol))]
|
||||||
[current-interned-constant-closure-table ((inst make-hash Symbol MakeCompiledProcedure))])
|
[current-interned-constant-closure-table ((inst make-hash Symbol MakeCompiledProcedure))])
|
||||||
(display "(function(M, success, fail, params) {\n" op)
|
(display "(function(M, success, fail, params) {\n" op)
|
||||||
|
@ -73,8 +73,16 @@ for (param in params) {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
op)
|
op)
|
||||||
|
(fprintf op "~a(M); })"
|
||||||
|
(assemble-label (make-Label (BasicBlock-name (first basic-blocks)))))
|
||||||
|
#;(cond [without-trampoline?
|
||||||
|
;; If it's a module statement, we just want to call it directly, to get things loaded.
|
||||||
|
(fprintf op "~a(M); })"
|
||||||
|
(assemble-label (make-Label (BasicBlock-name (first basic-blocks)))))]
|
||||||
|
[else
|
||||||
|
;; Otherwise, we want to run under a trampolining context.
|
||||||
(fprintf op "M.trampoline(~a, true); })"
|
(fprintf op "M.trampoline(~a, true); })"
|
||||||
(assemble-label (make-Label (BasicBlock-name (first basic-blocks)))))))
|
(assemble-label (make-Label (BasicBlock-name (first basic-blocks)))))])))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,13 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var raiseModuleLoadingError = function(MACHINE, name) {
|
||||||
|
var message = "unable to dynamically load module: " + name;
|
||||||
|
var contMarks = MACHINE.captureContinuationMarks();
|
||||||
|
raise(MACHINE,
|
||||||
|
ExnFail.constructor([message, contMarks]));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,6 +255,7 @@
|
||||||
exceptions.raiseOperatorApplicationError = raiseOperatorApplicationError;
|
exceptions.raiseOperatorApplicationError = raiseOperatorApplicationError;
|
||||||
exceptions.raiseOperatorIsNotPrimitiveProcedure = raiseOperatorIsNotPrimitiveProcedure;
|
exceptions.raiseOperatorIsNotPrimitiveProcedure = raiseOperatorIsNotPrimitiveProcedure;
|
||||||
exceptions.raiseUnimplementedPrimitiveError = raiseUnimplementedPrimitiveError;
|
exceptions.raiseUnimplementedPrimitiveError = raiseUnimplementedPrimitiveError;
|
||||||
|
exceptions.raiseModuleLoadingError = raiseModuleLoadingError;
|
||||||
|
|
||||||
|
|
||||||
}(this.plt.baselib));
|
}(this.plt.baselib));
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
// Frame structures.
|
// Frame structures.
|
||||||
(function(baselib) {
|
(function(baselib) {
|
||||||
'use strict';
|
|
||||||
var exports = {};
|
var exports = {};
|
||||||
baselib.loadscript = exports;
|
baselib.loadscript = exports;
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,8 @@
|
||||||
var raiseOperatorApplicationError = baselib.exceptions.raiseOperatorApplicationError;
|
var raiseOperatorApplicationError = baselib.exceptions.raiseOperatorApplicationError;
|
||||||
var raiseOperatorIsNotPrimitiveProcedure = baselib.exceptions.raiseOperatorIsNotPrimitiveProcedure;
|
var raiseOperatorIsNotPrimitiveProcedure = baselib.exceptions.raiseOperatorIsNotPrimitiveProcedure;
|
||||||
var raiseUnimplementedPrimitiveError = baselib.exceptions.raiseUnimplementedPrimitiveError;
|
var raiseUnimplementedPrimitiveError = baselib.exceptions.raiseUnimplementedPrimitiveError;
|
||||||
|
var raiseModuleLoadingError = baselib.exceptions.raiseModuleLoadingError;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var ArityAtLeast = baselib.arity.ArityAtLeast;
|
var ArityAtLeast = baselib.arity.ArityAtLeast;
|
||||||
|
@ -1151,7 +1153,7 @@
|
||||||
// their files.
|
// their files.
|
||||||
if (moduleManifest[moduleName]) {
|
if (moduleManifest[moduleName]) {
|
||||||
var modulePath = moduleManifest[moduleName];
|
var modulePath = moduleManifest[moduleName];
|
||||||
return loadScript(modulePath, success, fail);
|
return loadScript(modulePath+"?gensym="+Math.random(), success, fail);
|
||||||
}
|
}
|
||||||
return fail();
|
return fail();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user