From 0c8cd9234c46bfd58149986fbaf13e96fbce1696 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Thu, 14 Apr 2011 13:05:05 -0400 Subject: [PATCH] renaming PushControlFrame to more specific PushControlFrame/Call, since control frames can be of several types --- assemble.rkt | 10 +++++----- compiler.rkt | 14 +++++++------- il-structs.rkt | 5 +++-- simulator.rkt | 6 +++--- test-simulator.rkt | 14 +++++++------- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/assemble.rkt b/assemble.rkt index 49af240..56453c1 100644 --- a/assemble.rkt +++ b/assemble.rkt @@ -139,7 +139,7 @@ EOF (next)] [(PushImmediateOntoEnvironment? stmt) (next)] - [(PushControlFrame? stmt) + [(PushControlFrame/Call? stmt) (next)] [(PushControlFrame/Prompt? stmt) (next)] @@ -259,8 +259,8 @@ EOF empty] [(PushImmediateOntoEnvironment? stmt) (collect-input (PushImmediateOntoEnvironment-value stmt))] - [(PushControlFrame? stmt) - (label->labels (PushControlFrame-label stmt))] + [(PushControlFrame/Call? stmt) + (label->labels (PushControlFrame/Call-label stmt))] [(PushControlFrame/Prompt? stmt) (label->labels (PushControlFrame/Prompt-label stmt))] [(PopControlFrame? stmt) @@ -330,9 +330,9 @@ EOF [(GotoStatement? stmt) (assemble-jump (GotoStatement-target stmt))] - [(PushControlFrame? stmt) + [(PushControlFrame/Call? stmt) (format "MACHINE.control.push(new RUNTIME.CallFrame(~a, MACHINE.proc));" - (let ([label (PushControlFrame-label stmt)]) + (let ([label (PushControlFrame/Call-label stmt)]) (cond [(symbol? label) label] [(LinkedLabel? label) (LinkedLabel-label label)])))] diff --git a/compiler.rkt b/compiler.rkt index 53a8f4b..57c5411 100644 --- a/compiler.rkt +++ b/compiler.rkt @@ -968,7 +968,7 @@ proc-return-multiple)]) (append-instruction-sequences (make-instruction-sequence - `(,(make-PushControlFrame proc-return))) + `(,(make-PushControlFrame/Call proc-return))) maybe-install-jump-address (make-instruction-sequence `(,(make-GotoStatement entry-point-target))) @@ -985,7 +985,7 @@ proc-return-multiple)]) (append-instruction-sequences (make-instruction-sequence - `(,(make-PushControlFrame proc-return))) + `(,(make-PushControlFrame/Call proc-return))) maybe-install-jump-address (make-instruction-sequence `(,(make-GotoStatement entry-point-target))) @@ -1006,7 +1006,7 @@ proc-return-multiple)]) (append-instruction-sequences (make-instruction-sequence - `(,(make-PushControlFrame proc-return))) + `(,(make-PushControlFrame/Call proc-return))) maybe-install-jump-address (make-instruction-sequence `(,(make-GotoStatement entry-point-target))) @@ -1023,7 +1023,7 @@ proc-return-multiple)]) (append-instruction-sequences (make-instruction-sequence - `(,(make-PushControlFrame proc-return))) + `(,(make-PushControlFrame/Call proc-return))) maybe-install-jump-address (make-instruction-sequence `(,(make-GotoStatement entry-point-target))) @@ -1044,7 +1044,7 @@ proc-return-multiple)]) (append-instruction-sequences (make-instruction-sequence - `(,(make-PushControlFrame proc-return))) + `(,(make-PushControlFrame/Call proc-return))) maybe-install-jump-address (make-instruction-sequence `(,(make-GotoStatement entry-point-target))) @@ -1063,7 +1063,7 @@ proc-return-multiple)]) (append-instruction-sequences (make-instruction-sequence - `(,(make-PushControlFrame proc-return))) + `(,(make-PushControlFrame/Call proc-return))) maybe-install-jump-address (make-instruction-sequence `(,(make-GotoStatement entry-point-target))) @@ -1297,7 +1297,7 @@ ;; FIXME: create separate frame structure here, and don't try to reuse. (make-instruction-sequence `(,(make-AssignImmediateStatement 'proc (make-Const #f)) - ,(make-PushControlFrame after-body))) + ,(make-PushControlFrame/Call after-body))) ;(make-instruction-sequence ; `(,(make-AssignImmediateStatement 'proc (make-Const #f)) diff --git a/il-structs.rkt b/il-structs.rkt index a01f7e8..fbd126a 100644 --- a/il-structs.rkt +++ b/il-structs.rkt @@ -80,7 +80,7 @@ PushImmediateOntoEnvironment - PushControlFrame + PushControlFrame/Call PushControlFrame/Prompt PopControlFrame)) @@ -123,10 +123,11 @@ (define-struct: PopControlFrame () #:transparent) + ;; Adding a frame for getting back after procedure application. ;; The 'proc register must hold either #f or a closure at the time of ;; this call, as the control frame will hold onto the called procedure record. -(define-struct: PushControlFrame ([label : (U Symbol LinkedLabel)]) +(define-struct: PushControlFrame/Call ([label : (U Symbol LinkedLabel)]) #:transparent) (define-struct: PushControlFrame/Prompt ([tag : (U OpArg DefaultContinuationPromptTag)] diff --git a/simulator.rkt b/simulator.rkt index 5fc3a04..e8085ca 100644 --- a/simulator.rkt +++ b/simulator.rkt @@ -109,7 +109,7 @@ (step-push-environment! m i)] [(PushImmediateOntoEnvironment? i) (step-push-immediate-onto-environment! m i)] - [(PushControlFrame? i) + [(PushControlFrame/Call? i) (step-push-control-frame! m i)] [(PushControlFrame/Prompt? i) (step-push-control-frame/prompt! m i)] @@ -168,9 +168,9 @@ (step-push-environment! m (make-PushEnvironment 1 (PushImmediateOntoEnvironment-box? stmt))) ((get-target-updater t) m v))) -(: step-push-control-frame! (machine PushControlFrame -> 'ok)) +(: step-push-control-frame! (machine PushControlFrame/Call -> 'ok)) (define (step-push-control-frame! m stmt) - (control-push! m (make-CallFrame (PushControlFrame-label stmt) + (control-push! m (make-CallFrame (PushControlFrame/Call-label stmt) (ensure-closure-or-false (machine-proc m)) (make-hasheq) (make-hasheq)))) diff --git a/test-simulator.rkt b/test-simulator.rkt index f5b57f2..cca578d 100644 --- a/test-simulator.rkt +++ b/test-simulator.rkt @@ -167,9 +167,9 @@ ;; PushControl (let ([m (new-machine `(,(make-AssignImmediateStatement 'proc (make-Const #f)) foo - ,(make-PushControlFrame 'foo) + ,(make-PushControlFrame/Call 'foo) bar - ,(make-PushControlFrame 'bar) + ,(make-PushControlFrame/Call 'bar) baz ))]) (test (machine-control (run! m)) @@ -181,9 +181,9 @@ ;; PopControl (let ([m (new-machine `(,(make-AssignImmediateStatement 'proc (make-Const #f)) foo - ,(make-PushControlFrame 'foo) + ,(make-PushControlFrame/Call 'foo) bar - ,(make-PushControlFrame 'bar) + ,(make-PushControlFrame/Call 'bar) baz ,(make-PopControlFrame) ))]) @@ -192,9 +192,9 @@ (let ([m (new-machine `(,(make-AssignImmediateStatement 'proc (make-Const #f)) foo - ,(make-PushControlFrame 'foo) + ,(make-PushControlFrame/Call 'foo) bar - ,(make-PushControlFrame 'bar) + ,(make-PushControlFrame/Call 'bar) baz ,(make-PopControlFrame) ,(make-PopControlFrame)))]) @@ -488,7 +488,7 @@ ;; GetControlStackLabel (let ([m (new-machine `(,(make-AssignImmediateStatement 'proc (make-Const #f)) foo - ,(make-PushControlFrame 'foo) + ,(make-PushControlFrame/Call 'foo) ,(make-AssignPrimOpStatement 'proc (make-GetControlStackLabel))))]) (test (machine-proc (run! m)) 'foo))