<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        Hi Eliot --<div><br></div><div>(Full)BlockClosure works fine. I am talking about CompiledBlock.</div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div><blockquote class='history_container' type='cite' style='border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;'>
                        <p style='color: #AAAAAA; margin-top: 10px;'>Am 14.12.2021 23:29:42 schrieb Eliot Miranda <eliot.miranda@gmail.com>:</p><div style='font-family:Arial,Helvetica,sans-serif'>
<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size: 10pt"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 14, 2021 at 2:27 PM Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div style="font-size: 10pt"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 14, 2021 at 5:19 AM Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de" target="_blank">marcel.taeumel@hpi.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div id="gmail-m_4256451230450006763gmail-m_-6590189067939936233__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: rgb(0,0,0);text-align: left" dir="ltr">Hi all --<div></div><div><br></div><div>Decompilation for instances of CompiledBlock is currently wrong. It just treats the CompiledMethod where the CompiledBlock is embedded.</div></div></blockquote><div><br></div><div style="font-size: 10pt">Well, it's been that way for a long time and there's something to do with method wrappers (see methodForDecompile) that I don't understand that makes me leery of just changing this.</div><div style="font-size: 10pt"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div id="gmail-m_4256451230450006763gmail-m_-6590189067939936233__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: rgb(0,0,0);text-align: left" dir="ltr"><div><br></div><div>Compare the following two examples:</div><div><br></div><div><div><span style="font-size: 13.3333px">[3+4] method "i.e., compiledCode" decompile decompileString.</span></div><div><span style="font-size: 13.3333px">[3+4] decompile decompileString.</span></div></div><div><span style="font-size: 13.3333px"><br></span></div><div><span style="font-size: 13.3333px">Well, first, the message #method on FullBlockClosure  is misleading because we are looking for the compiled-code object, which is an instance of CompiledBlock here.</span></div><div><span style="font-size: 13.3333px"><br></span></div><div><span style="font-size: 13.3333px">Anyway, I then tried to understand how to make Decompiler >> decompileBlock: work for CompiledBlock and not just FullBlockClosure. It turns out, that there is no #pc set in any decompiled parse node.</span></div><div><span style="font-size: 13.3333px"><br></span></div><div><span style="font-size: 13.3333px">How to find a CompiledBlock's parse node in a CompiledMethod's parse tree?</span></div></div></blockquote><div><br></div><div><div style="font-size: 10pt">See Decompiler>>decompileBlock:</div><br></div><span class="gmail_default" style="font-size: 10pt">| block |</span></div><div class="gmail_quote"><span class="gmail_default" style="font-size: 10pt">block := [3+4].</span></div><div class="gmail_quote"><span class="gmail_default" style="font-size: 10pt">block</span> method decompileWithTemps nodesDo:<br><div><span class="gmail_default" style="font-size: 10pt">    </span>[:node| (node pc isVariableBinding and: [node pc key = <span class="gmail_default" style="font-size: 10pt">block</span> method]) ifTrue: [^node]] </div><div><br></div><div><div style="font-size: 10pt">=>  {[3 + 4]} </div><div style="font-size: 10pt"><br></div><div style="font-size: 10pt">i.e. the decompiler carefully sets the pc of a full block node to an association so you can find the thing.</div></div></div></div></blockquote><div><br></div><div class="gmail_default" style="font-size: 10pt">and #== works the same/is to be preferred:</div><div class="gmail_default" style="font-size: 10pt"><br></div>| block |<br>block := [3+4].<br>block method decompileWithTemps nodesDo:<br><div class="gmail_default" style="font-size: 10pt">    [:node| (node pc isVariableBinding and: [node pc key == block method]) ifTrue: [^node]]</div><div class="gmail_default" style="font-size: 10pt"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><div style="font-size: 10pt"><br></div><div style="font-size: 10pt">Now, as far as changing things to work the way you expect, I don't object, provided you check out MethodWrappers, etc.</div></div><div style="font-size: 10pt">CompiledMethod>>methodForDecompile has my initials on it, but I didn't write it.  So what its comment means I don't know but we shoud find out before we break things.</div><div style="font-size: 10pt"><br></div><div style="font-size: 10pt">CompiledMethod>>methodForDecompile<br>    "This is a hook to allow recursive methods like MwMethodWrapper to avoid infinite recursion."<br>    ^self<br></div><div style="font-size: 10pt"><br></div><div style="font-size: 10pt">I *really* don't like this method, but presumably it's there for a reason.</div><div style="font-size: 10pt"><br></div></div><div dir="ltr"><div dir="ltr"><div><span style="font-size: 10pt;border-collapse: separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size: 10pt;border-collapse: separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>
</div></blockquote>
                                        </div></body>