This commit is contained in:
Justin Ethier 2018-09-26 11:10:49 -04:00
parent ea7f401e77
commit 92fb2c176d
3 changed files with 21 additions and 15 deletions

View file

@ -24,6 +24,7 @@
ast:lambda-has-cont ast:lambda-has-cont
ast:set-lambda-has-cont! ast:set-lambda-has-cont!
ast:get-next-lambda-id! ast:get-next-lambda-id!
ast:reset-lambda-ids!
ast:ast->pp-sexp ast:ast->pp-sexp
ast:ast->sexp ast:ast->sexp
ast:sexp->ast ast:sexp->ast
@ -39,6 +40,9 @@
(set! *lambda-id* (+ 1 *lambda-id*)) (set! *lambda-id* (+ 1 *lambda-id*))
*lambda-id*) *lambda-id*)
(define (ast:reset-lambda-ids!)
(set! *lambda-id* 0))
(define-record-type <lambda-ast> (define-record-type <lambda-ast>
(ast:%make-lambda id args body has-cont) (ast:%make-lambda id args body has-cont)
ast:lambda? ast:lambda?

View file

@ -894,21 +894,21 @@
");"))) ");")))
(else (else
;;TODO: need to handle well-known functions: ;;TODO: need to handle well-known functions:
(let* ((wkf (well-known-lambda (car args))) ; (let* ((wkf (well-known-lambda (car args)))
(fnc (if wkf (adb:get/default (ast:lambda-id wkf) #f) #f)) ; (fnc (if wkf (adb:get/default (ast:lambda-id wkf) #f) #f))
) ; )
(when (and wkf fnc ; (when (and wkf fnc
(adbf:well-known fnc) ;; not really needed ; (adbf:well-known fnc) ;; not really needed
(equal? (adbf:closure-size fnc) 1)) ; (equal? (adbf:closure-size fnc) 1))
(trace:error `(JAE found well-known lambda in closure-ref call ; (trace:error `(JAE found well-known lambda in closure-ref call
,(car args) ; ,(car args)
,wkf ; ,wkf
;TODO: this is not going to work, we are going to need to use ast:lambda-id instead of ;;TODO: this is not going to work, we are going to need to use ast:lambda-id instead of
;an allocation ID. make that change in allocate-lambda, disable all WKL code, and make ;;an allocation ID. make that change in allocate-lambda, disable all WKL code, and make
;sure it is stable before proceeding... ;;sure it is stable before proceeding...
cgen id ,(adbf:cgen-id fnc) ; cgen id ,(adbf:cgen-id fnc)
))) ; )))
) ; )
(set-c-call-arity! (c:num-args cargs)) (set-c-call-arity! (c:num-args cargs))
(c-code (c-code
(string-append (string-append

View file

@ -1609,6 +1609,8 @@
((app? exp) ((app? exp)
(map (lambda (e) (scan e)) exp)) (map (lambda (e) (scan e)) exp))
(else exp))) (else exp)))
(ast:reset-lambda-ids!) ;; Convenient to start back from 1
(let ((result (scan exp))) (let ((result (scan exp)))
(adb:clear!) (adb:clear!)
(analyze-cps result) (analyze-cps result)