static TargetClassObject TryCurrentCast(ScriptingContext context, TargetClassObject source, TargetClassType target_type) { TargetClassObject current = source.GetCurrentObject (context.CurrentThread); if (current == null) return null; return TryParentCast (context, current, current.Type, target_type); }
static TargetClassObject TryParentCast(ScriptingContext context, TargetClassObject source, TargetClassType source_type, TargetClassType target_type) { if (source_type == target_type) return source; if (!source_type.HasParent) return null; TargetClassType parent_type = source_type.GetParentType (context.CurrentThread); source = TryParentCast (context, source, parent_type, target_type); if (source == null) return null; return source.GetParentObject (context.CurrentThread) as TargetClassObject; }
string MonoObjectToString(TargetClassObject obj) { TargetClassType ctype = obj.Type; if ((ctype.Name == "System.Object") || (ctype.Name == "System.ValueType")) return null; string text, dummy; EE.EvaluationResult result; if (ctype.DebuggerDisplayAttribute != null) { result = HandleDebuggerDisplay (Interpreter, CurrentThread, obj, ctype.DebuggerDisplayAttribute, -1, out text, out dummy); if (result == EE.EvaluationResult.Ok) return String.Format ("{{ {0} }}", text); else if (result == EE.EvaluationResult.InvalidExpression) { if (text != null) return text; } } result = EE.MonoObjectToString (CurrentThread, obj, EE.EvaluationFlags.None, -1, out text); if (result == EE.EvaluationResult.Ok) return String.Format ("{{ \"{0}\" }}", text); return null; }
static TargetObject ImplicitReferenceConversion(ScriptingContext context, TargetClassObject obj, TargetClassType type) { if (obj.Type == type) return obj; if (!obj.Type.HasParent) return null; return obj.GetParentObject (context.CurrentThread); }
protected void FormatStructObject(Thread target, TargetClassObject obj) { bool first = true; TargetClass class_info = obj.Type.GetClass (target); if (class_info != null) FormatClassObject (target, obj, class_info, ref first); }
protected void FormatClassObject(Thread target, TargetClassObject obj, TargetClass class_info, ref bool first) { Append ("{ "); indent_level += 3; if (obj.Type.HasParent) { TargetClassObject parent = obj.GetParentObject (target); if ((parent != null) && (parent.Type != parent.Type.Language.ObjectType)) { Append ("<{0}> = ", parent.Type.Name); CheckLineWrap (); FormatStructObject (target, parent); first = false; } } TargetFieldInfo[] fields = class_info.GetFields (target); for (int i = 0; i < fields.Length; i++) { if (fields [i].IsStatic || fields [i].HasConstValue) continue; if (fields [i].IsCompilerGenerated) continue; if (fields [i].DebuggerBrowsableState == DebuggerBrowsableState.Never) continue; if (!first) { Append (", "); CheckLineWrap (); } first = false; Append (fields [i].Name + " = "); try { TargetObject fobj = class_info.GetField (target, obj, fields [i]); if (fobj == null) Append ("null"); else FormatObjectRecursed (target, fobj, true); } catch { Append ("<cannot display object>"); } } Append (first ? "}" : " }"); indent_level -= 3; }
static TargetStructObject TryCurrentCast (MdbEvaluationContext ctx, TargetClassObject source, TargetClassType target_type) { TargetStructObject current = source.GetCurrentObject (ctx.Thread); if (current == null) return null; return TryParentCast (ctx, current, current.Type, target_type); }
static TargetObject ImplicitReferenceConversion (MdbEvaluationContext ctx, TargetClassObject obj, TargetClassType type) { if (obj.Type == type) return obj; if (obj.Type.HasParent) { TargetObject pobj = obj.GetParentObject (ctx.Thread); if (pobj != null) { pobj = ImplicitConversion (ctx, pobj, type); if (pobj != null) return pobj; } } if (ImplicitReferenceConversionExists (ctx, obj.Type, type)) return obj; return null; }
public ClassVariable(string name, StackFrame stackFrame, TargetClassObject obj) { this.name = name; this.stackFrame = stackFrame; this.obj = obj; }