List Info

Thread: last tests patch for a while -- ParseTreeRewriter




last tests patch for a while -- ParseTreeRewriter
country flaguser name
Switzerland
2007-05-22 03:17:27
This incorporates Stephen's ParseTreeRewriter tests, and
fixes the bugs 
exposed by the tests.

Paolo

_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

  
Re: last tests patch for a while -- ParseTreeRewriter
country flaguser name
United States
2007-05-22 19:19:00
On Tue, 2007-05-22 at 10:17 +0200, Paolo Bonzini wrote:
> -	    newValue := oldContext at: key put: value
"deepCopy <<<".
> +	    newValue := oldContext at: key put: value
deepCopy "<<<".

Quick postscript on this: I originally used `value collect:
[:each |
each copy]' instead of deepCopy because value may be a node
instead of a
list of nodes.  (RBProgramNode has 'collect: aBlock  ^aBlock
value:
self'.)  So deepCopy copies the 'parent' instvar, which
copies the value
and everything else in its tree.

The duplicate tree becomes garbage once the copied node is
inserted back
into the original tree, but I thought it was worth avoiding
anyway.  In
very rare cases, copying the parent's tree might cause
problems with
rewriters computed under #recusivelySearchInContext.

-- 
;;; Stephen Compall ** http://scompall.no
candysw.com/blog **
Failure to imagine vast possibilities usually stems from a
lack of
imagination, not a lack of possibility.

_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

Re: Re: last tests patch for a while -- ParseTreeRewriter
country flaguser name
Switzerland
2007-05-23 01:24:45
Stephen Compall wrote:
> On Tue, 2007-05-22 at 10:17 +0200, Paolo Bonzini
wrote:
>> -	    newValue := oldContext at: key put: value
"deepCopy <<<".
>> +	    newValue := oldContext at: key put: value
deepCopy "<<<".
> 
> Quick postscript on this: I originally used `value
collect: [:each |
> each copy]' instead of deepCopy because value may be a
node instead of a
> list of nodes.  (RBProgramNode has 'collect: aBlock 
^aBlock value:
> self'.)  So deepCopy copies the 'parent' instvar, which
copies the value
> and everything else in its tree.


Thanks for the explanation.  I added instead this one:

--- orig/compiler/RBParseNodes.st
+++ mod/compiler/RBParseNodes.st
 -253,6
+253,13  nodesDo: aBlock

  !RBProgramNode methodsFor: 'enumeration'!

+deepCopy
+    "Hacked to fit collection protocols.  We use
#deepCopy to obtain a list
+     of copied nodes.  We do already copy for our instance
variables
+     through #postCopy, so we redirect #deepCopy to be a
normal #copy."
+
+    ^self copy
+
  collect: aBlock
      "Hacked to fit collection protocols"


Thanks again for contributing these tests and bug fixes.  I
will contact 
other people I know that work on the refactoring browser in
order to 
have them merged.

Paolo



_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )