Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public override void RuntimeInvoke(TargetFunctionType function,
                                    TargetStructObject object_argument,
                                    TargetObject[] param_objects,
                                    RuntimeInvokeFlags flags,
                                    RuntimeInvokeResult result)
 {
     throw new InvalidOperationException();
 }
Ejemplo n.º 3
0
        public RuntimeInvokeFlags GetRuntimeInvokeFlags()
        {
            RuntimeInvokeFlags flags = RuntimeInvokeFlags.VirtualMethod;

            if ((ScriptingFlags & ScriptingFlags.NestedBreakStates) != 0)
            {
                flags |= RuntimeInvokeFlags.NestedBreakStates;
            }

            return(flags);
        }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
 public abstract void RuntimeInvoke(TargetFunctionType function,
                                    TargetStructObject object_argument,
                                    TargetObject[] param_objects,
                                    RuntimeInvokeFlags flags,
                                    RuntimeInvokeResult result);
Ejemplo n.º 7
0
        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;
            }
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
            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;
            }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        public static EvaluationResult GetProperty(Thread thread, TargetPropertyInfo property,
                                                   TargetStructObject instance, EvaluationFlags flags,
                                                   int timeout, out string error, out TargetObject result)
        {
            error = null;

            RuntimeInvokeResult rti;

            try {
                RuntimeInvokeFlags rti_flags = RuntimeInvokeFlags.VirtualMethod;

                if ((flags & EvaluationFlags.NestedBreakStates) != 0)
                {
                    rti_flags |= RuntimeInvokeFlags.NestedBreakStates;
                }

                rti = thread.RuntimeInvoke(
                    property.Getter, instance, new TargetObject [0], rti_flags);

                if (!rti.CompletedEvent.WaitOne(timeout, false))
                {
                    rti.Abort();
                    result = null;
                    return(EvaluationResult.Timeout);
                }

                if ((rti.TargetException != null) &&
                    (rti.TargetException.Type == TargetError.ClassNotInitialized))
                {
                    result = null;
                    error  = rti.ExceptionMessage;
                    return(EvaluationResult.NotInitialized);
                }

                if (rti.Result is Exception)
                {
                    result = null;
                    error  = ((Exception)rti.Result).Message;
                    return(EvaluationResult.UnknownError);
                }

                result = (TargetObject)rti.ReturnObject;

                if (rti.ExceptionMessage != null)
                {
                    error = rti.ExceptionMessage;
                    return(EvaluationResult.Exception);
                }
                else if (rti.ReturnObject == null)
                {
                    rti.Abort();
                    return(EvaluationResult.UnknownError);
                }

                return(EvaluationResult.Ok);
            } catch (TargetException ex) {
                result = null;
                error  = ex.ToString();
                return(EvaluationResult.UnknownError);
            }
        }
Ejemplo n.º 12
0
        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;
        }
Ejemplo n.º 13
0
            public override void RuntimeInvoke(TargetFunctionType function,
							    TargetStructObject object_argument,
							    TargetObject[] param_objects,
							    RuntimeInvokeFlags flags,
							    RuntimeInvokeResult result)
            {
                throw new InvalidOperationException ();
            }
Ejemplo n.º 14
0
        public abstract void RuntimeInvoke(TargetFunctionType function,
						    TargetStructObject object_argument,
						    TargetObject[] param_objects,
						    RuntimeInvokeFlags flags,
						    RuntimeInvokeResult result);