public JSTryCatchBlock(JSStatement body, JSVariable catchVariable = null, JSStatement @catch = null, JSStatement @finally = null) { Body = body; CatchVariable = catchVariable; Catch = @catch; Finally = @finally; }
public JSForLoop(JSStatement initializer, JSExpression condition, JSStatement increment, params JSStatement[] body) { _Initializer = initializer; _Condition = condition; _Increment = increment; Statements.AddRange(body); }
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); } }
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); }
private void MarkAsControlFlow(JSStatement s) { var bs = s as JSBlockStatement; if (bs != null) { bs.IsControlFlow = true; } }
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); }
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); }
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; } }
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); }
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; } }
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; } }
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); }
private void MarkAsControlFlow(JSStatement s) { s.IsControlFlow = true; }