mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Added validate:num-function-args
This commit is contained in:
parent
c22323e3ce
commit
74c545416c
1 changed files with 28 additions and 0 deletions
|
@ -48,6 +48,8 @@
|
|||
;; Analysis - well-known lambdas
|
||||
well-known-lambda
|
||||
analyze:find-known-lambdas
|
||||
;; Analysis - validation
|
||||
validate:num-function-args
|
||||
;; Analyze variables
|
||||
adb:make-var
|
||||
%adb:make-var
|
||||
|
@ -714,6 +716,7 @@
|
|||
,(analyze2 (if->else exp))))
|
||||
; Application:
|
||||
((app? exp)
|
||||
;(trace:info `(DEBUG ,exp ,(validate:num-function-args exp)))
|
||||
(for-each (lambda (e) (analyze2 e)) exp))
|
||||
(else #f)))
|
||||
|
||||
|
@ -2379,4 +2382,29 @@
|
|||
(set! *well-known-lambda-sym-lookup-tbl* candidates)
|
||||
)
|
||||
|
||||
|
||||
;; Analysis - validation section
|
||||
|
||||
;; Does given symbol define a procedure?
|
||||
;(define (avld:procedure? sym) #f)
|
||||
|
||||
;; Does the given function call pass enough arguments?
|
||||
(define (validate:num-function-args ast)
|
||||
(and-let* (((app? ast))
|
||||
((not (prim? (car ast))))
|
||||
((ref? (car ast)))
|
||||
(var (adb:get/default (car ast) #f))
|
||||
(lam* (adbv:assigned-value var))
|
||||
((pair? lam*))
|
||||
(lam (car lam*))
|
||||
((ast:lambda? lam))
|
||||
(formals-type (ast:lambda-formals-type lam))
|
||||
((equal? 'args:fixed formals-type)) ;; Could validate fixed-with-varargs, too
|
||||
(argc (length (ast:lambda-args lam)))
|
||||
)
|
||||
(cond
|
||||
((not (= argc (- (length ast) 1)))
|
||||
'error-not-enough-args))
|
||||
))
|
||||
|
||||
))
|
||||
|
|
Loading…
Add table
Reference in a new issue