use of org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_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.Hexstring_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);
}
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value in project titan.EclipsePlug-ins by eclipse.
the class Hex2BitExpression 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 HEXSTRING_VALUE:
final String temp = ((Hexstring_Value) last).getValue();
lastValue = new Bitstring_Value(hex2bit(temp));
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value in project titan.EclipsePlug-ins by eclipse.
the class Hex2OctExpression 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 HEXSTRING_VALUE:
final String temp = ((Hexstring_Value) last).getValue();
lastValue = new Octetstring_Value(hex2oct(temp));
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value in project titan.EclipsePlug-ins by eclipse.
the class Hex2StrExpression 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 HEXSTRING_VALUE:
final String temp = ((Hexstring_Value) last).getValue();
lastValue = new Charstring_Value(temp);
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
Aggregations