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