[slime-devel] Patch: suppress duplicated frame variables (Allegro)

Bradford W Miller Bradford_W_Miller at raytheon.com
Tue Jun 10 21:04:51 UTC 2008


Umm, did you test this against code like

(defun f (x y)
  (let ((y x)
          (x y))
   ...))

where there ARE both formal and local variables with the same name?

-- 
Bradford W. Miller
Cognitive/Computer Scientist/Engineer

Raytheon, Inc.
1847 West Main Road
Portsmouth, RI  02871-1087

(401) 842-3578



"Willem Broekema" <metawilm at gmail.com> 
Sent by: slime-devel-bounces at common-lisp.net
06/10/2008 04:28 PM

To
slime-devel at common-lisp.net
cc

Subject
[slime-devel] Patch: suppress duplicated frame variables (Allegro)






The Allegro debugger sometimes includes a local variable more than
once as a variable in a frame.
E.g.

(defun f (x y)
   (declare (optimize debug))
   (zut (bar x) y))

Allegro itself lists the frame variables as:

Compiled lexical environment:
0(required): x: 1
1(required): y: 2
2(local): y: 2

This patch suppresses the duplicates as shown by Slime (which does not
show the "required" / "local" labels).

- Willem


--- swank-allegro.lisp           10 Jun 2008 19:55:30 +0200 1.102
+++ swank-allegro.lisp           10 Jun 2008 22:16:09 +0200 
@@ -173,11 +173,16 @@
   (debugger:output-frame stream frame :moderate))

 (defimplementation frame-locals (index)
-  (let ((frame (nth-frame index)))
-    (loop for i from 0 below (debugger:frame-number-vars frame)
-                  collect (list :name (debugger:frame-var-name frame i)
-                                                :id 0
-                                                :value 
(debugger:frame-var-value frame i)))))
+  (let* ((frame (nth-frame index))
+         (locals (loop for i from 0 below (debugger:frame-number-vars 
frame)
+                     collect (cons (debugger:frame-var-name frame i)
+                                   (debugger:frame-var-value frame i)))))
+    ;; Remove e.g. function arguments duplicated as local variables.
+    (setq locals (delete-duplicates locals :test (lambda (x y)
+                                                   (and (eq (car x) (car 
y))
+                                                        (eq (cdr x)
(cdr y))))))
+    (loop for (name . val) in locals
+          collect (list :name name :id 0 :value val))))

 (defimplementation frame-var-value (frame var)
   (let ((frame (nth-frame frame)))
_______________________________________________
slime-devel site list
slime-devel at common-lisp.net
http://common-lisp.net/mailman/listinfo/slime-devel



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/slime-devel/attachments/20080610/0aa44e98/attachment.html>


More information about the slime-devel mailing list