mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 23:37:38 +02:00
Only emit funcall macros that are used by the generated code
This commit is contained in:
parent
b946e75a02
commit
503770a899
2 changed files with 12 additions and 11 deletions
4
TODO
4
TODO
|
@ -1,9 +1,5 @@
|
|||
Working TODO list:
|
||||
|
||||
- Only emit funcall* / return_funcall* definitions for cases that are actually used.
|
||||
IE, do not emit funcall9 just because funcall10 is required
|
||||
|
||||
|
||||
- Error handling
|
||||
need to perform much more error handling of input code. one of the biggest is to report if a function is passed the wrong number of arguments, as this will result in segfauls, bad transport errors, etc downstream if it is allowed.
|
||||
|
||||
|
|
15
cgen.scm
15
cgen.scm
|
@ -87,15 +87,17 @@
|
|||
return 0;}")
|
||||
|
||||
;;; Auto-generation of C macros
|
||||
(define *c-call-arity* 5)
|
||||
(define *c-call-max-args* 128)
|
||||
(define *c-call-arity* (make-vector (+ 1 *c-call-max-args*) #f))
|
||||
|
||||
(define (set-c-call-arity! arity)
|
||||
(cond
|
||||
((not (number? arity))
|
||||
(error `(Non-numeric number of arguments received ,arity)))
|
||||
((> arity *c-call-max-args*)
|
||||
(error "Only support up to 128 arguments. Received: " arity))
|
||||
(else
|
||||
(if (> arity *c-call-arity*)
|
||||
(set! *c-call-arity* arity)))))
|
||||
(vector-set! *c-call-arity* arity #t))))
|
||||
|
||||
(define (emit-c-macros)
|
||||
(c-macro-declare-globals)
|
||||
|
@ -103,10 +105,13 @@
|
|||
(emit-c-arity-macros 0))
|
||||
|
||||
(define (emit-c-arity-macros arity)
|
||||
(when (<= arity *c-call-arity*)
|
||||
(when (<= arity *c-call-max-args*)
|
||||
(cond
|
||||
((or (= arity 1) (= arity 2)
|
||||
(vector-ref *c-call-arity* arity))
|
||||
(emit (c-macro-funcall arity))
|
||||
(emit (c-macro-return-funcall arity))
|
||||
(emit (c-macro-return-check arity))
|
||||
(emit (c-macro-return-check arity))))
|
||||
(emit-c-arity-macros (+ arity 1))))
|
||||
|
||||
(define (c-macro-return-funcall num-args)
|
||||
|
|
Loading…
Add table
Reference in a new issue