use of org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value in project titan.EclipsePlug-ins by eclipse.
the class DoWhile_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
isInfiniteLoop = false;
if (statementblock != null) {
statementblock.setMyLaicStmt(null, this);
statementblock.check(timestamp);
}
if (expression != null) {
final IValue last = expression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
final Type_type temporalType = last.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (!last.getIsErroneous(timestamp)) {
if (!Type_type.TYPE_BOOL.equals(temporalType)) {
last.getLocation().reportSemanticError(BOOLEANEXPECTED);
expression.setIsErroneous(true);
} else if (!expression.isUnfoldable(timestamp)) {
if (!((Boolean_Value) last).getValue()) {
final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null);
expression.getLocation().reportConfigurableSemanticProblem(severity, UNNECESSARYCONTROL);
} else if (ReturnStatus_type.RS_NO.equals(hasReturn(timestamp))) {
isInfiniteLoop = true;
final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINFINITELOOPS, GeneralConstants.WARNING, null);
location.reportConfigurableSemanticProblem(severity, INFINITELOOP);
}
}
if (expression.getMyGovernor() == null) {
expression.setMyGovernor(new Boolean_Type());
}
}
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value in project titan.EclipsePlug-ins by eclipse.
the class If_Clause method check.
/**
* Does the semantic checking of this branch.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param unreachable
* boolean parameter telling if this if statement was
* already found unreachable by previous clauses or not
*
* @return true if following clauses are unreachable
*/
public boolean check(final CompilationTimeStamp timestamp, final boolean unreachable) {
if (unreachable) {
location.reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), NEVERREACH1);
}
boolean unreachable2 = unreachable;
if (expression != null) {
final IValue last = expression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
final Type_type temporalType = last.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (!last.getIsErroneous(timestamp) && !Type_type.TYPE_UNDEFINED.equals(temporalType)) {
if (!Type_type.TYPE_BOOL.equals(temporalType)) {
last.getLocation().reportSemanticError(BOOLEANEXPECTED);
expression.setIsErroneous(true);
} else if (!expression.isUnfoldable(timestamp)) {
if (((Boolean_Value) last).getValue()) {
expression.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), UNNECESSARYCONTROL1);
unreachable2 = true;
} else {
expression.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), UNNECESSARYCONTROL2);
statementblock.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), NEVERREACH2);
}
}
if (expression.getMyGovernor() == null) {
expression.setMyGovernor(new Boolean_Type());
}
}
}
if (statementblock != null) {
statementblock.check(timestamp);
}
return unreachable2;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value 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();
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value 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();
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value in project titan.EclipsePlug-ins by eclipse.
the class XorExpression method evaluateValue.
@Override
public /**
* {@inheritDoc}
*/
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return lastValue;
}
isErroneous = false;
lastTimeChecked = timestamp;
lastValue = this;
if (value1 == null || value2 == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp) || isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
if (last1.getIsErroneous(timestamp) || last2.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
final boolean b = ((Boolean_Value) last1).getValue() ^ ((Boolean_Value) last2).getValue();
lastValue = new Boolean_Value(b);
lastValue.copyGeneralProperties(this);
return lastValue;
}
Aggregations