From d078e4d1c16f1500aab6db193038ade3dafc7ef7 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 15 Sep 2016 18:47:21 -0400 Subject: [PATCH] WIP --- scheme/cyclone/util.sld | 10 +++++++--- scheme/eval.sld | 13 +++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/scheme/cyclone/util.sld b/scheme/cyclone/util.sld index 75a6fa25..f234b57e 100644 --- a/scheme/cyclone/util.sld +++ b/scheme/cyclone/util.sld @@ -483,11 +483,11 @@ (let ((renamed (gensym identifier))) (env:define-variable! renamed val mac-env) renamed)) - #;((not (eq? val 'not-defined)) + #;((eq? val 'not-defined) ;; Unrenamed variable identifier (let ((renamed (gensym identifier))) (env:define-variable! renamed identifier use-env) - (env:define-variable! renamed val mac-env) + ;(env:define-variable! renamed val mac-env) (Cyc-write `(ER rename ,identifier to ,renamed) (current-output-port)) (Cyc-display "\n" (current-output-port)) renamed) @@ -524,7 +524,11 @@ ;; TODO: this is not good enough, need to determine if these symbols ;; are the same identifier in their *environment of use* (lambda (a b) - (eq? a b))) + (let ((aval (env:lookup a use-env #f)) + (bval (env:lookup b use-env #f))) + (if (and aval bval) + (eq? aval bval) + (eq? a b))))) ;; Name-mangling. diff --git a/scheme/eval.sld b/scheme/eval.sld index 8d9bf6b5..98ea18be 100644 --- a/scheme/eval.sld +++ b/scheme/eval.sld @@ -13,7 +13,7 @@ ;(scheme cyclone libraries) ;; for handling import sets (scheme base) (scheme file) - ;(scheme write) ;; Only used for debugging + (scheme write) ;; Only used for debugging (scheme read)) (export ;environment @@ -341,7 +341,7 @@ (define (analyze exp env) ;(newline) ;(display "/* ") -;(display (list 'analyze exp)) +;(write (list 'analyze exp)) ;(display " */") (cond ((self-evaluating? exp) (analyze-self-evaluating exp)) @@ -436,20 +436,21 @@ #f)) (expand (lambda (macro-op) + (define use-env (env:extend-environment '() '() '())) (if (Cyc-macro? macro-op) ;; Compiled macro, call directly (analyze (apply macro-op (list (cons (car exp) (operands exp)) - (Cyc-er-rename a-env a-env) - (Cyc-er-compare? a-env))) + (Cyc-er-rename use-env a-env) + (Cyc-er-compare? use-env))) a-env) ;; Interpreted macro, build expression and eval (let ((expr (cons macro-op (list (cons 'quote (list (cons (car exp) (operands exp)))) - (Cyc-er-rename a-env a-env) - (Cyc-er-compare? a-env))))) + (Cyc-er-rename use-env a-env) + (Cyc-er-compare? use-env))))) (analyze (eval expr a-env) ;; Expand macro a-env))))))