Search in sources :

Example 1 with Or4bExpression

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

the class Def_Function_Writer method writeAssignmentStatement.

// updated
public String writeAssignmentStatement(Assignment_Statement tc_assignStatement) {
    StringBuilder functionString = new StringBuilder("");
    if (tc_assignStatement.getTemplate() instanceof SpecificValue_Template) {
        SpecificValue_Template specValTemplate = (SpecificValue_Template) tc_assignStatement.getTemplate();
        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
            functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");
            functionString.append(functionAssignIdentifiers.get(assignCounter) + functionAssignValues.get(assignCounter) + ";\r\n");
        // TODO: add logging here
        }
    }
    /*StringBuilder functionString = new StringBuilder("");

		if (tc_assignStatement.getTemplate() instanceof SpecificValue_Template) {
			SpecificValue_Template specValTemplate = (SpecificValue_Template) tc_assignStatement.getTemplate();

			if (specValTemplate.getSpecificValue() instanceof Bitstring_Value) {

				functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");

				functionString.append(functionAssignIdentifiers.get(assignCounter) + "=new BITSTRING(\""
						+ functionAssignValues.get(assignCounter) + "\");\r\n");

				// TODO: add logging here

			}

			if (specValTemplate.getSpecificValue() instanceof Integer_Value) {

				functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");

				functionString.append(functionAssignIdentifiers.get(assignCounter) + "=new INTEGER(\""
						+ functionAssignValues.get(assignCounter) + "\");\r\n");

				// TODO: add logging here

			}

			if (specValTemplate.getSpecificValue() instanceof Charstring_Value) {

				functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");

				functionString.append(functionAssignIdentifiers.get(assignCounter) + "=new CHARSTRING(\""
						+ functionAssignValues.get(assignCounter) + "\");\r\n");

				// TODO: add logging here

			}

			if (specValTemplate.getSpecificValue() instanceof Boolean_Value) {

				functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");

				functionString.append(functionAssignIdentifiers.get(assignCounter) + "=new BOOLEAN("
						+ functionAssignValues.get(assignCounter) + ");\r\n");

				// TODO: add logging here

			}

			if (specValTemplate.getSpecificValue() instanceof Undefined_LowerIdentifier_Value) {

				functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");

				functionString.append(functionAssignIdentifiers.get(assignCounter) + "="
						+ functionAssignValues.get(assignCounter) + ";\r\n");

				// TODO: add logging here
			}

			if (specValTemplate.getSpecificValue() instanceof Referenced_Value) {

				functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");

				functionString.append(functionAssignIdentifiers.get(assignCounter) + "="
						+ functionAssignValues.get(assignCounter) + ";\r\n");

				// TODO: add logging here
			}

			if ((specValTemplate.getSpecificValue() instanceof AddExpression)
					|| (specValTemplate.getSpecificValue() instanceof SubstractExpression)
					|| (specValTemplate.getSpecificValue() instanceof MultiplyExpression)
					|| (specValTemplate.getSpecificValue() instanceof DivideExpression)
					|| (specValTemplate.getSpecificValue() instanceof ModuloExpression)
					|| (specValTemplate.getSpecificValue() instanceof RemainderExpression)) {

				functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");

				functionString.append(functionAssignIdentifiers.get(assignCounter)
						+ functionAssignValues.get(assignCounter) + ";\r\n");

				// TODO: add logging here

			}

			if (specValTemplate.getSpecificValue() instanceof UnaryMinusExpression) {

				functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");

				functionString.append(functionAssignIdentifiers.get(assignCounter) + "=new INTEGER(\""
						+ functionAssignValues.get(assignCounter) + "\");\r\n");

				// TODO: add logging here

			}

		}
*/
    return functionString.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) 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)

Example 2 with Or4bExpression

use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.Or4bExpression 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 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)2 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)2 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)2 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)2 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)2 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)2 Undefined_LowerIdentifier_Value (org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)2 AddExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.AddExpression)2 And4bExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.And4bExpression)2 DivideExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.DivideExpression)2 ModuloExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ModuloExpression)2 MultiplyExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.MultiplyExpression)2 Not4bExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.Not4bExpression)2 Or4bExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.Or4bExpression)2 RemainderExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.RemainderExpression)2 RotateLeftExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.RotateLeftExpression)2 RotateRightExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.RotateRightExpression)2 ShiftLeftExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ShiftLeftExpression)2 ShiftRightExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ShiftRightExpression)2