Ejemplo n.º 1
0
        public void CompileTryCatchFinally(TryCatchFinally tcf)
        {
            XmlElement previousElement = currentElement;
            XmlElement tmpElement      = document.CreateElement("TryCatchFinally");

            tmpElement.SetAttribute("ExceptionName", tcf.ExceptionName);

            currentElement = document.CreateElement("TryBlock");
            tcf.TryBlock.AcceptCompiler(this);
            tmpElement.AppendChild(currentElement);

            if (tcf.CatchBlock != null)
            {
                currentElement = document.CreateElement("CatchBlock");
                tcf.CatchBlock.AcceptCompiler(this);
                tmpElement.AppendChild(currentElement);
            }

            if (tcf.FinallyBlock != null)
            {
                currentElement = document.CreateElement("FinallyBlock");
                tcf.FinallyBlock.AcceptCompiler(this);
                tmpElement.AppendChild(currentElement);
            }

            previousElement.AppendChild(tmpElement);
            currentElement = previousElement;
        }
Ejemplo n.º 2
0
 public BasicBlock(Source src, TryCatchFinally tryBlock, int tryDepth)
 {
     TryBlock = tryBlock;
     TryDepth = tryDepth;
     Source   = src;
     Ending   = BlockEnding.Open;
 }
Ejemplo n.º 3
0
        void EndTryCatchFinally(TryCatchFinally tcf)
        {
            if (tcf.OptionalFinallyBody != null)
            {
                _prependReturn.Pop();
            }

            _prependContinue.Pop();
            _prependBreak.Pop();
        }
Ejemplo n.º 4
0
        void BeginTryCatchFinally(TryCatchFinally tcf)
        {
            if (tcf.OptionalFinallyBody != null)
            {
                _prependReturn.Push(tcf.OptionalFinallyBody);
            }

            _prependContinue.Push(tcf.OptionalFinallyBody);
            _prependBreak.Push(tcf.OptionalFinallyBody);
            _insideTry = true;
        }
Ejemplo n.º 5
0
        public void CompileTryCatchFinally(TryCatchFinally tcf)
        {
            textWriter.WriteLine("try");
            tcf.TryBlock.AcceptCompiler(this);

            if (tcf.CatchBlock != null)
            {
                textWriter.WriteLine("catch ({0})", SafeName(tcf.ExceptionName));
                tcf.CatchBlock.AcceptCompiler(this);
            }

            if (tcf.FinallyBlock != null)
            {
                textWriter.WriteLine("finally");
                tcf.FinallyBlock.AcceptCompiler(this);
            }
        }
Ejemplo n.º 6
0
        public virtual void WriteTryCatchFinally(TryCatchFinally s)
        {
            Skip();
            WriteLine("try");
            WriteScope(s.TryBody, true, false);

            foreach (var c in s.CatchBlocks)
            {
                BeginLine("catch (");
                WriteCaughtException(c.Exception.Source, c.Exception.ValueType, c.Exception.Name);
                EndLine(")");
                WriteScope(c.Body, true, false);
            }

            if (s.OptionalFinallyBody != null)
            {
                WriteLine("finally");
                WriteScope(s.OptionalFinallyBody, true, false);
            }

            Skip();
        }
Ejemplo n.º 7
0
        public override void WriteTryCatchFinally(TryCatchFinally s)
        {
            WriteLine("try");
            WriteScope(s.TryBody);

            if (s.CatchBlocks.Length > 0)
            {
                WriteLine("catch ($js_exception)");
                BeginScope();

                WriteLine("$uno_exception = $ConvertNativeException($js_exception);");

                bool first = true;
                foreach (var c in s.CatchBlocks)
                {
                    BeginLine(!first ? "else " : "");
                    EndLine("if ($uno_exception instanceof " + Backend.GetGlobal(c.Exception.ValueType) + ")");
                    BeginScope();
                    WriteLine("var " + c.Exception.Name + " = $uno_exception;");
                    WriteScope(c.Body, false, false);
                    EndScope();
                    first = false;
                }

                WriteLine("else");
                BeginScope();
                WriteLine("throw $js_exception");
                EndScope();
                EndScope();
            }

            if (s.OptionalFinallyBody != null)
            {
                WriteLine("finally");
                WriteScope(s.OptionalFinallyBody);
            }
        }
Ejemplo n.º 8
0
        private void btnTryCatchFinally_Click(object sender, EventArgs e)
        {
            var x = new TryCatchFinally();

            x.Test();
        }
Ejemplo n.º 9
0
 public Label(TryCatchFinally tcBlock)
 {
     TryCatchBlock = tcBlock;
 }