use of org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value in project titan.EclipsePlug-ins by eclipse.
the class Int2OctExpression 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);
if (last1.getIsErroneous(timestamp) || last2.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
final Integer_Value i1 = (Integer_Value) last1;
final long i2 = ((Integer_Value) last2).getValue();
lastValue = new Octetstring_Value(Int2HexExpression.int2hex(i1, (int) i2 * 2));
lastValue.copyGeneralProperties(this);
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value in project titan.EclipsePlug-ins by eclipse.
the class LengthofExpression 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 (templateInstance == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final ITTCN3Template template = templateInstance.getTemplateBody();
final IValue value = ((SpecificValue_Template) template).getSpecificValue().getValueRefdLast(timestamp, referenceChain);
int length;
switch(value.getValuetype()) {
case CHARSTRING_VALUE:
length = ((Charstring_Value) value).getValueLength();
break;
case UNIVERSALCHARSTRING_VALUE:
length = ((UniversalCharstring_Value) value).getValueLength();
break;
case BITSTRING_VALUE:
length = ((Bitstring_Value) value).getValueLength();
break;
case HEXSTRING_VALUE:
length = ((Hexstring_Value) value).getValueLength();
break;
case OCTETSTRING_VALUE:
length = ((Octetstring_Value) value).getValueLength();
break;
case SEQUENCEOF_VALUE:
length = ((SequenceOf_Value) value).getNofComponents();
break;
case SETOF_VALUE:
length = ((SetOf_Value) value).getNofComponents();
break;
case ARRAY_VALUE:
length = ((Array_Value) value).getNofComponents();
break;
default:
setIsErroneous(true);
return lastValue;
}
lastValue = new Integer_Value(length);
lastValue.copyGeneralProperties(this);
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value in project titan.EclipsePlug-ins by eclipse.
the class ShiftLeftExpression 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;
long shiftSize;
switch(last1.getValuetype()) {
case BITSTRING_VALUE:
string = ((Bitstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).getValue();
lastValue = new Bitstring_Value(shiftLeft(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
case HEXSTRING_VALUE:
string = ((Hexstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).getValue();
lastValue = new Hexstring_Value(shiftLeft(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
case OCTETSTRING_VALUE:
string = ((Octetstring_Value) last1).getValue();
shiftSize = ((Integer_Value) last2).getValue() * 2;
lastValue = new Octetstring_Value(shiftLeft(string, shiftSize));
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value in project titan.EclipsePlug-ins by eclipse.
the class Str2OctExpression 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) || isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
if (last.getIsErroneous(timestamp)) {
return lastValue;
}
switch(last.getValuetype()) {
case CHARSTRING_VALUE:
{
final String string = ((Charstring_Value) last).getValue();
lastValue = new Octetstring_Value(string.toUpperCase());
break;
}
default:
return this;
}
lastValue.copyGeneralProperties(this);
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value in project titan.EclipsePlug-ins by eclipse.
the class SubstrExpression method checkExpressionOperandsHelper.
private void checkExpressionOperandsHelper(final CompilationTimeStamp timestamp, final IValue value1, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (value1 == null || value2 == null || value3 == 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 SEQUENCEOF_VALUE:
valueSize = ((SequenceOf_Value) temp).getNofComponents();
if (valueSize == 0) {
templateInstance1.getLocation().reportSemanticError(OPERANDERROR11);
}
break;
case SETOF_VALUE:
valueSize = ((SetOf_Value) temp).getNofComponents();
if (valueSize == 0) {
templateInstance1.getLocation().reportSemanticError(OPERANDERROR11);
}
break;
default:
break;
}
}
if (valueSize < 0) {
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(OPERANDERROR6, 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(OPERANDERROR7, 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(OPERANDERROR8, last2Value, last3Value, valueSize));
setIsErroneous(true);
}
}
}
}
Aggregations