public void VisitNode (JSTryCatchBlock tcb) {
            if ((tcb.Finally != null) && (tcb.Catch == null)) {
                do {
                    if (!tcb.Finally.Children.All((n) => n is JSExpressionStatement))
                        break;

                    var statements = tcb.Finally.Children.OfType<JSExpressionStatement>().ToArray();

                    if (statements.Any((es) => es.Expression.HasGlobalStateDependency))
                        break;

                    if (!statements.All((es) => IsEffectivelyConstant(es.Expression)))
                        break;

                    ParentNode.ReplaceChild(tcb, tcb.Body);
                    VisitReplacement(tcb.Body);
                    return;
                } while (false);
            }

            VisitChildren(tcb);
        }
Ejemplo n.º 2
0
        public void VisitNode(JSTryCatchBlock tcb)
        {
            // Hoisting a label out of the try {} body is safe since it always runs.
            MaybeHoist(tcb, tcb.Body.SelfAndChildren.OfType<JSStatement>());

            VisitChildren(tcb);
        }