use of org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type in project titan.EclipsePlug-ins by eclipse.
the class RangeLenghtRestriction method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
final Integer_Type integer = new Integer_Type();
lower.setMyGovernor(integer);
IValue last = integer.checkThisValueRef(timestamp, lower);
integer.checkThisValueLimit(timestamp, last, expectedValue, false, false, true, false);
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue valueLower = last.getValueRefdLast(timestamp, chain);
chain.release();
if (last.getIsErroneous(timestamp)) {
return;
}
BigInteger lowerInt;
switch(valueLower.getValuetype()) {
case INTEGER_VALUE:
{
lowerInt = ((Integer_Value) valueLower).getValueValue();
if (lowerInt.compareTo(BigInteger.ZERO) == -1) {
final String message = MessageFormat.format("The lower boundary of the length restriction must be a non-negative integer value instead of {0}", lowerInt);
valueLower.getLocation().reportSemanticError(message);
}
break;
}
default:
lowerInt = BigInteger.ZERO;
break;
}
if (upper == null) {
return;
}
upper.setMyGovernor(integer);
last = integer.checkThisValueRef(timestamp, upper);
integer.checkThisValueLimit(timestamp, last, expectedValue, false, false, true, false);
chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue valueUpper = last.getValueRefdLast(timestamp, chain);
chain.release();
if (last.getIsErroneous(timestamp)) {
return;
}
BigInteger upperInt;
switch(valueUpper.getValuetype()) {
case INTEGER_VALUE:
{
upperInt = ((Integer_Value) valueUpper).getValueValue();
if (upperInt.compareTo(BigInteger.ZERO) == -1) {
final String message = MessageFormat.format("The upper boundary of the length restriction must be a non-negative integer value instead of {0}", upperInt);
valueUpper.getLocation().reportSemanticError(message);
} else if (upperInt.compareTo(lowerInt) == -1) {
getLocation().reportSemanticError(MessageFormat.format("The upper boundary of the length restriction ({0}) cannot be smaller than the lower boundary {1}", upperInt, lowerInt));
}
break;
}
default:
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type in project titan.EclipsePlug-ins by eclipse.
the class SingleLenghtRestriction method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (value == null) {
return;
}
final Integer_Type integer = new Integer_Type();
value.setMyGovernor(integer);
IValue last = integer.checkThisValueRef(timestamp, value);
integer.checkThisValue(timestamp, last, null, new ValueCheckingOptions(expectedValue, false, false, true, false, false));
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
last = last.getValueRefdLast(timestamp, chain);
chain.release();
if (last.getIsErroneous(timestamp)) {
return;
}
switch(last.getValuetype()) {
case INTEGER_VALUE:
{
final BigInteger temp = ((Integer_Value) last).getValueValue();
if (temp.compareTo(BigInteger.ZERO) == -1) {
value.getLocation().reportSemanticError(MessageFormat.format("The length restriction must be a non-negative integer value instead of {0}", temp));
value.setIsErroneous(true);
}
break;
}
default:
break;
}
}
Aggregations