public SConditionalStatement(SExpression condition, SStatement trueStatement, SStatement nextStatement) : base(condition != null ? "if: " + condition.CodeString : "", nextStatement) { Condition = condition; IfTrueStatement = trueStatement; IfTrueStatement.SetNextStatement(null); }
public SLabeledStatement(string codeString, SExpression caseExpression, SStatement labeledStatement) : base(caseExpression != null ? "case " + caseExpression.CodeString : codeString, labeledStatement?.NextStatement) { LabeledStatement = labeledStatement; CaseExpression = caseExpression; }
public virtual void SetNextStatement(SStatement nextStatement) { if (_nextStatementSet) { return; } NextStatement = nextStatement; _nextStatementSet = true; }
public void SetLabeledStatement(SStatement labeledStatement) { if (_labeledStatementSet) { return; } LabeledStatement = labeledStatement; _labeledStatementSet = true; }
public SSwitchStatement(SExpression condition, SStatement switchStatement, SLabeledStatement[] jumpTargets, SStatement nextStatement) : base(condition != null ? "switch: " + condition.CodeString : "", new SLabeledStatement("switch break target", null, nextStatement) { Visible = false }) { Condition = condition; SwitchStatement = switchStatement; SwitchStatement.SetNextStatement(null); this.jumpTargets = (SLabeledStatement[])jumpTargets.Clone(); }
public SJumpStatement(string codeString, SStatement nextStatement) : base(codeString, nextStatement) { var parts = codeString.Split(' '); if (parts[0] == "goto" && parts.Length > 1) { TargetIdentifier = parts[1]; } else { TargetIdentifier = null; } ReturnedExpression = null; }
private void AddDirectedEdgeToElements(Graph <SStatement> graph, SStatement jumpTargetLabeledStatement, SStatement labeledStatement) { if (graph == null || jumpTargetLabeledStatement == null || labeledStatement == null) { return; } var a = FindNodes(graph, jumpTargetLabeledStatement.GetStatement()); var b = FindNodes(graph, labeledStatement.GetStatement()); foreach (var nodeStatement in a) { foreach (var statement in b) { if (statement != nodeStatement) { graph.AddDirectedEdge(nodeStatement, statement, 1); } } } }
private static List <GraphNode <SStatement> > FindNodes(Graph <SStatement> graph, SStatement statement1) { var hashSet = new HashSet <GraphNode <SStatement> >(); foreach (var graphNode in graph.Nodes) { if (statement1 != null && graphNode.Value == statement1.GetStatement()) { hashSet.Add((GraphNode <SStatement>)graphNode); } } return(hashSet.ToList()); }
public override bool Contains(SStatement statement) { return(statement == this || IfTrueStatement != null && IfTrueStatement.Contains(statement) || ElseStatement != null && ElseStatement.Contains(statement)); }
public abstract bool Contains(SStatement statement);
public override bool Contains(SStatement statement) { return(statement == this); }
public SJumpStatement(SExpression returnedExpression, SStatement nextStatement) : base("return " + returnedExpression.CodeString, nextStatement) { TargetIdentifier = null; ReturnedExpression = returnedExpression; }
public override void SetNextStatement(SStatement nextStatement) { LabeledStatement.SetNextStatement(nextStatement); }
public override bool Contains(SStatement statement) { return(statement == this || LabeledStatement != null && LabeledStatement.Contains(statement)); }
public override bool Contains(SStatement statement) { return(statement == this || SwitchStatement != null && SwitchStatement.Contains(statement)); }
public SStatement(string codeString, SStatement nextStatement) { CodeString = codeString; NextStatement = nextStatement; }
public SExpressionStatement(SExpression expression, SStatement nextStatement) : base(expression.CodeString, nextStatement) { _expression = expression; }