use of org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value in project titan.EclipsePlug-ins by eclipse.
the class Int2HexExpression 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 Hexstring_Value(int2hex(i1, (int) 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 Int2HexExpression 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 (value1 == null || value2 == null) {
return;
}
IValue last1 = null;
IValue last2 = null;
value1.setLoweridToReference(timestamp);
final Type_type tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType1) {
case TYPE_INTEGER:
last1 = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last1.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last1.getValuetype())) {
if (((Integer_Value) last1).signum() < 0) {
value1.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
break;
}
value2.setLoweridToReference(timestamp);
final Type_type tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
switch(tempType2) {
case TYPE_INTEGER:
last2 = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last2.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last2.getValuetype())) {
if (((Integer_Value) last2).isNative()) {
final long i2 = ((Integer_Value) last2).getValue();
if (i2 < 0) {
value2.getLocation().reportSemanticError(OPERANDERROR4);
setIsErroneous(true);
} else if (last1 != null && !last1.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last1.getValuetype())) {
if ((((Integer_Value) last1).shiftRight((int) i2 * 4)).signum() > 0) {
location.reportSemanticError(MessageFormat.format(OPERANDERROR5, ((Integer_Value) last1).intValue(), i2));
setIsErroneous(true);
}
}
} else {
value2.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR6, ((Integer_Value) last2).getValueValue()));
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR3);
setIsErroneous(true);
}
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value in project titan.EclipsePlug-ins by eclipse.
the class Int2OctExpression 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 (value1 == null || value2 == null) {
return;
}
IValue last1 = null;
IValue last2 = null;
Integer_Value i1 = new Integer_Value(0);
value1.setLoweridToReference(timestamp);
final Type_type tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType1) {
case TYPE_INTEGER:
last1 = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last1.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last1.getValuetype())) {
i1 = (Integer_Value) last1;
if (i1.signum() < 0) {
value1.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
break;
}
value2.setLoweridToReference(timestamp);
final Type_type tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
switch(tempType2) {
case TYPE_INTEGER:
last2 = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last2.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last2.getValuetype())) {
if (((Integer_Value) last2).isNative()) {
final long i2 = ((Integer_Value) last2).getValue();
if (i2 < 0) {
value2.getLocation().reportSemanticError(OPERANDERROR4);
setIsErroneous(true);
} else if (last1 != null && !last1.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last1.getValuetype())) {
if ((i1.shiftRight((int) i2 * 8)).signum() > 0) {
location.reportSemanticError(MessageFormat.format(OPERANDERROR5, ((Integer_Value) last1).intValue(), i2));
setIsErroneous(true);
}
}
} else {
value2.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR6, ((Integer_Value) last2).getValueValue()));
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR3);
setIsErroneous(true);
}
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value in project titan.EclipsePlug-ins by eclipse.
the class Int2StrExpression 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)) {
return lastValue;
}
switch(last.getValuetype()) {
case INTEGER_VALUE:
lastValue = new Charstring_Value(((Integer_Value) last).getValueValue().toString());
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 Unichar2IntExpression 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)) {
setIsErroneous(true);
return lastValue;
}
switch(last.getValuetype()) {
case UNIVERSALCHARSTRING_VALUE:
{
final UniversalCharstring string = ((UniversalCharstring_Value) last).getValue();
final UniversalChar uchar = string.get(0);
final int result = (uchar.group() << 24) | (uchar.plane() << 16) | (uchar.row() << 8) | uchar.cell();
lastValue = new Integer_Value(result);
break;
}
case CHARSTRING_VALUE:
{
final String string = ((Charstring_Value) last).getValue();
lastValue = new Integer_Value(string.charAt(0));
break;
}
default:
setIsErroneous(true);
return this;
}
lastValue.copyGeneralProperties(this);
return lastValue;
}
Aggregations