projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'BigIntegerParse'
[mono.git]
/
mcs
/
mcs
/
constant.cs
diff --git
a/mcs/mcs/constant.cs
b/mcs/mcs/constant.cs
index 799d81bfac6adb3706ede095c5177c615d7714e4..d37e0f01bf37b55a738b4cc3c8b06dcb89bfc67d 100644
(file)
--- a/
mcs/mcs/constant.cs
+++ b/
mcs/mcs/constant.cs
@@
-1646,20
+1646,32
@@
namespace Mono.CSharp {
}
public class FloatConstant : Constant {
}
public class FloatConstant : Constant {
- public readonly float Value;
+ //
+ // Store constant value as double because float constant operations
+ // need to work on double value to match JIT
+ //
+ public readonly double DoubleValue;
- public FloatConstant (BuiltinTypes types,
float
v, Location loc)
+ public FloatConstant (BuiltinTypes types,
double
v, Location loc)
: this (types.Float, v, loc)
{
}
: this (types.Float, v, loc)
{
}
- public FloatConstant (TypeSpec type,
float
v, Location loc)
+ public FloatConstant (TypeSpec type,
double
v, Location loc)
: base (loc)
{
this.type = type;
eclass = ExprClass.Value;
: base (loc)
{
this.type = type;
eclass = ExprClass.Value;
- Value = v;
+ DoubleValue = v;
+ }
+
+ public override Constant ConvertImplicitly (TypeSpec type)
+ {
+ if (type.BuiltinType == BuiltinTypeSpec.Type.Double)
+ return new DoubleConstant (type, DoubleValue, loc);
+
+ return base.ConvertImplicitly (type);
}
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
}
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
@@
-1672,6
+1684,12
@@
namespace Mono.CSharp {
ec.Emit (OpCodes.Ldc_R4, Value);
}
ec.Emit (OpCodes.Ldc_R4, Value);
}
+ public float Value {
+ get {
+ return (float) DoubleValue;
+ }
+ }
+
public override object GetValue ()
{
return Value;
public override object GetValue ()
{
return Value;
@@
-1707,59
+1725,59
@@
namespace Mono.CSharp {
if (Value < byte.MinValue || Value > byte.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
if (Value < byte.MinValue || Value > byte.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
- return new ByteConstant (target_type, (byte) Value, Location);
+ return new ByteConstant (target_type, (byte)
Double
Value, Location);
case BuiltinTypeSpec.Type.SByte:
if (in_checked_context) {
if (Value < sbyte.MinValue || Value > sbyte.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
case BuiltinTypeSpec.Type.SByte:
if (in_checked_context) {
if (Value < sbyte.MinValue || Value > sbyte.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
- return new SByteConstant (target_type, (sbyte) Value, Location);
+ return new SByteConstant (target_type, (sbyte)
Double
Value, Location);
case BuiltinTypeSpec.Type.Short:
if (in_checked_context) {
if (Value < short.MinValue || Value > short.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
case BuiltinTypeSpec.Type.Short:
if (in_checked_context) {
if (Value < short.MinValue || Value > short.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
- return new ShortConstant (target_type, (short) Value, Location);
+ return new ShortConstant (target_type, (short)
Double
Value, Location);
case BuiltinTypeSpec.Type.UShort:
if (in_checked_context) {
if (Value < ushort.MinValue || Value > ushort.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
case BuiltinTypeSpec.Type.UShort:
if (in_checked_context) {
if (Value < ushort.MinValue || Value > ushort.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
- return new UShortConstant (target_type, (ushort) Value, Location);
+ return new UShortConstant (target_type, (ushort)
Double
Value, Location);
case BuiltinTypeSpec.Type.Int:
if (in_checked_context) {
if (Value < int.MinValue || Value > int.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
case BuiltinTypeSpec.Type.Int:
if (in_checked_context) {
if (Value < int.MinValue || Value > int.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
- return new IntConstant (target_type, (int) Value, Location);
+ return new IntConstant (target_type, (int)
Double
Value, Location);
case BuiltinTypeSpec.Type.UInt:
if (in_checked_context) {
if (Value < uint.MinValue || Value > uint.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
case BuiltinTypeSpec.Type.UInt:
if (in_checked_context) {
if (Value < uint.MinValue || Value > uint.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
- return new UIntConstant (target_type, (uint) Value, Location);
+ return new UIntConstant (target_type, (uint)
Double
Value, Location);
case BuiltinTypeSpec.Type.Long:
if (in_checked_context) {
if (Value < long.MinValue || Value > long.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
case BuiltinTypeSpec.Type.Long:
if (in_checked_context) {
if (Value < long.MinValue || Value > long.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
- return new LongConstant (target_type, (long) Value, Location);
+ return new LongConstant (target_type, (long)
Double
Value, Location);
case BuiltinTypeSpec.Type.ULong:
if (in_checked_context) {
if (Value < ulong.MinValue || Value > ulong.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
case BuiltinTypeSpec.Type.ULong:
if (in_checked_context) {
if (Value < ulong.MinValue || Value > ulong.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
- return new ULongConstant (target_type, (ulong) Value, Location);
+ return new ULongConstant (target_type, (ulong)
Double
Value, Location);
case BuiltinTypeSpec.Type.Double:
case BuiltinTypeSpec.Type.Double:
- return new DoubleConstant (target_type,
(double)
Value, Location);
+ return new DoubleConstant (target_type,
Double
Value, Location);
case BuiltinTypeSpec.Type.Char:
if (in_checked_context) {
if (Value < (float) char.MinValue || Value > (float) char.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
case BuiltinTypeSpec.Type.Char:
if (in_checked_context) {
if (Value < (float) char.MinValue || Value > (float) char.MaxValue || float.IsNaN (Value))
throw new OverflowException ();
}
- return new CharConstant (target_type, (char) Value, Location);
+ return new CharConstant (target_type, (char)
Double
Value, Location);
case BuiltinTypeSpec.Type.Decimal:
case BuiltinTypeSpec.Type.Decimal:
- return new DecimalConstant (target_type, (decimal) Value, Location);
+ return new DecimalConstant (target_type, (decimal)
Double
Value, Location);
}
return null;
}
return null;