Ejemplo n.º 1
0
        public override object Run(RuntimeState state)
        {
            while ((bool)condition.Get(state))
            {
                object returned = body.Run(state);

                if (state.Returning != null)
                {
                    return(returned);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
 public override object Run(RuntimeState state)
 {
     if ((bool)condition.Get(state, null))
     {
         return(trueBody.Run(state));
     }
     else if (falseBody != null)
     {
         return(falseBody.Run(state));
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
        public override object Run(RuntimeState state)
        {
            try
            {
                return(tryBody.Run(state));
            }
            catch (Exception e)
            {
                state.RunningSource = Source;

                /*
                 *  If you use reflection to invoke a method, any exceptions
                 *  thrown inside the invoke will be wrapped in a
                 *  TargetInvocationException. This is a problem because then
                 *  you might filter for certain types of exception and miss
                 *  the wrapped instances. Also, the user doesn't care and
                 *  shouldn't know that reflection was used to invoke a
                 *  method. Might cause problems with expected behaviour if
                 *  a user explicitly uses invoke or throws a
                 *  TargetInvocationException.
                 *
                 *  Unwrap TargetInvocationException instances in all user
                 *  type blocks.
                 */

                while (true)
                {
                    TargetInvocationException wrapper
                        = e as TargetInvocationException;

                    if (wrapper == null)
                    {
                        break;
                    }

                    e = wrapper.InnerException;
                }

                if (catchVariable != null)
                {
                    catchVariable.Set(state, e);
                }

                return(catchBody.Run(state));
            }
        }