public static TargetObject ImplicitConversion(MdbEvaluationContext ctx, TargetObject obj, TargetType type) { if (obj.Type.Equals(type)) { return(obj); } if (type is TargetObjectType || ObjectUtil.FixTypeName(type.Name) == "System.Object") { if (obj.Type.IsByRef) { return(obj); } return(BoxValue(ctx, obj)); } if (obj is TargetEnumObject && type is TargetFundamentalType) { TargetEnumObject e = (TargetEnumObject)obj; return(ImplicitConversion(ctx, e.GetValue(ctx.Thread), type)); } if (type is TargetEnumType) { TargetEnumType e = (TargetEnumType)type; return(ImplicitConversion(ctx, obj, e.Value.Type)); } if (obj is TargetArrayObject && type.Name == "System.Array") { return(obj); } if (obj is TargetArrayObject && type is TargetArrayType) { TargetArrayObject sa = (TargetArrayObject)obj; TargetArrayType ta = (TargetArrayType)type; if (sa.Type.ElementType.Equals(ta.ElementType)) { return(obj); } } if ((obj is TargetFundamentalObject) && (type is TargetFundamentalType)) { return(ImplicitFundamentalConversion( ctx, (TargetFundamentalObject)obj, (TargetFundamentalType)type)); } if ((obj is TargetClassObject) && (type is TargetClassType)) { return(ImplicitReferenceConversion( ctx, (TargetClassObject)obj, (TargetClassType)type)); } return(null); }
public EnumVariable(string name, StackFrame stackFrame, TargetEnumObject obj) { this.name = name; this.stackFrame = stackFrame; this.obj = obj; this.value = GetValue(); }
protected void FormatEnum(Thread target, TargetEnumObject eobj) { TargetObject evalue = eobj.GetValue(target); TargetFundamentalObject fobj = evalue as TargetFundamentalObject; if ((DisplayFormat == DisplayFormat.HexaDecimal) || (fobj == null)) { FormatObjectRecursed(target, evalue, true); return; } object value = fobj.GetObject(target); SortedList members = new SortedList(); foreach (TargetEnumInfo field in eobj.Type.Members) { members.Add(field.Name, field.ConstValue); } if (!eobj.Type.IsFlagsEnum) { foreach (DictionaryEntry entry in members) { if (entry.Value.Equals(value)) { Append((string)entry.Key); return; } } } else if (value is ulong) { bool first = true; ulong the_value = (ulong)value; foreach (DictionaryEntry entry in members) { ulong fvalue = System.Convert.ToUInt64(entry.Value); if ((the_value & fvalue) != fvalue) { continue; } if (!first) { Append(" | "); CheckLineWrap(); } first = false; Append((string)entry.Key); } if (!first) { return; } } else { bool first = true; long the_value = System.Convert.ToInt64(value); foreach (DictionaryEntry entry in members) { long fvalue = System.Convert.ToInt64(entry.Value); if ((the_value & fvalue) != fvalue) { continue; } if (!first) { Append(" | "); CheckLineWrap(); } first = false; Append((string)entry.Key); } if (!first) { return; } } FormatObjectRecursed(target, fobj, true); }