trying to trace why the analyzer is breaking
This commit is contained in:
parent
81a80b328f
commit
b740fea82c
4
Makefile
4
Makefile
|
@ -1,3 +1,7 @@
|
|||
test-analyzer:
|
||||
raco make -v --disable-inline test-analyzer.rkt
|
||||
racket test-analyzer.rkt
|
||||
|
||||
test-all:
|
||||
raco make -v --disable-inline tests/test-all.rkt
|
||||
racket tests/test-all.rkt
|
||||
|
|
|
@ -33,3 +33,11 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
(define-struct: Analysis ([ht : (HashTable Expression CompileTimeEnvironmentEntry)]))
|
||||
|
||||
|
||||
(: empty-analysis (-> Analysis))
|
||||
(define (empty-analysis)
|
||||
(make-Analysis (make-hash)))
|
|
@ -21,12 +21,12 @@
|
|||
|
||||
|
||||
|
||||
(: -analyze (Expression -> (HashTable Expression CompileTimeEnvironmentEntry)))
|
||||
(: -analyze (Expression -> Analysis))
|
||||
(define (-analyze exp)
|
||||
(parameterize ([current-expression-map
|
||||
((inst make-hasheq Expression CompileTimeEnvironmentEntry))])
|
||||
(analyze exp '())
|
||||
(current-expression-map)))
|
||||
(make-Analysis (current-expression-map))))
|
||||
|
||||
|
||||
|
||||
|
|
59
compiler.rkt
59
compiler.rkt
|
@ -9,6 +9,7 @@
|
|||
"parameters.rkt"
|
||||
"sets.rkt"
|
||||
"analyzer-structs.rkt"
|
||||
"analyzer.rkt"
|
||||
racket/match
|
||||
racket/bool
|
||||
racket/list)
|
||||
|
@ -19,6 +20,9 @@
|
|||
|
||||
|
||||
|
||||
(: current-analysis (Parameterof Analysis))
|
||||
(define current-analysis (make-parameter (empty-analysis)))
|
||||
|
||||
|
||||
|
||||
(: -compile (Expression Target Linkage -> (Listof Statement)))
|
||||
|
@ -26,32 +30,35 @@
|
|||
;; Note: the toplevel generates the lambda body streams at the head, and then the
|
||||
;; rest of the instruction stream.
|
||||
(define (-compile exp target linkage)
|
||||
(let* ([after-lam-bodies (make-label 'afterLamBodies)]
|
||||
[before-pop-prompt-multiple (make-label 'beforePopPromptMultiple)]
|
||||
[before-pop-prompt (make-LinkedLabel (make-label 'beforePopPrompt) before-pop-prompt-multiple)])
|
||||
(optimize-il
|
||||
(statements
|
||||
(append-instruction-sequences
|
||||
|
||||
;; Layout the lambda bodies...
|
||||
(make-instruction-sequence
|
||||
`(,(make-GotoStatement (make-Label after-lam-bodies))))
|
||||
(compile-lambda-bodies (collect-all-lambdas-with-bodies exp))
|
||||
after-lam-bodies
|
||||
|
||||
;; Begin a prompted evaluation:
|
||||
(make-instruction-sequence
|
||||
`(,(make-PushControlFrame/Prompt default-continuation-prompt-tag
|
||||
before-pop-prompt)))
|
||||
(compile exp '() 'val return-linkage/nontail)
|
||||
before-pop-prompt-multiple
|
||||
(make-instruction-sequence
|
||||
`(,(make-PopEnvironment (make-Reg 'argcount) (make-Const 0))))
|
||||
before-pop-prompt
|
||||
(if (eq? target 'val)
|
||||
empty-instruction-sequence
|
||||
(make-instruction-sequence
|
||||
`(,(make-AssignImmediateStatement target (make-Reg 'val))))))))))
|
||||
(parameterize ([current-analysis (analyze exp)])
|
||||
(let* ([after-lam-bodies (make-label 'afterLamBodies)]
|
||||
[before-pop-prompt-multiple (make-label 'beforePopPromptMultiple)]
|
||||
[before-pop-prompt (make-LinkedLabel
|
||||
(make-label 'beforePopPrompt)
|
||||
before-pop-prompt-multiple)])
|
||||
(optimize-il
|
||||
(statements
|
||||
(append-instruction-sequences
|
||||
|
||||
;; Layout the lambda bodies...
|
||||
(make-instruction-sequence
|
||||
`(,(make-GotoStatement (make-Label after-lam-bodies))))
|
||||
(compile-lambda-bodies (collect-all-lambdas-with-bodies exp))
|
||||
after-lam-bodies
|
||||
|
||||
;; Begin a prompted evaluation:
|
||||
(make-instruction-sequence
|
||||
`(,(make-PushControlFrame/Prompt default-continuation-prompt-tag
|
||||
before-pop-prompt)))
|
||||
(compile exp '() 'val return-linkage/nontail)
|
||||
before-pop-prompt-multiple
|
||||
(make-instruction-sequence
|
||||
`(,(make-PopEnvironment (make-Reg 'argcount) (make-Const 0))))
|
||||
before-pop-prompt
|
||||
(if (eq? target 'val)
|
||||
empty-instruction-sequence
|
||||
(make-instruction-sequence
|
||||
`(,(make-AssignImmediateStatement target (make-Reg 'val)))))))))))
|
||||
|
||||
(define-struct: lam+cenv ([lam : (U Lam CaseLam)]
|
||||
[cenv : CompileTimeEnvironment]))
|
||||
|
|
9
test-analyzer.rkt
Normal file
9
test-analyzer.rkt
Normal 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)
|
Loading…
Reference in New Issue
Block a user