use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class Any2UnistrExpression method checkExpressionOperand1.
/**
* Checks the 1st operand
* in template (value) any_type
* @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 checkExpressionOperand1(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (templateInstance1 == null) {
setIsErroneous(true);
return;
}
final Expected_Value_type internalExpectation = Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) ? Expected_Value_type.EXPECTED_TEMPLATE : expectedValue;
IType type = templateInstance1.getExpressionGovernor(timestamp, internalExpectation);
ITTCN3Template template = templateInstance1.getTemplateBody();
if (type == null) {
template = template.setLoweridToReference(timestamp);
type = template.getExpressionGovernor(timestamp, internalExpectation);
}
if (type == null) {
if (!template.getIsErroneous(timestamp)) {
templateInstance1.getLocation().reportSemanticError(OPERAND1_ERROR1);
}
setIsErroneous(true);
return;
}
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance1, type, referenceChain, expectedValue);
if (getIsErroneous(timestamp)) {
return;
}
template.checkSpecificValue(timestamp, false);
type = type.getTypeRefdLast(timestamp);
switch(type.getTypetype()) {
case TYPE_UNDEFINED:
case TYPE_NULL:
case TYPE_REFERENCED:
case TYPE_VERDICT:
case TYPE_PORT:
case TYPE_COMPONENT:
case TYPE_DEFAULT:
case TYPE_SIGNATURE:
case TYPE_FUNCTION:
case TYPE_ALTSTEP:
case TYPE_TESTCASE:
if (!isErroneous) {
location.reportSemanticError(OPERAND1_ERROR2);
setIsErroneous(true);
}
break;
default:
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class Float2StrExpression 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:
final double double_val = ((Real_Value) last).getValue();
lastValue = new Charstring_Value(float2str(double_val));
break;
default:
return this;
}
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 GreaterThanOrEqualExpression 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.getIsErroneous(timestamp) || last2.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
switch(last1.getValuetype()) {
case INTEGER_VALUE:
{
lastValue = new Boolean_Value(((Integer_Value) last1).compareTo((Integer_Value) last2) >= 0);
lastValue.copyGeneralProperties(this);
break;
}
case REAL_VALUE:
{
final double float1 = ((Real_Value) last1).getValue();
final double float2 = ((Real_Value) last2).getValue();
lastValue = new Boolean_Value(Double.compare(float1, float2) >= 0);
lastValue.copyGeneralProperties(this);
break;
}
case ENUMERATED_VALUE:
{
IType governor1 = last1.getExpressionGovernor(timestamp, expectedValue);
governor1 = governor1.getTypeRefdLast(timestamp);
IType governor2 = last2.getExpressionGovernor(timestamp, expectedValue);
governor2 = governor2.getTypeRefdLast(timestamp);
if (governor1 instanceof TTCN3_Enumerated_Type) {
final EnumItem item1 = ((TTCN3_Enumerated_Type) governor1).getEnumItemWithName(((Enumerated_Value) last1).getValue());
final EnumItem item2 = ((TTCN3_Enumerated_Type) governor2).getEnumItemWithName(((Enumerated_Value) last2).getValue());
lastValue = new Boolean_Value(((Integer_Value) item1.getValue()).intValue() >= ((Integer_Value) item2.getValue()).intValue());
lastValue.copyGeneralProperties(this);
} else {
final EnumItem item1 = ((ASN1_Enumerated_Type) governor1).getEnumItemWithName(((Enumerated_Value) last1).getValue());
final EnumItem item2 = ((ASN1_Enumerated_Type) governor2).getEnumItemWithName(((Enumerated_Value) last2).getValue());
lastValue = new Boolean_Value(((Integer_Value) item1.getValue()).intValue() >= ((Integer_Value) item2.getValue()).intValue());
lastValue.copyGeneralProperties(this);
}
break;
}
default:
setIsErroneous(true);
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class Hex2IntExpression 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 = hex2int(temp);
break;
default:
return this;
}
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 Hex2IntExpression 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 (value == null) {
return;
}
value.setLoweridToReference(timestamp);
final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
switch(tempType) {
case TYPE_HEXSTRING:
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final String hexstring = ((Hexstring_Value) last).getValue();
int startIndex = 0;
while (startIndex < hexstring.length() && '0' == hexstring.charAt(startIndex)) {
startIndex++;
}
}
return;
case TYPE_UNDEFINED:
setIsErroneous(true);
return;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
return;
}
}
Aggregations