<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hi,<br><br></div>I want to generate code for this one<br><br></div>    csi &lt; 16rFFFFFFFF ifTrue: [...]<br><br></div>Unfortunately, csi is signed (csi = C-SmallInteger = the value in C of a SmallInteger)<br></div>And the generator generates the literal as unsigned long 0xffffffffUL<br></div>But my intention was rather to generate as signed long (for 64 bits VM)!<br><br></div>Guess what happens in C if you compare a negative int with an unsigned ?<br><br></div><div>#include &lt;stdio.h&gt;<br></div>int main()<br>{<br></div>    int csi = -1;<br></div>    printf( &quot;-1&gt;0xffUL =&gt; %d\n&quot;,csi&gt;0xffUL);<br></div>    return 0;<br>}<br><br></div>above program prints 1 of course (thus the condition is true).<br><br></div>Obviously, the signed are promoted to unsigned -1 is thus converted to 2^n-1 where n is the number of bits of unsigned long (sizeof unsigned long)*CHARBITS.<br><br></div>That happens for me in 64 bits, (unsigned long) -1 -&gt; 0xffffffffffffffffUL which is obviously greater than 0xffffffffUL.<br><br></div>Argh!<br><br></div><div>Does that means that literal translation cannot ignore the context?<br></div><div>That would mean that type analysis would have to be performed on the AST, before the AST is transformed into a C-AST...<br></div><div>Or is there a simpler way?<br><br></div><div>Nicolas<br></div><div><br></div></div>