39 internal static Type GetUnderlyingType(
Type enumType)
42#if IMPORTER || EXPORTER
43 return enumType.GetEnumUnderlyingType();
45 return Enum.GetUnderlyingType(enumType);
54 foreach (
string str
in value.Split(
','))
56 FieldInfo field = type.GetField(str.Trim(), BindingFlags.Public | BindingFlags.Static);
59 throw new InvalidOperationException(
"Enum value '" + str +
"' not found in " + type.FullName);
63 retval = field.GetRawConstantValue();
67 retval = OrBoxedIntegrals(context, retval, field.GetRawConstantValue());
77 internal static object OrBoxedIntegrals(
RuntimeContext context,
object v1,
object v2)
79 Debug.Assert(v1.GetType() == v2.GetType());
88 long v = ((IConvertible)v1).ToInt64(
null) | ((IConvertible)v2).ToInt64(
null);
89 switch (
Type.GetTypeCode(context.
Resolver.ResolveCoreType(v1.GetType().FullName).AsReflection()))
101 case TypeCode.UInt32:
106 throw new InvalidOperationException();
112 internal static object GetPrimitiveValue(
RuntimeContext context,
Type underlyingType,
object obj)
118 if (obj is ulong || (obj is Enum && underlyingType == context.
Types.
UInt64))
120 value = unchecked((
long)((IConvertible)obj).ToUInt64(
null));
124 value = ((IConvertible)obj).ToInt64(
null);
128 return unchecked((
byte)value);
132 return unchecked((
short)value);
136 return unchecked((
int)value);
144 throw new InvalidOperationException();
Maintains services relevant to an instane of the IKVM runtime.
Types Types
Gets the Types associated with this instance of the runtime.
ISymbolResolver Resolver
Gets the ISymbolResolver associated with this instance of the runtime.