use of org.eclipse.titan.designer.AST.TTCN3.values.Real_Value in project titan.EclipsePlug-ins by eclipse.
the class Def_Timer method checkSingleDuration.
private void checkSingleDuration(final CompilationTimeStamp timestamp, final IValue duration) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final Value v = (Value) duration.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (v.getValuetype() == Value_type.REAL_VALUE) {
final Real_Value value = (Real_Value) v;
final double valueReal = value.getValue();
if (valueReal < 0.0 || value.isSpecialFloat()) {
duration.getLocation().reportSemanticError("A non-negative float value was expected as timer duration instead of" + valueReal);
}
} else {
duration.getLocation().reportSemanticError("Value is not real");
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Real_Value in project titan.EclipsePlug-ins by eclipse.
the class Def_Timer method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
isUsed = false;
if (getMyScope() instanceof ComponentTypeBody) {
NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_COMPONENT_TIMER, identifier, this);
} else if (isLocal()) {
NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_LOCAL_TIMER, identifier, this);
} else {
NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_GLOBAL_TIMER, identifier, this);
}
NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
if (dimensions != null) {
dimensions.check(timestamp);
}
if (defaultDuration != null) {
if (dimensions == null) {
defaultDuration.setLoweridToReference(timestamp);
final Type_type tempType = defaultDuration.getExpressionReturntype(timestamp, isLocal() ? Expected_Value_type.EXPECTED_DYNAMIC_VALUE : Expected_Value_type.EXPECTED_STATIC_VALUE);
switch(tempType) {
case TYPE_REAL:
final IValue last = defaultDuration.getValueRefdLast(timestamp, null);
if (!last.isUnfoldable(timestamp)) {
final Real_Value real = (Real_Value) last;
final double value = real.getValue();
if (value < 0.0f) {
defaultDuration.getLocation().reportSemanticError(MessageFormat.format(NEGATIVDURATIONERROR, value));
} else if (real.isPositiveInfinity()) {
final String message = MessageFormat.format(INFINITYDURATIONERROR, real.createStringRepresentation());
defaultDuration.getLocation().reportSemanticError(message);
}
}
return;
default:
defaultDuration.getLocation().reportSemanticError(OPERANDERROR);
}
} else {
checkArrayDuration(timestamp, defaultDuration, 0);
}
defaultDuration.setCodeSection(CodeSectionType.CS_POST_INIT);
}
if (withAttributesPath != null) {
withAttributesPath.checkGlobalAttributes(timestamp, false);
withAttributesPath.checkAttributes(timestamp);
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Real_Value in project titan.EclipsePlug-ins by eclipse.
the class Call_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
final Port_Type portType = Port_Utility.checkPortReference(timestamp, this, portReference);
if (parameter == null) {
return;
}
IType signatureType = null;
boolean signatureTypeDetermined = false;
if (portType != null) {
// the port type is known
final PortTypeBody portTypeBody = portType.getPortBody();
final TypeSet outSignatures = portTypeBody.getOutSignatures();
if (OperationModes.OP_Message.equals(portTypeBody.getOperationMode())) {
portReference.getLocation().reportSemanticError(MessageFormat.format(SENDONPORT, portType.getTypename()));
} else if (outSignatures != null) {
if (outSignatures.getNofTypes() == 1) {
signatureType = outSignatures.getTypeByIndex(0);
} else {
signatureType = Port_Utility.getOutgoingType(timestamp, parameter);
if (signatureType == null) {
parameter.getLocation().reportSemanticError(UNKNOWNSIGNATURE);
} else {
if (!outSignatures.hasType(timestamp, signatureType)) {
parameter.getLocation().reportSemanticError(MessageFormat.format(TYPENOTPRESENT, signatureType.getTypename(), portType.getTypename()));
}
}
}
signatureTypeDetermined = true;
} else {
portReference.getLocation().reportSemanticError(MessageFormat.format(NOOUTGOINGSIGNATURETYPES, portType.getTypename()));
}
}
if (!signatureTypeDetermined) {
signatureType = Port_Utility.getOutgoingType(timestamp, parameter);
}
boolean isNonblocking = false;
if (signatureType != null) {
parameter.check(timestamp, signatureType);
signatureType = signatureType.getTypeRefdLast(timestamp);
switch(signatureType.getTypetype()) {
case TYPE_SIGNATURE:
((Signature_Type) signatureType).checkThisTemplate(timestamp, parameter.getTemplateBody(), false, false, null);
isNonblocking = ((Signature_Type) signatureType).isNonblocking();
break;
default:
parameter.getLocation().reportSemanticError(MessageFormat.format(CALLPARAMETERNOTSIGNATURE, signatureType.getTypename()));
break;
}
if (isNonblocking) {
if (timerValue != null) {
timerValue.getLocation().reportSemanticError(MessageFormat.format(NONBLOCKINGWITHTIMER, signatureType.getTypename()));
} else if (noWait) {
location.reportSemanticError(MessageFormat.format(NONBLOCKINGWITHNOWAIT, signatureType.getTypename()));
}
if (altGuards != null) {
location.reportSemanticError(MessageFormat.format(NONBLOCKINGWITHRESPONSEPART, signatureType.getTypename()));
}
} else if (noWait) {
if (altGuards != null) {
location.reportSemanticError(NOWAITWITHRESPONSEPART);
}
} else {
if (!getIsErroneous() && altGuards == null) {
location.reportSemanticError(RESPONSEPARTMISSING);
}
}
}
if (timerValue != null) {
timerValue.setLoweridToReference(timestamp);
final Type_type temporalType = timerValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(temporalType) {
case TYPE_REAL:
final IValue last = timerValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
if (Value_type.REAL_VALUE.equals(last.getValuetype()) && !last.getIsErroneous(timestamp)) {
final double temp = ((Real_Value) last).getValue();
if (temp < 0) {
timerValue.getLocation().reportSemanticError(MessageFormat.format(CALLTIMERNEGATIVE, temp));
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous();
break;
default:
if (!isErroneous) {
location.reportSemanticError(FLOATTIMEREXPECTED);
}
break;
}
}
Port_Utility.checkToClause(timestamp, this, portType, toClause);
if (altGuards != null) {
checkCallBody(timestamp, portType, signatureType);
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Real_Value in project titan.EclipsePlug-ins by eclipse.
the class RNDWithValueExpression 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_REAL:
{
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final Real_Value real = (Real_Value) last;
if (real.isSpecialFloat()) {
value.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR2, real.createStringRepresentation()));
setIsErroneous(true);
}
}
break;
}
case TYPE_UNDEFINED:
setIsErroneous(true);
return;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR);
setIsErroneous(true);
}
return;
}
checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Real_Value in project titan.EclipsePlug-ins by eclipse.
the class ExecuteDereferedExpression 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) {
IType type;
value.setLoweridToReference(timestamp);
final IValue last = value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_TEMPLATE, referenceChain);
if (last.getIsErroneous(timestamp)) {
type = null;
} else {
type = last.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
if (type != null) {
type = type.getTypeRefdLast(timestamp);
}
}
if (type == null || type.getIsErroneous(timestamp)) {
setIsErroneous(true);
} else if (Type_type.TYPE_TESTCASE.equals(type.getTypetype())) {
final FormalParameterList formalParameters = ((Testcase_Type) type).getFormalParameters();
actualParameters = new ActualParameterList();
final boolean isErroneous = formalParameters.checkActualParameterList(timestamp, actualParameterList, actualParameters);
if (isErroneous) {
setIsErroneous(true);
}
} else {
value.getLocation().reportSemanticError(MessageFormat.format("Reference to a value of type testcase was expected in the argument of `derefers()'' instead of `{0}''", type.getTypename()));
setIsErroneous(true);
}
}
if (timerValue != null) {
timerValue.setLoweridToReference(timestamp);
final Type_type tempType = timerValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(tempType) {
case TYPE_REAL:
final IValue last = timerValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final Real_Value real = (Real_Value) last;
final double i = real.getValue();
if (i < 0.0) {
timerValue.getLocation().reportSemanticError(MessageFormat.format(NEGATIVEDURATION, real.createStringRepresentation()));
} else if (real.isPositiveInfinity()) {
timerValue.getLocation().reportSemanticError(MessageFormat.format(FLOATEXPECTED, real.createStringRepresentation()));
}
}
return;
case TYPE_UNDEFINED:
setIsErroneous(true);
return;
default:
if (!isErroneous) {
timerValue.getLocation().reportSemanticError(OPERANDERROR);
setIsErroneous(true);
}
return;
}
}
checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, false, false);
}
Aggregations