use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class String2Ttcn_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (value != null) {
value.setLoweridToReference(timestamp);
final Type_type temporalType = value.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(temporalType) {
case TYPE_CHARSTRING:
value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
break;
case TYPE_UNDEFINED:
setIsErroneous();
break;
default:
if (!isErroneous) {
value.getLocation().reportSemanticError(OPERANDERROR1);
setIsErroneous();
}
}
}
if (reference != null) {
final Assignment assignment = reference.getRefdAssignment(timestamp, false);
if (assignment == null) {
reference.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous();
} else {
switch(assignment.getAssignmentType()) {
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_TEMP_IN:
case A_VAR:
case A_VAR_TEMPLATE:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
// valid assignment types
break;
default:
reference.getLocation().reportSemanticError(OPERANDERROR3);
setIsErroneous();
}
}
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Testcase_Instance_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (testcaseReference == null) {
return;
}
final Assignment assignment = testcaseReference.getRefdAssignment(timestamp, true);
if (assignment == null) {
return;
}
if (!Assignment_type.A_TESTCASE.semanticallyEquals(assignment.getAssignmentType())) {
testcaseReference.getLocation().reportSemanticError(MessageFormat.format(TESTCASEEXPECTED, assignment.getFullName()));
return;
}
if (myStatementBlock.getScopeRunsOn() != null) {
testcaseReference.getLocation().reportSemanticError(DEFINITIONWITHOUTRUNSONEXPECTED);
return;
}
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 (!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(FLOATEXPECTED2, real.createStringRepresentation()));
}
}
break;
default:
timerValue.getLocation().reportSemanticError(FLOATEXPECTED);
break;
}
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type 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.IType.Type_type 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.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Unichar2IntExpression 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);
IValue last;
switch(tempType) {
case TYPE_UCHARSTRING:
case TYPE_CHARSTRING:
last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final Value_type tempType1 = last.getValuetype();
// UniversalCharstring string; // = ((UniversalCharstring_Value) last).getValue();
switch(tempType1) {
case UNIVERSALCHARSTRING_VALUE:
{
final UniversalCharstring string = ((UniversalCharstring_Value) last).getValue();
if (string.isErrorneous()) {
value.getLocation().reportSemanticError(string.getErrorMessage());
setIsErroneous(true);
} else if (string.length() != 1) {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
}
break;
}
case CHARSTRING_VALUE:
{
final String originalString = ((Charstring_Value) last).getValue();
final CharstringExtractor cs = new CharstringExtractor(originalString);
if (cs.isErrorneous()) {
value.getLocation().reportSemanticError(cs.getErrorMessage());
setIsErroneous(true);
} else {
final String string = cs.getExtractedString();
if (string != null && string.length() != 1) {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
}
}
}
default:
// error???
break;
}
// switch
}
// if
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
break;
}
}
Aggregations