use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class AllPortCheckSateExpression method checkExpressionOperand1.
/**
* Checks the operand
* in charstring (mandatory)
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperand1(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (value == null) {
setIsErroneous(true);
return;
}
value.setLoweridToReference(timestamp);
final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
switch(tempType) {
case TYPE_CHARSTRING:
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final String originalString = ((Charstring_Value) last).getValue();
final CharstringExtractor cs = new CharstringExtractor(originalString);
if (cs.isErrorneous()) {
value.getLocation().reportSemanticError(cs.getErrorMessage());
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERAND1_ERROR1);
setIsErroneous(true);
}
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_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.Charstring_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.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class Unichar2IntExpression method checkExpressionOperands.
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (value == null) {
return;
}
value.setLoweridToReference(timestamp);
final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
IValue last;
switch(tempType) {
case TYPE_UCHARSTRING:
case TYPE_CHARSTRING:
last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final Value_type tempType1 = last.getValuetype();
// UniversalCharstring string; // = ((UniversalCharstring_Value) last).getValue();
switch(tempType1) {
case UNIVERSALCHARSTRING_VALUE:
{
final UniversalCharstring string = ((UniversalCharstring_Value) last).getValue();
if (string.isErrorneous()) {
value.getLocation().reportSemanticError(string.getErrorMessage());
setIsErroneous(true);
} else if (string.length() != 1) {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
}
break;
}
case CHARSTRING_VALUE:
{
final String originalString = ((Charstring_Value) last).getValue();
final CharstringExtractor cs = new CharstringExtractor(originalString);
if (cs.isErrorneous()) {
value.getLocation().reportSemanticError(cs.getErrorMessage());
setIsErroneous(true);
} else {
final String string = cs.getExtractedString();
if (string != null && string.length() != 1) {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
}
}
}
default:
// error???
break;
}
// switch
}
// if
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class ReplaceExpression 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 (templateInstance1 == null || value2 == null || value3 == null || templateInstance4 == null) {
setIsErroneous(true);
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
ITTCN3Template temp = templateInstance1.getTemplateBody();
final IValue value1 = ((SpecificValue_Template) temp).getSpecificValue();
final IValue v1 = value1.getValueRefdLast(timestamp, referenceChain);
final IValue v2 = value2.getValueRefdLast(timestamp, referenceChain);
final IValue v3 = value3.getValueRefdLast(timestamp, referenceChain);
temp = templateInstance4.getTemplateBody();
final IValue value4 = ((SpecificValue_Template) temp).getSpecificValue();
final IValue v4 = value4.getValueRefdLast(timestamp, referenceChain);
final Value_type vt = v1.getValuetype();
final int index = ((Integer_Value) v2).intValue();
final int len = ((Integer_Value) v3).intValue();
switch(vt) {
case BITSTRING_VALUE:
{
final String v1Str = ((Bitstring_Value) v1).getValue();
final String v4Str = ((Bitstring_Value) v4).getValue();
String result = v1Str.substring(0, index);
result = result.concat(v4Str);
result = result.concat(v1Str.substring(index + len));
lastValue = new Bitstring_Value(result);
lastValue.copyGeneralProperties(this);
break;
}
case HEXSTRING_VALUE:
{
final String v1Str = ((Hexstring_Value) v1).getValue();
final String v4Str = ((Hexstring_Value) v4).getValue();
String result = v1Str.substring(0, index);
result = result.concat(v4Str);
result = result.concat(v1Str.substring(index + len));
lastValue = new Hexstring_Value(result);
lastValue.copyGeneralProperties(this);
break;
}
case OCTETSTRING_VALUE:
{
final String v1Str = ((Octetstring_Value) v1).getValue();
final String v4Str = ((Octetstring_Value) v4).getValue();
String result = v1Str.substring(0, index * 2);
result = result.concat(v4Str);
result = result.concat(v1Str.substring((index + len) * 2));
lastValue = new Octetstring_Value(result);
lastValue.copyGeneralProperties(this);
break;
}
case CHARSTRING_VALUE:
{
final String v1Str = ((Charstring_Value) v1).getValue();
final String v4Str = ((Charstring_Value) v4).getValue();
String result = v1Str.substring(0, index);
result = result.concat(v4Str);
result = result.concat(v1Str.substring(index + len));
lastValue = new Charstring_Value(result);
lastValue.copyGeneralProperties(this);
break;
}
case UNIVERSALCHARSTRING_VALUE:
{
final UniversalCharstring v1Str = ((UniversalCharstring_Value) v1).getValue();
final UniversalCharstring v4Str = ((UniversalCharstring_Value) v4).getValue();
final UniversalCharstring result = v1Str.substring(0, index);
// This append() is not like concat().
result.append(v4Str);
result.append(v1Str.substring(index + len));
lastValue = new UniversalCharstring_Value(result);
lastValue.copyGeneralProperties(this);
break;
}
default:
setIsErroneous(true);
break;
}
return lastValue;
}
Aggregations