use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class EqualsExpression 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);
if (last1 == null || last2 == null) {
setIsErroneous(true);
return lastValue;
}
lastValue = new Boolean_Value(last1.checkEquality(timestamp, last2));
lastValue.copyGeneralProperties(this);
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class Float2IntExpression 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 REAL_VALUE:
lastValue = new Integer_Value((long) ((Real_Value) last).getValue());
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 AddExpression 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)) {
setIsErroneous(true);
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;
}
switch(last1.getValuetype()) {
case INTEGER_VALUE:
// If the operands exist they must be of the same type.
// Avoid
// dependency from BigInteger.
lastValue = ((Integer_Value) last1).add((Integer_Value) last2);
lastValue.copyGeneralProperties(this);
break;
case REAL_VALUE:
final double f1 = ((Real_Value) last1).getValue();
final double f2 = ((Real_Value) last2).getValue();
lastValue = new Real_Value(f1 + f2);
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 And4bExpression 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)) {
setIsErroneous(true);
return lastValue;
}
final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
String str1;
String str2;
switch(last1.getValuetype()) {
case BITSTRING_VALUE:
str1 = ((Bitstring_Value) last1).getValue();
str2 = ((Bitstring_Value) last2).getValue();
lastValue = new Bitstring_Value(and4b(str1, str2));
lastValue.copyGeneralProperties(this);
break;
case HEXSTRING_VALUE:
str1 = ((Hexstring_Value) last1).getValue();
str2 = ((Hexstring_Value) last2).getValue();
lastValue = new Hexstring_Value(and4b(str1, str2));
lastValue.copyGeneralProperties(this);
break;
case OCTETSTRING_VALUE:
str1 = ((Octetstring_Value) last1).getValue();
str2 = ((Octetstring_Value) last2).getValue();
lastValue = new Octetstring_Value(and4b(str1, str2));
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 AndExpression 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)) {
setIsErroneous(true);
return lastValue;
}
final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
if (Value_type.BOOLEAN_VALUE.equals(last1.getValuetype())) {
if (((Boolean_Value) last1).getValue()) {
final Boolean_Value temp = (Boolean_Value) value2.getValueRefdLast(timestamp, referenceChain);
lastValue = new Boolean_Value(temp.getValue());
lastValue.copyGeneralProperties(this);
} else {
lastValue = new Boolean_Value(false);
lastValue.copyGeneralProperties(this);
}
} else {
// we must keep the left operand because of the
// potential side effects
// the right operand can only be eliminated if it is a
// literal "true"
final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
if (Value_type.BOOLEAN_VALUE.equals(last2.getValuetype()) && ((Boolean_Value) last2).getValue()) {
final Boolean_Value temp = (Boolean_Value) value1.getValueRefdLast(timestamp, referenceChain);
lastValue = new Boolean_Value(temp.getValue());
lastValue.copyGeneralProperties(this);
}
}
return lastValue;
}
Aggregations