reducing code size by renaming MACHINE to M, RUNTIME to RT
This commit is contained in:
parent
11799d3a9c
commit
9f978f5592
|
@ -14,7 +14,7 @@
|
|||
(define (assemble-op-expression op)
|
||||
(cond
|
||||
[(GetCompiledProcedureEntry? op)
|
||||
"MACHINE.proc.label"]
|
||||
"M.proc.label"]
|
||||
|
||||
[(MakeCompiledProcedure? op)
|
||||
(format "new RT.Closure(~a, ~a, [~a], ~a)"
|
||||
|
@ -37,14 +37,14 @@
|
|||
(assemble-display-name (MakeCompiledProcedureShell-display-name op)))]
|
||||
|
||||
[(ApplyPrimitiveProcedure? op)
|
||||
(format "MACHINE.proc(MACHINE)")]
|
||||
(format "M.proc(M)")]
|
||||
|
||||
[(CaptureEnvironment? op)
|
||||
(format "MACHINE.env.slice(0, MACHINE.env.length - ~a)"
|
||||
(format "M.env.slice(0, M.env.length - ~a)"
|
||||
(CaptureEnvironment-skip op))]
|
||||
|
||||
[(CaptureControl? op)
|
||||
(format "MACHINE.captureControl(~a, ~a)"
|
||||
(format "M.captureControl(~a, ~a)"
|
||||
(CaptureControl-skip op)
|
||||
(let: ([tag : (U DefaultContinuationPromptTag OpArg)
|
||||
(CaptureControl-tag op)])
|
||||
|
@ -55,7 +55,7 @@
|
|||
|
||||
|
||||
[(MakeBoxedEnvironmentValue? op)
|
||||
(format "[MACHINE.env[MACHINE.env.length - 1 - ~a]]"
|
||||
(format "[M.env[M.env.length - 1 - ~a]]"
|
||||
(MakeBoxedEnvironmentValue-depth op))]
|
||||
|
||||
[(CallKernelPrimitiveProcedure? op)
|
||||
|
|
|
@ -83,11 +83,11 @@
|
|||
(format "~a=~a;"
|
||||
(cond
|
||||
[(eq? target 'proc)
|
||||
"MACHINE.proc"]
|
||||
"M.proc"]
|
||||
[(eq? target 'val)
|
||||
"MACHINE.val"]
|
||||
"M.val"]
|
||||
[(eq? target 'argcount)
|
||||
"MACHINE.argcount"]
|
||||
"M.argcount"]
|
||||
[(EnvLexicalReference? target)
|
||||
(assemble-lexical-reference target)]
|
||||
[(EnvPrefixReference? target)
|
||||
|
@ -95,7 +95,7 @@
|
|||
[(ControlFrameTemporary? target)
|
||||
(assemble-control-frame-temporary target)]
|
||||
[(ModulePrefixTarget? target)
|
||||
(format "MACHINE.modules[~s].prefix"
|
||||
(format "M.modules[~s].prefix"
|
||||
(symbol->string (ModuleLocator-name (ModulePrefixTarget-path target))))])
|
||||
rhs))]))
|
||||
|
||||
|
@ -103,7 +103,7 @@
|
|||
|
||||
(: assemble-control-frame-temporary (ControlFrameTemporary -> String))
|
||||
(define (assemble-control-frame-temporary t)
|
||||
(format "MACHINE.control[MACHINE.control.length-1].~a"
|
||||
(format "M.control[M.control.length-1].~a"
|
||||
(ControlFrameTemporary-name t)))
|
||||
|
||||
;; fixme: use js->string
|
||||
|
@ -253,26 +253,26 @@
|
|||
(: assemble-lexical-reference (EnvLexicalReference -> String))
|
||||
(define (assemble-lexical-reference a-lex-ref)
|
||||
(if (EnvLexicalReference-unbox? a-lex-ref)
|
||||
(format "MACHINE.env[MACHINE.env.length-~a][0]"
|
||||
(format "M.env[M.env.length-~a][0]"
|
||||
(add1 (EnvLexicalReference-depth a-lex-ref)))
|
||||
(format "MACHINE.env[MACHINE.env.length-~a]"
|
||||
(format "M.env[M.env.length-~a]"
|
||||
(add1 (EnvLexicalReference-depth a-lex-ref)))))
|
||||
|
||||
(: assemble-prefix-reference (EnvPrefixReference -> String))
|
||||
(define (assemble-prefix-reference a-ref)
|
||||
(format "MACHINE.env[MACHINE.env.length-~a][~a]"
|
||||
(format "M.env[M.env.length-~a][~a]"
|
||||
(add1 (EnvPrefixReference-depth a-ref))
|
||||
(EnvPrefixReference-pos a-ref)))
|
||||
|
||||
(: assemble-whole-prefix-reference (EnvWholePrefixReference -> String))
|
||||
(define (assemble-whole-prefix-reference a-prefix-ref)
|
||||
(format "MACHINE.env[MACHINE.env.length-~a]"
|
||||
(format "M.env[M.env.length-~a]"
|
||||
(add1 (EnvWholePrefixReference-depth a-prefix-ref))))
|
||||
|
||||
|
||||
(: assemble-reg (Reg -> String))
|
||||
(define (assemble-reg a-reg)
|
||||
(string-append "MACHINE." (symbol->string (Reg-name a-reg))))
|
||||
(string-append "M." (symbol->string (Reg-name a-reg))))
|
||||
|
||||
|
||||
|
||||
|
@ -302,12 +302,12 @@
|
|||
|
||||
(: assemble-control-stack-label (ControlStackLabel -> String))
|
||||
(define (assemble-control-stack-label a-csl)
|
||||
"MACHINE.control[MACHINE.control.length-1].label")
|
||||
"M.control[M.control.length-1].label")
|
||||
|
||||
|
||||
(: assemble-control-stack-label/multiple-value-return (ControlStackLabel/MultipleValueReturn -> String))
|
||||
(define (assemble-control-stack-label/multiple-value-return a-csl)
|
||||
"MACHINE.control[MACHINE.control.length-1].label.multipleValueReturn")
|
||||
"M.control[M.control.length-1].label.multipleValueReturn")
|
||||
|
||||
|
||||
|
||||
|
@ -337,7 +337,7 @@
|
|||
;; lexical references: they must remain boxes. So all we need is
|
||||
;; the depth into the environment.
|
||||
(define (assemble-env-reference/closure-capture depth)
|
||||
(format "MACHINE.env[MACHINE.env.length - ~a]"
|
||||
(format "M.env[M.env.length - ~a]"
|
||||
(add1 depth)))
|
||||
|
||||
|
||||
|
@ -370,7 +370,7 @@
|
|||
|
||||
(: assemble-jump (OpArg -> String))
|
||||
(define (assemble-jump target)
|
||||
(format "return(~a)(MACHINE);" (assemble-oparg target)))
|
||||
(format "return(~a)(M);" (assemble-oparg target)))
|
||||
|
||||
|
||||
|
||||
|
@ -399,25 +399,25 @@
|
|||
|
||||
(: assemble-primitive-kernel-value (PrimitiveKernelValue -> String))
|
||||
(define (assemble-primitive-kernel-value a-prim)
|
||||
(format "MACHINE.primitives[~s]" (symbol->string (PrimitiveKernelValue-id a-prim))))
|
||||
(format "M.primitives[~s]" (symbol->string (PrimitiveKernelValue-id a-prim))))
|
||||
|
||||
|
||||
|
||||
(: assemble-module-entry (ModuleEntry -> String))
|
||||
(define (assemble-module-entry entry)
|
||||
(format "MACHINE.modules[~s].label"
|
||||
(format "M.modules[~s].label"
|
||||
(symbol->string (ModuleLocator-name (ModuleEntry-name entry)))))
|
||||
|
||||
|
||||
(: assemble-is-module-invoked (IsModuleInvoked -> String))
|
||||
(define (assemble-is-module-invoked entry)
|
||||
(format "MACHINE.modules[~s].isInvoked"
|
||||
(format "M.modules[~s].isInvoked"
|
||||
(symbol->string (ModuleLocator-name (IsModuleInvoked-name entry)))))
|
||||
|
||||
|
||||
(: assemble-is-module-linked (IsModuleLinked -> String))
|
||||
(define (assemble-is-module-linked entry)
|
||||
(format "(MACHINE.modules[~s]!==undefined)"
|
||||
(format "(M.modules[~s]!==undefined)"
|
||||
(symbol->string (ModuleLocator-name (IsModuleLinked-name entry)))))
|
||||
|
||||
|
||||
|
@ -425,6 +425,6 @@
|
|||
(: assemble-variable-reference (VariableReference -> String))
|
||||
(define (assemble-variable-reference varref)
|
||||
(let ([t (VariableReference-toplevel varref)])
|
||||
(format "(new RT.VariableReference(MACHINE.env[MACHINE.env.length-~a],~a))"
|
||||
(format "(new RT.VariableReference(M.env[M.env.length-~a],~a))"
|
||||
(add1 (ToplevelRef-depth t))
|
||||
(ToplevelRef-pos t))))
|
|
@ -163,7 +163,7 @@
|
|||
(format "RT.isPair")]
|
||||
[(box)
|
||||
(format "RT.isBox")])])
|
||||
(format "RT.testArgument(MACHINE, ~s, ~a, ~a, ~a, ~s)"
|
||||
(format "RT.testArgument(M, ~s, ~a, ~a, ~a, ~s)"
|
||||
(symbol->string domain)
|
||||
predicate
|
||||
operand-string
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
(cond
|
||||
|
||||
[(CheckToplevelBound!? op)
|
||||
(format "if (MACHINE.env[MACHINE.env.length - 1 - ~a][~a] === undefined) { RT.raiseUnboundToplevelError(MACHINE.env[MACHINE.env.length - 1 - ~a].names[~a]); }"
|
||||
(format "if (M.env[M.env.length - 1 - ~a][~a] === undefined) { RT.raiseUnboundToplevelError(M.env[M.env.length - 1 - ~a].names[~a]); }"
|
||||
(CheckToplevelBound!-depth op)
|
||||
(CheckToplevelBound!-pos op)
|
||||
(CheckToplevelBound!-depth op)
|
||||
|
@ -22,31 +22,31 @@
|
|||
|
||||
|
||||
[(CheckClosureArity!? op)
|
||||
(format "if(!(MACHINE.proc instanceof RT.Closure)){RT.raiseOperatorIsNotClosure(MACHINE,MACHINE.proc);}if(!RT.isArityMatching(MACHINE.proc.racketArity,~a)){RT.raiseArityMismatchError(MACHINE, MACHINE.proc,~a);}"
|
||||
(format "if(!(M.proc instanceof RT.Closure)){RT.raiseOperatorIsNotClosure(M,M.proc);}if(!RT.isArityMatching(M.proc.racketArity,~a)){RT.raiseArityMismatchError(M, M.proc,~a);}"
|
||||
(assemble-oparg (CheckClosureArity!-num-args op))
|
||||
(assemble-oparg (CheckClosureArity!-num-args op)))]
|
||||
|
||||
|
||||
[(CheckPrimitiveArity!? op)
|
||||
(format "if(!RT.isArityMatching(MACHINE.proc.racketArity,~a)){RT.raiseArityMismatchError(MACHINE,MACHINE.proc,~a);}"
|
||||
(format "if(!RT.isArityMatching(M.proc.racketArity,~a)){RT.raiseArityMismatchError(M,M.proc,~a);}"
|
||||
(assemble-oparg (CheckPrimitiveArity!-num-args op))
|
||||
(assemble-oparg (CheckPrimitiveArity!-num-args op)))]
|
||||
|
||||
|
||||
[(ExtendEnvironment/Prefix!? op)
|
||||
(let: ([names : (Listof (U Symbol False GlobalBucket ModuleVariable)) (ExtendEnvironment/Prefix!-names op)])
|
||||
(format "MACHINE.env.push([~a]);MACHINE.env[MACHINE.env.length-1].names=[~a];"
|
||||
(format "M.env.push([~a]);M.env[M.env.length-1].names=[~a];"
|
||||
(string-join (map
|
||||
(lambda: ([n : (U Symbol False GlobalBucket ModuleVariable)])
|
||||
(cond [(symbol? n)
|
||||
(format "MACHINE.params.currentNamespace[~s] || MACHINE.primitives[~s]"
|
||||
(format "M.params.currentNamespace[~s] || M.primitives[~s]"
|
||||
(symbol->string n)
|
||||
(symbol->string n))]
|
||||
[(eq? n #f)
|
||||
"false"]
|
||||
[(GlobalBucket? n)
|
||||
;; FIXME: maybe we should keep a set of global variables here?
|
||||
(format "MACHINE.primitives[~s]"
|
||||
(format "M.primitives[~s]"
|
||||
(symbol->string (GlobalBucket-name n)))]
|
||||
;; FIXME: this should be looking at the module path and getting
|
||||
;; the value here! It shouldn't be looking into Primitives...
|
||||
|
@ -54,10 +54,10 @@
|
|||
(cond
|
||||
[((current-kernel-module-locator?)
|
||||
(ModuleVariable-module-name n))
|
||||
(format "MACHINE.primitives[~s]"
|
||||
(format "M.primitives[~s]"
|
||||
(symbol->string (ModuleVariable-name n)))]
|
||||
[else
|
||||
(format "MACHINE.modules[~s].namespace[~s]"
|
||||
(format "M.modules[~s].namespace[~s]"
|
||||
(symbol->string
|
||||
(ModuleLocator-name
|
||||
(ModuleVariable-module-name n)))
|
||||
|
@ -79,13 +79,13 @@
|
|||
",")))]
|
||||
|
||||
[(InstallClosureValues!? op)
|
||||
"MACHINE.env.splice.apply(MACHINE.env,[MACHINE.env.length, 0].concat(MACHINE.proc.closedVals));"]
|
||||
"M.env.splice.apply(M.env,[M.env.length, 0].concat(M.proc.closedVals));"]
|
||||
|
||||
[(RestoreEnvironment!? op)
|
||||
"MACHINE.env=MACHINE.env[MACHINE.env.length-2].slice(0);"]
|
||||
"M.env=M.env[M.env.length-2].slice(0);"]
|
||||
|
||||
[(RestoreControl!? op)
|
||||
(format "MACHINE.restoreControl(~a);"
|
||||
(format "M.restoreControl(~a);"
|
||||
(let: ([tag : (U DefaultContinuationPromptTag OpArg)
|
||||
(RestoreControl!-tag op)])
|
||||
(cond
|
||||
|
@ -95,7 +95,7 @@
|
|||
(assemble-oparg tag)])))]
|
||||
|
||||
[(FixClosureShellMap!? op)
|
||||
(format "MACHINE.env[MACHINE.env.length-~a].closedVals=[~a];"
|
||||
(format "M.env[M.env.length-~a].closedVals=[~a];"
|
||||
(add1 (FixClosureShellMap!-depth op))
|
||||
(string-join (map
|
||||
assemble-env-reference/closure-capture
|
||||
|
@ -107,60 +107,60 @@
|
|||
","))]
|
||||
|
||||
[(SetFrameCallee!? op)
|
||||
(format "MACHINE.control[MACHINE.control.length-1].proc = ~a;"
|
||||
(format "M.control[M.control.length-1].proc = ~a;"
|
||||
(assemble-oparg (SetFrameCallee!-proc op)))]
|
||||
|
||||
[(SpliceListIntoStack!? op)
|
||||
(format "MACHINE.spliceListIntoStack(~a);"
|
||||
(format "M.spliceListIntoStack(~a);"
|
||||
(assemble-oparg (SpliceListIntoStack!-depth op)))]
|
||||
|
||||
[(UnspliceRestFromStack!? op)
|
||||
(format "MACHINE.unspliceRestFromStack(~a,~a);"
|
||||
(format "M.unspliceRestFromStack(~a,~a);"
|
||||
(assemble-oparg (UnspliceRestFromStack!-depth op))
|
||||
(assemble-oparg (UnspliceRestFromStack!-length op)))]
|
||||
|
||||
[(InstallContinuationMarkEntry!? op)
|
||||
(string-append "MACHINE.installContinuationMarkEntry("
|
||||
"MACHINE.control[MACHINE.control.length-1].pendingContinuationMarkKey,"
|
||||
"MACHINE.val);")]
|
||||
(string-append "M.installContinuationMarkEntry("
|
||||
"M.control[M.control.length-1].pendingContinuationMarkKey,"
|
||||
"M.val);")]
|
||||
|
||||
[(RaiseContextExpectedValuesError!? op)
|
||||
(format "RT.raiseContextExpectedValuesError(MACHINE,~a);"
|
||||
(format "RT.raiseContextExpectedValuesError(M,~a);"
|
||||
(RaiseContextExpectedValuesError!-expected op))]
|
||||
|
||||
|
||||
[(RaiseArityMismatchError!? op)
|
||||
(format "RT.raiseArityMismatchError(MACHINE,~a,~a);"
|
||||
(format "RT.raiseArityMismatchError(M,~a,~a);"
|
||||
(assemble-oparg (RaiseArityMismatchError!-proc op))
|
||||
(assemble-oparg (RaiseArityMismatchError!-received op)))]
|
||||
|
||||
|
||||
[(RaiseOperatorApplicationError!? op)
|
||||
(format "RT.raiseOperatorApplicationError(MACHINE,~a);"
|
||||
(format "RT.raiseOperatorApplicationError(M,~a);"
|
||||
(assemble-oparg (RaiseOperatorApplicationError!-operator op)))]
|
||||
|
||||
|
||||
[(RaiseUnimplementedPrimitiveError!? op)
|
||||
(format "RT.raiseUnimplementedPrimitiveError(MACHINE,~s);"
|
||||
(format "RT.raiseUnimplementedPrimitiveError(M,~s);"
|
||||
(symbol->string (RaiseUnimplementedPrimitiveError!-name op)))]
|
||||
|
||||
|
||||
[(InstallModuleEntry!? op)
|
||||
(format "MACHINE.modules[~s]=new RT.ModuleRecord(~s,~a);"
|
||||
(format "M.modules[~s]=new RT.ModuleRecord(~s,~a);"
|
||||
(symbol->string (ModuleLocator-name (InstallModuleEntry!-path op)))
|
||||
(symbol->string (InstallModuleEntry!-name op))
|
||||
(assemble-label (make-Label (InstallModuleEntry!-entry-point op))))]
|
||||
|
||||
[(MarkModuleInvoked!? op)
|
||||
(format "MACHINE.modules[~s].isInvoked=true;"
|
||||
(format "M.modules[~s].isInvoked=true;"
|
||||
(symbol->string (ModuleLocator-name (MarkModuleInvoked!-path op))))]
|
||||
|
||||
|
||||
[(AliasModuleAsMain!? op)
|
||||
(format "MACHINE.mainModules.push(MACHINE.modules[~s]);"
|
||||
(format "M.mainModules.push(M.modules[~s]);"
|
||||
(symbol->string (ModuleLocator-name (AliasModuleAsMain!-from op))))]
|
||||
|
||||
[(FinalizeModuleInvokation!? op)
|
||||
(format "MACHINE.modules[~s].finalizeModuleInvokation();"
|
||||
(format "M.modules[~s].finalizeModuleInvokation();"
|
||||
(symbol->string
|
||||
(ModuleLocator-name (FinalizeModuleInvokation!-path op))))]))
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
;; What's emitted is a function expression that, when invoked, runs the
|
||||
;; statements.
|
||||
(define (assemble/write-invoke stmts op)
|
||||
(display "(function(MACHINE, success, fail, params) {\n" op)
|
||||
(display "(function(M, success, fail, params) {\n" op)
|
||||
(display "var param;\n" op)
|
||||
(display "var RT = plt.runtime;\n" op)
|
||||
|
||||
|
@ -49,17 +49,17 @@
|
|||
|
||||
(write-linked-label-attributes stmts op)
|
||||
|
||||
(display "MACHINE.params.currentErrorHandler = fail;\n" op)
|
||||
(display "MACHINE.params.currentSuccessHandler = success;\n" op)
|
||||
(display "M.params.currentErrorHandler = fail;\n" op)
|
||||
(display "M.params.currentSuccessHandler = success;\n" op)
|
||||
(display #<<EOF
|
||||
for (param in params) {
|
||||
if (params.hasOwnProperty(param)) {
|
||||
MACHINE.params[param] = params[param];
|
||||
M.params[param] = params[param];
|
||||
}
|
||||
}
|
||||
EOF
|
||||
op)
|
||||
(fprintf op "MACHINE.trampoline(~a); })"
|
||||
(fprintf op "M.trampoline(~a); })"
|
||||
(assemble-label (make-Label (BasicBlock-name (first basic-blocks))))))
|
||||
|
||||
|
||||
|
@ -171,7 +171,7 @@ EOF
|
|||
|
||||
(: assemble-basic-block (BasicBlock Blockht (Setof Symbol) Output-Port -> 'ok))
|
||||
(define (assemble-basic-block a-basic-block blockht entry-points op)
|
||||
(fprintf op "var ~a = function(MACHINE) { if(--MACHINE.callsBeforeTrampoline < 0) { throw ~a; }\n"
|
||||
(fprintf op "var ~a = function(M) { if(--M.callsBeforeTrampoline < 0) { throw ~a; }\n"
|
||||
(assemble-label (make-Label (BasicBlock-name a-basic-block)))
|
||||
(assemble-label (make-Label (BasicBlock-name a-basic-block))))
|
||||
(assemble-block-statements (BasicBlock-name a-basic-block)
|
||||
|
@ -399,7 +399,7 @@ EOF
|
|||
(define assembled
|
||||
(cond
|
||||
[(DebugPrint? stmt)
|
||||
(format "MACHINE.params.currentOutputPort.writeDomNode(MACHINE, $('<span/>').text(~a));"
|
||||
(format "M.params.currentOutputPort.writeDomNode(M, $('<span/>').text(~a));"
|
||||
(assemble-oparg (DebugPrint-value stmt)))]
|
||||
[(AssignImmediateStatement? stmt)
|
||||
(let: ([t : (String -> String) (assemble-target (AssignImmediateStatement-target stmt))]
|
||||
|
@ -450,10 +450,10 @@ EOF
|
|||
(assemble-jump (GotoStatement-target stmt))]
|
||||
|
||||
[(PushControlFrame/Generic? stmt)
|
||||
"MACHINE.control.push(new RT.Frame());"]
|
||||
"M.control.push(new RT.Frame());"]
|
||||
|
||||
[(PushControlFrame/Call? stmt)
|
||||
(format "MACHINE.control.push(new RT.CallFrame(~a,MACHINE.proc));"
|
||||
(format "M.control.push(new RT.CallFrame(~a,M.proc));"
|
||||
(let: ([label : (U Symbol LinkedLabel) (PushControlFrame/Call-label stmt)])
|
||||
(cond
|
||||
[(symbol? label)
|
||||
|
@ -463,7 +463,7 @@ EOF
|
|||
|
||||
[(PushControlFrame/Prompt? stmt)
|
||||
;; fixme: use a different frame structure
|
||||
(format "MACHINE.control.push(new RT.PromptFrame(~a,~a));"
|
||||
(format "M.control.push(new RT.PromptFrame(~a,~a));"
|
||||
(let: ([label : (U Symbol LinkedLabel) (PushControlFrame/Prompt-label stmt)])
|
||||
(cond
|
||||
[(symbol? label)
|
||||
|
@ -480,12 +480,12 @@ EOF
|
|||
(assemble-oparg tag)])))]
|
||||
|
||||
[(PopControlFrame? stmt)
|
||||
"MACHINE.control.pop();"]
|
||||
"M.control.pop();"]
|
||||
|
||||
[(PushEnvironment? stmt)
|
||||
(if (= (PushEnvironment-n stmt) 0)
|
||||
""
|
||||
(format "MACHINE.env.push(~a);" (string-join
|
||||
(format "M.env.push(~a);" (string-join
|
||||
(build-list (PushEnvironment-n stmt)
|
||||
(lambda: ([i : Natural])
|
||||
(if (PushEnvironment-unbox? stmt)
|
||||
|
@ -496,16 +496,16 @@ EOF
|
|||
(let: ([skip : OpArg (PopEnvironment-skip stmt)])
|
||||
(cond
|
||||
[(and (Const? skip) (= (ensure-natural (Const-const skip)) 0))
|
||||
(format "MACHINE.env.length-=~a;"
|
||||
(format "M.env.length-=~a;"
|
||||
(assemble-oparg (PopEnvironment-n stmt)))]
|
||||
[else
|
||||
(format "MACHINE.env.splice(MACHINE.env.length-(~a +~a),~a);"
|
||||
(format "M.env.splice(M.env.length-(~a +~a),~a);"
|
||||
(assemble-oparg (PopEnvironment-skip stmt))
|
||||
(assemble-oparg (PopEnvironment-n stmt))
|
||||
(assemble-oparg (PopEnvironment-n stmt)))]))]
|
||||
|
||||
[(PushImmediateOntoEnvironment? stmt)
|
||||
(format "MACHINE.env.push(~a);"
|
||||
(format "M.env.push(~a);"
|
||||
(let: ([val-string : String
|
||||
(cond [(PushImmediateOntoEnvironment-box? stmt)
|
||||
(format "[~a]" (assemble-oparg (PushImmediateOntoEnvironment-value stmt)))]
|
||||
|
|
|
@ -155,23 +155,23 @@
|
|||
module-requires))
|
||||
(let ([module-body-text
|
||||
(format "
|
||||
if(--MACHINE.callsBeforeTrampoline<0) { throw arguments.callee; }
|
||||
var modrec = MACHINE.modules[~s];
|
||||
if(--M.callsBeforeTrampoline<0) { throw arguments.callee; }
|
||||
var modrec = M.modules[~s];
|
||||
var exports = {};
|
||||
modrec.isInvoked = true;
|
||||
(function(MACHINE, RUNTIME, EXPORTS){~a})(MACHINE, plt.runtime, exports);
|
||||
(function(MACHINE, RUNTIME, EXPORTS){~a})(M, plt.runtime, exports);
|
||||
~a
|
||||
modrec.privateExports = exports;
|
||||
return MACHINE.control.pop().label(MACHINE);"
|
||||
return M.control.pop().label(M);"
|
||||
(symbol->string name)
|
||||
text
|
||||
(get-provided-name-code bytecode))])
|
||||
|
||||
(make-UninterpretedSource
|
||||
(format "
|
||||
MACHINE.modules[~s] =
|
||||
M.modules[~s] =
|
||||
new plt.runtime.ModuleRecord(~s,
|
||||
function(MACHINE) {
|
||||
function(M) {
|
||||
~a
|
||||
});
|
||||
"
|
||||
|
@ -204,10 +204,10 @@ MACHINE.modules[~s] =
|
|||
(let ([name (rewrite-path (path->string path))]
|
||||
[afterName (gensym 'afterName)])
|
||||
(format "var ~a = function() { ~a };
|
||||
if (! MACHINE.modules[~s].isInvoked) {
|
||||
MACHINE.modules[~s].internalInvoke(MACHINE,
|
||||
if (! M.modules[~s].isInvoked) {
|
||||
M.modules[~s].internalInvoke(M,
|
||||
~a,
|
||||
MACHINE.params.currentErrorHandler);
|
||||
M.params.currentErrorHandler);
|
||||
} else {
|
||||
~a();
|
||||
}"
|
||||
|
@ -229,7 +229,7 @@ MACHINE.modules[~s] =
|
|||
;; 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
|
||||
;; four arguments (M, SUCCESS, FAIL, PARAMS). When called, it will
|
||||
;; execute the code to either run standalone expressions or
|
||||
;; load in modules.
|
||||
(define (package source-code
|
||||
|
@ -265,7 +265,7 @@ MACHINE.modules[~s] =
|
|||
plt.runtime.setReadyFalse();
|
||||
(")
|
||||
(assemble/write-invoke stmts op)
|
||||
(fprintf op ")(MACHINE,
|
||||
(fprintf op ")(M,
|
||||
function() {
|
||||
if (window.console && window.console.log) {
|
||||
window.console.log('loaded ' + ~s);
|
||||
|
@ -308,7 +308,7 @@ MACHINE.modules[~s] =
|
|||
;; last
|
||||
on-last-src))
|
||||
|
||||
(fprintf op "var invoke = (function(MACHINE, SUCCESS, FAIL, PARAMS) {")
|
||||
(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))
|
||||
|
@ -347,7 +347,7 @@ MACHINE.modules[~s] =
|
|||
;; on
|
||||
(lambda (src ast stmts)
|
||||
(assemble/write-invoke stmts op)
|
||||
(fprintf op "(MACHINE, function() { "))
|
||||
(fprintf op "(M, function() { "))
|
||||
|
||||
;; after
|
||||
(lambda (src)
|
||||
|
@ -360,7 +360,7 @@ MACHINE.modules[~s] =
|
|||
(display (runtime:get-runtime) op)
|
||||
|
||||
(newline op)
|
||||
(fprintf op "(function(MACHINE, SUCCESS, FAIL, PARAMS) {")
|
||||
(fprintf op "(function(M, SUCCESS, FAIL, PARAMS) {")
|
||||
(make (list only-bootstrapped-code) packaging-configuration)
|
||||
(fprintf op "})(plt.runtime.currentMachine,\nfunction(){ plt.runtime.setReadyTrue(); },\nfunction(){},\n{});\n")))
|
||||
|
||||
|
@ -465,12 +465,12 @@ EOF
|
|||
(define invoke-main-module-code
|
||||
#<<EOF
|
||||
var invokeMainModule = function() {
|
||||
var MACHINE = plt.runtime.currentMachine;
|
||||
invoke(MACHINE,
|
||||
var M = plt.runtime.currentMachine;
|
||||
invoke(M,
|
||||
function() {
|
||||
var startTime = new Date().valueOf();
|
||||
plt.runtime.invokeMains(
|
||||
MACHINE,
|
||||
M,
|
||||
function() {
|
||||
// On main module invokation success:
|
||||
var stopTime = new Date().valueOf();
|
||||
|
@ -478,25 +478,25 @@ var invokeMainModule = function() {
|
|||
window.console.log('evaluation took ' + (stopTime - startTime) + ' milliseconds');
|
||||
}
|
||||
},
|
||||
function(MACHINE, e) {
|
||||
function(M, e) {
|
||||
var contMarkSet, context, i, appName;
|
||||
// On main module invokation failure
|
||||
if (window.console && window.console.log) {
|
||||
window.console.log(e.stack || e);
|
||||
}
|
||||
|
||||
MACHINE.params.currentErrorDisplayer(
|
||||
MACHINE, $(plt.baselib.format.toDomNode(e.stack || e)).css('color', 'red'));
|
||||
M.params.currentErrorDisplayer(
|
||||
M, $(plt.baselib.format.toDomNode(e.stack || e)).css('color', 'red'));
|
||||
|
||||
if (e.hasOwnProperty('racketError') &&
|
||||
plt.baselib.exceptions.isExn(e.racketError)) {
|
||||
contMarkSet = plt.baselib.exceptions.exnContMarks(e.racketError);
|
||||
if (contMarkSet) {
|
||||
context = contMarkSet.getContext(MACHINE);
|
||||
context = contMarkSet.getContext(M);
|
||||
for (i = 0; i < context.length; i++) {
|
||||
if (plt.runtime.isVector(context[i])) {
|
||||
MACHINE.params.currentErrorDisplayer(
|
||||
MACHINE,
|
||||
M.params.currentErrorDisplayer(
|
||||
M,
|
||||
$('<div/>').text(' at ' + context[i].elts[0] +
|
||||
', line ' + context[i].elts[2] +
|
||||
', column ' + context[i].elts[3])
|
||||
|
@ -505,8 +505,8 @@ var invokeMainModule = function() {
|
|||
.css('whitespace', 'pre')
|
||||
.css('color', 'red'));
|
||||
} else if (plt.runtime.isProcedure(context[i])) {
|
||||
MACHINE.params.currentErrorDisplayer(
|
||||
MACHINE,
|
||||
M.params.currentErrorDisplayer(
|
||||
M,
|
||||
$('<div/>').text(' in ' + context[i].displayName)
|
||||
.addClass('stacktrace')
|
||||
.css('margin-left', '10px')
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
runtime
|
||||
"var RT = plt.runtime;"
|
||||
"var MACHINE = new plt.runtime.Machine();\n"
|
||||
"var M = new plt.runtime.Machine();\n"
|
||||
|
||||
"return function(success, fail, params){"
|
||||
snippet
|
||||
|
@ -55,7 +55,7 @@
|
|||
"});")])
|
||||
(displayln snippet)
|
||||
(display code op))))))
|
||||
(define (E-single a-statement (inspector "MACHINE.val"))
|
||||
(define (E-single a-statement (inspector "M.val"))
|
||||
(evaluated-value ((force -E) (cons a-statement inspector))))
|
||||
|
||||
;; evaluating many expressions[.
|
||||
|
@ -66,24 +66,24 @@
|
|||
|
||||
(display runtime op)
|
||||
"var RT = plt.runtime;"
|
||||
(display "var MACHINE = new plt.runtime.Machine();\n" op)
|
||||
(display "var M = new plt.runtime.Machine();\n" op)
|
||||
(display "(function() { " op)
|
||||
(display "var myInvoke = " op)
|
||||
(assemble/write-invoke a-statement op)
|
||||
(display ";" op)
|
||||
(fprintf op
|
||||
"return function(succ, fail, params) {
|
||||
var newParams = { currentDisplayer: function(MACHINE, v) {
|
||||
var newParams = { currentDisplayer: function(M, v) {
|
||||
params.currentDisplayer(v); } };
|
||||
|
||||
myInvoke(MACHINE,
|
||||
myInvoke(M,
|
||||
function(v) { succ(plt.runtime.toDisplayedString(~a));},
|
||||
function(MACHINE, exn) { fail(exn); },
|
||||
function(M, exn) { fail(exn); },
|
||||
newParams);
|
||||
}"
|
||||
inspector)
|
||||
(display "})" op))))))
|
||||
(define (E-many stmts (inspector "MACHINE.val"))
|
||||
(define (E-many stmts (inspector "M.val"))
|
||||
(evaluated-value ((force -E-many) (cons stmts inspector))))
|
||||
|
||||
|
||||
|
@ -108,27 +108,27 @@
|
|||
;; Assigning to proc means val should still be uninitialized.
|
||||
(test (E-single (make-AssignImmediateStatement 'proc (make-Const "Danny")))
|
||||
"#<undefined>")
|
||||
;; But we should see the assignment if we inspect MACHINE.proc.
|
||||
;; But we should see the assignment if we inspect M.proc.
|
||||
(test (E-single (make-AssignImmediateStatement 'proc (make-Const "Danny"))
|
||||
"MACHINE.proc")
|
||||
"M.proc")
|
||||
"Danny")
|
||||
|
||||
|
||||
(test (E-single (make-PushEnvironment 1 #f)
|
||||
"MACHINE.env.length")
|
||||
"M.env.length")
|
||||
"1")
|
||||
(test (E-single (make-PushEnvironment 20 #f)
|
||||
"MACHINE.env.length")
|
||||
"M.env.length")
|
||||
"20")
|
||||
|
||||
;; PopEnvironment
|
||||
(test (E-many (list (make-PushEnvironment 2 #f))
|
||||
"MACHINE.env.length")
|
||||
"M.env.length")
|
||||
"2")
|
||||
(test (E-many (list (make-PushEnvironment 2 #f)
|
||||
(make-PopEnvironment (make-Const 1)
|
||||
(make-Const 0)))
|
||||
"MACHINE.env.length")
|
||||
"M.env.length")
|
||||
"1")
|
||||
|
||||
|
||||
|
@ -137,23 +137,23 @@
|
|||
(test (E-many (list (make-PushEnvironment 2 #f)
|
||||
(make-AssignImmediateStatement (make-EnvLexicalReference 0 #f)
|
||||
(make-Const 12345)))
|
||||
"MACHINE.env[1]")
|
||||
"M.env[1]")
|
||||
"12345")
|
||||
(test (E-many (list (make-PushEnvironment 2 #f)
|
||||
(make-AssignImmediateStatement (make-EnvLexicalReference 0 #f)
|
||||
(make-Const 12345)))
|
||||
"MACHINE.env[0]")
|
||||
"M.env[0]")
|
||||
"#<undefined>")
|
||||
(test (E-many (list (make-PushEnvironment 2 #f)
|
||||
(make-AssignImmediateStatement (make-EnvLexicalReference 1 #f)
|
||||
(make-Const 12345)))
|
||||
"MACHINE.env[0]")
|
||||
"M.env[0]")
|
||||
"12345")
|
||||
|
||||
|
||||
;; Toplevel Environment loading
|
||||
(test (E-single (make-PerformStatement (make-ExtendEnvironment/Prefix! '(pi)))
|
||||
"plt.runtime.toWrittenString(MACHINE.env[0]).slice(0, 5)")
|
||||
"plt.runtime.toWrittenString(M.env[0]).slice(0, 5)")
|
||||
"3.141")
|
||||
|
||||
|
||||
|
@ -180,7 +180,7 @@
|
|||
(make-GotoStatement (make-Label 'afterLambda))
|
||||
'afterLambda
|
||||
(make-AssignPrimOpStatement 'val (make-MakeCompiledProcedure 'closureStart 0 '() 'closureStart)))
|
||||
"MACHINE.val.displayName")
|
||||
"M.val.displayName")
|
||||
"closureStart")
|
||||
|
||||
|
||||
|
@ -197,7 +197,7 @@
|
|||
(make-AssignPrimOpStatement 'val (make-MakeCompiledProcedure 'closureStart 0
|
||||
(list 0 1)
|
||||
'closureStart)))
|
||||
"MACHINE.val.closedVals[1] + ',' + MACHINE.val.closedVals[0]")
|
||||
"M.val.closedVals[1] + ',' + M.val.closedVals[0]")
|
||||
"hello,world")
|
||||
|
||||
;; Let's try to install the closure values.
|
||||
|
@ -220,7 +220,7 @@
|
|||
(make-Const 0))
|
||||
(make-GotoStatement (make-Label 'closureStart))
|
||||
'theEnd)
|
||||
"plt.runtime.toWrittenString(MACHINE.env.length) + ',' + MACHINE.env[1] + ',' + MACHINE.env[0]")
|
||||
"plt.runtime.toWrittenString(M.env.length) + ',' + M.env[1] + ',' + M.env[0]")
|
||||
"2,hello,world")
|
||||
|
||||
|
||||
|
@ -244,7 +244,7 @@
|
|||
(make-PopEnvironment (make-Const 2) (make-Const 0))
|
||||
(make-AssignPrimOpStatement 'val (make-GetCompiledProcedureEntry))
|
||||
'theEnd)
|
||||
"typeof(MACHINE.val) + ',' + (MACHINE.val === MACHINE.proc.label)")
|
||||
"typeof(M.val) + ',' + (M.val === M.proc.label)")
|
||||
"function,true")
|
||||
|
||||
|
||||
|
@ -364,7 +364,7 @@
|
|||
(test (E-many `(,(make-PerformStatement (make-ExtendEnvironment/Prefix! '(advisor)))
|
||||
,(make-AssignImmediateStatement 'val (make-Const "Kathi"))
|
||||
,(make-AssignImmediateStatement (make-EnvPrefixReference 0 0) (make-Reg 'val)))
|
||||
"MACHINE.env[0][0]")
|
||||
"M.env[0][0]")
|
||||
"Kathi")
|
||||
|
||||
|
||||
|
@ -381,7 +381,7 @@
|
|||
,(make-AssignImmediateStatement 'val (make-Const "Shriram"))
|
||||
,(make-AssignImmediateStatement (make-EnvPrefixReference 0 0) (make-Reg 'val))
|
||||
,(make-PerformStatement (make-CheckToplevelBound! 0 0)))
|
||||
"MACHINE.env[0][0]")
|
||||
"M.env[0][0]")
|
||||
"Shriram")
|
||||
|
||||
|
||||
|
@ -391,7 +391,7 @@
|
|||
(make-Const '(1 2 3)))
|
||||
,(make-AssignImmediateStatement 'argcount (make-Const 1))
|
||||
,(make-PerformStatement (make-SpliceListIntoStack! (make-Const 0))))
|
||||
"MACHINE.argcount + ',' + MACHINE.env[0] + ',' + MACHINE.env[1] + ',' + MACHINE.env[2]")
|
||||
"M.argcount + ',' + M.env[0] + ',' + M.env[1] + ',' + M.env[2]")
|
||||
"3,3,2,1")
|
||||
|
||||
|
||||
|
@ -404,7 +404,7 @@
|
|||
(make-Const '(1 2 3)))
|
||||
,(make-AssignImmediateStatement 'argcount (make-Const 3))
|
||||
,(make-PerformStatement (make-SpliceListIntoStack! (make-Const 2))))
|
||||
"MACHINE.argcount + ',' + MACHINE.env[0] + ',' + MACHINE.env[1] + ',' + MACHINE.env[2] + ',' + MACHINE.env[3] + ',' + MACHINE.env[4]")
|
||||
"M.argcount + ',' + M.env[0] + ',' + M.env[1] + ',' + M.env[2] + ',' + M.env[3] + ',' + M.env[4]")
|
||||
"5,3,2,1,world,hello")
|
||||
|
||||
|
||||
|
@ -420,7 +420,7 @@
|
|||
,(make-AssignImmediateStatement 'argcount (make-Const 1))
|
||||
,(make-PerformStatement (make-UnspliceRestFromStack! (make-Const 0)
|
||||
(make-Const 1))))
|
||||
"MACHINE.argcount + ',' + plt.runtime.isList(MACHINE.env[0])")
|
||||
"M.argcount + ',' + plt.runtime.isList(M.env[0])")
|
||||
"1,true")
|
||||
|
||||
|
||||
|
@ -438,7 +438,7 @@
|
|||
(make-Const 'z))
|
||||
,(make-AssignImmediateStatement 'argcount (make-Const 5))
|
||||
,(make-PerformStatement (make-UnspliceRestFromStack! (make-Const 2) (make-Const 3))))
|
||||
"MACHINE.argcount + ',' + MACHINE.env.length + ',' + plt.runtime.isList(MACHINE.env[0]) + ',' + MACHINE.env[2] + ',' + MACHINE.env[1]")
|
||||
"M.argcount + ',' + M.env.length + ',' + plt.runtime.isList(M.env[0]) + ',' + M.env[2] + ',' + M.env[1]")
|
||||
"3,3,true,hello,world")
|
||||
|
||||
|
||||
|
@ -457,7 +457,7 @@
|
|||
bad
|
||||
,(make-AssignImmediateStatement 'val (make-Const 'bad))
|
||||
end)
|
||||
"MACHINE.val")
|
||||
"M.val")
|
||||
"ok")
|
||||
|
||||
|
||||
|
@ -474,7 +474,7 @@
|
|||
ok
|
||||
,(make-AssignImmediateStatement 'val (make-Const 'ok))
|
||||
end)
|
||||
"MACHINE.val")
|
||||
"M.val")
|
||||
"ok")
|
||||
|
||||
(test (E-many `(procedure-entry
|
||||
|
@ -490,7 +490,7 @@
|
|||
ok
|
||||
,(make-AssignImmediateStatement 'val (make-Const 'ok))
|
||||
end)
|
||||
"MACHINE.val")
|
||||
"M.val")
|
||||
"ok")
|
||||
|
||||
(test (E-many `(procedure-entry
|
||||
|
@ -506,7 +506,7 @@
|
|||
bad
|
||||
,(make-AssignImmediateStatement 'val (make-Const 'bad))
|
||||
end)
|
||||
"MACHINE.val")
|
||||
"M.val")
|
||||
"ok")
|
||||
|
||||
|
||||
|
@ -521,7 +521,7 @@
|
|||
'proc
|
||||
(make-MakeCompiledProcedure 'procedure-entry (make-ArityAtLeast 2) (list 0 1) 'procedure-entry))
|
||||
,(make-AssignImmediateStatement 'val (make-CompiledProcedureClosureReference (make-Reg 'proc) 0)))
|
||||
"MACHINE.val")
|
||||
"M.val")
|
||||
"4")
|
||||
|
||||
(test (E-many `(,(make-PushImmediateOntoEnvironment (make-Const 3) #f)
|
||||
|
@ -532,7 +532,7 @@
|
|||
'proc
|
||||
(make-MakeCompiledProcedure 'procedure-entry (make-ArityAtLeast 2) (list 0 1) 'procedure-entry))
|
||||
,(make-AssignImmediateStatement 'val (make-CompiledProcedureClosureReference (make-Reg 'proc) 1)))
|
||||
"MACHINE.val")
|
||||
"M.val")
|
||||
"3")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user