Example #1
0
 public JSTryCatchBlock(JSStatement body, JSVariable catchVariable = null, JSStatement @catch = null, JSStatement @finally = null)
 {
     Body          = body;
     CatchVariable = catchVariable;
     Catch         = @catch;
     Finally       = @finally;
 }
Example #2
0
 public JSForLoop(JSStatement initializer, JSExpression condition, JSStatement increment, params JSStatement[] body)
 {
     _Initializer = initializer;
     _Condition   = condition;
     _Increment   = increment;
     Statements.AddRange(body);
 }
Example #3
0
        public override void ReplaceChild(JSNode oldChild, JSNode newChild)
        {
            if (oldChild == null)
            {
                throw new ArgumentNullException("oldChild");
            }

            if (_Initializer == oldChild)
            {
                _Initializer = (JSStatement)newChild;
            }

            if (_Condition == oldChild)
            {
                _Condition = (JSExpression)newChild;
            }

            if (_Increment == oldChild)
            {
                _Increment = (JSStatement)newChild;
            }

            if (newChild is JSStatement)
            {
                base.ReplaceChild(oldChild, newChild);
            }
        }
Example #4
0
        public void Add(JSStatement statement)
        {
            if (statement.Label == null)
            {
                throw new InvalidOperationException("Cannot add an unlabeled statement to a label group");
            }

            Labels.Enqueue(statement.Label, statement);
        }
Example #5
0
        private void MarkAsControlFlow(JSStatement s)
        {
            var bs = s as JSBlockStatement;

            if (bs != null)
            {
                bs.IsControlFlow = true;
            }
        }
Example #6
0
        public JSLabelGroupStatement(int index, JSStatement entryLabel, JSStatement exitLabel)
        {
            GroupIndex = index;

            MarkAsControlFlow(entryLabel);
            MarkAsControlFlow(exitLabel);

            EntryLabelNode = Labels.Enqueue(entryLabel.Label, entryLabel);
            ExitLabelNode  = Labels.Enqueue(exitLabel.Label, exitLabel);
        }
Example #7
0
        public void Add(JSStatement statement)
        {
            if (statement.Label == null)
            {
                throw new InvalidOperationException("Cannot add an unlabeled statement to a label group");
            }

            MarkAsControlFlow(statement);

            Labels.EnqueueBefore(ExitLabelNode, statement.Label, statement);
        }
Example #8
0
        public JSIfStatement(JSExpression condition, JSStatement trueClause, JSStatement falseClause = null)
        {
            _Condition   = condition;
            _TrueClause  = trueClause;
            _FalseClause = falseClause;

            if (_TrueClause != null)
            {
                _TrueClause.IsControlFlow = true;
            }
            if (_FalseClause != null)
            {
                _FalseClause.IsControlFlow = true;
            }
        }
Example #9
0
        public bool InsertNearChildRecursive(JSStatement relativeTo, JSStatement newChild, int offset = 0)
        {
            for (int i = 0, c = Statements.Count; i < c; i++)
            {
                if (
                    (Statements[i] == relativeTo) ||
                    Statements[i].AllChildrenRecursive.Any((n) => n == relativeTo)
                    )
                {
                    Statements.Insert(i + offset, newChild);
                    return(true);
                }
            }

            return(false);
        }
Example #10
0
        public JSIfStatement(JSExpression condition, JSStatement trueClause, JSStatement falseClause = null)
        {
            _Condition   = condition;
            _TrueClause  = trueClause;
            _FalseClause = falseClause;

            var trueBlock = _TrueClause as JSBlockStatement;

            if (trueBlock != null)
            {
                trueBlock.IsControlFlow = true;
            }

            var falseBlock = _FalseClause as JSBlockStatement;

            if (falseBlock != null)
            {
                falseBlock.IsControlFlow = true;
            }
        }
Example #11
0
        public override void ReplaceChild(JSNode oldChild, JSNode newChild)
        {
            if (oldChild == null)
            {
                throw new ArgumentNullException("oldChild");
            }

            if (_Condition == oldChild)
            {
                _Condition = (JSExpression)newChild;
            }

            if (_TrueClause == oldChild)
            {
                _TrueClause = (JSStatement)newChild;
            }

            if (_FalseClause == oldChild)
            {
                _FalseClause = (JSStatement)newChild;
            }
        }
Example #12
0
        public override void ReplaceChild(JSNode oldChild, JSNode newChild)
        {
            if (oldChild == null)
            {
                throw new ArgumentNullException("oldChild");
            }

            if (CatchVariable == oldChild)
            {
                CatchVariable = (JSVariable)newChild;
            }

            if (Catch == oldChild)
            {
                Catch = (JSStatement)newChild;
            }

            if (Finally == oldChild)
            {
                Finally = (JSStatement)newChild;
            }

            Body.ReplaceChild(oldChild, newChild);
        }
Example #13
0
 private void MarkAsControlFlow(JSStatement s)
 {
     s.IsControlFlow = true;
 }