This commit is contained in:
Danny Yoo 2011-03-01 02:56:20 -05:00
parent fb0fb941e3
commit 81b1637a10

View File

@ -220,9 +220,15 @@
[operand-codes (map (lambda: ([operand : Expression]) [operand-codes (map (lambda: ([operand : Expression])
(compile operand cenv 'val 'next)) (compile operand cenv 'val 'next))
(App-operands exp))]) (App-operands exp))])
;; FIXME: we need to allocate space for the arguments in the environment.
;; FIXME: we need to compile each operand especially to write to the correct
;; environment location.
;; FIXME: we need to push the control.
;; FIXME: at procedure entry, the arguments need to be installed ;; FIXME: at procedure entry, the arguments need to be installed
;; in the environment. We need to install ;; in the environment. We need to install
;; the closure's values now. ;; the closure's values now.
;;
;; FIXME: if we're calling in tail position, preserve space.
(append-instruction-sequences (append-instruction-sequences
proc-code proc-code
(append-instruction-sequences (append-instruction-sequences
@ -261,27 +267,27 @@
#;(: compile-procedure-call (Target Linkage -> InstructionSequence)) #;(: compile-procedure-call (Target Linkage -> InstructionSequence))
#;(define (compile-procedure-call target linkage) #;(define (compile-procedure-call target linkage)
(let ([primitive-branch (make-label 'primitiveBranch)] (let ([primitive-branch (make-label 'primitiveBranch)]
[compiled-branch (make-label 'compiledBranch)] [compiled-branch (make-label 'compiledBranch)]
[after-call (make-label 'afterCall)]) [after-call (make-label 'afterCall)])
(let ([compiled-linkage (let ([compiled-linkage
(if (eq? linkage 'next) after-call linkage)]) (if (eq? linkage 'next) after-call linkage)])
(append-instruction-sequences
(make-instruction-sequence `(,(make-TestStatement 'primitive-procedure? 'proc)
,(make-BranchLabelStatement primitive-branch)))
(parallel-instruction-sequences
(append-instruction-sequences (append-instruction-sequences
compiled-branch (make-instruction-sequence `(,(make-TestStatement 'primitive-procedure? 'proc)
(compile-proc-appl target compiled-linkage)) ,(make-BranchLabelStatement primitive-branch)))
(append-instruction-sequences (parallel-instruction-sequences
primitive-branch (append-instruction-sequences
(end-with-linkage linkage compiled-branch
(make-instruction-sequence (compile-proc-appl target compiled-linkage))
`(,(make-AssignPrimOpStatement target (append-instruction-sequences
'apply-primitive-procedure primitive-branch
(list (make-Reg 'proc) (end-with-linkage linkage
(make-Reg 'argl)))))))) (make-instruction-sequence
after-call)))) `(,(make-AssignPrimOpStatement target
'apply-primitive-procedure
(list (make-Reg 'proc)
(make-Reg 'argl))))))))
after-call))))
#;(: compile-proc-appl (Target Linkage -> InstructionSequence)) #;(: compile-proc-appl (Target Linkage -> InstructionSequence))
#;(define (compile-proc-appl target linkage) #;(define (compile-proc-appl target linkage)