mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
More ast lambda conversions
This commit is contained in:
parent
f8af9833e1
commit
c4de5b057e
1 changed files with 14 additions and 4 deletions
|
@ -1112,17 +1112,27 @@
|
|||
;; Note this must be the count before additional closure/CPS arguments
|
||||
;; are added, so we need to detect those and not include them.
|
||||
(define (compute-num-args lam)
|
||||
AST TODO: lambda-num-args does not work for AST lambda's
|
||||
(let ((count (lambda-num-args lam))) ;; Current arg count, may be too high
|
||||
(let ((count (ast:lambda-num-args lam))) ;; Current arg count, may be too high
|
||||
(cond
|
||||
((< count 0) -1) ;; Unlimited
|
||||
(else
|
||||
AST TODO:
|
||||
(let ((formals (lambda-formals->list lam)))
|
||||
(let ((formals (ast:lambda-formals->list lam)))
|
||||
(- count
|
||||
(if (fl/closure? formals) 1 0)
|
||||
(if (fl/cont? formals) 1 0)))))))
|
||||
|
||||
;; Minimum number of required arguments for a lambda
|
||||
(define (ast:lambda-num-args exp)
|
||||
(let ((type (ast:lambda-formals-type exp))
|
||||
(num (length (ast:lambda-formals->list exp))))
|
||||
(cond
|
||||
((equal? type 'args:varargs)
|
||||
-1) ;; Unlimited
|
||||
((equal? type 'args:fixed-with-varargs)
|
||||
(- num 1)) ;; Last arg is optional
|
||||
(else
|
||||
num))))
|
||||
|
||||
;; Formal list with a closure?
|
||||
(define (fl/closure? lis)
|
||||
(cond
|
||||
|
|
Loading…
Add table
Reference in a new issue