<div dir="ltr"><div><div><div>If you look at the terminal instructions in primitiveBitShift you'll see:<br><br> self push: (self positive32BitIntegerFor: shifted)<br><br></div>If you inquire a bit, you will see that positive32BitIntegerFor: will create a LargePositiveInteger instead of failing the primitive.<br>
</div>The balance between purity and efficiency I guess...<br><br></div>Nicolas<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/15 Helmut Rohregger <span dir="ltr"><<a href="mailto:helmut.rohregger@gmail.com" target="_blank">helmut.rohregger@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Am 15.04.2013 11:55, schrieb Igor Stasenko:<div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 15 April 2013 11:46, Helmut Rohregger <<a href="mailto:helmut.rohregger@gmail.com" target="_blank">helmut.rohregger@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Am 15.04.2013 11:40, schrieb Igor Stasenko:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 15 April 2013 11:31, Helmut Rohregger <<a href="mailto:helmut.rohregger@gmail.com" target="_blank">helmut.rohregger@gmail.com</a>><br>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
i am interested in the implementations of primitives in the VMMaker<br>
package<br>
and found some code, which i think may be implemented incorrectly.<br>
Maybe some of you can help me out and correct me if i am wrong.<br>
<br>
Its located in InterpreterPrimitives>>#<u></u>primitiveBitShift<br>
(VMMaker-dtl.319):<br>
the code: "self success: integerArgument <= 31" checks, if we lose bits<br>
by<br>
shifting to the left. This is because of processing SmallIntegers here,<br>
isn't it? But a "1 bitShift: 31" will produce a LargePositiveInteger<br>
instead<br>
of a SmallInteger. In fact a left shift of 30 will produce a<br>
LargePositiveInteger too.<br>
<br>
I know the code works, because the resulting object gets checked being a<br>
SmallInteger and fails if not. But the correct check would be "self<br>
success:<br>
integerArgument <= 29", isn't it?<br>
What do you think?<br>
<br>
</blockquote>
hmm., how do you know if shifted result will fit into smallint, if you<br>
don't check both operands?<br>
<br>
"1 << 29 " fits<br>
"SmallInteger maxVal << 29 " doesnt.<br>
even<br>
"SmallInteger maxVal << 1 " doesnt.<br>
</blockquote>
<br>
but " x << 30 " does never fit, no matter which value 'x' has.<br>
</blockquote>
0 << 30 = 0.<br>
fits.<br>
<br>
<br>
</blockquote></div></div>
hehe i know.<br>
and "0 << SmallInteger maxVal" fits too, but will fail with the implemented primitive.<br>
<br>
</blockquote></div><br></div>