diff --git a/js-assembler/assemble.rkt b/js-assembler/assemble.rkt index fdfde55..ffe7512 100644 --- a/js-assembler/assemble.rkt +++ b/js-assembler/assemble.rkt @@ -186,7 +186,7 @@ EOF "") (cond [(DebugPrint? stmt) - (format "MACHINE.params.currentOutputPort.write(MACHINE, ~a);" (assemble-oparg (DebugPrint-value stmt)))] + (format "MACHINE.params.currentOutputPort.writeDomNode(MACHINE, $('').text(~a));" (assemble-oparg (DebugPrint-value stmt)))] [(AssignImmediateStatement? stmt) (let: ([t : String (assemble-target (AssignImmediateStatement-target stmt))] [v : OpArg (AssignImmediateStatement-value stmt)]) diff --git a/js-assembler/package.rkt b/js-assembler/package.rkt index dddd831..a75598f 100644 --- a/js-assembler/package.rkt +++ b/js-assembler/package.rkt @@ -2,8 +2,8 @@ (require "assemble.rkt" "quote-cdata.rkt" - "../make.rkt" - "../make-structs.rkt" + "../make/make.rkt" + "../make/make-structs.rkt" "../parameters.rkt" (planet dyoo/closure-compile:1:1) (prefix-in runtime: "get-runtime.rkt") @@ -28,11 +28,11 @@ (define (package-anonymous source-code - #:should-follow? should-follow? + #:should-follow-children? should-follow? #:output-port op) (fprintf op "(function() {\n") (package source-code - #:should-follow? should-follow? + #:should-follow-children? should-follow? #:output-port op) (fprintf op " return invoke; })\n")) @@ -41,15 +41,17 @@ ;; package: Source (path -> boolean) output-port -> void -;; Compile package for the given source program. should-follow? -;; indicates whether we should continue following module paths. +;; Compile package for the given source program. +;; +;; should-follow-children? indicates whether we should continue +;; following module paths of a source's dependencies. ;; ;; The generated output defines a function called 'invoke' with ;; four arguments (MACHINE, SUCCESS, FAIL, PARAMS). When called, it will ;; execute the code to either run standalone expressions or ;; load in modules. (define (package source-code - #:should-follow? should-follow? + #:should-follow-children? should-follow? #:output-port op) (define packaging-configuration (make-Configuration @@ -93,7 +95,7 @@ (define (write-runtime op) (let ([packaging-configuration (make-Configuration - ;; should-follow? + ;; should-follow-children? (lambda (src p) #t) ;; on (lambda (src ast stmts) @@ -158,7 +160,7 @@ EOF (define (get-code source-code) (let ([buffer (open-output-string)]) (package source-code - #:should-follow? (lambda (src p) #t) + #:should-follow-children? (lambda (src p) #t) #:output-port buffer) (compress (get-output-string buffer)))) @@ -176,7 +178,7 @@ EOF ;; write-standalone-code: source output-port -> void (define (write-standalone-code source-code op) (package-anonymous source-code - #:should-follow? (lambda (src p) #t) + #:should-follow-children? (lambda (src p) #t) #:output-port op) (fprintf op "()(plt.runtime.currentMachine, function() {}, function() {}, {});\n")) diff --git a/get-dependencies.rkt b/make/get-dependencies.rkt similarity index 91% rename from get-dependencies.rkt rename to make/get-dependencies.rkt index 7483948..e2e29e2 100644 --- a/get-dependencies.rkt +++ b/make/get-dependencies.rkt @@ -1,7 +1,7 @@ #lang typed/racket/base -(require "compiler/expression-structs.rkt" - "compiler/lexical-structs.rkt" - "sets.rkt") +(require "../compiler/expression-structs.rkt" + "../compiler/lexical-structs.rkt" + "../sets.rkt") ;; Collect the complete list of dependencies for a module. diff --git a/make-structs.rkt b/make/make-structs.rkt similarity index 87% rename from make-structs.rkt rename to make/make-structs.rkt index 1939c2c..5ee23f3 100644 --- a/make-structs.rkt +++ b/make/make-structs.rkt @@ -1,8 +1,8 @@ #lang typed/racket/base -(require "compiler/il-structs.rkt" - "compiler/bootstrapped-primitives.rkt" - "compiler/expression-structs.rkt" +(require "../compiler/il-structs.rkt" + "../compiler/bootstrapped-primitives.rkt" + "../compiler/expression-structs.rkt" "get-dependencies.rkt") @@ -26,7 +26,7 @@ (define-struct: Configuration - ([should-follow? : (Source Path -> Boolean)] + ([should-follow-children? : (Source Path -> Boolean)] [on-module-statements : (Source (U Expression #f) (Listof Statement) diff --git a/make.rkt b/make/make.rkt similarity index 90% rename from make.rkt rename to make/make.rkt index 4eb7133..178d4ea 100644 --- a/make.rkt +++ b/make/make.rkt @@ -1,22 +1,22 @@ #lang typed/racket/base -(require "compiler/compiler.rkt" - "compiler/il-structs.rkt" - "compiler/lexical-structs.rkt" - "compiler/compiler-structs.rkt" - "compiler/expression-structs.rkt" +(require "../compiler/compiler.rkt" + "../compiler/il-structs.rkt" + "../compiler/lexical-structs.rkt" + "../compiler/compiler-structs.rkt" + "../compiler/expression-structs.rkt" + "../parameters.rkt" + "../sets.rkt" "get-dependencies.rkt" - "parameters.rkt" - "sets.rkt" "make-structs.rkt" racket/list racket/match) -(require/typed "parser/parse-bytecode.rkt" +(require/typed "../parser/parse-bytecode.rkt" [parse-bytecode (Any -> Expression)]) -(require/typed "get-module-bytecode.rkt" +(require/typed "../get-module-bytecode.rkt" [get-module-bytecode ((U String Path Input-Port) -> Bytes)]) @@ -96,7 +96,7 @@ ((inst new-seteq Symbol))]) (match config - [(struct Configuration (should-follow? + [(struct Configuration (should-follow-children? on-module-statements after-module-statements after-last)) @@ -113,6 +113,8 @@ [(eq? ast #f) empty] [else + ;; FIXME: the logic here is wrong. + ;; Needs to check should-follow-children before continuing here. (let* ([dependent-module-names (get-dependencies ast)] [paths (foldl (lambda: ([mp : ModuleLocator] @@ -123,7 +125,7 @@ mp) acc] [(and (path? rp) - (should-follow? this-source rp) + (should-follow-children? this-source rp) (cons (make-ModuleSource rp) acc))] [else diff --git a/simulator/simulator.rkt b/simulator/simulator.rkt index 2283769..c3997ae 100644 --- a/simulator/simulator.rkt +++ b/simulator/simulator.rkt @@ -312,10 +312,10 @@ (cond [(closure? clos) (if (arity-match? (closure-arity clos) - (ensure-natural (evaluate-oparg m (CheckClosureArity!-arity op)))) + (ensure-natural (evaluate-oparg m (CheckClosureArity!-num-args op)))) 'ok (error 'check-closure-arity "arity mismatch: passed ~s args to ~s" - (ensure-natural (evaluate-oparg m (CheckClosureArity!-arity op))) + (ensure-natural (evaluate-oparg m (CheckClosureArity!-num-args op))) (closure-display-name clos)))] [else (error 'check-closure-arity "not a closure: ~s" clos)]))] @@ -325,10 +325,10 @@ (cond [(primitive-proc? clos) (if (arity-match? (primitive-proc-arity clos) - (ensure-natural (evaluate-oparg m (CheckPrimitiveArity!-arity op)))) + (ensure-natural (evaluate-oparg m (CheckPrimitiveArity!-num-args op)))) 'ok (error 'check-primitive-arity "arity mismatch: passed ~s args to ~s" - (ensure-natural (evaluate-oparg m (CheckPrimitiveArity!-arity op))) + (ensure-natural (evaluate-oparg m (CheckPrimitiveArity!-num-args op))) (primitive-proc-display-name clos)))] [else (error 'check-primitive-arity "not a primitive: ~s" clos)]))] diff --git a/tests/browser-evaluate.rkt b/tests/browser-evaluate.rkt index 8b898d5..93d5d67 100644 --- a/tests/browser-evaluate.rkt +++ b/tests/browser-evaluate.rkt @@ -236,7 +236,7 @@ var comet = function() { var onFail = function(machine, e) { endTime = new Date(); sendRequest("/eval", function(req) { setTimeout(comet, 0); }, - "e=" + encodeURIComponent(String(e)) + + "e=" + encodeURIComponent(String(e.stack || e)) + "&t=" + encodeURIComponent(String(endTime - startTime))); }; startTime = new Date(); diff --git a/tests/test-browser-evaluate.rkt b/tests/test-browser-evaluate.rkt index 3860db5..1cc03ef 100644 --- a/tests/test-browser-evaluate.rkt +++ b/tests/test-browser-evaluate.rkt @@ -1,7 +1,7 @@ #lang racket (require "browser-evaluate.rkt" "../js-assembler/package.rkt" - "../make-structs.rkt") + "../make/make-structs.rkt") (printf "test-browser-evaluate.rkt\n") @@ -20,7 +20,7 @@ (fprintf op "var innerInvoke = ") (package-anonymous (make-SexpSource program) - #:should-follow? should-follow? + #:should-follow-children? should-follow? #:output-port op) (fprintf op "();\n") diff --git a/tests/test-conform-browser.rkt b/tests/test-conform-browser.rkt index 076384f..9c500b3 100644 --- a/tests/test-conform-browser.rkt +++ b/tests/test-conform-browser.rkt @@ -1,7 +1,7 @@ #lang racket (require "browser-evaluate.rkt" "../js-assembler/package.rkt" - "../make-structs.rkt" + "../make/make-structs.rkt" racket/port racket/runtime-path) @@ -21,7 +21,7 @@ (fprintf op "var innerInvoke = ") (package-anonymous (make-SexpSource program) - #:should-follow? (lambda (src p) #t) + #:should-follow-children? (lambda (src p) #t) #:output-port op) (fprintf op "();\n") diff --git a/tests/test-earley-browser.rkt b/tests/test-earley-browser.rkt index 8b7f6e8..b0a6bc7 100644 --- a/tests/test-earley-browser.rkt +++ b/tests/test-earley-browser.rkt @@ -1,7 +1,7 @@ #lang racket (require "browser-evaluate.rkt" "../js-assembler/package.rkt" - "../make-structs.rkt" + "../make/make-structs.rkt" racket/port racket/runtime-path racket/runtime-path @@ -23,7 +23,7 @@ (fprintf op "var innerInvoke = ") (package-anonymous (make-SexpSource program) - #:should-follow? (lambda (src path) #t) + #:should-follow-children? (lambda (src path) #t) #:output-port op) (fprintf op "();\n") diff --git a/tests/test-get-dependencies.rkt b/tests/test-get-dependencies.rkt index 5e1e8c9..325c885 100644 --- a/tests/test-get-dependencies.rkt +++ b/tests/test-get-dependencies.rkt @@ -1,5 +1,5 @@ #lang racket -(require "../get-dependencies.rkt" +(require "../make/get-dependencies.rkt" "../get-module-bytecode.rkt" "../parser/parse-bytecode.rkt" "../compiler/lexical-structs.rkt" @@ -11,7 +11,7 @@ (define-runtime-path get-dependencies-path - (build-path ".." "get-dependencies.rkt")) + (build-path ".." "make" "get-dependencies.rkt")) (define-runtime-path get-module-bytecode-path (build-path ".." "get-module-bytecode.rkt")) diff --git a/tests/test-package.rkt b/tests/test-package.rkt index e5ff135..d031601 100644 --- a/tests/test-package.rkt +++ b/tests/test-package.rkt @@ -1,7 +1,7 @@ #lang racket/base (require "../js-assembler/package.rkt" - "../make-structs.rkt") + "../make/make-structs.rkt") (printf "test-package.rkt\n") @@ -11,7 +11,7 @@ (define (test s-exp) (package (make-SexpSource s-exp) - #:should-follow? follow? + #:should-follow-children? follow? #:output-port (open-output-string) #;(current-output-port))) diff --git a/whalesong.rkt b/whalesong.rkt index b405ca2..b026a5a 100755 --- a/whalesong.rkt +++ b/whalesong.rkt @@ -3,7 +3,7 @@ (require racket/list racket/string - "make-structs.rkt" + "make/make-structs.rkt" "js-assembler/package.rkt")