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