diff --git a/js-assembler/assemble.rkt b/js-assembler/assemble.rkt
index c4b510b..099f10c 100644
--- a/js-assembler/assemble.rkt
+++ b/js-assembler/assemble.rkt
@@ -66,7 +66,7 @@ for (param in params) {
}
EOF
op)
- (fprintf op "M.trampoline(~a); })"
+ (fprintf op "M.trampoline(~a, true); })"
(assemble-label (make-Label (BasicBlock-name (first basic-blocks))))))
diff --git a/js-assembler/package.rkt b/js-assembler/package.rkt
index a0f210a..c07e4a8 100644
--- a/js-assembler/package.rkt
+++ b/js-assembler/package.rkt
@@ -236,7 +236,8 @@ M.modules[~s] =
;; load in modules.
(define (package source-code
#:should-follow-children? should-follow?
- #:output-port op)
+ #:output-port op
+ #:next-file-path (next-file-path (lambda () (error 'package))))
(define resources (set))
@@ -257,22 +258,28 @@ M.modules[~s] =
;; Record the use of resources on source module visitation...
(set! resources (set-union resources (list->set (source-resources src))))
+
(fprintf op "\n// ** Visiting ~a\n" (source-name src))
(define start-time (current-inexact-milliseconds))
(cond
[(UninterpretedSource? src)
- (fprintf op "~a" (UninterpretedSource-datum src))]
+ (fprintf op "(function(M) { ~a }(plt.runtime.currentMachine));" (UninterpretedSource-datum src))]
[else
(fprintf op "(")
(assemble/write-invoke stmts op)
- (fprintf op ")(M,
+ (fprintf op ")(plt.runtime.currentMachine,
function() {
if (window.console && window.console.log) {
window.console.log('loaded ' + ~s);
}
},
- FAIL,
- PARAMS);"
+ function(err) {
+ if (window.console && window.console.log) {
+ window.console.log('error: unable to load ' + ~s);
+ }
+ },
+ {});"
+ (format "~a" (source-name src))
(format "~a" (source-name src)))
(define stop-time (current-inexact-milliseconds))
(fprintf (current-timing-port) " assembly: ~s milliseconds\n" (- stop-time start-time))
@@ -284,7 +291,7 @@ M.modules[~s] =
(define (on-last-src)
- (fprintf op "plt.runtime.setReadyTrue(); SUCCESS();"))
+ (void))
@@ -303,13 +310,8 @@ M.modules[~s] =
;; last
on-last-src))
- (fprintf op "var invoke = (function(M, SUCCESS, FAIL, PARAMS) {")
- (fprintf op " plt.runtime.ready(function() {")
- (fprintf op " plt.runtime.setReadyFalse();")
(make (list (make-MainModuleSource source-code))
packaging-configuration)
- (fprintf op " });");
- (fprintf op "});\n")
(for ([r resources])
((current-on-resource) r)))
@@ -322,7 +324,8 @@ M.modules[~s] =
(display *header* op)
(display (quote-cdata
(string-append (get-runtime)
- (get-inert-code source-code)
+ (get-inert-code source-code
+ (lambda () (error 'package-standalone-xhtml)))
invoke-main-module-code)) op)
(display *footer* op))
@@ -431,12 +434,13 @@ EOF
invoke-main-module-code))
-;; get-inert-code: source -> string
-(define (get-inert-code source-code)
+;; get-inert-code: source (-> path) -> string
+(define (get-inert-code source-code next-file-path)
(let ([buffer (open-output-string)])
(package source-code
#:should-follow-children? (lambda (src) #t)
- #:output-port buffer)
+ #:output-port buffer
+ #:next-file-path next-file-path)
(compress
(get-output-string buffer))))
@@ -465,66 +469,56 @@ EOF
#<').text(' at ' + context[i].elts[0] +
- ', line ' + context[i].elts[2] +
- ', column ' + context[i].elts[3])
- .addClass('stacktrace')
- .css('margin-left', '10px')
- .css('whitespace', 'pre')
- .css('color', 'red'));
- } else if (plt.runtime.isProcedure(context[i])) {
- M.params.currentErrorDisplayer(
- M,
- $('
').text(' in ' + context[i].displayName)
- .addClass('stacktrace')
- .css('margin-left', '10px')
- .css('whitespace', 'pre')
- .css('color', 'red'));
- }
- }
- }
- }
- })},
- function() {
- // On module loading failure
- if (window.console && window.console.log) {
- window.console.log(e.stack || e);
- }
- },
- {});
+ if (e.hasOwnProperty('racketError') &&
+ plt.baselib.exceptions.isExn(e.racketError)) {
+ contMarkSet = plt.baselib.exceptions.exnContMarks(e.racketError);
+ if (contMarkSet) {
+ context = contMarkSet.getContext(M);
+ for (i = 0; i < context.length; i++) {
+ if (plt.runtime.isVector(context[i])) {
+ M.params.currentErrorDisplayer(
+ M,
+ $('').text(' at ' + context[i].elts[0] +
+ ', line ' + context[i].elts[2] +
+ ', column ' + context[i].elts[3])
+ .addClass('stacktrace')
+ .css('margin-left', '10px')
+ .css('whitespace', 'pre')
+ .css('color', 'red'));
+ } else if (plt.runtime.isProcedure(context[i])) {
+ M.params.currentErrorDisplayer(
+ M,
+ $('').text(' in ' + context[i].displayName)
+ .addClass('stacktrace')
+ .css('margin-left', '10px')
+ .css('whitespace', 'pre')
+ .css('color', 'red'));
+ }
+ }
+ }
+ }
+ });
};
-
$(document).ready(invokeMainModule);
EOF
)
diff --git a/js-assembler/runtime-src/baselib-primitives.js b/js-assembler/runtime-src/baselib-primitives.js
index 7ebe65f..7d6c564 100644
--- a/js-assembler/runtime-src/baselib-primitives.js
+++ b/js-assembler/runtime-src/baselib-primitives.js
@@ -694,7 +694,7 @@
'substring',
makeList(2, 3),
function(M) {
- var str = String(checkString(M, 'substring', 0));
+ var str = checkString(M, 'substring', 0).toString();
var start = baselib.numbers.toFixnum(checkNatural(M, 'substring', 1));
var end = str.length;
if (M.a === 3) {
@@ -1722,8 +1722,8 @@
var i;
if (M.a === 1) {
var sym = checkSymbol(M, 'error', 1);
- raise(M, baselib.exceptions.makeExnFail(String(sym),
- M.captureContinuationMarks()));
+ raise(M, baselib.exceptions.makeExnFail(sym.toString(),
+ M.captureContinuationMarks()));
}
if (isString(M.e[M.e.length - 1])) {
@@ -1731,7 +1731,7 @@
for (i = 1; i < M.a; i++) {
vs.push(baselib.format.format("~e", [M.e[M.e.length - 1 - i]]));
}
- raise(M, baselib.exceptions.makeExnFail(String(M.e[M.e.length - 1]) +
+ raise(M, baselib.exceptions.makeExnFail(M.e[M.e.length - 1].toString() +
": " +
vs.join(' '),
M.captureContinuationMarks()));
@@ -1744,7 +1744,7 @@
args.push(M.e[M.e.length - 1 - i]);
}
raise(M, baselib.exceptions.makeExnFail(
- baselib.format.format('~s: ' + String(fmtString),
+ baselib.format.format('~s: ' + fmtString.toString(),
args),
M.captureContinuationMarks()));
}
@@ -1850,7 +1850,7 @@
var predicateValue =
makePrimitiveProcedure(
- String(name) + "?",
+ name.toString() + "?",
1,
function (M) {
return structType.predicate(M.e[M.e.length - 1]);
@@ -1858,7 +1858,7 @@
var accessorValue =
makePrimitiveProcedure(
- String(name) + "-accessor",
+ name.toString() + "-accessor",
2,
function (M) {
return structType.accessor(
@@ -1869,7 +1869,7 @@
var mutatorValue =
makePrimitiveProcedure(
- String(name) + "-mutator",
+ name.toString() + "-mutator",
3,
function (M) {
return structType.mutator(
@@ -1913,7 +1913,7 @@
var index = M.e[M.e.length - 2];
var name;
if (M.a === 3) {
- name = String(M.e[M.e.length - 3]);
+ name = M.e[M.e.length - 3].toString();
} else {
name = 'field' + index;
}
@@ -1940,7 +1940,7 @@
var index = M.e[M.e.length - 2];
var name;
if (M.a === 3) {
- name = String(M.e[M.e.length - 3]);
+ name = M.e[M.e.length - 3].toString();
} else {
name = 'field' + index;
}
diff --git a/js-assembler/runtime-src/runtime.js b/js-assembler/runtime-src/runtime.js
index 674a8d1..0e56efe 100644
--- a/js-assembler/runtime-src/runtime.js
+++ b/js-assembler/runtime-src/runtime.js
@@ -443,7 +443,7 @@
};
- Machine.prototype.trampoline = function(initialJump) {
+ Machine.prototype.trampoline = function(initialJump, noJumpingOff) {
var thunk = initialJump;
var startTime = (new Date()).valueOf();
this.cbt = STACK_LIMIT_ESTIMATE;
@@ -480,6 +480,13 @@
thunk = e;
this.cbt = STACK_LIMIT_ESTIMATE;
+
+ // If we're running an a model that prohibits
+ // jumping off the trampoline, continue.
+ if (noJumpingOff) {
+ continue;
+ }
+
if (this.params.numBouncesBeforeYield-- < 0) {
recomputeMaxNumBouncesBeforeYield(
this,
@@ -506,9 +513,7 @@
}
this.running = false;
var that = this;
- setTimeout(
- function() { that.params.currentSuccessHandler(that); },
- 0);
+ this.params.currentSuccessHandler(this);
return;
};
diff --git a/whalesong-helpers.rkt b/whalesong-helpers.rkt
index abb6766..27ee014 100644
--- a/whalesong-helpers.rkt
+++ b/whalesong-helpers.rkt
@@ -141,7 +141,8 @@
(call-with-output-file* output-js-filename
(lambda (op)
(display (get-runtime) op)
- (display (get-inert-code (make-ModuleSource (build-path f)))
+ (display (get-inert-code (make-ModuleSource (build-path f))
+ make-output-js-filename)
op))
#:exists 'replace)