mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 08:17:35 +02:00
Validate number of args to prims
This commit is contained in:
parent
8d8c6fcd06
commit
a72a7e1718
2 changed files with 17 additions and 15 deletions
|
@ -305,17 +305,19 @@
|
||||||
(string-append
|
(string-append
|
||||||
prefix
|
prefix
|
||||||
(number->string expected)
|
(number->string expected)
|
||||||
" args but received "
|
" arguments to "
|
||||||
|
(symbol->string sym)
|
||||||
|
" but received "
|
||||||
(number->string actual)
|
(number->string actual)
|
||||||
))))
|
))))
|
||||||
(cond
|
(cond
|
||||||
((not expected) #t)
|
((not expected) #t)
|
||||||
((and (car expected)
|
|
||||||
(> num-args (car expected)))
|
|
||||||
(error (build-error-str "Expected " (car expected) num-args) sym))
|
|
||||||
((and (not (null? (cdr expected)))
|
((and (not (null? (cdr expected)))
|
||||||
(cadr expected)
|
(cadr expected)
|
||||||
(< num-args (cadr expected)))
|
(> num-args (cadr expected)))
|
||||||
|
(error (build-error-str "Expected " (car expected) num-args) sym))
|
||||||
|
((and (car expected)
|
||||||
|
(< num-args (car expected)))
|
||||||
(error (build-error-str "Expected at least " (car expected) num-args) sym))
|
(error (build-error-str "Expected at least " (car expected) num-args) sym))
|
||||||
(else #t))))
|
(else #t))))
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
(scheme cyclone primitives)
|
(scheme cyclone primitives)
|
||||||
(scheme cyclone pretty-print)
|
(scheme cyclone pretty-print)
|
||||||
(scheme cyclone util)
|
(scheme cyclone util)
|
||||||
; (srfi 69)
|
(srfi 69)
|
||||||
)
|
)
|
||||||
(export
|
(export
|
||||||
*defined-macros*
|
*defined-macros*
|
||||||
|
@ -1297,8 +1297,8 @@
|
||||||
;;
|
;;
|
||||||
;; Helpers to syntax check primitive calls
|
;; Helpers to syntax check primitive calls
|
||||||
;;
|
;;
|
||||||
;(define *prim-args-table*
|
(define *prim-args-table*
|
||||||
; (alist->hash-table *primitives-num-args*))
|
(alist->hash-table *primitives-num-args*))
|
||||||
|
|
||||||
;; CPS conversion
|
;; CPS conversion
|
||||||
;;
|
;;
|
||||||
|
@ -1347,13 +1347,13 @@
|
||||||
cont-ast)))))
|
cont-ast)))))
|
||||||
|
|
||||||
((prim-call? ast)
|
((prim-call? ast)
|
||||||
;(prim:check-arg-count
|
(prim:check-arg-count
|
||||||
; (car ast)
|
(car ast)
|
||||||
; (- (length ast) 1)
|
(- (length ast) 1)
|
||||||
; (hash-table-ref/default
|
(hash-table-ref/default
|
||||||
; *prim-args-table*
|
*prim-args-table*
|
||||||
; (car ast)
|
(car ast)
|
||||||
; #f))
|
#f))
|
||||||
(cps-list (cdr ast) ; args to primitive function
|
(cps-list (cdr ast) ; args to primitive function
|
||||||
(lambda (args)
|
(lambda (args)
|
||||||
(list cont-ast
|
(list cont-ast
|
||||||
|
|
Loading…
Add table
Reference in a new issue