toplevel refs remember if they need to be checked
This commit is contained in:
parent
e445c61ed2
commit
b5bc821ef9
|
@ -336,7 +336,7 @@
|
||||||
|
|
||||||
;; Compiling modules
|
;; Compiling modules
|
||||||
(check-true
|
(check-true
|
||||||
(match (run-my-parse #'(module foo racket/base
|
(match (run-my-parse #'(module foo1 racket/base
|
||||||
42))
|
42))
|
||||||
[(struct Top ((struct Prefix (list))
|
[(struct Top ((struct Prefix (list))
|
||||||
(struct Module ((? symbol?)
|
(struct Module ((? symbol?)
|
||||||
|
@ -345,12 +345,12 @@
|
||||||
_ ;; requires
|
_ ;; requires
|
||||||
_ ;; provides
|
_ ;; provides
|
||||||
(struct Splice ((list (struct ApplyValues
|
(struct Splice ((list (struct ApplyValues
|
||||||
((struct ToplevelRef ('0 '0 '#t)) (struct Constant ('42)))))))))))
|
((struct ToplevelRef ('0 '0 _)) (struct Constant ('42)))))))))))
|
||||||
#t]))
|
#t]))
|
||||||
|
|
||||||
|
|
||||||
(check-true
|
(check-true
|
||||||
(match (run-my-parse #'(module foo racket/base
|
(match (run-my-parse #'(module foo2 racket/base
|
||||||
(provide x)
|
(provide x)
|
||||||
(define x "x")))
|
(define x "x")))
|
||||||
[(struct Top ((struct Prefix ((? list?)))
|
[(struct Top ((struct Prefix ((? list?)))
|
||||||
|
@ -360,7 +360,7 @@
|
||||||
_ ;; requires
|
_ ;; requires
|
||||||
_ ;; provides
|
_ ;; provides
|
||||||
(struct Splice ((list (struct DefValues
|
(struct Splice ((list (struct DefValues
|
||||||
((list (struct ToplevelRef ('0 '0 '#t)))
|
((list (struct ToplevelRef ('0 '0 _)))
|
||||||
(struct Constant ("x")))))))))))
|
(struct Constant ("x")))))))))))
|
||||||
#t]))
|
#t]))
|
||||||
|
|
||||||
|
@ -405,7 +405,7 @@
|
||||||
(#%provide f))))
|
(#%provide f))))
|
||||||
|
|
||||||
|
|
||||||
#;(parameterize ([current-root-path this-test-path]
|
(parameterize ([current-root-path this-test-path]
|
||||||
[current-module-path (build-path this-test-path "foo.rkt")])
|
[current-module-path (build-path this-test-path "foo.rkt")])
|
||||||
(check-true
|
(check-true
|
||||||
(match (run-my-parse #'(module foo racket/base))
|
(match (run-my-parse #'(module foo racket/base))
|
||||||
|
|
|
@ -41,58 +41,58 @@
|
||||||
|
|
||||||
(test (parse 'hello)
|
(test (parse 'hello)
|
||||||
(make-Top (make-Prefix '(hello))
|
(make-Top (make-Prefix '(hello))
|
||||||
(make-ToplevelRef 0 0)))
|
(make-ToplevelRef 0 0 #t)))
|
||||||
|
|
||||||
(test (parse '(begin hello world))
|
(test (parse '(begin hello world))
|
||||||
(make-Top (make-Prefix '(hello world))
|
(make-Top (make-Prefix '(hello world))
|
||||||
(make-Splice (list (make-ToplevelRef 0 0)
|
(make-Splice (list (make-ToplevelRef 0 0 #t)
|
||||||
(make-ToplevelRef 0 1)))))
|
(make-ToplevelRef 0 1 #t)))))
|
||||||
|
|
||||||
(test (parse '(define x y))
|
(test (parse '(define x y))
|
||||||
(make-Top (make-Prefix '(x y))
|
(make-Top (make-Prefix '(x y))
|
||||||
(make-ToplevelSet 0 0 (make-ToplevelRef 0 1))))
|
(make-ToplevelSet 0 0 (make-ToplevelRef 0 1 #t))))
|
||||||
|
|
||||||
(test (parse '(begin (define x 42)
|
(test (parse '(begin (define x 42)
|
||||||
(define y x)))
|
(define y x)))
|
||||||
(make-Top (make-Prefix '(x y))
|
(make-Top (make-Prefix '(x y))
|
||||||
(make-Splice (list (make-ToplevelSet 0 0 (make-Constant 42))
|
(make-Splice (list (make-ToplevelSet 0 0 (make-Constant 42))
|
||||||
(make-ToplevelSet 0 1 (make-ToplevelRef 0 0))))))
|
(make-ToplevelSet 0 1 (make-ToplevelRef 0 0 #t))))))
|
||||||
|
|
||||||
(test (parse '(if x y z))
|
(test (parse '(if x y z))
|
||||||
(make-Top (make-Prefix '(x y z))
|
(make-Top (make-Prefix '(x y z))
|
||||||
(make-Branch (make-ToplevelRef 0 0)
|
(make-Branch (make-ToplevelRef 0 0 #t)
|
||||||
(make-ToplevelRef 0 1)
|
(make-ToplevelRef 0 1 #t)
|
||||||
(make-ToplevelRef 0 2))))
|
(make-ToplevelRef 0 2 #t))))
|
||||||
|
|
||||||
(test (parse '(if x (if y z 1) #t))
|
(test (parse '(if x (if y z 1) #t))
|
||||||
(make-Top (make-Prefix '(x y z))
|
(make-Top (make-Prefix '(x y z))
|
||||||
(make-Branch (make-ToplevelRef 0 0)
|
(make-Branch (make-ToplevelRef 0 0 #t)
|
||||||
(make-Branch (make-ToplevelRef 0 1)
|
(make-Branch (make-ToplevelRef 0 1 #t)
|
||||||
(make-ToplevelRef 0 2)
|
(make-ToplevelRef 0 2 #t)
|
||||||
(make-Constant 1))
|
(make-Constant 1))
|
||||||
(make-Constant #t))))
|
(make-Constant #t))))
|
||||||
|
|
||||||
(test (parse '(if x y))
|
(test (parse '(if x y))
|
||||||
(make-Top (make-Prefix '(x y))
|
(make-Top (make-Prefix '(x y))
|
||||||
(make-Branch (make-ToplevelRef 0 0)
|
(make-Branch (make-ToplevelRef 0 0 #t)
|
||||||
(make-ToplevelRef 0 1)
|
(make-ToplevelRef 0 1 #t)
|
||||||
(make-Constant (void)))))
|
(make-Constant (void)))))
|
||||||
|
|
||||||
(test (parse '(cond [x y]))
|
(test (parse '(cond [x y]))
|
||||||
(make-Top (make-Prefix '(x y))
|
(make-Top (make-Prefix '(x y))
|
||||||
(make-Branch (make-ToplevelRef 0 0)
|
(make-Branch (make-ToplevelRef 0 0 #t)
|
||||||
(make-ToplevelRef 0 1)
|
(make-ToplevelRef 0 1 #t)
|
||||||
(make-Constant (void)))))
|
(make-Constant (void)))))
|
||||||
|
|
||||||
(test (parse '(cond [x y] [else "ok"]))
|
(test (parse '(cond [x y] [else "ok"]))
|
||||||
(make-Top (make-Prefix '(x y))
|
(make-Top (make-Prefix '(x y))
|
||||||
(make-Branch (make-ToplevelRef 0 0)
|
(make-Branch (make-ToplevelRef 0 0 #t)
|
||||||
(make-ToplevelRef 0 1)
|
(make-ToplevelRef 0 1 #t)
|
||||||
(make-Constant "ok"))))
|
(make-Constant "ok"))))
|
||||||
|
|
||||||
(test (parse '(lambda () x))
|
(test (parse '(lambda () x))
|
||||||
(make-Top (make-Prefix '(x))
|
(make-Top (make-Prefix '(x))
|
||||||
(make-Lam 'unknown 0 #f (make-ToplevelRef 0 0)
|
(make-Lam 'unknown 0 #f (make-ToplevelRef 0 0 #t)
|
||||||
'(0) 'lamEntry1)))
|
'(0) 'lamEntry1)))
|
||||||
|
|
||||||
(test (parse '(lambda args args))
|
(test (parse '(lambda args args))
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
(make-Lam 'unknown
|
(make-Lam 'unknown
|
||||||
3
|
3
|
||||||
#f
|
#f
|
||||||
(make-ToplevelRef 0 0 )
|
(make-ToplevelRef 0 0 #t)
|
||||||
'(0)
|
'(0)
|
||||||
'lamEntry1)))
|
'lamEntry1)))
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
(make-Lam 'unknown
|
(make-Lam 'unknown
|
||||||
3
|
3
|
||||||
#f
|
#f
|
||||||
(make-Seq (list (make-ToplevelRef 0 0 )
|
(make-Seq (list (make-ToplevelRef 0 0 #t)
|
||||||
(make-LocalRef 1 #f)
|
(make-LocalRef 1 #f)
|
||||||
(make-LocalRef 2 #f)
|
(make-LocalRef 2 #f)
|
||||||
(make-LocalRef 3 #f)))
|
(make-LocalRef 3 #f)))
|
||||||
|
@ -177,7 +177,7 @@
|
||||||
(make-LocalRef 1 #f)
|
(make-LocalRef 1 #f)
|
||||||
(make-LocalRef 2 #f)
|
(make-LocalRef 2 #f)
|
||||||
(make-LocalRef 3 #f)
|
(make-LocalRef 3 #f)
|
||||||
(make-ToplevelRef 0 0)))
|
(make-ToplevelRef 0 0 #t)))
|
||||||
'(0 1 2) ;; w x y
|
'(0 1 2) ;; w x y
|
||||||
'lamEntry1)
|
'lamEntry1)
|
||||||
|
|
||||||
|
@ -213,15 +213,15 @@
|
||||||
(test (parse '(+ x x))
|
(test (parse '(+ x x))
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable '+ (make-ModuleLocator '#%kernel '#%kernel))
|
(make-Top (make-Prefix `(,(make-ModuleVariable '+ (make-ModuleLocator '#%kernel '#%kernel))
|
||||||
x))
|
x))
|
||||||
(make-App (make-ToplevelRef 2 0)
|
(make-App (make-ToplevelRef 2 0 #t)
|
||||||
(list (make-ToplevelRef 2 1)
|
(list (make-ToplevelRef 2 1 #t)
|
||||||
(make-ToplevelRef 2 1)))))
|
(make-ToplevelRef 2 1 #t)))))
|
||||||
|
|
||||||
|
|
||||||
(test (parse '(lambda (x) (+ x x)))
|
(test (parse '(lambda (x) (+ x x)))
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable '+ (make-ModuleLocator '#%kernel '#%kernel))))
|
(make-Top (make-Prefix `(,(make-ModuleVariable '+ (make-ModuleLocator '#%kernel '#%kernel))))
|
||||||
(make-Lam 'unknown 1 #f
|
(make-Lam 'unknown 1 #f
|
||||||
(make-App (make-ToplevelRef 2 0)
|
(make-App (make-ToplevelRef 2 0 #t)
|
||||||
(list (make-LocalRef 3 #f)
|
(list (make-LocalRef 3 #f)
|
||||||
(make-LocalRef 3 #f)))
|
(make-LocalRef 3 #f)))
|
||||||
'(0)
|
'(0)
|
||||||
|
@ -233,10 +233,10 @@
|
||||||
,(make-ModuleVariable '+ (make-ModuleLocator '#%kernel '#%kernel))))
|
,(make-ModuleVariable '+ (make-ModuleLocator '#%kernel '#%kernel))))
|
||||||
(make-Lam 'unknown 1 #f
|
(make-Lam 'unknown 1 #f
|
||||||
;; stack layout: [???, ???, prefix, x]
|
;; stack layout: [???, ???, prefix, x]
|
||||||
(make-App (make-ToplevelRef 2 1)
|
(make-App (make-ToplevelRef 2 1 #t)
|
||||||
(list
|
(list
|
||||||
;; stack layout: [???, ???, ???, ???, prefix, x]
|
;; stack layout: [???, ???, ???, ???, prefix, x]
|
||||||
(make-App (make-ToplevelRef 4 0)
|
(make-App (make-ToplevelRef 4 0 #t)
|
||||||
(list (make-LocalRef 5 #f)
|
(list (make-LocalRef 5 #f)
|
||||||
(make-LocalRef 5 #f)))
|
(make-LocalRef 5 #f)))
|
||||||
(make-LocalRef 3 #f)))
|
(make-LocalRef 3 #f)))
|
||||||
|
@ -246,7 +246,7 @@
|
||||||
(test (parse '(let ()
|
(test (parse '(let ()
|
||||||
x))
|
x))
|
||||||
(make-Top (make-Prefix '(x))
|
(make-Top (make-Prefix '(x))
|
||||||
(make-ToplevelRef 0 0)))
|
(make-ToplevelRef 0 0 #t)))
|
||||||
|
|
||||||
(test (parse '(let ([x 3])
|
(test (parse '(let ([x 3])
|
||||||
x))
|
x))
|
||||||
|
@ -304,10 +304,10 @@
|
||||||
(make-App
|
(make-App
|
||||||
|
|
||||||
;; stack layout: [???, ???, x_0, prefix]
|
;; stack layout: [???, ???, x_0, prefix]
|
||||||
(make-ToplevelRef 3 0) (list (make-LocalRef 2 #f)))
|
(make-ToplevelRef 3 0 #t) (list (make-LocalRef 2 #f)))
|
||||||
|
|
||||||
;; stack layout [???, x_1, x_0, prefix]
|
;; stack layout [???, x_1, x_0, prefix]
|
||||||
(make-App (make-ToplevelRef 3 0)
|
(make-App (make-ToplevelRef 3 0 #t)
|
||||||
(list (make-LocalRef 1 #f)))))))
|
(list (make-LocalRef 1 #f)))))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@
|
||||||
(make-Lam 'unknown 0 #f
|
(make-Lam 'unknown 0 #f
|
||||||
(make-Seq (list (make-InstallValue
|
(make-Seq (list (make-InstallValue
|
||||||
1 1
|
1 1
|
||||||
(make-App (make-ToplevelRef 1 0)
|
(make-App (make-ToplevelRef 1 0 #t)
|
||||||
(list (make-LocalRef 2 #t)))
|
(list (make-LocalRef 2 #t)))
|
||||||
#t)
|
#t)
|
||||||
(make-Constant (void))))
|
(make-Constant (void))))
|
||||||
|
@ -446,7 +446,7 @@
|
||||||
(make-Seq
|
(make-Seq
|
||||||
(list (make-InstallValue
|
(list (make-InstallValue
|
||||||
1 1
|
1 1
|
||||||
(make-App (make-ToplevelRef 1 0)
|
(make-App (make-ToplevelRef 1 0 #t)
|
||||||
(list (make-LocalRef 2 #t)))
|
(list (make-LocalRef 2 #t)))
|
||||||
#t)
|
#t)
|
||||||
(make-Constant (void))))
|
(make-Constant (void))))
|
||||||
|
@ -483,42 +483,42 @@
|
||||||
(make-Seq (list (make-ToplevelSet 0 1 (make-Constant '())) (make-Constant (void))))))
|
(make-Seq (list (make-ToplevelSet 0 1 (make-Constant '())) (make-Constant (void))))))
|
||||||
'(0)
|
'(0)
|
||||||
'lamEntry1))
|
'lamEntry1))
|
||||||
(make-App (make-ToplevelRef 0 3) '())
|
(make-App (make-ToplevelRef 0 3 #t) '())
|
||||||
(make-App (make-ToplevelRef 2 2) (list (make-ToplevelRef 2 0) (make-ToplevelRef 2 1)))))))
|
(make-App (make-ToplevelRef 2 2 #t) (list (make-ToplevelRef 2 0 #t) (make-ToplevelRef 2 1 #t)))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(test (parse '(with-continuation-mark x y z))
|
(test (parse '(with-continuation-mark x y z))
|
||||||
(make-Top (make-Prefix '(x y z))
|
(make-Top (make-Prefix '(x y z))
|
||||||
(make-WithContMark (make-ToplevelRef 0 0)
|
(make-WithContMark (make-ToplevelRef 0 0 #t)
|
||||||
(make-ToplevelRef 0 1)
|
(make-ToplevelRef 0 1 #t)
|
||||||
(make-ToplevelRef 0 2))))
|
(make-ToplevelRef 0 2 #t))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(test (parse '(call-with-values x y))
|
(test (parse '(call-with-values x y))
|
||||||
(make-Top (make-Prefix '(x y))
|
(make-Top (make-Prefix '(x y))
|
||||||
(make-ApplyValues (make-ToplevelRef 0 1)
|
(make-ApplyValues (make-ToplevelRef 0 1 #t)
|
||||||
(make-App (make-ToplevelRef 0 0) (list)))))
|
(make-App (make-ToplevelRef 0 0 #t) (list)))))
|
||||||
|
|
||||||
(test (parse '(call-with-values (lambda () x) y))
|
(test (parse '(call-with-values (lambda () x) y))
|
||||||
(make-Top (make-Prefix '(x y))
|
(make-Top (make-Prefix '(x y))
|
||||||
(make-ApplyValues (make-ToplevelRef 0 1)
|
(make-ApplyValues (make-ToplevelRef 0 1 #t)
|
||||||
(make-ToplevelRef 0 0))))
|
(make-ToplevelRef 0 0 #t))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(test (parse '(define-values () (values)))
|
(test (parse '(define-values () (values)))
|
||||||
(make-Top (make-Prefix '(values))
|
(make-Top (make-Prefix '(values))
|
||||||
(make-DefValues '()
|
(make-DefValues '()
|
||||||
(make-App (make-ToplevelRef 0 0) '()))))
|
(make-App (make-ToplevelRef 0 0 #t) '()))))
|
||||||
|
|
||||||
(test (parse '(define-values (x y z) (values 'hello 'world 'testing)))
|
(test (parse '(define-values (x y z) (values 'hello 'world 'testing)))
|
||||||
(make-Top (make-Prefix '(values x y z))
|
(make-Top (make-Prefix '(values x y z))
|
||||||
(make-DefValues (list (make-ToplevelRef 0 1)
|
(make-DefValues (list (make-ToplevelRef 0 1 #t)
|
||||||
(make-ToplevelRef 0 2)
|
(make-ToplevelRef 0 2 #t)
|
||||||
(make-ToplevelRef 0 3))
|
(make-ToplevelRef 0 3 #t))
|
||||||
(make-App (make-ToplevelRef 3 0)
|
(make-App (make-ToplevelRef 3 0 #t)
|
||||||
(list (make-Constant 'hello)
|
(list (make-Constant 'hello)
|
||||||
(make-Constant 'world)
|
(make-Constant 'world)
|
||||||
(make-Constant 'testing))))))
|
(make-Constant 'testing))))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user