Skip to content

Commit ee63147

Browse files
committed
any working, dynamic still has bugs
1 parent 6ed2f30 commit ee63147

File tree

1 file changed

+25
-34
lines changed

1 file changed

+25
-34
lines changed

dynamic-typing.rkt

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@
116116
[else (super free-variables e)]
117117
))
118118

119+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
120+
;; expose-allocation
121+
122+
(define/override (expose-allocation)
123+
(lambda (e)
124+
(verbose "expose-allocation" e)
125+
(match e
126+
[`(inject ,(app (expose-allocation) e) ,ty)
127+
`(inject ,e ,ty)]
128+
[`(project ,(app (expose-allocation) e) ,ty)
129+
`(project ,e ,ty)]
130+
[else
131+
((super expose-allocation) e)]
132+
)))
133+
119134
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
120135
;; flatten
121136

@@ -127,25 +142,21 @@
127142
(define-values (new-e e-ss xs) ((send this flatten #t) e))
128143
(cond [need-atomic
129144
(define tmp (gensym 'tmp))
130-
(values `(has-type ,tmp ,ty2)
131-
(append e-ss `((assign ,tmp
132-
(has-type (inject ,new-e ,ty)
133-
,ty2))))
145+
(values tmp
146+
(append e-ss `((assign ,tmp (inject ,new-e ,ty))))
134147
(cons (cons tmp ty2) xs)
135148
)]
136149
[else
137-
(values `(has-type (inject ,new-e ,ty) ,ty2) e-ss xs)])]
150+
(values `(inject ,new-e ,ty) e-ss xs)])]
138151
[`(has-type (project ,e ,ty) ,ty2)
139152
(define-values (new-e e-ss xs) ((send this flatten #t) e))
140153
(cond [need-atomic
141154
(define tmp (gensym 'tmp))
142-
(values `(has-type ,tmp ,ty2)
143-
(append e-ss `((assign ,tmp
144-
(has-type (project ,new-e ,ty)
145-
,ty2))))
155+
(values tmp
156+
(append e-ss `((assign ,tmp (project ,new-e ,ty))))
146157
(cons (cons tmp ty2) xs))]
147158
[else
148-
(values `(has-type (project ,new-e ,ty) ,ty2) e-ss xs)])]
159+
(values `(project ,new-e ,ty) e-ss xs)])]
149160
[else
150161
((super flatten need-atomic) e)]
151162
)))
@@ -205,26 +216,6 @@
205216
[else
206217
`((movq ,new-e ,new-lhs)
207218
(orq (int ,(any-tag ty)) ,new-lhs))])]
208-
;; Old inefficient version of project. -Jeremy
209-
;; [`(assign ,lhs (project ,e ,ty))
210-
;; (define new-lhs (recur lhs))
211-
;; (define new-e (recur e))
212-
;; `((movq ,new-e ,new-lhs)
213-
;; (andq (int ,any-mask) ,new-lhs)
214-
;; (if (eq? ,new-lhs (int ,(any-tag ty)))
215-
;; ((andq (int ,pointer-mask) ,new-lhs)
216-
;; (if (eq? ,new-lhs (int ,pointer-mask))
217-
;; ;; vectors and procedures.
218-
;; ;; To do: check length of vector, arity of procedure. -Jeremy
219-
;; ((movq (int ,any-mask) ,new-lhs)
220-
;; (notq ,new-lhs)
221-
;; (andq ,new-e ,new-lhs))
222-
;; ;; booleans and integers
223-
;; ((movq ,new-e ,new-lhs)
224-
;; (sarq (int ,tag-len) ,new-lhs))
225-
;; ))
226-
;; ;; shouldn't we push the status code? -Jeremy
227-
;; ((callq ,(string->symbol (label-name 'exit))))))]
228219
[`(assign ,lhs (project ,e ,ty))
229220
(define new-lhs (recur lhs))
230221
(define new-e (recur e))
@@ -500,10 +491,10 @@
500491
,(send interp interp-F '()))
501492
("convert-to-closures" ,(send compiler convert-to-closures)
502493
,(send interp interp-F '()))
503-
("flatten" ,(send compiler flatten #f)
504-
,(send interp interp-C '()))
505494
("expose allocation"
506495
,(send compiler expose-allocation)
496+
,(send interp interp-F '()))
497+
("flatten" ,(send compiler flatten #f)
507498
,(send interp interp-C '()))
508499
("instruction selection" ,(send compiler select-instructions)
509500
,(send interp interp-x86 '()))
@@ -538,10 +529,10 @@
538529
,(send interp interp-F '()))
539530
("convert-to-closures" ,(send compiler convert-to-closures)
540531
,(send interp interp-F '()))
541-
("flatten" ,(send compiler flatten #f)
542-
,(send interp interp-C '()))
543532
("expose allocation"
544533
,(send compiler expose-allocation)
534+
,(send interp interp-F '()))
535+
("flatten" ,(send compiler flatten #f)
545536
,(send interp interp-C '()))
546537
("instruction selection" ,(send compiler select-instructions)
547538
,(send interp interp-x86 '()))

0 commit comments

Comments
 (0)