mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
WIP - store allocated lambda id
This commit is contained in:
parent
d4e3c65ca7
commit
f461e26fa4
1 changed files with 9 additions and 5 deletions
|
@ -741,7 +741,7 @@
|
||||||
(fun (app->fun exp)))
|
(fun (app->fun exp)))
|
||||||
(cond
|
(cond
|
||||||
((ast:lambda? fun)
|
((ast:lambda? fun)
|
||||||
(let* ((lid (allocate-lambda (c-compile-lambda fun trace #t))) ;; TODO: pass in free vars? may be needed to track closures
|
(let* ((lid (allocate-lambda fun (c-compile-lambda fun trace #t))) ;; TODO: pass in free vars? may be needed to track closures
|
||||||
;; properly, wait until this comes up in an example
|
;; properly, wait until this comes up in an example
|
||||||
(this-cont (string-append "__lambda_" (number->string lid)))
|
(this-cont (string-append "__lambda_" (number->string lid)))
|
||||||
(cgen
|
(cgen
|
||||||
|
@ -1043,7 +1043,7 @@
|
||||||
,(caddr exp) ;; Args
|
,(caddr exp) ;; Args
|
||||||
,(cadddr exp) ;; Body
|
,(cadddr exp) ;; Body
|
||||||
))
|
))
|
||||||
(lid (allocate-lambda lambda-data))
|
(lid (allocate-lambda #f lambda-data))
|
||||||
(total-num-args
|
(total-num-args
|
||||||
(let ((count 1)) ;; Start at 1 because there will be one less comma than args
|
(let ((count 1)) ;; Start at 1 because there will be one less comma than args
|
||||||
(string-for-each
|
(string-for-each
|
||||||
|
@ -1117,13 +1117,17 @@
|
||||||
;; of cgen lambda ID to it, in order to use data from the
|
;; of cgen lambda ID to it, in order to use data from the
|
||||||
;; analysis DB later on during code generation.
|
;; analysis DB later on during code generation.
|
||||||
;;
|
;;
|
||||||
; allocate-lambda : (string -> string) -> lambda-id
|
; allocate-lambda : (Either ast boolean) -> (string -> string) -> lambda-id
|
||||||
(define (allocate-lambda lam . cps?)
|
(define (allocate-lambda ast:lam lam . cps?)
|
||||||
(let ((id num-lambdas))
|
(let ((id num-lambdas))
|
||||||
(set! num-lambdas (+ 1 num-lambdas))
|
(set! num-lambdas (+ 1 num-lambdas))
|
||||||
(set! lambdas (cons (list id lam) lambdas))
|
(set! lambdas (cons (list id lam) lambdas))
|
||||||
(if (equal? cps? '(#f))
|
(if (equal? cps? '(#f))
|
||||||
(set! inline-lambdas (cons id inline-lambdas)))
|
(set! inline-lambdas (cons id inline-lambdas)))
|
||||||
|
(when ast:lam
|
||||||
|
;; TODO: store the allocated ID within the adbf
|
||||||
|
'todo
|
||||||
|
)
|
||||||
id))
|
id))
|
||||||
|
|
||||||
; get-lambda : lambda-id -> (symbol -> string)
|
; get-lambda : lambda-id -> (symbol -> string)
|
||||||
|
@ -1223,7 +1227,7 @@
|
||||||
(mangle free-var)))
|
(mangle free-var)))
|
||||||
(closure->fv exp))) ; Note these are not necessarily symbols, but in cc form
|
(closure->fv exp))) ; Note these are not necessarily symbols, but in cc form
|
||||||
(cv-name (mangle (gensym 'c)))
|
(cv-name (mangle (gensym 'c)))
|
||||||
(lid (allocate-lambda (c-compile-lambda lam trace cps?) cps?))
|
(lid (allocate-lambda lam (c-compile-lambda lam trace cps?) cps?))
|
||||||
(macro? (assoc (st:->var trace) (get-macros)))
|
(macro? (assoc (st:->var trace) (get-macros)))
|
||||||
(call/cc? (and (equal? (car trace) "scheme/base.sld")
|
(call/cc? (and (equal? (car trace) "scheme/base.sld")
|
||||||
(equal? (st:->var trace) 'call/cc)))
|
(equal? (st:->var trace) 'call/cc)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue