<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><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">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_-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 class="gmail_default" style="font-size:small">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 class="gmail_default" style="font-size:small"><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_-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 class="gmail_default" style="font-size:small">See Decompiler>>decompileBlock:</div><br></div><span class="gmail_default" style="font-size:small">| block |</span></div><div class="gmail_quote"><span class="gmail_default" style="font-size:small">block := [3+4].</span></div><div class="gmail_quote"><span class="gmail_default" style="font-size:small">block</span> method decompileWithTemps nodesDo:<br><div><span class="gmail_default" style="font-size:small">    </span>[:node| (node pc isVariableBinding and: [node pc key = <span class="gmail_default" style="font-size:small">block</span> method]) ifTrue: [^node]] </div><div><br></div><div><div class="gmail_default" style="font-size:small">=>  {[3 + 4]} </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">i.e. the decompiler carefully sets the pc of a full block node to an association so you can find the thing.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">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 class="gmail_default" style="font-size:small">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 class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">CompiledMethod>>methodForDecompile<br>    "This is a hook to allow recursive methods like MwMethodWrapper to avoid infinite recursion."<br>    ^self<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I *really* don't like this method, but presumably it's there for a reason.</div><div class="gmail_default" style="font-size:small"><br></div></div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>