static bool ImplicitReferenceConversionExists(MdbEvaluationContext ctx, TargetStructType source, TargetStructType target) { if (source == target) { return(true); } if (source.Module.Name.StartsWith("mscorlib,") && target.Module.Name.StartsWith("mscorlib,")) { Type t1 = Type.GetType(source.Name); Type t2 = Type.GetType(target.Name); return(t2.IsAssignableFrom(t1)); } if (!source.HasParent) { return(false); } TargetStructType parent_type = source.GetParentType(ctx.Thread); return(ImplicitReferenceConversionExists(ctx, parent_type, target)); }
static bool TryParentCast(MdbEvaluationContext ctx, TargetStructType source_type, TargetStructType target_type) { if (source_type == target_type) { return(true); } if (!source_type.HasParent) { return(false); } TargetStructType parent_type = source_type.GetParentType(ctx.Thread); return(TryParentCast(ctx, parent_type, target_type)); }
static TargetStructObject TryParentCast(MdbEvaluationContext ctx, TargetStructObject source, TargetStructType source_type, TargetStructType target_type) { if (source_type == target_type) { return(source); } if (!source_type.HasParent) { return(null); } TargetStructType parent_type = source_type.GetParentType(ctx.Thread); source = TryParentCast(ctx, source, parent_type, target_type); if (source == null) { return(null); } return(source.GetParentObject(ctx.Thread) as TargetClassObject); }
internal TargetStructObject(TargetStructType type, TargetLocation location) : base(type, location) { this.Type = type; }
internal TargetStructObject(TargetStructType type, TargetLocation location) : base(type, location) { this.Type = type; }
public static EvaluationResult MonoObjectToString(Thread thread, TargetStructObject obj, EvaluationFlags flags, int timeout, out string result) { result = null; if (!obj.Type.Language.IsManaged) { return(EvaluationResult.MethodNotFound); } again: TargetStructType ctype = obj.Type; if ((ctype.Name == "System.Object") || (ctype.Name == "System.ValueType")) { return(EvaluationResult.MethodNotFound); } TargetClass klass = ctype.GetClass(thread); if (klass == null) { return(EvaluationResult.NotInitialized); } TargetMethodInfo[] methods = klass.GetMethods(thread); if (methods == null) { return(EvaluationResult.MethodNotFound); } foreach (TargetMethodInfo minfo in methods) { if (minfo.Name != "ToString") { continue; } TargetFunctionType ftype = minfo.Type; if (ftype.ParameterTypes.Length != 0) { continue; } if (ftype.ReturnType != ftype.Language.StringType) { continue; } RuntimeInvokeResult rti; try { RuntimeInvokeFlags rti_flags = RuntimeInvokeFlags.VirtualMethod; if ((flags & EvaluationFlags.NestedBreakStates) != 0) { rti_flags |= RuntimeInvokeFlags.NestedBreakStates; } rti = thread.RuntimeInvoke( ftype, obj, new TargetObject [0], rti_flags); if (!rti.CompletedEvent.WaitOne(timeout, false)) { rti.Abort(); return(EvaluationResult.Timeout); } if ((rti.TargetException != null) && (rti.TargetException.Type == TargetError.ClassNotInitialized)) { result = null; return(EvaluationResult.NotInitialized); } if (rti.Result is Exception) { result = ((Exception)rti.Result).Message; return(EvaluationResult.UnknownError); } if (rti.ExceptionMessage != null) { result = rti.ExceptionMessage; return(EvaluationResult.Exception); } else if (rti.ReturnObject == null) { rti.Abort(); return(EvaluationResult.UnknownError); } } catch (TargetException ex) { result = ex.ToString(); return(EvaluationResult.UnknownError); } TargetObject retval = (TargetObject)rti.ReturnObject; result = (string)((TargetFundamentalObject)retval).GetObject(thread); return(EvaluationResult.Ok); } if (obj.Type.HasParent) { obj = obj.GetParentObject(thread) as TargetClassObject; if (obj != null) { goto again; } } return(EvaluationResult.MethodNotFound); }