mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 07:17:37 +02:00
Compute number of arguments
This commit is contained in:
parent
ae22ecffbe
commit
4ab9f085fd
1 changed files with 13 additions and 6 deletions
|
@ -995,16 +995,23 @@
|
||||||
|
|
||||||
;; TODO: not tested, does not work yet:
|
;; TODO: not tested, does not work yet:
|
||||||
(define (c-compile-raw-global-lambda exp append-preamble cont trace)
|
(define (c-compile-raw-global-lambda exp append-preamble cont trace)
|
||||||
(let* (
|
(let* ((lambda-data
|
||||||
;(fnc-name (string-append "static void __lambda_" (number->string lid)))
|
|
||||||
(lambda-data
|
|
||||||
`(precompiled-lambda
|
`(precompiled-lambda
|
||||||
,(caddr exp) ;; Args
|
,(caddr exp) ;; Args
|
||||||
,(cadddr exp) ;; Body
|
,(cadddr exp) ;; Body
|
||||||
))
|
))
|
||||||
(lid (allocate-lambda lambda-data))
|
(lid (allocate-lambda lambda-data))
|
||||||
;(lid 999) ;; TODO: (allocate-lambda lambda-data))
|
(total-num-args
|
||||||
)
|
(let ((count 1)) ;; Start at 1 because there will be one less comma than args
|
||||||
|
(string-for-each
|
||||||
|
(lambda (c)
|
||||||
|
(if (equal? #\, c) (set! count (+ count 1))))
|
||||||
|
(caddr exp))
|
||||||
|
count)) ;; args
|
||||||
|
;; Subtract "internal" args added for runtime
|
||||||
|
(num-args
|
||||||
|
(- total-num-args 4))
|
||||||
|
)
|
||||||
(add-global
|
(add-global
|
||||||
(define->var exp)
|
(define->var exp)
|
||||||
#t ;(lambda? body)
|
#t ;(lambda? body)
|
||||||
|
@ -1014,7 +1021,7 @@
|
||||||
(list
|
(list
|
||||||
(string-append "mclosure0(" cv-name ", (function_type)__lambda_"
|
(string-append "mclosure0(" cv-name ", (function_type)__lambda_"
|
||||||
(number->string lid) ");" cv-name ".num_args = "
|
(number->string lid) ");" cv-name ".num_args = "
|
||||||
(number->string 2) ;; TODO: figure out number of args
|
(number->string num-args)
|
||||||
";")))
|
";")))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue