Search in sources :

Example 1 with Return_Statement

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

the class TestCase_Function_Visit_Handler method leave.

public void leave(IVisitableNode node) {
    if (waitForTC || waitForFunction) {
        if (node instanceof Definition_Statement) {
            if (!waitForRecord) {
                nodeVarIsRecord.add(false);
            }
            waitForRecord = false;
            waitForValue = false;
            evaluateExpression();
        }
        if (node instanceof Undefined_LowerIdentifier_Value) {
            blockReferenceListing = false;
        }
        if ((node instanceof Assignment_Statement) || ((node instanceof If_Clause))) {
            waitForValue = false;
            // if assignment is a createExpression
            if (node instanceof Assignment_Statement) {
                if (((Assignment_Statement) node).getTemplate() instanceof SpecificValue_Template) {
                    SpecificValue_Template specValTemplate = (SpecificValue_Template) ((Assignment_Statement) node).getTemplate();
                    if (specValTemplate.getSpecificValue() instanceof ComponentCreateExpression) {
                        isCreate = true;
                    }
                }
            }
            evaluateExpression();
        }
        if (node instanceof SequenceOf_Value) {
            evaluateExpression();
        }
        if ((waitForFunction && (node instanceof Return_Statement)) || (waitForTC && (node instanceof ComponentCreateExpression)) || (node instanceof Send_Statement) || (node instanceof Receive_Port_Statement)) {
            evaluateExpression();
        }
        if (waitForTcStartValues && (node instanceof Identifier) && myASTVisitor.blockIdListing) {
            myASTVisitor.blockIdListing = false;
        }
        if (waitForTcStopValues && (node instanceof Identifier) && myASTVisitor.blockIdListing) {
            myASTVisitor.blockIdListing = false;
        }
        if (node instanceof Connect_Statement) {
            waitForTcConnectValues = false;
        }
        if (node instanceof Disconnect_Statement) {
            waitForTcDisconnectValues = false;
        }
        if (node instanceof Unknown_Start_Statement) {
            waitForTcStartValues = false;
        }
        if (node instanceof Unknown_Stop_Statement) {
            waitForTcStopValues = false;
        }
        if (node instanceof Definition_Statement) {
            waitForDefStatement = false;
            if (waitForValue) {
                nodeVarValues.add(null);
                nodeVarIsAValueReference.add(false);
                waitForValue = false;
            }
        }
        if (node instanceof Map_Statement) {
            waitForMapIdentifiers = false;
        }
        if (node instanceof ComponentCreateExpression) {
            // switch first two values
            testCaseCreateValues.add(testCaseCreateCharValues.get(0));
            testCaseCreateValues.add(testCaseCreateRefValues.get(0));
            for (int i = 1; i < testCaseCreateCharValues.size(); i++) {
                testCaseCreateValues.add(testCaseCreateCharValues.get(i));
            }
            testCaseCreateCharValues.clear();
            testCaseCreateRefValues.clear();
            waitForTcCreateValues = false;
        }
        if (node instanceof Assignment_Statement) {
            waitForAssignmentIdentifiers = false;
            waitForValue = true;
        }
        if (waitForTcIfCondition && (node instanceof If_Clause)) {
            waitForTcIfCondition = false;
        }
        if (waitForTcStartParameter && (node instanceof Unknown_Start_Statement)) {
            testCaseStartValueParameters.add(null);
        }
        if (waitForTcStopParameter && (node instanceof Unknown_Stop_Statement)) {
            testCaseStopValueParameters.add(null);
        }
        if (isAltGuards && (node instanceof Operation_Altguard)) {
            altGuardConditions.add(null);
        }
        if (node instanceof Operation_Altguard) {
            waitForAltStatements = false;
            isAltGuards = false;
            isReceiveValue = false;
        }
        handleAltCases(node);
        if (node instanceof Unknown_Start_Statement) {
            waitForUnknownStartStatement = false;
        }
        if (node instanceof Unknown_Stop_Statement) {
            waitForUnknownStopStatement = false;
        }
        if (node instanceof Receive_Port_Statement) {
            if (waitForReceiveParameter) {
                altGuardReceiveType.add("noparam");
            }
        // TODO checkAnyport = true;
        }
    }
    if (node instanceof Def_Testcase) {
        handleTestcase(node);
        waitForTC = false;
    }
    if (node instanceof Def_Function) {
        handleFunction(node);
        waitForTC = false;
    }
    if (waitForAssignmentIdentifiers && (node instanceof ArraySubReference)) {
        waitForAssignmentIdentifiers = false;
    }
}
Also used : Connect_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Connect_Statement) Definition_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Definition_Statement) Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) ComponentCreateExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ComponentCreateExpression) If_Clause(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function) Operation_Altguard(org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference) Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement) Assignment_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Identifier(org.eclipse.titan.designer.AST.Identifier) Unknown_Stop_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Stop_Statement) Return_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Return_Statement) Send_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement) Disconnect_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Disconnect_Statement) Unknown_Start_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Start_Statement) Map_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Map_Statement) Undefined_LowerIdentifier_Value(org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)

