<div dir="ltr"><div>Hi Christoph,</div><div>Sure, it's a duplicate. Feel free to republish your original fix.</div><div>We might probably also want to fix the Decompiler.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 17 avr. 2020 à 13:43, Thiede, Christoph <<a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de">Christoph.Thiede@student.hpi.uni-potsdam.de</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div>


<div dir="ltr">
<div id="gmail-m_3438800036161332674x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif">
<p>Hi Nicolas,</p>
<p><br>
</p>
<p>is this a duplicate of fix caseerror.1.cs (<a href="http://forum.world.st/Problems-with-caseError-tp5111930p5112255.html" id="gmail-m_3438800036161332674LPlnk492663" target="_blank">http://forum.world.st/Problems-with-caseError-tp5111930p5112255.html</a>)?</p>
<br>
<p><span style="font-size:12pt">Best,</span><br>
</p>
<p>Christoph</p>
<div id="gmail-m_3438800036161332674x_Signature">
<div id="gmail-m_3438800036161332674x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div name="x_divtagdefaultwrapper">
<div>
<div id="gmail-m_3438800036161332674x_Item.MessagePartBody">
<div id="gmail-m_3438800036161332674x_Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="gmail-m_3438800036161332674x_divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="gmail-m_3438800036161332674x_Signature">
<div style="margin:0px"><font style="font-family:Calibri,Arial,Helvetica,sans-serif,serif,EmojiFont">
<div><font size="3" color="black"><span style="font-size:12pt"><a href="http://www.hpi.de/" rel="noopener noreferrer" id="gmail-m_3438800036161332674LPNoLP" target="_blank"><font size="2"><span id="gmail-m_3438800036161332674LPlnk909538"><font color="#757B80"></font></span></font></a></span></font></div>
</font></div>
</div>
</font></div>
</div>
</div>
</div>
</div>
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_3438800036161332674x_divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>Von:</b> Squeak-dev <<a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org" target="_blank">squeak-dev-bounces@lists.squeakfoundation.org</a>> im Auftrag von <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> <<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>><br>
<b>Gesendet:</b> Freitag, 17. April 2020 12:52:18<br>
<b>An:</b> <a href="mailto:squeak-dev@lists.squeakfoundation.org" target="_blank">squeak-dev@lists.squeakfoundation.org</a><br>
<b>Betreff:</b> [squeak-dev] The Inbox: Compiler-nice.427.mcz</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt">
<div>Nicolas Cellier uploaded a new version of Compiler to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Compiler-nice.427.mcz" target="_blank">http://source.squeak.org/inbox/Compiler-nice.427.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Compiler-nice.427<br>
Author: nice<br>
Time: 17 April 2020, 12:52:15.465993 pm<br>
UUID: 1ea19d4a-47f4-4c94-8fef-2b43c99f2b04<br>
Ancestors: Compiler-ct.426<br>
<br>
Fixup: caseError must be sent to the receiver of the caseOf: message, not to the receiver of the home method.<br>
<br>
For this, we must also dup/pop in the last case whenever there is no otherwise argument.<br>
<br>
TODO: also fix the Decompiler...<br>
<br>
=============== Diff against Compiler-ct.426 ===============<br>
<br>
Item was changed:<br>
  ----- Method: MessageNode>>emitCodeForCase:encoder:value: (in category 'code generation') -----<br>
  emitCodeForCase: stack encoder: encoder value: forValue<br>
  <br>
         | braceNode sizeStream allReturn |<br>
         forValue ifFalse:<br>
                 [^super emitCodeForEffect: stack encoder: encoder].<br>
         braceNode := arguments first.<br>
         sizeStream := ReadStream on: sizes.<br>
         receiver emitCodeForValue: stack encoder: encoder.<br>
         "There must be at least one branch around the otherwise/caseError<br>
           so the decompiler can identify the end of the otherwise/caseError."<br>
         allReturn := true. "assume every case ends with a return"<br>
         braceNode casesForwardDo:<br>
                 [:keyNode :valueNode :last | | thenSize elseSize |<br>
                 thenSize := sizeStream next.<br>
                 elseSize := sizeStream next.<br>
+                (last and: [arguments size = 2]) ifFalse: [encoder genDup. stack push: 1].<br>
-                last ifFalse: [encoder genDup. stack push: 1].<br>
                 keyNode emitCodeForEvaluatedValue: stack encoder: encoder.<br>
                 keyNode pc: encoder nextPC.<br>
                 equalNode emitCode: stack args: 1 encoder: encoder.<br>
                 self emitCodeForBranchOn: false dist: thenSize pop: stack encoder: encoder.<br>
+                (last and: [arguments size = 2]) ifFalse: [encoder genPop. stack pop: 1].<br>
-                last ifFalse: [encoder genPop. stack pop: 1].<br>
                 valueNode emitCodeForEvaluatedValue: stack encoder: encoder.<br>
+                (last and: [arguments size = 2]) ifTrue: [stack pop: 1].<br>
-                last ifTrue: [stack pop: 1].<br>
                 valueNode returns ifFalse:<br>
                         [self emitCodeForJump: elseSize encoder: encoder.<br>
                          allReturn := false].<br>
                 (last and: [allReturn]) ifTrue:<br>
                         [self emitCodeForJump: elseSize encoder: encoder]].<br>
         arguments size = 2<br>
                 ifTrue:<br>
                         [arguments last emitCodeForEvaluatedValue: stack encoder: encoder] "otherwise: [...]"<br>
                 ifFalse:<br>
+                        ["the receiver of caseOf: has been previously dup, just send"<br>
-                        [NodeSelf emitCodeForValue: stack encoder: encoder.<br>
                         caseErrorNode emitCode: stack args: 0 encoder: encoder]!<br>
<br>
Item was changed:<br>
  ----- Method: MessageNode>>sizeCodeForCase:value: (in category 'code generation') -----<br>
  sizeCodeForCase: encoder value: forValue<br>
  <br>
         | braceNode sizeIndex elseSize allReturn |<br>
         forValue not ifTrue:<br>
                 [^super sizeCodeForEffect: encoder].<br>
         equalNode := encoder encodeSelector: #=.<br>
         braceNode := arguments first.<br>
         sizes := Array new: 2 * braceNode numElements.<br>
         sizeIndex := sizes size.<br>
         elseSize := arguments size = 2<br>
                 ifTrue:<br>
                         [arguments last sizeCodeForEvaluatedValue: encoder] "otherwise: [...]"<br>
                 ifFalse:<br>
                         [caseErrorNode := encoder encodeSelector: #caseError.<br>
+                         "Assume that the receiver of caseOf: has been dup"<br>
+                        (caseErrorNode sizeCode: encoder args: 0 super: false)]. "self caseError"<br>
-                         (NodeSelf sizeCodeForValue: encoder)<br>
-                         + (caseErrorNode sizeCode: encoder args: 0 super: false)]. "self caseError"<br>
         "There must be at least one branch around the otherwise/caseError<br>
           so the decompiler can identify the end of the otherwise/caseError."<br>
         allReturn := true. "assume every case ends with a return"<br>
         braceNode casesForwardDo:<br>
                 [:keyNode :valueNode :last |<br>
                 valueNode returns ifFalse: [allReturn := false]].<br>
         braceNode casesReverseDo:<br>
                 [:keyNode :valueNode :last | | thenSize |<br>
                 sizes at: sizeIndex put: elseSize.<br>
                 thenSize := valueNode sizeCodeForEvaluatedValue: encoder.<br>
+                (last and: [arguments size = 2]) ifFalse: [thenSize := thenSize + encoder sizePop].<br>
-                last ifFalse: [thenSize := thenSize + encoder sizePop].<br>
                 valueNode returns ifFalse: [thenSize := thenSize + (self sizeCode: encoder forJump: elseSize)].<br>
                 (last and: [allReturn]) ifTrue: [thenSize := thenSize + (self sizeCode: encoder forJump: elseSize)].<br>
                 sizes at: sizeIndex-1 put: thenSize.<br>
+                (last and: [arguments size = 2]) ifFalse: [elseSize := elseSize + encoder sizeDup].<br>
-                last ifFalse: [elseSize := elseSize + encoder sizeDup].<br>
                 elseSize := elseSize<br>
                                         + (keyNode sizeCodeForEvaluatedValue: encoder)<br>
                                         + (equalNode sizeCode: encoder args: 1 super: false)<br>
                                         + (self sizeCode: encoder forBranchOn: false dist: thenSize)<br>
                                         + thenSize.<br>
                 sizeIndex := sizeIndex - 2].<br>
         ^(receiver sizeCodeForValue: encoder) + elseSize!<br>
<br>
<br>
</div>
</span></font>
</div>

<br>
</blockquote></div>