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;
}
}
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();
}
Aggregations