fixing indentation, enabling comments in emitted source
This commit is contained in:
parent
fc521f6f7b
commit
e9d3c207f7
|
@ -648,7 +648,6 @@
|
||||||
(let ([evaluate-and-save-first-expression
|
(let ([evaluate-and-save-first-expression
|
||||||
(let ([after-first-seq (make-label 'afterFirstSeqEvaluated)])
|
(let ([after-first-seq (make-label 'afterFirstSeqEvaluated)])
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-Comment "begin0")
|
|
||||||
;; Evaluate the first expression in a multiple-value context, and get the values on the stack.
|
;; Evaluate the first expression in a multiple-value context, and get the values on the stack.
|
||||||
(compile (first seq) cenv 'val next-linkage/keep-multiple-on-stack)
|
(compile (first seq) cenv 'val next-linkage/keep-multiple-on-stack)
|
||||||
|
|
||||||
|
@ -764,7 +763,6 @@
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
;; Make some temporary space for the lambdas
|
;; Make some temporary space for the lambdas
|
||||||
|
|
||||||
(make-Comment "scratch space for case-lambda")
|
|
||||||
(make-PushEnvironment n #f)
|
(make-PushEnvironment n #f)
|
||||||
|
|
||||||
;; Compile each of the lambdas
|
;; Compile each of the lambdas
|
||||||
|
@ -870,10 +868,18 @@
|
||||||
singular-context-check))))
|
singular-context-check))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;; We keep track of which lambda is currently being compiled for potential optimizations
|
||||||
|
;; e.g. self tail calls.
|
||||||
|
(: current-lambda-body-being-compiled (Parameterof (U #f Lam)))
|
||||||
|
(define current-lambda-body-being-compiled (make-parameter #f))
|
||||||
|
|
||||||
|
|
||||||
(: compile-lambda-body (Lam CompileTimeEnvironment -> InstructionSequence))
|
(: compile-lambda-body (Lam CompileTimeEnvironment -> InstructionSequence))
|
||||||
;; Compiles the body of the lambda in the appropriate environment.
|
;; Compiles the body of the lambda in the appropriate environment.
|
||||||
;; Closures will target their value to the 'val register, and use return linkage.
|
;; Closures will target their value to the 'val register, and use return linkage.
|
||||||
(define (compile-lambda-body exp cenv)
|
(define (compile-lambda-body exp cenv)
|
||||||
|
(parameterize ([current-lambda-body-being-compiled exp])
|
||||||
(let: ([maybe-unsplice-rest-argument : InstructionSequence
|
(let: ([maybe-unsplice-rest-argument : InstructionSequence
|
||||||
(if (Lam-rest? exp)
|
(if (Lam-rest? exp)
|
||||||
(make-Perform
|
(make-Perform
|
||||||
|
@ -885,7 +891,6 @@
|
||||||
[maybe-install-closure-values : InstructionSequence
|
[maybe-install-closure-values : InstructionSequence
|
||||||
(if (not (empty? (Lam-closure-map exp)))
|
(if (not (empty? (Lam-closure-map exp)))
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-Comment (format "installing closure for ~s" (Lam-name exp)))
|
|
||||||
(make-Perform (make-InstallClosureValues!
|
(make-Perform (make-InstallClosureValues!
|
||||||
(length (Lam-closure-map exp)))))
|
(length (Lam-closure-map exp)))))
|
||||||
empty-instruction-sequence)]
|
empty-instruction-sequence)]
|
||||||
|
@ -897,9 +902,10 @@
|
||||||
|
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(Lam-entry-label exp)
|
(Lam-entry-label exp)
|
||||||
|
(Comment (format "lambda body for ~a" (Lam-name exp)))
|
||||||
maybe-unsplice-rest-argument
|
maybe-unsplice-rest-argument
|
||||||
maybe-install-closure-values
|
maybe-install-closure-values
|
||||||
lam-body-code)))
|
lam-body-code))))
|
||||||
|
|
||||||
|
|
||||||
(: compile-case-lambda-body (CaseLam CompileTimeEnvironment -> InstructionSequence))
|
(: compile-case-lambda-body (CaseLam CompileTimeEnvironment -> InstructionSequence))
|
||||||
|
@ -1058,7 +1064,6 @@
|
||||||
'val))))])
|
'val))))])
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
|
|
||||||
(make-Comment "scratch space for general application")
|
|
||||||
(make-PushEnvironment (length (App-operands exp)) #f)
|
(make-PushEnvironment (length (App-operands exp)) #f)
|
||||||
proc-code
|
proc-code
|
||||||
(juggle-operands operand-codes)
|
(juggle-operands operand-codes)
|
||||||
|
@ -1428,7 +1433,6 @@
|
||||||
'proc
|
'proc
|
||||||
next-linkage/expects-single)])
|
next-linkage/expects-single)])
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-Comment "scratch space for statically known lambda application")
|
|
||||||
(make-PushEnvironment (length (App-operands exp)) #f)
|
(make-PushEnvironment (length (App-operands exp)) #f)
|
||||||
(apply append-instruction-sequences operand-codes)
|
(apply append-instruction-sequences operand-codes)
|
||||||
proc-code
|
proc-code
|
||||||
|
@ -1784,7 +1788,6 @@
|
||||||
linkage
|
linkage
|
||||||
extended-cenv
|
extended-cenv
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-Comment "scratch space for let1")
|
|
||||||
(make-PushEnvironment 1 #f)
|
(make-PushEnvironment 1 #f)
|
||||||
rhs-code
|
rhs-code
|
||||||
body-code
|
body-code
|
||||||
|
@ -1859,7 +1862,6 @@
|
||||||
linkage
|
linkage
|
||||||
extended-cenv
|
extended-cenv
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-Comment "scratch space for let-void")
|
|
||||||
(make-PushEnvironment n (LetVoid-boxes? exp))
|
(make-PushEnvironment n (LetVoid-boxes? exp))
|
||||||
body-code
|
body-code
|
||||||
after-body-code
|
after-body-code
|
||||||
|
@ -1952,7 +1954,6 @@
|
||||||
(map (lambda: ([lam : Lam]
|
(map (lambda: ([lam : Lam]
|
||||||
[i : Natural])
|
[i : Natural])
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-Comment (format "Installing shell for ~s\n" (Lam-name lam)))
|
|
||||||
(make-Perform (make-FixClosureShellMap! i
|
(make-Perform (make-FixClosureShellMap! i
|
||||||
(Lam-closure-map lam)))))
|
(Lam-closure-map lam)))))
|
||||||
(LetRec-procs exp)
|
(LetRec-procs exp)
|
||||||
|
@ -1968,7 +1969,6 @@
|
||||||
(: compile-install-value (InstallValue CompileTimeEnvironment Target Linkage -> InstructionSequence))
|
(: compile-install-value (InstallValue CompileTimeEnvironment Target Linkage -> InstructionSequence))
|
||||||
(define (compile-install-value exp cenv target linkage)
|
(define (compile-install-value exp cenv target linkage)
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-Comment "install-value")
|
|
||||||
(let ([count (InstallValue-count exp)])
|
(let ([count (InstallValue-count exp)])
|
||||||
(cond [(= count 0)
|
(cond [(= count 0)
|
||||||
(end-with-linkage
|
(end-with-linkage
|
||||||
|
@ -1980,8 +1980,6 @@
|
||||||
(make-NextLinkage 0)))]
|
(make-NextLinkage 0)))]
|
||||||
[(= count 1)
|
[(= count 1)
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-Comment (format "installing single value into ~s"
|
|
||||||
(InstallValue-depth exp)))
|
|
||||||
(end-with-linkage
|
(end-with-linkage
|
||||||
linkage
|
linkage
|
||||||
cenv
|
cenv
|
||||||
|
@ -1994,7 +1992,6 @@
|
||||||
linkage
|
linkage
|
||||||
cenv
|
cenv
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-Comment "install-value: evaluating values")
|
|
||||||
(compile (InstallValue-body exp)
|
(compile (InstallValue-body exp)
|
||||||
cenv
|
cenv
|
||||||
'val
|
'val
|
||||||
|
@ -2003,7 +2000,6 @@
|
||||||
(map (lambda: ([to : EnvLexicalReference]
|
(map (lambda: ([to : EnvLexicalReference]
|
||||||
[from : OpArg])
|
[from : OpArg])
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-Comment "install-value: installing value")
|
|
||||||
(make-AssignImmediate to from)))
|
(make-AssignImmediate to from)))
|
||||||
(build-list count (lambda: ([i : Natural])
|
(build-list count (lambda: ([i : Natural])
|
||||||
(make-EnvLexicalReference (+ i
|
(make-EnvLexicalReference (+ i
|
||||||
|
|
|
@ -193,8 +193,8 @@
|
||||||
]
|
]
|
||||||
|
|
||||||
[(Comment? a-stmt)
|
[(Comment? a-stmt)
|
||||||
(loop (rest stmts))
|
;(loop (rest stmts))
|
||||||
;(cons a-stmt (loop (rest stmts)))
|
(cons a-stmt (loop (rest stmts)))
|
||||||
]
|
]
|
||||||
|
|
||||||
[(AssignImmediate? a-stmt)
|
[(AssignImmediate? a-stmt)
|
||||||
|
@ -386,7 +386,7 @@
|
||||||
[(PopControlFrame? stmt)
|
[(PopControlFrame? stmt)
|
||||||
#f]
|
#f]
|
||||||
[(Comment? stmt)
|
[(Comment? stmt)
|
||||||
#t]))
|
#f]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
"../sets.rkt"
|
"../sets.rkt"
|
||||||
"../helpers.rkt"
|
"../helpers.rkt"
|
||||||
racket/string
|
racket/string
|
||||||
racket/list
|
racket/list)
|
||||||
racket/match)
|
|
||||||
(require/typed "../logger.rkt"
|
(require/typed "../logger.rkt"
|
||||||
[log-debug (String -> Void)])
|
[log-debug (String -> Void)])
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@
|
||||||
|
|
||||||
|
|
||||||
;; Parameter that controls the generation of a trace.
|
;; Parameter that controls the generation of a trace.
|
||||||
(define current-emit-debug-trace? (make-parameter #f))
|
(define emit-debug-trace? #f)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -635,10 +634,9 @@ EOF
|
||||||
blockht)])])
|
blockht)])])
|
||||||
val-string))]
|
val-string))]
|
||||||
[(Comment? stmt)
|
[(Comment? stmt)
|
||||||
;; TODO: maybe comments should be emitted as JavaScript comments.
|
(format "//~s\n" (Comment-val stmt))]))
|
||||||
""]))
|
|
||||||
(cond
|
(cond
|
||||||
#;[(current-emit-debug-trace?)
|
[emit-debug-trace?
|
||||||
(string-append
|
(string-append
|
||||||
(format "if(window.console!==void(0)&&typeof(window.console.log)==='function'){window.console.log(~s);\n}"
|
(format "if(window.console!==void(0)&&typeof(window.console.log)==='function'){window.console.log(~s);\n}"
|
||||||
(format "~a" stmt))
|
(format "~a" stmt))
|
||||||
|
|
|
@ -7,4 +7,4 @@
|
||||||
(provide version)
|
(provide version)
|
||||||
(: version String)
|
(: version String)
|
||||||
|
|
||||||
(define version "1.195")
|
(define version "1.198")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user