<br><br><div class="gmail_quote">On Tue, Mar 3, 2009 at 12:09 PM, Igor Stasenko <span dir="ltr"><<a href="mailto:siguctua@gmail.com">siguctua@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>
2009/3/3 Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>>:<br>
<div><div></div><div class="h5">><br>
> Hi All,<br>
> I'm being bitten by Slang's treatment of bitShift: & >>. In both cases (generateBitShift:on:indent: & generateShiftRight:on:indent:) Slang generates an unsigned shift by explicitly casting the shifted expression to usqInt. I can understand the benefit of having an unsigned shift. But there are times when one really needs a signed shift. Further, the Smalltalk versions of both bitShift: and >> are signed shifts.<br>
> Dare I change e.g. generateShiftRight:on:indent: to leave the expression alone and generate either a signed or an unsigned shift based on the variable's declaration? Or must I live with a maddening cCode: '(signed)' inSmalltalk: [] carbuncle?<br>
> E.<br>
><br>
<br>
</div></div>I think an easier way would be to add:<br>
<br>
#<<+ #generateSignedShiftLeft:on:indent:<br>
#>>+ #generateSignedShiftRight:on:indent:<br>
<br>
in #initializeCTranslationDictionary<br>
so you can use:<br>
<br>
a <<+ b<br>
or<br>
a >>+ b<br>
<br>
without writing horrible cCode:</blockquote><div><br></div><div>OK, my workaround is as follows. I've previously added the "vmClass" to the CCodeGenerator, which is non-nil if translating the Interpreter (also StackInterpreter & CoInterpreter/Cogit). Now the CCodeGenerator asks the vmClass if non-nil whether to genenrate signed shifts and to default to the old behaviour. So I can defer fixing all uses elsewhere and just concentrate on fixing uses in Cog.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
<font color="#888888"><br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
</font></blockquote></div><br>