use of org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value in project titan.EclipsePlug-ins by eclipse.
the class RotateRightExpression 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) {
Type_type tempType1 = null;
Type_type tempType2 = null;
long valueSize = 0;
long rotationSize = 0;
IValue tempValue;
if (value1 != null) {
value1.setLoweridToReference(timestamp);
tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType1) {
case TYPE_BITSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.BITSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Bitstring_Value) tempValue).getValueLength();
}
break;
case TYPE_HEXSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.HEXSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Hexstring_Value) tempValue).getValueLength();
}
break;
case TYPE_OCTETSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.OCTETSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Octetstring_Value) tempValue).getValueLength();
}
break;
case TYPE_CHARSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.CHARSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Charstring_Value) tempValue).getValueLength();
}
break;
case TYPE_UCHARSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.UNIVERSALCHARSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((UniversalCharstring_Value) tempValue).getValueLength();
}
break;
case TYPE_SET_OF:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
tempValue = tempValue.setValuetype(timestamp, Value_type.SETOF_VALUE);
}
if (Value_type.SETOF_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((SetOf_Value) tempValue).getNofComponents();
}
break;
case TYPE_SEQUENCE_OF:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((SequenceOf_Value) tempValue).getNofComponents();
} else if (Value_type.SETOF_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((SetOf_Value) tempValue).getNofComponents();
}
break;
case TYPE_ARRAY:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
tempValue = tempValue.setValuetype(timestamp, Value_type.ARRAY_VALUE);
}
if (Value_type.ARRAY_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Array_Value) tempValue).getNofComponents();
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(FIRSTOPERANDERROR);
setIsErroneous(true);
break;
}
}
if (value2 != null) {
value2.setLoweridToReference(timestamp);
tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
switch(tempType2) {
case TYPE_INTEGER:
tempValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.INTEGER_VALUE.equals(tempValue.getValuetype()) && !getIsErroneous(timestamp)) {
if (!((Integer_Value) tempValue).isNative()) {
value2.getLocation().reportSemanticError(MessageFormat.format(LARGEINTEGERSECONDOPERANDERROR, ((Integer_Value) tempValue).getValueValue()));
setIsErroneous(true);
break;
}
rotationSize = ((Integer_Value) tempValue).getValue();
if (value1 != null && !value1.isUnfoldable(timestamp)) {
final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINCORRECTSHIFTROTATESIZE, GeneralConstants.WARNING, null);
if (valueSize == 0 || valueSize == 1) {
location.reportConfigurableSemanticProblem(severity, EFFECTLESSROTATION);
} else if (rotationSize < 0) {
location.reportConfigurableSemanticProblem(severity, NEGATIVEROTATEPROBLEM);
} else if (rotationSize == 0) {
location.reportConfigurableSemanticProblem(severity, ZEROROTATEPROBLEM);
} else if (rotationSize > valueSize) {
location.reportConfigurableSemanticProblem(severity, MessageFormat.format(TOOBIGROTATEPROBLEM, valueSize, rotationSize, rotationSize % valueSize));
}
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(SECONDOPERANDERROR);
setIsErroneous(true);
break;
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value in project titan.EclipsePlug-ins by eclipse.
the class Int2BitExpression 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 int i2 = ((Integer_Value) last2).intValue();
lastValue = new Bitstring_Value(int2bit((Integer_Value) last1, i2));
lastValue.copyGeneralProperties(this);
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value in project titan.EclipsePlug-ins by eclipse.
the class Int2CharExpression 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 INTEGER_VALUE:
final long i = ((Integer_Value) last).getValue();
lastValue = new Charstring_Value(new String(new char[] { (char) i }));
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value in project titan.EclipsePlug-ins by eclipse.
the class Int2HexExpression method int2hex.
public static String int2hex(final Integer_Value value, final int length) {
final StringBuilder builder = new StringBuilder(length);
final Integer_Value zero = new Integer_Value(Long.valueOf(0x0f));
Integer_Value temp = value;
for (int i = 1; i <= length; i++) {
builder.insert(0, (char) BitstringUtilities.DIGITS[(temp.and(zero)).intValue()]);
temp = temp.shiftRight(4);
}
return builder.toString();
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Integer_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;
}
Aggregations