Example 2 with Return_Statement

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

the class LazyChecker method process.

public void process(final IVisitableNode node) {
    // This variable indicates occurrence of Return_Statement.
    haveToContinue = true;
    // Collect and store FormalParameters.
    formalParameterCollector = new RelevantFormalParameterCollector();
    node.accept(formalParameterCollector);
    // Build structure.
    final RelevantNodeBuilder relevantNodeBuilder = new RelevantNodeBuilder(node);
    node.accept(relevantNodeBuilder);
    // Evaluate tree and return with FormalParameters which have to be evaluated.
    final Set<FormalParameter> shouldBeEvaluated = relevantNodeBuilder.collectRelevantReferences();
    for (final FormalParameter formalParameter : formalParameterCollector.getItems()) {
        if (!shouldBeEvaluated.contains(formalParameter) && !formalParameter.getIsLazy()) {
            lazyParameterList.add(formalParameter);
        }
    }
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter)

Example 3 with Return_Statement

use of org.eclipse.titan.designer.AST.TTCN3.statements.Return_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)

Example 4 with Return_Statement

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

the class Lazy method process.

@Override
protected void process(final IVisitableNode node, final Problems problems) {
    // This variable indicates occurrence of Return_Statement.
    haveToContinue = true;
    // Collect and store FormalParameters.
    formalParameterCollector = new RelevantFormalParameterCollector();
    node.accept(formalParameterCollector);
    // Build structure.
    final RelevantNodeBuilder relevantNodeBuilder = new RelevantNodeBuilder(node);
    node.accept(relevantNodeBuilder);
    // Evaluate tree and return with FormalParameters which have to be evaluated.
    final Set<FormalParameter> shouldBeEvaluated = relevantNodeBuilder.collectRelevantReferences();
    for (final FormalParameter formalParameter : formalParameterCollector.getItems()) {
        final boolean isLazy = formalParameter.getIsLazy();
        String message = null;
        if (shouldBeEvaluated.contains(formalParameter)) {
            if (isLazy) {
                message = "not ";
            }
        } else {
            if (!isLazy) {
                message = "";
            }
        }
        if (message != null) {
            final String msg = MessageFormat.format(ERROR_MESSAGE, formalParameter.getIdentifier().getDisplayName(), message);
            problems.report(formalParameter.getLocation(), msg);
        }
    }
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter)

Aggregations

FormalParameter (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter)2 Return_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Return_Statement)2 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)1 Identifier (org.eclipse.titan.designer.AST.Identifier)1 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)1 Def_Testcase (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase)1 AltGuards (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuards)1 Alt_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement)1 Assignment_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement)1 Connect_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Connect_Statement)1 Definition_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Definition_Statement)1 Disconnect_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Disconnect_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_Clause (org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause)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 Map_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Map_Statement)1 Operation_Altguard (org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard)1 Receive_Port_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement)1