protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
        {
            if (Try == null || Try.Body.Count == 0)
            {
                return(Completion.Void);
            }
            ExecutionEnvironment te = new ExecutionEnvironment(enviroment);
            var c = Try.Execute(te);

            if (c.Type == CompletionType.Exception)
            {
                ExecutionEnvironment ec = new ExecutionEnvironment(enviroment);
                ec.RegisterValue("e", c.ReturnValue);
                if (Catch != null && Catch.Body.Count > 0)
                {
                    ExecutionEnvironment ee = new ExecutionEnvironment(ec);
                    c = Catch.Execute(ee);
                }
                else
                {
                    c = Completion.Void;
                }
                if (c.Type == CompletionType.Exception)
                {
                    return(c);
                }
            }
            Completion fc = Completion.Void;

            if (Finally != null && Finally.Body.Count > 0)
            {
                ExecutionEnvironment fe = new ExecutionEnvironment(enviroment);
                fc = Finally.Execute(fe);
            }
            if (c.Type == CompletionType.Return)
            {
                return(c);
            }
            else if (c.Type == CompletionType.Value)
            {
                return(c);
            }
            if (fc.Type == CompletionType.Return)
            {
                return(fc);
            }
            return(c);
        }
Esempio n. 2
0
        public Completion Execute(ExecutionEnvironment enviroment)
        {
            if (Try == null || Try.Body.Count == 0)
            {
                return(Completion.Void);
            }
            ExecutionEnvironment te = new ExecutionEnvironment(enviroment);
            var c = Try.Execute(te);

            if (c.Type == CompletionType.Exception)
            {
                if (Catch != null && Catch.Body.Count > 0)
                {
                    ExecutionEnvironment ee = new ExecutionEnvironment(enviroment);
                    c = Catch.Execute(ee);
                }
            }
            Completion fc = Completion.Void;

            if (Finally != null && Finally.Body.Count > 0)
            {
                ExecutionEnvironment fe = new ExecutionEnvironment(enviroment);
                fc = Finally.Execute(fe);
            }
            if (c.Type == CompletionType.Return)
            {
                return(c);
            }
            else if (c.Type == CompletionType.Value)
            {
                return(fc);
            }
            if (fc.Type == CompletionType.Return)
            {
                return(fc);
            }
            return(c);
        }