<br><br><div class="gmail_quote">On Fri, Dec 2, 2011 at 5:13 PM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div class="im">On Fri, Dec 2, 2011 at 4:01 PM, Juan Vuletich <span dir="ltr"><<a href="mailto:juan@jvuletich.org" target="_blank">juan@jvuletich.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Eliot Miranda wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Juan,<br>
<br>
...<div><br>
<br>
<br>
I can say that it does indeed work. But I'd be really grateful if<br>
Eliot took a good look at that code!<br>
<br>
<br>
There is a much better way, using InstructionStream>><u></u>interpreetNextInstructionFor: which abstracts away from the bytecode encoding and allows one to simply use messages. e.g. look at <br>
<br></div><div>
and (SortedCollection sortBlock: [:a :b| a compare: b caseSensitive: false]) sortBlock abstractBytecodes evaluates to<br>
<br>
an OrderedCollection(#<u></u>pushTemporaryVariable: #pushTemporaryVariable: #pushConstant: #send:super:numArgs:)<br>
<br>
So a check for clean blocks would check for a block's abstractBytecodes not including some particular set of banned messages (which I *think* is pushReceiver pushReceiverVariable: popIntoReceiverVariable: storeIntoReceiverVariable: methodReturnConstant: methodReturnReceiver methodReturnTop).<br>
<br>
e.g.<br>
<br>
isClean<br>
^(self abstractBytecodes intersection: #(pushReceiver pushReceiverVariable: popIntoReceiverVariable: storeIntoReceiverVariable: methodReturnConstant: methodReturnReceiver methodReturnTop)) isEmpty<br>
<br>
<br>
Cheers,<br>
Juan Vuletich<br>
<br>
<br>
<br>
<br></div>
-- <br>
best,<br>
Eliot<br>
<br>
</blockquote>
<br>
Thanks Eliot. However, it looks to me that this needs more tweaking. </blockquote><div><br></div></div><div><blush>Damn right :) I've done zero testing. It was just an example</blush></div><div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
For instance, your method answers true for<br>
[ xx size ] isClean<br>
and<br>
[ ^ nil ] isClean<br>
while mine answers false for both. Maybe we could serialize non local returns using the Compiler (although we won't be able to return anywhere), but external variable acess is a problem.<br>
<br>
Will keep playing with this for a while...<br></blockquote><div><br></div></div><div>Can you (can I??) write some tests? What's xx in the above? Ah! [^nil] isn't clean in my code since it should be pc <= end, not pc < end!! Try the attached...</div>
</div></blockquote><div><br></div><div>having played around with this some it strikes me we might want a method that checks whether a block refers only to block local variables and constants, or block locals, globals and constants. Say BlockClosure>>isSqueakyClean ;)</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br><font color="#888888">
Juan Vuletich<br>
<br>
</font></blockquote></div><font color="#888888"><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
</font></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>