From cba24e923d8cdd1afa80f8d828c69bcfacc81eaa Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 10 Jul 2018 06:45:42 -0700 Subject: compiler: duplicated code when compiling switch. * share/txr/stdlib/compiler.tl (compiler comp-ift): Fix incorrect reference to the vec function rather than the cases-vec local variable. Thus the variable shared is now correctly calculated, and switch syntax which implements fall through cases via a single block of shared code is now translated properly as one block of instructions with with multiple entry points. --- share/txr/stdlib/compiler.tl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index be76f470..04a92bf5 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -532,8 +532,8 @@ (defmeth compiler comp-switch (me oreg env form) (mac-param-bind form (op idx-form cases-vec) form (let* ((ncases (len cases-vec)) - (cs (and (plusp ncases) (conses [vec 0]))) - (shared (and cs (all [vec 1..:] (op memq @1 cs)))) + (cs (and (plusp ncases) (conses [cases-vec 0]))) + (shared (and cs (all [cases-vec 1..:] (op memq @1 cs)))) (cases (if shared (let ((cs-nil ^(,*cs nil))) [mapcar ldiff cs-nil (cdr cs-nil)]) -- cgit v1.2.3