Search in sources :

Example 1 with ComponentCreateExpression

use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ComponentCreateExpression 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 ComponentCreateExpression

use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ComponentCreateExpression in project titan.EclipsePlug-ins by eclipse.

the class Def_Testcase_Writer method writeAssignmentStatement.

public String writeAssignmentStatement(Assignment_Statement tc_assignStatement) {
    StringBuilder testCaseString = new StringBuilder("");
    if (tc_assignStatement.getTemplate() instanceof SpecificValue_Template) {
        SpecificValue_Template specValTemplate = (SpecificValue_Template) tc_assignStatement.getTemplate();
        if (specValTemplate.getSpecificValue() instanceof ComponentCreateExpression) {
            ComponentCreateExpression componenetCreateExp = (ComponentCreateExpression) specValTemplate.getSpecificValue();
            createCounter++;
            logCreateCounter++;
            int logSizeValue = 1;
            while (tcCreateCounter.get(logCreateCounter).equals(String.valueOf(createCounter))) {
                logCreateCounter++;
                logSizeValue++;
                if (tcCreateCounter.size() == (logCreateCounter)) {
                    break;
                }
            }
            String[] logValues = new String[logSizeValue];
            int logWriteCounter = 0;
            testCaseString.append("rownum=" + componenetCreateExp.getLocation().getLine() + ";\r\n");
            if (tcAssignIdentifiers.get(assignCounter).endsWith("=")) {
                tcAssignIdentifiers.set(assignCounter, tcAssignIdentifiers.get(assignCounter).substring(0, tcAssignIdentifiers.get(assignCounter).length() - 1));
            }
            testCaseString.append("hc.create(" + "\"" + tcAssignIdentifiers.get(assignCounter) + "\"");
            logValues[logWriteCounter] = tcAssignIdentifiers.get(assignCounter);
            currentCounterValue++;
            // assignCounter++;
            logWriteCounter++;
            while (tcCreateCounter.get(currentCounterValue).equals(String.valueOf(createCounter))) {
                testCaseString.append(",\"" + tcCreateValues.get(currentCounterValue) + "\"");
                logValues[logWriteCounter] = tcCreateValues.get(currentCounterValue);
                logWriteCounter++;
                currentCounterValue++;
                if (tcCreateCounter.size() == (currentCounterValue)) {
                    break;
                }
            }
            testCaseString.append("); " + "\r\n");
            testCaseString.append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \"" + nodeName + "\", \"Starting PTC " + logValues[0] + " type " + logValues[1] + " on " + logValues[2] + "\", false);" + "\r\n");
        } else if ((specValTemplate.getSpecificValue() instanceof Bitstring_Value) || (specValTemplate.getSpecificValue() instanceof Integer_Value) || (specValTemplate.getSpecificValue() instanceof Charstring_Value) || (specValTemplate.getSpecificValue() instanceof Boolean_Value) || (specValTemplate.getSpecificValue() instanceof Octetstring_Value) || (specValTemplate.getSpecificValue() instanceof Undefined_LowerIdentifier_Value) || (specValTemplate.getSpecificValue() instanceof Referenced_Value) || (specValTemplate.getSpecificValue() instanceof And4bExpression) || (specValTemplate.getSpecificValue() instanceof Xor4bExpression) || (specValTemplate.getSpecificValue() instanceof Not4bExpression) || (specValTemplate.getSpecificValue() instanceof Or4bExpression) || (specValTemplate.getSpecificValue() instanceof ShiftLeftExpression) || (specValTemplate.getSpecificValue() instanceof ShiftRightExpression) || (specValTemplate.getSpecificValue() instanceof RotateRightExpression) || (specValTemplate.getSpecificValue() instanceof RotateLeftExpression) || (specValTemplate.getSpecificValue() instanceof StringConcatenationExpression) || (specValTemplate.getSpecificValue() instanceof AddExpression) || (specValTemplate.getSpecificValue() instanceof SubstractExpression) || (specValTemplate.getSpecificValue() instanceof MultiplyExpression) || (specValTemplate.getSpecificValue() instanceof DivideExpression) || (specValTemplate.getSpecificValue() instanceof ModuloExpression) || (specValTemplate.getSpecificValue() instanceof RemainderExpression) || (specValTemplate.getSpecificValue() instanceof UnaryMinusExpression)) {
            // TODO assignments for indexed bitstrings
            testCaseString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");
            testCaseString.append(tcAssignIdentifiers.get(assignCounter) + tcAssignValues.get(assignCounter) + ";\r\n");
        // TODO: add logging here
        }
    }
    return testCaseString.toString();
}
Also used : Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) StringConcatenationExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.StringConcatenationExpression) Not4bExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.Not4bExpression) ComponentCreateExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ComponentCreateExpression) RotateLeftExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.RotateLeftExpression) ShiftRightExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ShiftRightExpression) Or4bExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.Or4bExpression) RemainderExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.RemainderExpression) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) UnaryMinusExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.UnaryMinusExpression) Bitstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) Boolean_Value(org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value) RotateRightExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.RotateRightExpression) MultiplyExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.MultiplyExpression) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value) DivideExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.DivideExpression) AddExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.AddExpression) ShiftLeftExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ShiftLeftExpression) SubstractExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.SubstractExpression) And4bExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.And4bExpression) Xor4bExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.Xor4bExpression) ModuloExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ModuloExpression) Undefined_LowerIdentifier_Value(org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)

Aggregations

SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)2 Undefined_LowerIdentifier_Value (org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)2 ComponentCreateExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ComponentCreateExpression)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 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 If_Clause (org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause)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 Return_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Return_Statement)1 Send_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement)1 Unknown_Start_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Start_Statement)1 Unknown_Stop_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Stop_Statement)1 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)1