<div dir="ltr"><div><div><div>If you look at the terminal instructions in primitiveBitShift you&#39;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">&lt;<a href="mailto:helmut.rohregger@gmail.com" target="_blank">helmut.rohregger@gmail.com</a>&gt;</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 &lt;<a href="mailto:helmut.rohregger@gmail.com" target="_blank">helmut.rohregger@gmail.com</a>&gt; 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 &lt;<a href="mailto:helmut.rohregger@gmail.com" target="_blank">helmut.rohregger@gmail.com</a>&gt;<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&gt;&gt;#<u></u>primitiveBitShift<br>
(VMMaker-dtl.319):<br>
the code: &quot;self success: integerArgument &lt;= 31&quot; checks, if we lose bits<br>
by<br>
shifting to the left. This is because of processing SmallIntegers here,<br>
isn&#39;t it? But a &quot;1 bitShift: 31&quot; 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 &quot;self<br>
success:<br>
integerArgument &lt;= 29&quot;, isn&#39;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&#39;t check both operands?<br>
<br>
&quot;1 &lt;&lt; 29 &quot; fits<br>
&quot;SmallInteger maxVal &lt;&lt; 29 &quot; doesnt.<br>
even<br>
&quot;SmallInteger maxVal &lt;&lt; 1 &quot; doesnt.<br>
</blockquote>
<br>
but &quot; x &lt;&lt; 30 &quot; does never fit, no matter which value &#39;x&#39; has.<br>
</blockquote>
0 &lt;&lt; 30 = 0.<br>
fits.<br>
<br>
<br>
</blockquote></div></div>
hehe i know.<br>
and &quot;0 &lt;&lt; SmallInteger maxVal&quot; fits too, but will fail with the implemented primitive.<br>
<br>
</blockquote></div><br></div>