adding rest? argument to Lams
This commit is contained in:
parent
1aa3e77a57
commit
9094c345cd
|
@ -1287,6 +1287,7 @@
|
||||||
[(Lam? exp)
|
[(Lam? exp)
|
||||||
(make-Lam (Lam-name exp)
|
(make-Lam (Lam-name exp)
|
||||||
(Lam-num-parameters exp)
|
(Lam-num-parameters exp)
|
||||||
|
(Lam-rest? exp)
|
||||||
(Lam-body exp)
|
(Lam-body exp)
|
||||||
(map (lambda: ([d : Natural])
|
(map (lambda: ([d : Natural])
|
||||||
(if (< d skip)
|
(if (< d skip)
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
(define-struct: Lam ([name : (U Symbol False)]
|
(define-struct: Lam ([name : (U Symbol False)]
|
||||||
[num-parameters : Natural]
|
[num-parameters : Natural]
|
||||||
|
[rest? : Boolean]
|
||||||
[body : Expression]
|
[body : Expression]
|
||||||
[closure-map : (Listof Natural)]
|
[closure-map : (Listof Natural)]
|
||||||
[entry-label : Symbol]) #:transparent)
|
[entry-label : Symbol]) #:transparent)
|
||||||
|
|
|
@ -185,6 +185,7 @@
|
||||||
mutated-parameters)])
|
mutated-parameters)])
|
||||||
(make-Lam (current-defined-name)
|
(make-Lam (current-defined-name)
|
||||||
(length (lambda-parameters exp))
|
(length (lambda-parameters exp))
|
||||||
|
#f
|
||||||
lam-body
|
lam-body
|
||||||
(map env-reference-depth closure-references)
|
(map env-reference-depth closure-references)
|
||||||
(fresh-lam-label)))))
|
(fresh-lam-label)))))
|
||||||
|
|
|
@ -89,20 +89,20 @@
|
||||||
|
|
||||||
(test (parse '(lambda (x y z) x))
|
(test (parse '(lambda (x y z) x))
|
||||||
(make-Top (make-Prefix '())
|
(make-Top (make-Prefix '())
|
||||||
(make-Lam #f 3 (make-LocalRef 0 #f) '() 'lamEntry1)))
|
(make-Lam #f 3 #f (make-LocalRef 0 #f) '() 'lamEntry1)))
|
||||||
|
|
||||||
(test (parse '(lambda (x y z) y))
|
(test (parse '(lambda (x y z) y))
|
||||||
(make-Top (make-Prefix '())
|
(make-Top (make-Prefix '())
|
||||||
(make-Lam #f 3 (make-LocalRef 1 #f) '() 'lamEntry1)))
|
(make-Lam #f 3 #f (make-LocalRef 1 #f) '() 'lamEntry1)))
|
||||||
|
|
||||||
(test (parse '(lambda (x y z) z))
|
(test (parse '(lambda (x y z) z))
|
||||||
(make-Top (make-Prefix '())
|
(make-Top (make-Prefix '())
|
||||||
(make-Lam #f 3 (make-LocalRef 2 #f) '() 'lamEntry1)))
|
(make-Lam #f 3 #f (make-LocalRef 2 #f) '() 'lamEntry1)))
|
||||||
|
|
||||||
|
|
||||||
(test (parse '(lambda (x y z) x y z))
|
(test (parse '(lambda (x y z) x y z))
|
||||||
(make-Top (make-Prefix '())
|
(make-Top (make-Prefix '())
|
||||||
(make-Lam #f 3 (make-Seq (list (make-LocalRef 0 #f)
|
(make-Lam #f 3 #f (make-Seq (list (make-LocalRef 0 #f)
|
||||||
(make-LocalRef 1 #f)
|
(make-LocalRef 1 #f)
|
||||||
(make-LocalRef 2 #f)))
|
(make-LocalRef 2 #f)))
|
||||||
'()
|
'()
|
||||||
|
@ -112,6 +112,7 @@
|
||||||
(make-Top (make-Prefix '(k))
|
(make-Top (make-Prefix '(k))
|
||||||
(make-Lam #f
|
(make-Lam #f
|
||||||
3
|
3
|
||||||
|
#f
|
||||||
(make-ToplevelRef 0 0 )
|
(make-ToplevelRef 0 0 )
|
||||||
'(0)
|
'(0)
|
||||||
'lamEntry1)))
|
'lamEntry1)))
|
||||||
|
@ -119,7 +120,9 @@
|
||||||
(test (parse '(lambda (x y z) k x y z))
|
(test (parse '(lambda (x y z) k x y z))
|
||||||
(make-Top (make-Prefix '(k))
|
(make-Top (make-Prefix '(k))
|
||||||
(make-Lam #f
|
(make-Lam #f
|
||||||
3 (make-Seq (list (make-ToplevelRef 0 0 )
|
3
|
||||||
|
#f
|
||||||
|
(make-Seq (list (make-ToplevelRef 0 0 )
|
||||||
(make-LocalRef 1 #f)
|
(make-LocalRef 1 #f)
|
||||||
(make-LocalRef 2 #f)
|
(make-LocalRef 2 #f)
|
||||||
(make-LocalRef 3 #f)))
|
(make-LocalRef 3 #f)))
|
||||||
|
@ -134,9 +137,9 @@
|
||||||
z
|
z
|
||||||
w))))
|
w))))
|
||||||
(make-Top (make-Prefix '(w))
|
(make-Top (make-Prefix '(w))
|
||||||
(make-Lam #f 1
|
(make-Lam #f 1 #f
|
||||||
(make-Lam #f 1
|
(make-Lam #f 1 #f
|
||||||
(make-Lam #f 1
|
(make-Lam #f 1 #f
|
||||||
(make-Seq (list
|
(make-Seq (list
|
||||||
(make-LocalRef 1 #f)
|
(make-LocalRef 1 #f)
|
||||||
(make-LocalRef 2 #f)
|
(make-LocalRef 2 #f)
|
||||||
|
@ -154,8 +157,8 @@
|
||||||
(lambda (y)
|
(lambda (y)
|
||||||
x)))
|
x)))
|
||||||
(make-Top (make-Prefix '())
|
(make-Top (make-Prefix '())
|
||||||
(make-Lam #f 1
|
(make-Lam #f 1 #f
|
||||||
(make-Lam #f 1
|
(make-Lam #f 1 #f
|
||||||
(make-LocalRef 0 #f)
|
(make-LocalRef 0 #f)
|
||||||
'(0)
|
'(0)
|
||||||
'lamEntry1)
|
'lamEntry1)
|
||||||
|
@ -166,8 +169,8 @@
|
||||||
(lambda (y)
|
(lambda (y)
|
||||||
y)))
|
y)))
|
||||||
(make-Top (make-Prefix '())
|
(make-Top (make-Prefix '())
|
||||||
(make-Lam #f 1
|
(make-Lam #f 1 #f
|
||||||
(make-Lam #f 1
|
(make-Lam #f 1 #f
|
||||||
(make-LocalRef 0 #f)
|
(make-LocalRef 0 #f)
|
||||||
(list)
|
(list)
|
||||||
'lamEntry1)
|
'lamEntry1)
|
||||||
|
@ -184,7 +187,7 @@
|
||||||
|
|
||||||
(test (parse '(lambda (x) (+ x x)))
|
(test (parse '(lambda (x) (+ x x)))
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable '+ '#%kernel)))
|
(make-Top (make-Prefix `(,(make-ModuleVariable '+ '#%kernel)))
|
||||||
(make-Lam #f 1
|
(make-Lam #f 1 #f
|
||||||
(make-App (make-ToplevelRef 2 0)
|
(make-App (make-ToplevelRef 2 0)
|
||||||
(list (make-LocalRef 3 #f)
|
(list (make-LocalRef 3 #f)
|
||||||
(make-LocalRef 3 #f)))
|
(make-LocalRef 3 #f)))
|
||||||
|
@ -195,7 +198,7 @@
|
||||||
(+ (* x x) x)))
|
(+ (* x x) x)))
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable '* '#%kernel)
|
(make-Top (make-Prefix `(,(make-ModuleVariable '* '#%kernel)
|
||||||
,(make-ModuleVariable '+ '#%kernel)))
|
,(make-ModuleVariable '+ '#%kernel)))
|
||||||
(make-Lam #f 1
|
(make-Lam #f 1 #f
|
||||||
;; stack layout: [???, ???, prefix, x]
|
;; stack layout: [???, ???, prefix, x]
|
||||||
(make-App (make-ToplevelRef 2 1)
|
(make-App (make-ToplevelRef 2 1)
|
||||||
(list
|
(list
|
||||||
|
@ -285,7 +288,7 @@
|
||||||
(test (parse '(letrec ([omega (lambda () (omega))])
|
(test (parse '(letrec ([omega (lambda () (omega))])
|
||||||
(omega)))
|
(omega)))
|
||||||
(make-Top (make-Prefix '())
|
(make-Top (make-Prefix '())
|
||||||
(make-LetRec (list (make-Lam 'omega 0 (make-App (make-LocalRef 0 #f)
|
(make-LetRec (list (make-Lam 'omega 0 #f (make-App (make-LocalRef 0 #f)
|
||||||
(list)) '(0) 'lamEntry1))
|
(list)) '(0) 'lamEntry1))
|
||||||
(make-App (make-LocalRef 0 #f) (list)))))
|
(make-App (make-LocalRef 0 #f) (list)))))
|
||||||
|
|
||||||
|
@ -296,9 +299,9 @@
|
||||||
[c (lambda () (a))])
|
[c (lambda () (a))])
|
||||||
(a)))
|
(a)))
|
||||||
(make-Top (make-Prefix '())
|
(make-Top (make-Prefix '())
|
||||||
(make-LetRec (list (make-Lam 'a 0 (make-App (make-LocalRef 0 #f) '()) '(1) 'lamEntry1)
|
(make-LetRec (list (make-Lam 'a 0 #f (make-App (make-LocalRef 0 #f) '()) '(1) 'lamEntry1)
|
||||||
(make-Lam 'b 0 (make-App (make-LocalRef 0 #f) '()) '(0) 'lamEntry2)
|
(make-Lam 'b 0 #f (make-App (make-LocalRef 0 #f) '()) '(0) 'lamEntry2)
|
||||||
(make-Lam 'c 0 (make-App (make-LocalRef 0 #f) '()) '(2) 'lamEntry3))
|
(make-Lam 'c 0 #f (make-App (make-LocalRef 0 #f) '()) '(2) 'lamEntry3))
|
||||||
(make-App (make-LocalRef 2 #f) '()))))
|
(make-App (make-LocalRef 2 #f) '()))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,10 +315,10 @@
|
||||||
(make-Seq
|
(make-Seq
|
||||||
(list
|
(list
|
||||||
(make-InstallValue 1
|
(make-InstallValue 1
|
||||||
(make-Lam 'x 1 (make-LocalRef 0 #f) '() 'lamEntry1)
|
(make-Lam 'x 1 #f (make-LocalRef 0 #f) '() 'lamEntry1)
|
||||||
#t)
|
#t)
|
||||||
(make-InstallValue 0
|
(make-InstallValue 0
|
||||||
(make-Lam 'y 1 (make-LocalRef 0 #f) '() 'lamEntry2)
|
(make-Lam 'y 1 #f (make-LocalRef 0 #f) '() 'lamEntry2)
|
||||||
#t)
|
#t)
|
||||||
;; stack layout: ??? x y
|
;; stack layout: ??? x y
|
||||||
(make-Seq (list (make-Seq (list (make-InstallValue 1 (make-LocalRef 1 #t) #t)
|
(make-Seq (list (make-Seq (list (make-InstallValue 1 (make-LocalRef 1 #t) #t)
|
||||||
|
@ -357,14 +360,14 @@
|
||||||
(make-Seq
|
(make-Seq
|
||||||
(list
|
(list
|
||||||
(make-InstallValue 0
|
(make-InstallValue 0
|
||||||
(make-Lam 'x 1
|
(make-Lam 'x 1 #f
|
||||||
(make-App (make-LocalRef 1 #t)
|
(make-App (make-LocalRef 1 #t)
|
||||||
(list (make-LocalRef 2 #f)))
|
(list (make-LocalRef 2 #f)))
|
||||||
'(1)
|
'(1)
|
||||||
'lamEntry1)
|
'lamEntry1)
|
||||||
#t)
|
#t)
|
||||||
(make-InstallValue 1
|
(make-InstallValue 1
|
||||||
(make-Lam 'y 1
|
(make-Lam 'y 1 #f
|
||||||
(make-App (make-LocalRef 2 #f)
|
(make-App (make-LocalRef 2 #f)
|
||||||
(list (make-LocalRef 1 #t)))
|
(list (make-LocalRef 1 #t)))
|
||||||
'(1)
|
'(1)
|
||||||
|
@ -381,7 +384,7 @@
|
||||||
(make-Top (make-Prefix `(,(make-ModuleVariable 'add1 '#%kernel)))
|
(make-Top (make-Prefix `(,(make-ModuleVariable 'add1 '#%kernel)))
|
||||||
(make-Let1 (make-Constant 0)
|
(make-Let1 (make-Constant 0)
|
||||||
(make-BoxEnv 0
|
(make-BoxEnv 0
|
||||||
(make-Lam #f 0
|
(make-Lam #f 0 #f
|
||||||
(make-Seq (list (make-InstallValue
|
(make-Seq (list (make-InstallValue
|
||||||
1
|
1
|
||||||
(make-App (make-ToplevelRef 1 0)
|
(make-App (make-ToplevelRef 1 0)
|
||||||
|
@ -402,7 +405,7 @@
|
||||||
(make-Seq (list
|
(make-Seq (list
|
||||||
(make-InstallValue 0 (make-Constant 0) #t)
|
(make-InstallValue 0 (make-Constant 0) #t)
|
||||||
(make-InstallValue 1 (make-Constant 1) #t)
|
(make-InstallValue 1 (make-Constant 1) #t)
|
||||||
(make-Lam #f 0
|
(make-Lam #f 0 #f
|
||||||
(make-Seq
|
(make-Seq
|
||||||
(list (make-InstallValue
|
(list (make-InstallValue
|
||||||
1
|
1
|
||||||
|
@ -437,6 +440,7 @@
|
||||||
(make-Lam
|
(make-Lam
|
||||||
'reset!
|
'reset!
|
||||||
0
|
0
|
||||||
|
#f
|
||||||
(make-Seq
|
(make-Seq
|
||||||
(list
|
(list
|
||||||
(make-Seq (list (make-ToplevelSet 0 0 'a (make-Constant '())) (make-Constant (void))))
|
(make-Seq (list (make-ToplevelSet 0 0 'a (make-Constant '())) (make-Constant (void))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user