Dechenjm / crack-language

Automatically exported from code.google.com/p/crack-language
Other
0 stars 0 forks source link

UNT explicit constructors should default to doing range checks. #83

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We should default to doing a runtime check when converting to a UNT with less 
precision than the original type:

  i := int32(0x1234567890);  # should cause a runtime error (possibly a compile time error, but that's a separate issue)

To suppress this error, there should be a version of the constructor with a 
"truncate" option:

  i := int32(0x1234567890, true);  # i = 0x34567890

The Builder should generate separate versions of these for PDNTs in cases where 
the PDNT is of the same size or smaller than the UNT it is converting to.  For 
example, on a platform with a 32 bit int, int32(int val) should be a no-op.

Original issue reported on code.google.com by mind...@gmail.com on 25 May 2011 at 3:38