Author: manjula
Date: 2005-03-17 01:39:11 -0500 (Thu, 17 Mar 2005)
New Revision: 41926
Modified:
trunk/mcs/mbas/ChangeLog
trunk/mcs/mbas/ecore.cs
Log:
Support Double in case statement and do necessary conversion to Int Literal
Modified: trunk/mcs/mbas/ChangeLog
===================================================================
--- trunk/mcs/mbas/ChangeLog 2005-03-17 01:22:31 UTC (rev 41925)
+++ trunk/mcs/mbas/ChangeLog 2005-03-17 06:39:11 UTC (rev 41926)
@@ -1,3 +1,6 @@
+2005-03-17 Manjula GHM <[EMAIL PROTECTED]>
+ *ecore.cs : Support Double in case statement and do necessary
conversion to Int Literal
+
2005-03-16 Manjula GHM <[EMAIL PROTECTED]>
* mb-parser.jay:
Support 'expression TO expression' case clause for select
statement
Modified: trunk/mcs/mbas/ecore.cs
===================================================================
--- trunk/mcs/mbas/ecore.cs 2005-03-17 01:22:31 UTC (rev 41925)
+++ trunk/mcs/mbas/ecore.cs 2005-03-17 06:39:11 UTC (rev 41926)
@@ -3,6 +3,7 @@
//
// Author:
// Miguel de Icaza ([EMAIL PROTECTED])
+// Manjula GHM ([EMAIL PROTECTED])
//
// (C) 2001 Ximian, Inc.
//
@@ -3083,7 +3084,7 @@
/// <summary>
/// Converts the IntConstant, UIntConstant, LongConstant or
- /// ULongConstant into the integral target_type. Notice
+ /// ULongConstant,Double into the integral target_type.
Notice
/// that we do not return an 'Expression' we do return
/// a boxed integral type.
///
@@ -3345,7 +3346,38 @@
return (ulong) v;
s = v.ToString ();
+
+ } else if (c is DoubleConstant){
+ double v = ((DoubleConstant) c).Value;
+
+ if (target_type == TypeManager.sbyte_type){
+ if (v >= SByte.MinValue && v <=
SByte.MaxValue)
+ return (sbyte) v;
+ } else if (target_type ==
TypeManager.byte_type){
+ if (v >= Byte.MinValue && v <=
Byte.MaxValue)
+ return (byte) v;
+ } else if (target_type ==
TypeManager.char_type){
+ if (v >= Char.MinValue && v <=
Char.MaxValue)
+ return (char) v;
+ } else if (target_type ==
TypeManager.short_type){
+ if (v >= Int16.MinValue && v <=
Int16.MaxValue)
+ return (short) v;
+ } else if (target_type ==
TypeManager.ushort_type){
+ if (v >= UInt16.MinValue && v <=
UInt16.MaxValue)
+ return (ushort) v;
+ } else if (target_type ==
TypeManager.int32_type){
+ if (v >= Int32.MinValue && v <=
Int32.MaxValue)
+ return (int) v;
+ } else if (target_type ==
TypeManager.uint32_type){
+ if (v >= 0 && v <= UInt32.MaxValue)
+ return (uint) v;
+ } else if (target_type ==
TypeManager.uint64_type){
+ if (v > 0)
+ return (ulong) v;
+ }
+ s = v.ToString ();
}
+
Error_ConstantValueCannotBeConverted (loc, s,
target_type);
return null;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches