From 7d9aae56d80638c24325c6a3f5cd508f822faa02 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 14 Apr 2016 23:25:53 -0400 Subject: [PATCH] Added lib:rename-exports, made lib:exports handle renames --- scheme/cyclone/libraries.sld | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scheme/cyclone/libraries.sld b/scheme/cyclone/libraries.sld index 795af26c..a642026d 100644 --- a/scheme/cyclone/libraries.sld +++ b/scheme/cyclone/libraries.sld @@ -26,6 +26,7 @@ lib:name->symbol lib:result lib:exports + lib:rename-exports lib:imports lib:body lib:includes @@ -80,10 +81,23 @@ ;; TODO: most of these below assume 0 or 1 instances of the directive. ;; may need to replace some of these later with filter operations to ;; support more than 1 instance. -(define (lib:exports ast) +(define (lib:raw-exports ast) (lib:result (let ((code (assoc 'export (cddr ast)))) (if code (cdr code) #f)))) +(define (lib:rename-exports ast) + (filter + (lambda (ex) + (tagged-list? 'rename ex)) + (lib:raw-exports ast))) +(define (lib:exports ast) + (map + (lambda (ex) + ;; Replace any renamed exports + (if (tagged-list? 'rename ex) + (caddr ex) + ex)) + (lib:raw-exports ast))) (define (lib:imports ast) (lib:result (let ((code (assoc 'import (cddr ast))))