use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Send_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 messageType = null;
boolean messageTypeDetermined = false;
if (portType != null) {
// the port type is known
portType.check(timestamp);
final PortTypeBody portTypeBody = portType.getPortBody();
final TypeSet outMessages = portTypeBody.getOutMessage();
if (OperationModes.OP_Procedure.equals(portTypeBody.getOperationMode())) {
portReference.getLocation().reportSemanticError(MessageFormat.format(SENDONPORT, portType.getTypename()));
} else if (outMessages != null) {
if (outMessages.getNofTypes() == 1) {
messageType = outMessages.getTypeByIndex(0);
} else {
messageType = Port_Utility.getOutgoingType(timestamp, parameter);
if (messageType == null) {
parameter.getLocation().reportSemanticError(UNKNOWNOUTGOINGMESSAGE);
} else {
final int nofCompatibleTypes = outMessages.getNofCompatibleTypes(timestamp, messageType);
if (nofCompatibleTypes == 0) {
parameter.getLocation().reportSemanticError(MessageFormat.format(TYPENOTPRESENT, messageType.getTypename(), portType.getTypename()));
} else if (nofCompatibleTypes > 1) {
parameter.getLocation().reportSemanticError(MessageFormat.format(TYPEISAMBIGUOUS, messageType.getTypename(), portType.getTypename()));
}
}
}
messageTypeDetermined = true;
} else {
portReference.getLocation().reportSemanticError(MessageFormat.format(NOOUTGOINGMESSAGETYPES, portType.getTypename()));
}
}
if (!messageTypeDetermined) {
messageType = Port_Utility.getOutgoingType(timestamp, parameter);
}
if (messageType != null) {
parameter.check(timestamp, messageType);
messageType = messageType.getTypeRefdLast(timestamp);
switch(messageType.getTypetype()) {
case TYPE_SIGNATURE:
parameter.getLocation().reportSemanticError(MessageFormat.format(SENDPARAMETERSIGNATURE, messageType.getTypename()));
break;
case TYPE_PORT:
parameter.getLocation().reportSemanticError(MessageFormat.format(SENDPARAMETERPORT, messageType.getTypename()));
break;
case TYPE_DEFAULT:
parameter.getLocation().reportSemanticError(MessageFormat.format(SENDPARAMETERDEFAULT, messageType.getTypename()));
break;
default:
break;
}
parameter.getTemplateBody().checkSpecificValue(timestamp, false);
Port_Utility.checkToClause(timestamp, this, portType, toClause);
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class CheckStateExpression 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) {
// check mPortReference
final Port_Type portType = Port_Utility.checkPortReference(timestamp, portReference);
if (portType != null && !portType.getPortBody().hasQueue(timestamp)) {
portReference.getLocation().reportSemanticError(MessageFormat.format(NOINCOMINGQUEUE, portType.getTypename()));
}
// check the operand (mValue)
checkExpressionOperand1(timestamp, expectedValue, referenceChain);
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Reply_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);
IType signature = null;
boolean signatureDetermined = false;
if (portType != null) {
// the port type is known
final PortTypeBody portTypeBody = portType.getPortBody();
final TypeSet inSignatures = portTypeBody.getInSignatures();
if (OperationModes.OP_Message.equals(portTypeBody.getOperationMode())) {
portReference.getLocation().reportSemanticError(MessageFormat.format(REPLYONMESSAGEPORT, portType.getTypename()));
} else if (inSignatures != null) {
if (inSignatures.getNofTypes() == 1) {
signature = inSignatures.getTypeByIndex(0);
} else {
signature = Port_Utility.getOutgoingType(timestamp, parameter);
if (signature == null) {
parameter.getLocation().reportSemanticError(UNKNOWNINCOMINGSIGNATURE);
} else {
if (!inSignatures.hasType(timestamp, signature)) {
parameter.getLocation().reportSemanticError(MessageFormat.format(INCOMINGSIGNATURENOTPRESENT, signature.getTypename(), portType.getTypename()));
}
}
}
signatureDetermined = true;
} else {
portReference.getLocation().reportSemanticError(MessageFormat.format(NOINCOMINGSIGNATURES, portType.getTypename()));
}
}
if (!signatureDetermined) {
signature = Port_Utility.getOutgoingType(timestamp, parameter);
}
if (signature != null) {
parameter.check(timestamp, signature);
signature = signature.getTypeRefdLast(timestamp);
Type returnType = null;
switch(signature.getTypetype()) {
case TYPE_SIGNATURE:
if (((Signature_Type) signature).isNonblocking()) {
getLocation().reportSemanticError(MessageFormat.format("Operation `reply'' is not applicable to non-blocking signature `{0}''", signature.getTypename()));
} else {
returnType = ((Signature_Type) signature).getSignatureReturnType();
}
// checking the presence/absence of reply value
if (replyValue != null) {
if (returnType == null) {
final String message = MessageFormat.format("Unexpected return value. Signature `{0}'' does not have return type", signature.getTypename());
replyValue.getLocation().reportSemanticError(message);
}
} else if (returnType != null) {
getLocation().reportSemanticError(MessageFormat.format("Missing return value. Signature `{0}'' returns type `{1}''", signature.getTypename(), returnType.getTypename()));
}
break;
default:
parameter.getLocation().reportSemanticError(MessageFormat.format("The type of parameter is `{0}'', which is not a signature", signature.getTypename()));
break;
}
// checking the reply value if present
if (replyValue != null && returnType != null) {
replyValue.setMyGovernor(returnType);
final IValue temp = returnType.checkThisValueRef(timestamp, replyValue);
returnType.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
}
Port_Utility.checkToClause(timestamp, this, portType, toClause);
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkPortReference.
/**
* Checks a port reference.
* Statement independent version.
*
* @param timestamp
* the timestamp of the actual build cycle.
* @param portReference
* the port reference to be checked
*
* @return the port type of the reference if it is a correct port
* reference, or null otherwise
*/
public static Port_Type checkPortReference(final CompilationTimeStamp timestamp, final Reference portReference) {
if (portReference == null) {
return null;
}
final Assignment assignment = portReference.getRefdAssignment(timestamp, true);
if (assignment == null || assignment.getIsErroneous()) {
return null;
}
IType result = null;
switch(assignment.getAssignmentType()) {
case A_PORT:
final ArrayDimensions dimensions = ((Def_Port) assignment).getDimensions();
if (dimensions != null) {
dimensions.checkIndices(timestamp, portReference, "port", false, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
} else if (portReference.getSubreferences().size() > 1) {
portReference.getLocation().reportSemanticError(MessageFormat.format("Reference to single {0} cannot have field or array sub-references", assignment.getDescription()));
}
result = ((Def_Port) assignment).getType(timestamp);
break;
case A_PAR_PORT:
if (portReference.getSubreferences().size() > 1) {
portReference.getLocation().reportSemanticError(MessageFormat.format("Reference to {0} cannot have field or array sub-references", assignment.getDescription()));
}
result = ((FormalParameter) assignment).getType(timestamp);
break;
default:
portReference.getLocation().reportSemanticError(MessageFormat.format(PORTREFERENCEEXPECTED, assignment.getAssignmentName()));
break;
}
if (result == null) {
return null;
}
result = result.getTypeRefdLast(timestamp);
if (Type_type.TYPE_PORT.equals(result.getTypetype())) {
return (Port_Type) result;
}
return null;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Raise_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);
IType signature = Port_Utility.checkSignatureReference(timestamp, signatureReference);
if (portType != null) {
final PortTypeBody portTypeBody = portType.getPortBody();
final TypeSet inSignatures = portTypeBody.getInSignatures();
if (OperationModes.OP_Message.equals(portTypeBody.getOperationMode())) {
portReference.getLocation().reportSemanticError(MessageFormat.format(RAISEONPORT, portType.getTypename()));
} else if (inSignatures != null) {
if (signature != null) {
if (!inSignatures.hasType(timestamp, signature)) {
portReference.getLocation().reportSemanticError(MessageFormat.format(SIGNATURENOTPRESENT, signature.getTypename(), portType.getTypename()));
}
} else if (inSignatures.getNofTypes() == 1) {
signature = inSignatures.getTypeByIndex(0).getTypeRefdLast(timestamp);
}
} else {
portReference.getLocation().reportSemanticError(MessageFormat.format(NOINCOMINGSIGNATURES, portType.getTypename()));
}
}
IType exception = null;
boolean exceptionDetermined = false;
if (signature != null) {
final SignatureExceptions exceptions = ((Signature_Type) signature).getSignatureExceptions();
if (exceptions == null) {
signatureReference.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREWITHOUTEXCEPTIONS, signature.getTypename()));
} else {
if (exceptions.getNofExceptions() == 1) {
exception = exceptions.getExceptionByIndex(0);
} else {
exception = Port_Utility.getOutgoingType(timestamp, parameter);
if (exception == null) {
parameter.getLocation().reportSemanticError(UNKNOWNEXCEPTIONTYPE);
} else {
final int nofCompatibleTypes = exceptions.getNofCompatibleExceptions(timestamp, exception);
if (nofCompatibleTypes == 0) {
parameter.getLocation().reportSemanticError(MessageFormat.format(TYPENOTONEXCEPTIONLIST, exception.getTypename(), signature.getTypename()));
} else if (nofCompatibleTypes > 1) {
parameter.getLocation().reportSemanticError(MessageFormat.format(AMBIGUOUSEXCEPTION, exception.getTypename(), signature.getTypename()));
}
}
}
exceptionDetermined = true;
}
}
if (!exceptionDetermined) {
exception = Port_Utility.getOutgoingType(timestamp, parameter);
}
if (exception != null) {
parameter.check(timestamp, exception);
exception = exception.getTypeRefdLast(timestamp);
switch(exception.getTypetype()) {
case TYPE_SIGNATURE:
parameter.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREEXCEPTION, exception.getTypename()));
break;
case TYPE_PORT:
parameter.getLocation().reportSemanticError(MessageFormat.format(PORTEXCEPTION, exception.getTypename()));
break;
case TYPE_DEFAULT:
parameter.getLocation().reportSemanticError(MessageFormat.format(DEFAULTEXCEPTION, exception.getTypename()));
break;
default:
break;
}
}
parameter.getTemplateBody().checkSpecificValue(timestamp, false);
Port_Utility.checkToClause(timestamp, this, portType, toClause);
lastTimeChecked = timestamp;
}
Aggregations