Search in sources :

Example 1 with Interleave_Statement

use of org.eclipse.titan.designer.AST.TTCN3.statements.Interleave_Statement in project titan.EclipsePlug-ins by eclipse.

the class ReturnVisitor method visit.

@Override
public int visit(final IVisitableNode node) {
    // certain YES
    if (node instanceof Return_Statement) {
        certainty = ReturnCertainty.YES;
        return V_ABORT;
    }
    // 
    if (node instanceof StatementBlock || node instanceof StatementList) {
        final StatementBlockVisitor blockVis = new StatementBlockVisitor();
        node.accept(blockVis);
        certainty = blockVis.getCertainty();
        return V_SKIP;
    }
    // custom statements
    if (node instanceof While_Statement || node instanceof DoWhile_Statement || node instanceof For_Statement) {
        final BranchMerger branchMerger = new BranchMerger();
        node.accept(branchMerger);
        // conditional blocks: maximum MAYBE
        certainty = branchMerger.getCertainty().or(ReturnCertainty.NO);
        return V_SKIP;
    }
    if (node instanceof If_Statement) {
        final If_Statement ifs = (If_Statement) node;
        final BranchMerger branchMerger = new BranchMerger();
        node.accept(branchMerger);
        if (ifs.getStatementBlock() != null) {
            // must enter one block: maximum YES
            certainty = branchMerger.getCertainty();
        } else {
            // conditional blocks: maximum MAYBE
            certainty = branchMerger.getCertainty().or(ReturnCertainty.NO);
        }
        return V_SKIP;
    }
    if (node instanceof Alt_Statement) {
        final AltGuards ags = ((Alt_Statement) node).getAltGuards();
        final BranchMerger branchMerger = new BranchMerger();
        ags.accept(branchMerger);
        if (ags.hasElse()) {
            // must enter one block: maximum YES
            certainty = branchMerger.getCertainty();
        } else {
            // conditional blocks: maximum MAYBE
            certainty = branchMerger.getCertainty().or(ReturnCertainty.NO);
        }
        return V_SKIP;
    }
    if (node instanceof Interleave_Statement) {
        final BranchMerger branchMerger = new BranchMerger();
        node.accept(branchMerger);
        // conditional block: maximum MAYBE
        certainty = branchMerger.getCertainty().or(ReturnCertainty.NO);
        return V_SKIP;
    }
    if (node instanceof StatementBlock_Statement) {
        final BranchMerger branchMerger = new BranchMerger();
        node.accept(branchMerger);
        // must enter block: maximum YES
        certainty = branchMerger.getCertainty();
        return V_SKIP;
    }
    if (node instanceof SelectCase_Statement) {
        final BranchMerger branchMerger = new BranchMerger();
        node.accept(branchMerger);
        // must enter one block: maximum YES
        certainty = branchMerger.getCertainty();
        return V_SKIP;
    }
    return V_ABORT;
}
Also used : For_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.For_Statement) SelectCase_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.SelectCase_Statement) Interleave_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Interleave_Statement) DoWhile_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.DoWhile_Statement) StatementBlock_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock_Statement) AltGuards(org.eclipse.titan.designer.AST.TTCN3.statements.AltGuards) Return_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Return_Statement) Alt_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) StatementBlock(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock) While_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.While_Statement) DoWhile_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.DoWhile_Statement)

Aggregations

AltGuards (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuards)1 Alt_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement)1 DoWhile_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.DoWhile_Statement)1 For_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.For_Statement)1 If_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement)1 Interleave_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Interleave_Statement)1 Return_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Return_Statement)1 SelectCase_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.SelectCase_Statement)1 StatementBlock (org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)1 StatementBlock_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock_Statement)1 While_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.While_Statement)1