combining test and branch together formally.
This commit is contained in:
parent
2a9fe0d72a
commit
8ad291e320
12
compile.rkt
12
compile.rkt
|
@ -146,8 +146,10 @@
|
||||||
(append-instruction-sequences p-code
|
(append-instruction-sequences p-code
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-instruction-sequence
|
(make-instruction-sequence
|
||||||
`(,(make-TestStatement 'false? 'val)
|
`(,(make-TestAndBranchStatement 'false?
|
||||||
,(make-BranchLabelStatement f-branch)))
|
'val
|
||||||
|
f-branch)
|
||||||
|
))
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(append-instruction-sequences t-branch c-code)
|
(append-instruction-sequences t-branch c-code)
|
||||||
(append-instruction-sequences f-branch a-code))
|
(append-instruction-sequences f-branch a-code))
|
||||||
|
@ -293,8 +295,10 @@
|
||||||
(if (eq? linkage 'next) after-call linkage)])
|
(if (eq? linkage 'next) after-call linkage)])
|
||||||
|
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
(make-instruction-sequence `(,(make-TestStatement 'primitive-procedure? 'proc)
|
(make-instruction-sequence
|
||||||
,(make-BranchLabelStatement primitive-branch)))
|
`(,(make-TestAndBranchStatement 'primitive-procedure?
|
||||||
|
'proc
|
||||||
|
primitive-branch)))
|
||||||
|
|
||||||
compiled-branch
|
compiled-branch
|
||||||
(compile-proc-appl n target compiled-linkage)
|
(compile-proc-appl n target compiled-linkage)
|
||||||
|
|
|
@ -47,10 +47,11 @@
|
||||||
(define-type UnlabeledStatement (U
|
(define-type UnlabeledStatement (U
|
||||||
AssignImmediateStatement
|
AssignImmediateStatement
|
||||||
AssignPrimOpStatement
|
AssignPrimOpStatement
|
||||||
GotoStatement
|
|
||||||
PerformStatement
|
PerformStatement
|
||||||
TestStatement
|
|
||||||
BranchLabelStatement
|
GotoStatement
|
||||||
|
TestAndBranchStatement
|
||||||
|
|
||||||
PopEnv
|
PopEnv
|
||||||
PopControl
|
PopControl
|
||||||
PushEnv
|
PushEnv
|
||||||
|
@ -79,17 +80,16 @@
|
||||||
(define-struct: PushControlFrame ([label : Symbol])
|
(define-struct: PushControlFrame ([label : Symbol])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
|
|
||||||
(define-struct: GotoStatement ([target : (U Label Reg)])
|
(define-struct: GotoStatement ([target : (U Label Reg)])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
|
|
||||||
(define-struct: PerformStatement ([op : PrimitiveCommand]
|
(define-struct: PerformStatement ([op : PrimitiveCommand]
|
||||||
[rands : (Listof (U Label Reg Const))]) #:transparent)
|
[rands : (Listof (U Label Reg Const))])
|
||||||
(define-struct: TestStatement ([op : PrimitiveTest]
|
#:transparent)
|
||||||
[register-rand : RegisterSymbol]) #:transparent)
|
(define-struct: TestAndBranchStatement ([op : PrimitiveTest]
|
||||||
(define-struct: BranchLabelStatement ([label : Symbol]) #:transparent)
|
[register-rand : RegisterSymbol]
|
||||||
|
[label : Symbol])
|
||||||
|
#:transparent)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +136,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;; The following is used with TestStatement: each is passed the register-rand and
|
||||||
|
;; is expected to
|
||||||
(define-type PrimitiveTest (U
|
(define-type PrimitiveTest (U
|
||||||
|
|
||||||
;; register -> boolean
|
;; register -> boolean
|
||||||
|
@ -149,8 +150,8 @@
|
||||||
'primitive-procedure?
|
'primitive-procedure?
|
||||||
))
|
))
|
||||||
|
|
||||||
(define-type PrimitiveCommand (U
|
|
||||||
|
|
||||||
|
(define-type PrimitiveCommand (U
|
||||||
;; depth pos symbol
|
;; depth pos symbol
|
||||||
;; Assign the value in the val register into
|
;; Assign the value in the val register into
|
||||||
;; the prefix installed at (depth, pos).
|
;; the prefix installed at (depth, pos).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user