use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class RemoveBomExpression 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 (value == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
switch(last.getValuetype()) {
case OCTETSTRING_VALUE:
{
final String octetString = ((Octetstring_Value) last).getValue();
lastValue = new Octetstring_Value(calculateValue(octetString));
lastValue.copyGeneralProperties(this);
break;
}
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class ReplaceExpression method checkExpressionOperandsHelper.
private void checkExpressionOperandsHelper(final CompilationTimeStamp timestamp, final IValue value1, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (templateInstance1 == null || getIsErroneous(timestamp)) {
return;
}
long valueSize = -1;
if (!value1.isUnfoldable(timestamp)) {
IValue temp = value1.setLoweridToReference(timestamp);
temp = temp.getValueRefdLast(timestamp, referenceChain);
switch(temp.getValuetype()) {
case BITSTRING_VALUE:
valueSize = ((Bitstring_Value) temp).getValueLength();
break;
case HEXSTRING_VALUE:
valueSize = ((Hexstring_Value) temp).getValueLength();
break;
case OCTETSTRING_VALUE:
valueSize = ((Octetstring_Value) temp).getValueLength();
break;
case CHARSTRING_VALUE:
valueSize = ((Charstring_Value) temp).getValueLength();
break;
case UNIVERSALCHARSTRING_VALUE:
valueSize = ((UniversalCharstring_Value) temp).getValueLength();
break;
case SETOF_VALUE:
valueSize = ((SetOf_Value) temp).getNofComponents();
break;
case SEQUENCEOF_VALUE:
valueSize = ((SequenceOf_Value) temp).getNofComponents();
break;
default:
break;
}
}
if (valueSize < 0) {
return;
}
if (value2 == null || value3 == null || templateInstance4 == null) {
return;
}
if (value2.isUnfoldable(timestamp)) {
if (!value3.isUnfoldable(timestamp)) {
final IValue last3 = value3.getValueRefdLast(timestamp, expectedValue, referenceChain);
final long last3Value = ((Integer_Value) last3).getValue();
if (last3Value > valueSize) {
location.reportSemanticError(MessageFormat.format(OPERANDERROR8, last3Value, valueSize));
setIsErroneous(true);
}
}
} else {
final IValue last2 = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
final long last2Value = ((Integer_Value) last2).getValue();
if (value3.isUnfoldable(timestamp)) {
if (last2Value > valueSize) {
location.reportSemanticError(MessageFormat.format(OPERANDERROR9, last2Value, valueSize));
setIsErroneous(true);
}
} else {
final IValue last3 = value3.getValueRefdLast(timestamp, expectedValue, referenceChain);
final long last3Value = ((Integer_Value) last3).getValue();
if (last2Value + last3Value > valueSize) {
location.reportSemanticError(MessageFormat.format(OPERANDERROR10, last2Value, last3Value, valueSize));
setIsErroneous(true);
}
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class ReplaceExpression method getExpressionReturntype.
@Override
public /**
* {@inheritDoc}
*/
Type_type getExpressionReturntype(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
final IValue last = getValueRefdLast(timestamp, expectedValue, null);
if (last == null || templateInstance1 == null) {
return Type_type.TYPE_UNDEFINED;
}
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return Type_type.TYPE_UNDEFINED;
}
final ITTCN3Template template = templateInstance1.getTemplateBody().setLoweridToReference(timestamp);
final Type_type tempType = template.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
switch(tempType) {
case TYPE_BITSTRING:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
case TYPE_SET_OF:
case TYPE_SEQUENCE_OF:
return tempType;
case TYPE_UNDEFINED:
return tempType;
default:
setIsErroneous(true);
return Type_type.TYPE_UNDEFINED;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class RotateLeftExpression 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)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
String string;
int shiftSize;
switch(last1.getValuetype()) {
case BITSTRING_VALUE:
string = ((Bitstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).intValue();
lastValue = new Bitstring_Value(rotateLeft(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
case HEXSTRING_VALUE:
string = ((Hexstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).intValue();
lastValue = new Hexstring_Value(rotateLeft(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
case OCTETSTRING_VALUE:
string = ((Octetstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).intValue() * 2;
lastValue = new Octetstring_Value(rotateLeft(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
case CHARSTRING_VALUE:
string = ((Charstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).intValue();
lastValue = new Charstring_Value(rotateLeft(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
case UNIVERSALCHARSTRING_VALUE:
final UniversalCharstring string2 = ((UniversalCharstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).intValue();
lastValue = new UniversalCharstring_Value(rotateLeft(string2, shiftSize));
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class RotateRightExpression 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);
String string;
int shiftSize;
switch(last1.getValuetype()) {
case BITSTRING_VALUE:
string = ((Bitstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).intValue();
lastValue = new Bitstring_Value(rotateRight(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
case HEXSTRING_VALUE:
string = ((Hexstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).intValue();
lastValue = new Hexstring_Value(rotateRight(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
case OCTETSTRING_VALUE:
string = ((Octetstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).intValue() * 2;
lastValue = new Octetstring_Value(rotateRight(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
case CHARSTRING_VALUE:
string = ((Charstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).intValue();
lastValue = new Charstring_Value(rotateRight(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
case UNIVERSALCHARSTRING_VALUE:
final UniversalCharstring string2 = ((UniversalCharstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).intValue();
lastValue = new UniversalCharstring_Value(rotateRight(string2, shiftSize));
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
Aggregations