protected TargetMethodInfo(TargetFunctionType type, string name, int index, bool is_static, TargetMemberAccessibility accessibility, string full_name) : base(type, name, index, is_static, accessibility) { this.Type = type; this.FullName = full_name; }
protected TargetPropertyInfo(TargetType type, string name, int index, bool is_static, TargetMemberAccessibility accessibility, TargetFunctionType getter, TargetFunctionType setter) : base(type, name, index, is_static, accessibility) { this.Getter = getter; this.Setter = setter; }
public ML.TargetObject RuntimeInvoke(MdbEvaluationContext ctx, ML.TargetFunctionType function, ML.TargetStructObject object_argument, params ML.TargetObject[] param_objects) { MethodCall mc = new MethodCall(ctx, function, object_argument, param_objects); ctx.Adapter.AsyncExecute(mc, ctx.Options.EvaluationTimeout); return(mc.ReturnValue); }
protected TargetEventInfo(TargetType type, string name, int index, bool is_static, TargetMemberAccessibility accessibility, TargetFunctionType add, TargetFunctionType remove, TargetFunctionType raise) : base(type, name, index, is_static, accessibility) { this.Add = add; this.Remove = remove; this.Raise = raise; }
protected TargetEventInfo(TargetType type, string name, int index, bool is_static, TargetMemberAccessibility accessibility, TargetFunctionType add, TargetFunctionType remove, TargetFunctionType raise) : base(type, name, index, is_static, accessibility) { this.Add = add; this.Remove = remove; this.Raise = raise; }
public SourceLocation(TargetFunctionType function) : this(new DynamicSourceLocation (function, -1, -1)) { Module = function.Module.Name; Method = function.FullName; Name = function.FullName; MethodSource source = function.GetSourceCode (); if (source != null) FileName = source.SourceFile.FileName; }
public RuntimeInvokeResult RuntimeInvoke(Thread thread, TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, RuntimeInvokeFlags flags) { IInterruptionHandler interruption = InterruptionHandler ?? Interpreter; if (interruption.CheckInterruption ()) throw new EvaluationTimeoutException (); RuntimeInvokeResult result = thread.RuntimeInvoke ( function, object_argument, param_objects, flags); WaitHandle[] handles = new WaitHandle [2]; handles [0] = interruption.InterruptionEvent; handles [1] = result.CompletedEvent; int ret = WaitHandle.WaitAny (handles); if (ret == 0) { result.Abort (); throw new EvaluationTimeoutException (); } return result; }
public RuntimeInvokeResult RuntimeInvoke(TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, RuntimeInvokeFlags flags) { lock (this) { check_alive (); RuntimeInvokeResult result = new RuntimeInvokeResult (this); servant.RuntimeInvoke ( function, object_argument, param_objects, flags, result); return result; } }
public RuntimeInvokeResult RuntimeInvoke(TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, bool is_virtual, bool debug) { RuntimeInvokeFlags flags = RuntimeInvokeFlags.None; if (is_virtual) flags |= RuntimeInvokeFlags.VirtualMethod; if (debug) flags |= RuntimeInvokeFlags.BreakOnEntry; return RuntimeInvoke (function, object_argument, param_objects, flags); }
public override void RuntimeInvoke(TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, RuntimeInvokeFlags flags, RuntimeInvokeResult result) { throw new InvalidOperationException (); }
protected MethodGroupExpression CreateMethodGroup(TargetFunctionType func) { return new MethodGroupExpression ( func.DeclaringType, instance, func.Name, new TargetFunctionType[] { func }, !func.IsStatic, func.IsStatic); }
protected override TargetObject DoEvaluateObject(ScriptingContext context) { Thread target = context.CurrentThread; TargetObject obj = expr.EvaluateObject (context); // array[int] TargetArrayObject aobj = obj as TargetArrayObject; if (aobj != null) { int[] int_indices = GetIntIndices (target, context); try { return aobj.GetElement (target, int_indices); } catch (ArgumentException) { throw new ScriptingException ( "Index of array expression `{0}' out of bounds.", expr.Name); } } // pointer[int] TargetPointerObject pobj = obj as TargetPointerObject; if (pobj != null) { // single dimensional array only at present int[] int_indices = GetIntIndices (target, context); if (int_indices.Length != 1) throw new ScriptingException ( "Multi-dimensial arrays of type {0} are not yet supported", expr.Name); if (pobj.Type.IsArray) return pobj.GetArrayElement (target, int_indices [0]); throw new ScriptingException ( "Variable {0} is not an array type.", expr.Name); } // indexers TargetClassObject sobj = Convert.ToClassObject (target, obj); if (sobj != null) { ArrayList props = new ArrayList (); foreach (TargetPropertyInfo prop in sobj.Type.Properties) { if (!prop.CanRead) continue; props.Add (prop.Getter); } if (props.Count == 0) throw new ScriptingException ( "Indexer `{0}' doesn't have a getter.", expr.Name); TargetFunctionType[] funcs = new TargetFunctionType [props.Count]; props.CopyTo (funcs, 0); MethodGroupExpression mg = new MethodGroupExpression ( sobj.Type, sobj, expr.Name + ".this", funcs, true, false); InvocationExpression invocation = new InvocationExpression ( mg, indices); invocation.Resolve (context); return invocation.EvaluateObject (context); } throw new ScriptingException ( "{0} is neither an array/pointer type, nor is it " + "an object with a valid indexer.", expr); }
public static bool IsApplicable(ScriptingContext context, TargetFunctionType method, TargetType[] types, out string error) { TargetMethodSignature sig = method.GetSignature (context.CurrentThread); for (int i = 0; i < types.Length; i++) { TargetType param_type = sig.ParameterTypes [i]; if (param_type == types [i]) continue; if (Convert.ImplicitConversionExists (context, types [i], param_type)) continue; error = String.Format ( "Argument {0}: Cannot implicitly convert `{1}' to `{2}'", i, types [i].Name, param_type.Name); return false; } error = null; return true; }
protected override bool DoAssign(ScriptingContext context, TargetObject right) { Thread target = context.CurrentThread; TargetObject obj = expr.EvaluateObject (context); // array[int] TargetArrayObject aobj = obj as TargetArrayObject; if (aobj != null) { int[] int_indices = GetIntIndices (target, context); try { aobj.SetElement (target, int_indices, right); } catch (ArgumentException) { throw new ScriptingException ( "Index of array expression `{0}' out of bounds.", expr.Name); } return true; } // indexers TargetClassObject sobj = Convert.ToClassObject (target, obj); if (sobj != null) { ArrayList props = new ArrayList (); foreach (TargetPropertyInfo prop in sobj.Type.Properties) { if (!prop.CanWrite) continue; props.Add (prop.Setter); } if (props.Count == 0) throw new ScriptingException ( "Indexer `{0}' doesn't have a setter.", expr.Name); TargetFunctionType[] funcs = new TargetFunctionType [props.Count]; props.CopyTo (funcs, 0); MethodGroupExpression mg = new MethodGroupExpression ( sobj.Type, sobj, expr.Name + "[]", funcs, true, false); Expression[] indexargs = new Expression [indices.Length + 1]; indices.CopyTo (indexargs, 0); indexargs [indices.Length] = new ArgumentExpression (right); InvocationExpression invocation = new InvocationExpression ( mg, indexargs); invocation.Resolve (context); invocation.Invoke (context, false); return true; } throw new ScriptingException ( "{0} is neither an array/pointer type, nor is it " + "an object with a valid indexer.", expr); }
public static MethodGroupExpression ResolveDelegate(ScriptingContext context, Expression expr) { TargetClassType ctype = Convert.ToClassType (expr.EvaluateType (context)); if (ctype == null) return null; TargetClassObject cobj; try { cobj = Convert.ToClassObject ( context.CurrentThread, expr.EvaluateObject (context)); } catch { cobj = null; } TargetClassType delegate_type = ctype.Language.DelegateType; if (!CastExpression.TryCast (context, ctype, delegate_type)) return null; TargetFunctionType invoke = null; foreach (TargetMethodInfo method in ctype.Methods) { if (method.Name == "Invoke") { invoke = method.Type; break; } } if (invoke == null) return null; TargetFunctionType[] methods = new TargetFunctionType[] { invoke }; MethodGroupExpression mg = new MethodGroupExpression ( ctype, cobj, "Invoke", methods, true, false); return mg; }
public MethodCall (MdbEvaluationContext ctx, TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects) { this.ctx = ctx; this.function = function; this.object_argument = object_argument; this.param_objects = param_objects; }
internal BreakpointHandle ResolveBreakpoint(Breakpoint breakpoint) { if (!module.IsLoaded) return null; if ((function == null) && (source == null)) { if (file != null) { source = file.FindMethod (line); } else { throw new TargetException (TargetError.LocationInvalid); } if ((source != null) && source.IsManaged) function = source.Function; } if (function != null) return function.GetBreakpointHandle (breakpoint, line, column); if ((source == null) || source.IsManaged) throw new TargetException (TargetError.LocationInvalid); TargetAddress address = GetAddress (); if (!address.IsNull) return new AddressBreakpointHandle (breakpoint, address); return null; }
public DynamicSourceLocation(TargetFunctionType function, int line, int column) { this.function = function; this.file = null; this.module = function.Module; this.line = line; this.column = column; }
public DynamicSourceLocation(MethodSource source, SourceFile file, int line, int column) { if (source.IsManaged) { this.function = source.Function; this.module = function.Module; } else { this.module = source.Module; this.source = source; } this.file = file; this.line = line; this.column = column; }
static bool IsApplicable (MdbEvaluationContext ctx, TargetFunctionType method, TargetType[] types, out string error, out int matchCount) { TargetMethodSignature sig = method.GetSignature (ctx.Thread); matchCount = 0; for (int i = 0; i < types.Length; i++) { TargetType param_type = sig.ParameterTypes [i]; if (param_type == types [i]) { matchCount++; continue; } if (TargetObjectConvert.ImplicitConversionExists (ctx, types [i], param_type)) continue; error = String.Format ( "Argument {0}: Cannot implicitly convert `{1}' to `{2}'", i, types [i].Name, param_type.Name); return false; } error = null; return true; }
internal StackFrame(Thread thread, FrameType type, TargetAddress address, TargetAddress stack_ptr, TargetAddress frame_address, Registers registers, TargetFunctionType function, SourceLocation location) : this(thread, type, address, stack_ptr, frame_address, registers) { this.function = function; this.language = function.DeclaringType.Language; this.name = new Symbol (function.FullName, address, 0); this.location = location; }
protected override Expression DoResolve(ScriptingContext context) { method_expr = (MethodGroupExpression) expr.ResolveMethod ( context, LocationType.Method); if (method_expr == null) return null; argtypes = new TargetType [arguments.Length]; for (int i = 0; i < arguments.Length; i++) { arguments [i] = arguments [i].Resolve (context); if (arguments [i] == null) return null; argtypes [i] = arguments [i].EvaluateType (context); } method = method_expr.OverloadResolve (context, argtypes); resolved = true; return this; }
protected TargetMethodInfo(TargetFunctionType type, string name, int index, bool is_static, TargetMemberAccessibility accessibility, string full_name) : base(type, name, index, is_static, accessibility) { this.Type = type; this.FullName = full_name; }
public MethodGroupExpression(TargetStructType stype, TargetStructObject instance, string name, TargetFunctionType[] methods, bool is_instance, bool is_static) { this.stype = stype; this.instance = instance; this.name = name; this.methods = methods; this.is_instance = is_instance; this.is_static = is_static; resolved = true; }
protected TargetPropertyInfo(TargetType type, string name, int index, bool is_static, TargetMemberAccessibility accessibility, TargetFunctionType getter, TargetFunctionType setter) : base(type, name, index, is_static, accessibility) { this.Getter = getter; this.Setter = setter; }
public TargetObject Invoke(ScriptingContext context) { TargetClassType stype = Convert.ToClassType ( type_expr.EvaluateType (context)); TargetMethodInfo[] ctors = stype.Constructors; TargetFunctionType[] funcs = new TargetFunctionType [ctors.Length]; for (int i = 0; i < ctors.Length; i++) funcs [i] = ctors [i].Type; MethodGroupExpression mg = new MethodGroupExpression ( stype, null, ".ctor", funcs, false, true); InvocationExpression invocation = new InvocationExpression (mg, arguments); invocation.Resolve (context); return invocation.EvaluateObject (context); }
public OperationRuntimeInvoke(SingleSteppingEngine sse, TargetFunctionType function, TargetStructObject instance, TargetObject[] param_objects, RuntimeInvokeFlags flags, RuntimeInvokeResult result) : base(sse, result) { this.Result = result; this.Function = (MonoFunctionType) function; this.Instance = instance; this.ParamObjects = param_objects; this.Flags = flags; }
public static MemberExpression FindMember(Thread target, TargetStructType stype, TargetStructObject instance, string name, bool search_static, bool search_instance) { again: TargetClass klass = stype.GetClass (target); if (klass != null) { TargetMemberInfo member = klass.FindMember ( target, name, search_static, search_instance); if (member != null) return new StructAccessExpression (stype, instance, member); ArrayList methods = new ArrayList (); bool is_instance = false; bool is_static = false; TargetMethodInfo[] klass_methods = klass.GetMethods (target); if (klass_methods != null) { foreach (TargetMethodInfo method in klass_methods) { if (method.IsStatic && !search_static) continue; if (!method.IsStatic && !search_instance) continue; if (method.Name != name) continue; methods.Add (method.Type); if (method.IsStatic) is_static = true; else is_instance = true; } } if (methods.Count > 0) { TargetFunctionType[] funcs = new TargetFunctionType [methods.Count]; methods.CopyTo (funcs, 0); return new MethodGroupExpression ( stype, instance, name, funcs, is_instance, is_static); } } TargetClassType ctype = stype as TargetClassType; if (ctype != null) { TargetMemberInfo member = ctype.FindMember ( name, search_static, search_instance); if (member != null) return new StructAccessExpression (ctype, instance, member); ArrayList methods = new ArrayList (); bool is_instance = false; bool is_static = false; if (name == ".ctor") { foreach (TargetMethodInfo method in ctype.Constructors) { if (method.IsStatic) continue; methods.Add (method.Type); is_instance = true; } } else if (name == ".cctor") { foreach (TargetMethodInfo method in ctype.Constructors) { if (!method.IsStatic) continue; methods.Add (method.Type); is_static = true; } } else { foreach (TargetMethodInfo method in ctype.Methods) { if (method.IsStatic && !search_static) continue; if (!method.IsStatic && !search_instance) continue; if (method.Name != name) continue; methods.Add (method.Type); if (method.IsStatic) is_static = true; else is_instance = true; } } if (methods.Count > 0) { TargetFunctionType[] funcs = new TargetFunctionType [methods.Count]; methods.CopyTo (funcs, 0); return new MethodGroupExpression ( ctype, instance, name, funcs, is_instance, is_static); } } if (stype.HasParent) { stype = stype.GetParentType (target); if (instance != null) { instance = instance.GetParentObject (target); if (instance == null) return null; } goto again; } return null; }
public override void RuntimeInvoke(TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, RuntimeInvokeFlags flags, RuntimeInvokeResult result) { enforce_managed_context (); StartOperation (new OperationRuntimeInvoke ( this, function, object_argument, param_objects, flags, result)); }
public TargetFunctionType QueryMethod(TargetFunctionType[] methods) { Report.Print ("More than one method matches your query:\n"); ArrayList list = new ArrayList (); foreach (TargetFunctionType method in methods) { list.Add (method); Report.Print ("{0,4} {1}\n", list.Count, method.Name); } Report.Print ("Select a method or 0 to abort: "); string result = Report.ReadLine (); uint index; try { index = UInt32.Parse (result); } catch { Report.Print ("Invalid number."); return null; } if (index == 0) return null; if (index > list.Count) { Report.Print ("No such method."); return null; } return (TargetFunctionType) list [(int) index]; }
public abstract void RuntimeInvoke(TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, RuntimeInvokeFlags flags, RuntimeInvokeResult result);