This commit is contained in:
Ivan Bondarev 2023-06-18 14:48:32 +02:00
parent 98da0c909f
commit 5e40de630a
5 changed files with 66 additions and 40 deletions

View file

@ -62,7 +62,7 @@ namespace VisualPascalABC
public CodeCompletionImagesProvider()
{
images.ColorDepth = ColorDepth.Depth32Bit;
images.ColorDepth = ColorDepth.Depth24Bit;
IconNumberMethod = AddImageFromManifestResource("Icons.16x16.Method.png");
IconNumberField = AddImageFromManifestResource("Icons.16x16.Field.png");
IconNumberProperty = AddImageFromManifestResource("Icons.16x16.Property.png");

View file

@ -383,7 +383,7 @@ namespace VisualPascalABC
}
catch (System.Exception ex)
{
throw new System.Exception(ex.Message);
throw new System.Exception(ex.Message + " " + ex.StackTrace);
}
finally
{
@ -6212,10 +6212,10 @@ namespace VisualPascalABC
if (i < _indexer.indexes.expressions.Count - 1)
names.Add(",");
RetValue val = eval_stack.Pop();
if (val.prim_val == null && val.obj_val != null)
if (val.prim_val == null && val.monoValue != null)
{
if (val.obj_val.IsPrimitive)
val.prim_val = val.obj_val.PrimitiveValue;
if (val.monoValue.IsPrimitive)
val.prim_val = val.monoValue.GetRawValue();
}
if (val.prim_val != null)
{
@ -6237,13 +6237,13 @@ namespace VisualPascalABC
}
else
{
indices.Add(val.obj_val);
indices.Add(val.monoValue);
}
}
by_dot = tmp;
names.Add("]");
if (rv.obj_val != null)
if (rv.monoValue != null)
{
if (rv.obj_val is MemberValue && (rv.obj_val as MemberValue).MemberInfo is PropertyInfo)
{
@ -6264,11 +6264,12 @@ namespace VisualPascalABC
eval_stack.Push(res);
return;
}
if (rv.obj_val.IsArray)
if (rv.monoValue.IsArray)
{
RetValue res = new RetValue();
res.obj_val = rv.obj_val.GetArrayElement(conv_to_uint_arr(indices));
check_for_out_of_range(res.obj_val);
res.monoValue = rv.monoValue.GetArrayItem(conv_to_int_arr(indices)[0]);
//check_for_out_of_range(res.monoValue);
eval_stack.Push(res);
}
@ -6424,13 +6425,13 @@ namespace VisualPascalABC
return null;
}
private uint[] conv_to_uint_arr(List<object> arr)
private int[] conv_to_int_arr(List<object> arr)
{
try
{
List<uint> l = new List<uint>();
List<int> l = new List<int>();
foreach (object i in arr)
l.Add(Convert.ToUInt32(i));
l.Add(Convert.ToInt32(i));
return l.ToArray();
}
catch

View file

@ -14,6 +14,7 @@ using System.Runtime.ExceptionServices;
namespace VisualPascalABC
{
public static class DebugUtils
{
private static Hashtable ht = new Hashtable();

View file

@ -120,8 +120,12 @@ namespace Mono.Debugging.Soft
{
try {
var result = ctx.RuntimeInvoke (method, obj, new Value[0]);
if (result is StringMirror str)
return MirrorStringToString (ctx, str);
var str = result as StringMirror;
if (str != null)
{
return MirrorStringToString(ctx, str);
}
return null;
} catch {
@ -133,17 +137,21 @@ namespace Mono.Debugging.Soft
{
if (obj == null)
return null;
if (obj is StringMirror str)
var str = obj as StringMirror;
if (str != null)
{
return str.Value;
}
if (obj is EnumMirror em)
var em = obj as EnumMirror;
if (em != null)
return em.StringValue;
if (obj is PrimitiveValue primitive)
var primitive = obj as PrimitiveValue;
if (primitive != null)
return primitive.Value.ToString ();
if (obj is PointerValue pointer)
var pointer = obj as PointerValue;
if (pointer != null)
return string.Format ("0x{0:x}", pointer.Address);
var cx = (SoftEvaluationContext) ctx;
@ -184,7 +192,8 @@ namespace Mono.Debugging.Soft
var tt = targetType as Type;
if (tt != null) {
try {
if (obj is PrimitiveValue primitive)
var primitive = obj as PrimitiveValue;
if (primitive != null)
obj = primitive.Value;
res = System.Convert.ChangeType (obj, tt);
@ -360,7 +369,8 @@ namespace Mono.Debugging.Soft
if (fromType != null) {
// Try casting the primitive type of the enum
if (val is EnumMirror em)
var em = val as EnumMirror;
if (em != null)
return TryCast (ctx, CreateValue (ctx, em.Value), type);
if (toType != null && toType.IsAssignableFrom(fromType))
@ -380,8 +390,10 @@ namespace Mono.Debugging.Soft
}
if (toType.IsGenericType && toType.FullName.StartsWith ("System.Nullable`1", StringComparison.Ordinal)) {
if (val is PrimitiveValue primitiveVal && primitiveVal.Value == null) {
if (toType.IsGenericType && toType.FullName.StartsWith ("System.Nullable`1", StringComparison.Ordinal))
{
var primitiveVal = val as PrimitiveValue;
if (primitiveVal != null && primitiveVal.Value == null) {
val = CreateValue (ctx, toType, new object [0]);
} else {
val = CreateValue (ctx, toType, val);
@ -412,7 +424,8 @@ namespace Mono.Debugging.Soft
try {
if (tt.IsPrimitive || tt == typeof (string)) {
if (val is PrimitiveValue primitive)
var primitive = val as PrimitiveValue;
if (primitive != null)
val = primitive.Value;
if (val == null)
@ -526,8 +539,8 @@ namespace Mono.Debugging.Soft
public override object CreateValue (EvaluationContext ctx, object value)
{
var cx = (SoftEvaluationContext) ctx;
if (value is string str)
var str = value as string;
if (str != null)
return cx.Domain.CreateString (str);
if (value is decimal) {
@ -1528,8 +1541,8 @@ namespace Mono.Debugging.Soft
args += ",";
string tn;
if (!(argType is TypeMirror atm)) {
var atm = argType as TypeMirror;
if (atm == null) {
var att = (Type) argType;
tn = att.FullName + ", " + att.Assembly.GetName ();
@ -1600,7 +1613,8 @@ namespace Mono.Debugging.Soft
public override object GetParentType (EvaluationContext ctx, object type)
{
if (type is TypeMirror tm) {
var tm = type as TypeMirror;
if (tm != null) {
int plus = tm.FullName.LastIndexOf ('+');
return plus != -1 ? GetType (ctx, tm.FullName.Substring (0, plus)) : null;
@ -1671,7 +1685,8 @@ namespace Mono.Debugging.Soft
public override object GetBaseType (EvaluationContext ctx, object type)
{
return type is TypeMirror tm ? tm.BaseType : null;
var tm = type as TypeMirror;
return tm != null ? tm.BaseType : null;
}
public override bool HasMethodWithParamLength (EvaluationContext ctx, object targetType, string methodName, BindingFlags flags, int paramLength)
@ -1776,12 +1791,14 @@ namespace Mono.Debugging.Soft
public override bool IsValueType (object type)
{
return type is TypeMirror tm && tm.IsValueType;
var tm = type as TypeMirror;
return tm != null && tm.IsValueType;
}
public override bool IsPrimitiveType (object type)
{
if (!(type is TypeMirror tm))
var tm = type as TypeMirror;
if (tm == null)
return false;
if (tm.IsPrimitive)
@ -1795,7 +1812,8 @@ namespace Mono.Debugging.Soft
public override bool IsClass (EvaluationContext ctx, object type)
{
return type is TypeMirror tm && (tm.IsClass || tm.IsValueType) && !tm.IsPrimitive;
var tm = type as TypeMirror;
return tm != null && (tm.IsClass || tm.IsValueType) && !tm.IsPrimitive;
}
public override bool IsNull (EvaluationContext ctx, object val)
@ -1807,7 +1825,8 @@ namespace Mono.Debugging.Soft
{
if (val is PrimitiveValue || val is StringMirror || val is PointerValue)
return true;
if (!(val is StructMirror sm))
var sm = val as StructMirror;
if (sm == null)
return false;
if (sm.Type.IsPrimitive)
return true;

View file

@ -1152,7 +1152,9 @@ namespace Mono.Debugging.Soft
return breakInfo;
}
if (breakEvent is FunctionBreakpoint function) {
if (breakEvent is FunctionBreakpoint) {
var function = breakEvent as FunctionBreakpoint;
foreach (var method in FindMethodsByName (function.TypeName, function.MethodName, function.ParamTypes)) {
if (!ResolveFunctionBreakpoint (breakInfo, function, method)) {
breakInfo.SetStatus (BreakEventStatus.NotBound, null);
@ -1164,7 +1166,8 @@ namespace Mono.Debugging.Soft
lock (pending_bes) {
pending_bes.Add (breakInfo);
}
} else if (breakEvent is InstructionBreakpoint instruction) {
} else if (breakEvent is InstructionBreakpoint) {
var instruction = breakEvent as InstructionBreakpoint;
Location location;
breakInfo.FileName = instruction.FileName;
@ -1181,7 +1184,8 @@ namespace Mono.Debugging.Soft
lock (pending_bes) {
pending_bes.Add (breakInfo);
}
} else if (breakEvent is Breakpoint breakpoint) {
} else if (breakEvent is Breakpoint) {
var breakpoint = breakEvent as Breakpoint;
bool insideLoadedRange;
bool found = false;
@ -1208,7 +1212,8 @@ namespace Mono.Debugging.Soft
else
breakInfo.SetStatus (BreakEventStatus.NotBound, null);
}
} else if (breakEvent is Catchpoint catchpoint) {
} else if (breakEvent is Catchpoint) {
var catchpoint = breakEvent as Catchpoint;
if (!types.ContainsKey (catchpoint.ExceptionName)) {
//
// Same as in FindLocationByFile (), fetch types matching the type name