From e1d7ac548f6bfec14f0e27ca0e8c0893b282556d Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 18 May 2016 22:06:10 -0400 Subject: [PATCH] CPS optimization --- scheme/cyclone/cps-optimizations.sld | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scheme/cyclone/cps-optimizations.sld b/scheme/cyclone/cps-optimizations.sld index f9e83e94..918fde9e 100644 --- a/scheme/cyclone/cps-optimizations.sld +++ b/scheme/cyclone/cps-optimizations.sld @@ -233,12 +233,14 @@ (cond ; Core forms: ((ast:lambda? exp) - ;(let ((fnc (adb:get id))) - ;; TODO: simplify if necessary - (ast:%make-lambda - (ast:lambda-id exp) - (ast:lambda-args exp) - (opt:contract (ast:lambda-body exp))));) + (let* ((id (ast:lambda-id exp)) + (fnc (adb:get id))) + (if (adbf:simple fnc) + (opt:contract (caar (ast:lambda-body exp))) ;; Optimize-out the lambda + (ast:%make-lambda + (ast:lambda-id exp) + (ast:lambda-args exp) + (opt:contract (ast:lambda-body exp)))))) ((const? exp) exp) ((ref? exp) exp) ((prim? exp) exp) @@ -267,6 +269,7 @@ (analyze-cps ast) (trace:info "---------------- cps analysis db:") (trace:info (adb:get-db)) + ;ast ;; DEBUGGING!!! (opt:contract ast) ) ))