Nice/src/bossa/syntax constant.nice,1.12,1.13
Arjan Boeijink <[email protected]>
| Newsgroups | gmane.comp.lang.nice.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29079/F:/nice/src/bossa/syntax
Modified Files:
constant.nice
Log Message:
Fix handling of non decimal litetal int/long distinction.
Index: constant.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constant.nice,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** constant.nice 11 Mar 2005 21:32:01 -0000 1.12
--- constant.nice 12 Mar 2005 00:01:55 -0000 1.13
***************
*** 105,109 ****
try {
! long value = parseInteger(removeUnderscores(rep));
mlsub.typing.Polytype type;
--- 105,109 ----
try {
! (long value, boolean isDecimal) = parseInteger(removeUnderscores(rep));
mlsub.typing.Polytype type;
***************
*** 129,132 ****
--- 129,147 ----
object = value;
}
+ else if (!isLong && !isDecimal && (-(1L << 32) ) < value < (1L << 32))
+ { // handle 32 bit bin/hex literals which don't fit in a int
+ if (value > 0)
+ value = (1L << 32) - value;
+ else
+ value = (1L << 32) + value;
+
+ type = nice.tools.typing.PrimitiveType.intPolytype;
+ tc = nice.tools.typing.PrimitiveType.intTC;
+ object = value;
+ }
+ else if (!isLong && !isDecimal)
+ { // a non decimal long must be explicit
+ throw User.error(representation, rep + " is too large for an int literal");
+ }
else
{
***************
*** 164,168 ****
! private long parseInteger(String rep)
{
int radix = 10;
--- 179,183 ----
! private (long, boolean) parseInteger(String rep)
{
int radix = 10;
***************
*** 206,210 ****
result = -result;
! return result;
}
--- 221,225 ----
result = -result;
! return (result, radix == 10);
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click