in the middle of namespacing the exports from the runtime
This commit is contained in:
parent
c461152e39
commit
7b8eb2b04f
|
@ -46,7 +46,7 @@
|
||||||
[(EnvPrefixReference? target)
|
[(EnvPrefixReference? target)
|
||||||
(assemble-prefix-reference target)]
|
(assemble-prefix-reference target)]
|
||||||
[(PrimitivesReference? target)
|
[(PrimitivesReference? target)
|
||||||
(format "Primitives[~s]" (symbol->string (PrimitivesReference-name target)))]))
|
(format "MACHINE.primitives[~s]" (symbol->string (PrimitivesReference-name target)))]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
23
assemble.rkt
23
assemble.rkt
|
@ -24,6 +24,7 @@
|
||||||
(let ([basic-blocks (fracture stmts)])
|
(let ([basic-blocks (fracture stmts)])
|
||||||
(fprintf op "(function(MACHINE, success, fail, params) {\n")
|
(fprintf op "(function(MACHINE, success, fail, params) {\n")
|
||||||
(fprintf op "var param;\n")
|
(fprintf op "var param;\n")
|
||||||
|
(fprintf op "var RUNTIME = plt.runtime;\n")
|
||||||
(for-each (lambda: ([basic-block : BasicBlock])
|
(for-each (lambda: ([basic-block : BasicBlock])
|
||||||
(displayln (assemble-basic-block basic-block) op)
|
(displayln (assemble-basic-block basic-block) op)
|
||||||
(newline op))
|
(newline op))
|
||||||
|
@ -38,7 +39,7 @@ for (param in params) {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
(fprintf op "trampoline(MACHINE, ~a); })"
|
(fprintf op "RUNTIME.trampoline(MACHINE, ~a); })"
|
||||||
(BasicBlock-name (first basic-blocks)))))
|
(BasicBlock-name (first basic-blocks)))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -265,10 +266,10 @@ EOF
|
||||||
(assemble-jump (GotoStatement-target stmt))]
|
(assemble-jump (GotoStatement-target stmt))]
|
||||||
|
|
||||||
[(PushControlFrame? stmt)
|
[(PushControlFrame? stmt)
|
||||||
(format "MACHINE.control.push(new CallFrame(~a, MACHINE.proc));" (PushControlFrame-label stmt))]
|
(format "MACHINE.control.push(new RUNTIME.CallFrame(~a, MACHINE.proc));" (PushControlFrame-label stmt))]
|
||||||
[(PushControlFrame/Prompt? stmt)
|
[(PushControlFrame/Prompt? stmt)
|
||||||
;; fixme: use a different frame structure
|
;; fixme: use a different frame structure
|
||||||
(format "MACHINE.control.push(new PromptFrame(~a, ~a));"
|
(format "MACHINE.control.push(new RUNTIME.PromptFrame(~a, ~a));"
|
||||||
(PushControlFrame/Prompt-label stmt)
|
(PushControlFrame/Prompt-label stmt)
|
||||||
(let ([tag (PushControlFrame/Prompt-tag stmt)])
|
(let ([tag (PushControlFrame/Prompt-tag stmt)])
|
||||||
(cond
|
(cond
|
||||||
|
@ -332,7 +333,7 @@ EOF
|
||||||
"MACHINE.proc.label"]
|
"MACHINE.proc.label"]
|
||||||
|
|
||||||
[(MakeCompiledProcedure? op)
|
[(MakeCompiledProcedure? op)
|
||||||
(format "new Closure(~a, ~a, [~a], ~a)"
|
(format "new RUNTIME.Closure(~a, ~a, [~a], ~a)"
|
||||||
(MakeCompiledProcedure-label op)
|
(MakeCompiledProcedure-label op)
|
||||||
(MakeCompiledProcedure-arity op)
|
(MakeCompiledProcedure-arity op)
|
||||||
(string-join (map assemble-env-reference/closure-capture
|
(string-join (map assemble-env-reference/closure-capture
|
||||||
|
@ -345,7 +346,7 @@ EOF
|
||||||
(assemble-display-name (MakeCompiledProcedure-display-name op)))]
|
(assemble-display-name (MakeCompiledProcedure-display-name op)))]
|
||||||
|
|
||||||
[(MakeCompiledProcedureShell? op)
|
[(MakeCompiledProcedureShell? op)
|
||||||
(format "new Closure(~a, ~a, undefined, ~a)"
|
(format "new RUNTIME.Closure(~a, ~a, undefined, ~a)"
|
||||||
(MakeCompiledProcedureShell-label op)
|
(MakeCompiledProcedureShell-label op)
|
||||||
(MakeCompiledProcedureShell-arity op)
|
(MakeCompiledProcedureShell-arity op)
|
||||||
(assemble-display-name (MakeCompiledProcedureShell-display-name op)))]
|
(assemble-display-name (MakeCompiledProcedureShell-display-name op)))]
|
||||||
|
@ -362,7 +363,7 @@ EOF
|
||||||
(CaptureEnvironment-skip op))]
|
(CaptureEnvironment-skip op))]
|
||||||
|
|
||||||
[(CaptureControl? op)
|
[(CaptureControl? op)
|
||||||
(format "captureControl(MACHINE, ~a, ~a)"
|
(format "RUNTIME.captureControl(MACHINE, ~a, ~a)"
|
||||||
(CaptureControl-skip op)
|
(CaptureControl-skip op)
|
||||||
(let ([tag (CaptureControl-tag op)])
|
(let ([tag (CaptureControl-tag op)])
|
||||||
(cond [(DefaultContinuationPromptTag? tag)
|
(cond [(DefaultContinuationPromptTag? tag)
|
||||||
|
@ -381,7 +382,7 @@ EOF
|
||||||
|
|
||||||
(: assemble-default-continuation-prompt-tag (-> String))
|
(: assemble-default-continuation-prompt-tag (-> String))
|
||||||
(define (assemble-default-continuation-prompt-tag)
|
(define (assemble-default-continuation-prompt-tag)
|
||||||
"DEFAULT_CONTINUATION_PROMPT_TAG")
|
"RUNTIME.DEFAULT_CONTINUATION_PROMPT_TAG")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -399,7 +400,7 @@ EOF
|
||||||
(CheckToplevelBound!-pos op))]
|
(CheckToplevelBound!-pos op))]
|
||||||
|
|
||||||
[(CheckClosureArity!? op)
|
[(CheckClosureArity!? op)
|
||||||
(format "if (! (MACHINE.proc instanceof Closure && MACHINE.proc.arity === ~a)) { if (! (MACHINE.proc instanceof Closure)) { throw new Error(\"not a closure\"); } else { throw new Error(\"arity failure\"); } }"
|
(format "if (! (MACHINE.proc instanceof RUNTIME.Closure && MACHINE.proc.arity === ~a)) { if (! (MACHINE.proc instanceof RUNTIME.Closure)) { throw new Error(\"not a closure\"); } else { throw new Error(\"arity failure\"); } }"
|
||||||
(CheckClosureArity!-arity op))]
|
(CheckClosureArity!-arity op))]
|
||||||
|
|
||||||
[(ExtendEnvironment/Prefix!? op)
|
[(ExtendEnvironment/Prefix!? op)
|
||||||
|
@ -407,13 +408,13 @@ EOF
|
||||||
(format "MACHINE.env.push([~a]); MACHINE.env[MACHINE.env.length-1].names = [~a];"
|
(format "MACHINE.env.push([~a]); MACHINE.env[MACHINE.env.length-1].names = [~a];"
|
||||||
(string-join (map (lambda: ([n : (U Symbol False ModuleVariable)])
|
(string-join (map (lambda: ([n : (U Symbol False ModuleVariable)])
|
||||||
(cond [(symbol? n)
|
(cond [(symbol? n)
|
||||||
(format "MACHINE.params.currentNamespace[~s] || Primitives[~s]"
|
(format "MACHINE.params.currentNamespace[~s] || MACHINE.primitives[~s]"
|
||||||
(symbol->string n)
|
(symbol->string n)
|
||||||
(symbol->string n))]
|
(symbol->string n))]
|
||||||
[(eq? n #f)
|
[(eq? n #f)
|
||||||
"false"]
|
"false"]
|
||||||
[(ModuleVariable? n)
|
[(ModuleVariable? n)
|
||||||
(format "Primitives[~s]"
|
(format "MACHINE.primitives[~s]"
|
||||||
(symbol->string (ModuleVariable-name n)))]))
|
(symbol->string (ModuleVariable-name n)))]))
|
||||||
names)
|
names)
|
||||||
",")
|
",")
|
||||||
|
@ -433,7 +434,7 @@ EOF
|
||||||
[(RestoreEnvironment!? op)
|
[(RestoreEnvironment!? op)
|
||||||
"MACHINE.env = MACHINE.env[MACHINE.env.length - 2].slice(0);"]
|
"MACHINE.env = MACHINE.env[MACHINE.env.length - 2].slice(0);"]
|
||||||
[(RestoreControl!? op)
|
[(RestoreControl!? op)
|
||||||
(format "restoreControl(MACHINE, ~a);"
|
(format "RUNTIME.restoreControl(MACHINE, ~a);"
|
||||||
(let ([tag (RestoreControl!-tag op)])
|
(let ([tag (RestoreControl!-tag op)])
|
||||||
(cond
|
(cond
|
||||||
[(DefaultContinuationPromptTag? tag)
|
[(DefaultContinuationPromptTag? tag)
|
||||||
|
|
1037
runtime.js
1037
runtime.js
File diff suppressed because it is too large
Load Diff
|
@ -43,6 +43,7 @@
|
||||||
"(function() { "
|
"(function() { "
|
||||||
|
|
||||||
runtime
|
runtime
|
||||||
|
"var MACHINE = new plt.runtime.Machine();\n"
|
||||||
|
|
||||||
"return function(success, fail, params){"
|
"return function(success, fail, params){"
|
||||||
snippet
|
snippet
|
||||||
|
@ -59,10 +60,9 @@
|
||||||
(let* ([a-statement (car a-statement+inspector)]
|
(let* ([a-statement (car a-statement+inspector)]
|
||||||
[inspector (cdr a-statement+inspector)])
|
[inspector (cdr a-statement+inspector)])
|
||||||
|
|
||||||
(display "(function() { " op)
|
|
||||||
|
|
||||||
(display runtime op)
|
(display runtime op)
|
||||||
|
(display "var MACHINE = new plt.runtime.Machine();\n" op)
|
||||||
|
(display "(function() { " op)
|
||||||
(display "var myInvoke = " op)
|
(display "var myInvoke = " op)
|
||||||
(assemble/write-invoke a-statement op)
|
(assemble/write-invoke a-statement op)
|
||||||
(display ";" op)
|
(display ";" op)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
(fprintf op #<<EOF
|
(fprintf op #<<EOF
|
||||||
return (function(succ, fail, params) {
|
return (function(succ, fail, params) {
|
||||||
return innerInvoke(MACHINE, succ, fail, params);
|
return innerInvoke(new plt.runtime.Machine(), succ, fail, params);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in New Issue
Block a user