trying to trace why the analyzer is breaking

This commit is contained in:
Danny Yoo 2011-05-24 12:53:47 -04:00
parent 81a80b328f
commit b740fea82c
5 changed files with 56 additions and 28 deletions

View File

@ -1,3 +1,7 @@
test-analyzer:
raco make -v --disable-inline test-analyzer.rkt
racket test-analyzer.rkt
test-all: test-all:
raco make -v --disable-inline tests/test-all.rkt raco make -v --disable-inline tests/test-all.rkt
racket tests/test-all.rkt racket tests/test-all.rkt

View File

@ -33,3 +33,11 @@
(define-struct: Analysis ([ht : (HashTable Expression CompileTimeEnvironmentEntry)]))
(: empty-analysis (-> Analysis))
(define (empty-analysis)
(make-Analysis (make-hash)))

View File

@ -21,12 +21,12 @@
(: -analyze (Expression -> (HashTable Expression CompileTimeEnvironmentEntry))) (: -analyze (Expression -> Analysis))
(define (-analyze exp) (define (-analyze exp)
(parameterize ([current-expression-map (parameterize ([current-expression-map
((inst make-hasheq Expression CompileTimeEnvironmentEntry))]) ((inst make-hasheq Expression CompileTimeEnvironmentEntry))])
(analyze exp '()) (analyze exp '())
(current-expression-map))) (make-Analysis (current-expression-map))))

View File

@ -9,6 +9,7 @@
"parameters.rkt" "parameters.rkt"
"sets.rkt" "sets.rkt"
"analyzer-structs.rkt" "analyzer-structs.rkt"
"analyzer.rkt"
racket/match racket/match
racket/bool racket/bool
racket/list) racket/list)
@ -19,6 +20,9 @@
(: current-analysis (Parameterof Analysis))
(define current-analysis (make-parameter (empty-analysis)))
(: -compile (Expression Target Linkage -> (Listof Statement))) (: -compile (Expression Target Linkage -> (Listof Statement)))
@ -26,32 +30,35 @@
;; Note: the toplevel generates the lambda body streams at the head, and then the ;; Note: the toplevel generates the lambda body streams at the head, and then the
;; rest of the instruction stream. ;; rest of the instruction stream.
(define (-compile exp target linkage) (define (-compile exp target linkage)
(let* ([after-lam-bodies (make-label 'afterLamBodies)] (parameterize ([current-analysis (analyze exp)])
[before-pop-prompt-multiple (make-label 'beforePopPromptMultiple)] (let* ([after-lam-bodies (make-label 'afterLamBodies)]
[before-pop-prompt (make-LinkedLabel (make-label 'beforePopPrompt) before-pop-prompt-multiple)]) [before-pop-prompt-multiple (make-label 'beforePopPromptMultiple)]
(optimize-il [before-pop-prompt (make-LinkedLabel
(statements (make-label 'beforePopPrompt)
(append-instruction-sequences before-pop-prompt-multiple)])
(optimize-il
;; Layout the lambda bodies... (statements
(make-instruction-sequence (append-instruction-sequences
`(,(make-GotoStatement (make-Label after-lam-bodies))))
(compile-lambda-bodies (collect-all-lambdas-with-bodies exp)) ;; Layout the lambda bodies...
after-lam-bodies (make-instruction-sequence
`(,(make-GotoStatement (make-Label after-lam-bodies))))
;; Begin a prompted evaluation: (compile-lambda-bodies (collect-all-lambdas-with-bodies exp))
(make-instruction-sequence after-lam-bodies
`(,(make-PushControlFrame/Prompt default-continuation-prompt-tag
before-pop-prompt))) ;; Begin a prompted evaluation:
(compile exp '() 'val return-linkage/nontail) (make-instruction-sequence
before-pop-prompt-multiple `(,(make-PushControlFrame/Prompt default-continuation-prompt-tag
(make-instruction-sequence before-pop-prompt)))
`(,(make-PopEnvironment (make-Reg 'argcount) (make-Const 0)))) (compile exp '() 'val return-linkage/nontail)
before-pop-prompt before-pop-prompt-multiple
(if (eq? target 'val) (make-instruction-sequence
empty-instruction-sequence `(,(make-PopEnvironment (make-Reg 'argcount) (make-Const 0))))
(make-instruction-sequence before-pop-prompt
`(,(make-AssignImmediateStatement target (make-Reg 'val)))))))))) (if (eq? target 'val)
empty-instruction-sequence
(make-instruction-sequence
`(,(make-AssignImmediateStatement target (make-Reg 'val)))))))))))
(define-struct: lam+cenv ([lam : (U Lam CaseLam)] (define-struct: lam+cenv ([lam : (U Lam CaseLam)]
[cenv : CompileTimeEnvironment])) [cenv : CompileTimeEnvironment]))

9
test-analyzer.rkt Normal file
View File

@ -0,0 +1,9 @@
#lang racket/base
(require "make-dependencies.rkt"
"make-structs.rkt")
;; For some reason, this is breaking. Why?
(make/dependencies
(list (build-path "make-dependencies.rkt"))
debug-configuration)