use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Receive_Port_Statement method checkReceivingStatement.
/**
* Checks a port receiving statement.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param origin
* the original statement.
* @param statementName
* the name of the original statement.
* @param portReference
* the port reference.
* @param receiveParameter
* the receiving parameter.
* @param fromClause
* the from clause of the statement
* @param redirectValue
* the redirection value of the statement.
* @param redirectSender
* the sender redirection of the statement.
*/
public static void checkReceivingStatement(final CompilationTimeStamp timestamp, final Statement origin, final String statementName, final Reference portReference, final TemplateInstance receiveParameter, final TemplateInstance fromClause, final Reference redirectValue, final Reference redirectSender) {
final Port_Type portType = Port_Utility.checkPortReference(timestamp, origin, portReference);
if (receiveParameter == null) {
if (portType != null && Type_type.TYPE_PORT.equals(portType.getTypetype())) {
final PortTypeBody body = portType.getPortBody();
if (OperationModes.OP_Procedure.equals(body.getOperationMode())) {
portReference.getLocation().reportSemanticError(MessageFormat.format(MESSAGEBASEOPERATIONONPROCEDUREPORT, statementName, portType.getTypename()));
} else if (body.getInMessages() == null) {
portReference.getLocation().reportSemanticError(MessageFormat.format(NOINCOMINGMESSAGETYPES, portType.getTypename()));
}
}
if (redirectValue != null) {
redirectValue.getLocation().reportSemanticError(VALUEREDIRECTWITHOUTRECEIVEPARAMETER);
Port_Utility.checkValueRedirect(timestamp, redirectValue, null);
}
} else {
// determine the type of the incoming message
IType messageType = null;
boolean messageTypeDetermined = false;
final boolean[] valueRedirectChecked = new boolean[] { false };
if (portType != null) {
// the port type is known
final PortTypeBody portTypeBody = portType.getPortBody();
final TypeSet inMessages = portTypeBody.getInMessages();
if (OperationModes.OP_Procedure.equals(portTypeBody.getOperationMode())) {
portReference.getLocation().reportSemanticError(MessageFormat.format(RECEIVEONPORT, statementName, portType.getTypename()));
} else if (inMessages != null) {
if (inMessages.getNofTypes() == 1) {
messageType = inMessages.getTypeByIndex(0);
} else {
messageType = Port_Utility.getIncomingType(timestamp, receiveParameter, redirectValue, valueRedirectChecked);
if (messageType == null) {
receiveParameter.getLocation().reportSemanticError(UNKNOWNINCOMINGMESSAGE);
} else {
final int nofCompatibleTypes = inMessages.getNofCompatibleTypes(timestamp, messageType);
if (nofCompatibleTypes == 0) {
receiveParameter.getLocation().reportSemanticError(MessageFormat.format(TYPENOTPRESENT, messageType.getTypename(), portType.getTypename()));
} else if (nofCompatibleTypes > 1) {
receiveParameter.getLocation().reportSemanticError(MessageFormat.format(TYPEISAMBIGUOUS, messageType.getTypename(), portType.getTypename()));
}
}
}
messageTypeDetermined = true;
} else {
portReference.getLocation().reportSemanticError(MessageFormat.format(NOINCOMINGMESSAGETYPES, portType.getTypename()));
}
} else if (portReference == null) {
// any port
receiveParameter.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHPARAMETER, statementName));
if (redirectValue != null) {
redirectValue.getLocation().reportSemanticError(MessageFormat.format(RECEIVEWITHVALUEREDIRECT, statementName));
}
}
if (!messageTypeDetermined) {
messageType = Port_Utility.getIncomingType(timestamp, receiveParameter, redirectValue, valueRedirectChecked);
}
if (messageType != null) {
receiveParameter.check(timestamp, messageType);
if (!valueRedirectChecked[0]) {
Port_Utility.checkValueRedirect(timestamp, redirectValue, messageType);
}
}
}
Port_Utility.checkFromClause(timestamp, origin, portType, fromClause, redirectSender);
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Unmap_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
IType portType1;
IType portType2;
PortTypeBody body1;
PortTypeBody body2;
boolean cref1IsTestcomponents = false;
boolean cref1IsSystem = false;
boolean cref2IsTestcomponent = false;
boolean cref2IsSystem = false;
portType1 = Port_Utility.checkConnectionEndpoint(timestamp, this, componentReference1, portReference1, true);
if (portType1 == null) {
body1 = null;
} else {
body1 = ((Port_Type) portType1).getPortBody();
if (body1.isInternal()) {
componentReference1.getLocation().reportSemanticWarning(MessageFormat.format("Port type `{0}'' was marked as `internal''", portType1.getTypename()));
}
}
final IValue configReference1 = componentReference1.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
if (Value_type.EXPRESSION_VALUE.equals(configReference1.getValuetype())) {
switch(((Expression_Value) configReference1).getOperationType()) {
case MTC_COMPONENT_OPERATION:
cref1IsTestcomponents = true;
break;
case SELF_COMPONENT_OPERATION:
cref1IsTestcomponents = true;
break;
case COMPONENT_CREATE_OPERATION:
cref1IsTestcomponents = true;
break;
case SYSTEM_COMPONENT_OPERATION:
cref1IsSystem = true;
break;
default:
break;
}
}
portType2 = Port_Utility.checkConnectionEndpoint(timestamp, this, componentReference2, portReference2, true);
if (portType2 == null) {
body2 = null;
} else {
body2 = ((Port_Type) portType2).getPortBody();
if (body2.isInternal()) {
componentReference2.getLocation().reportSemanticWarning(MessageFormat.format("Port type `{0}'' was marked as `internal''", portType2.getTypename()));
}
}
final IValue configReference2 = componentReference2.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
if (Value_type.EXPRESSION_VALUE.equals(configReference2.getValuetype())) {
switch(((Expression_Value) configReference2).getOperationType()) {
case MTC_COMPONENT_OPERATION:
cref2IsTestcomponent = true;
break;
case SELF_COMPONENT_OPERATION:
cref2IsTestcomponent = true;
break;
case COMPONENT_CREATE_OPERATION:
cref2IsTestcomponent = true;
break;
case SYSTEM_COMPONENT_OPERATION:
cref2IsSystem = true;
break;
default:
break;
}
}
lastTimeChecked = timestamp;
if (cref1IsTestcomponents && cref2IsTestcomponent) {
location.reportSemanticError(Map_Statement.BOTHENDSARETESTCOMPONENTPORTS);
return;
}
if (cref1IsSystem && cref2IsSystem) {
location.reportSemanticError(Map_Statement.BOTHENDSARESYSTEMPORTS);
return;
}
if (portType1 == null || portType2 == null || body1 == null || body2 == null) {
return;
}
if (cref1IsTestcomponents || cref2IsSystem) {
if (!body1.isMappable(timestamp, body2)) {
location.reportSemanticError(MessageFormat.format(Map_Statement.INCONSISTENTMAPPING1, portType1.getTypename(), portType2.getTypename()));
body1.reportMappingErrors(timestamp, body2);
}
} else if (cref2IsTestcomponent || cref1IsSystem) {
if (!body2.isMappable(timestamp, body1)) {
location.reportSemanticError(MessageFormat.format(Map_Statement.INCONSISTENTMAPPING2, portType1.getTypename(), portType2.getTypename()));
body2.reportMappingErrors(timestamp, body1);
}
} else {
// we don't know which is the system port
if (!body1.isMappable(timestamp, body2) && !body2.isMappable(timestamp, body1)) {
location.reportSemanticError(MessageFormat.format(Map_Statement.INCONSISTENTMAPPING3, portType1.getTypename(), portType2.getTypename()));
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Disconnect_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
IType portType1;
IType portType2;
PortTypeBody body1;
PortTypeBody body2;
portType1 = Port_Utility.checkConnectionEndpoint(timestamp, this, componentReference1, portReference1, false);
if (portType1 == null) {
body1 = null;
} else {
body1 = ((Port_Type) portType1).getPortBody();
}
portType2 = Port_Utility.checkConnectionEndpoint(timestamp, this, componentReference2, portReference2, false);
if (portType2 == null) {
body2 = null;
} else {
body2 = ((Port_Type) portType2).getPortBody();
}
if (portType1 == null || portType2 == null || body1 == null || body2 == null) {
lastTimeChecked = timestamp;
return;
}
if (!body1.isConnectable(timestamp, body2) || (body1 != body2 && !body2.isConnectable(timestamp, body1))) {
location.reportSemanticError(MessageFormat.format(Connect_Statement.INCONSISTENTCONNECTION, portType1.getTypename(), portType2.getTypename()));
body1.reportConnectionErrors(timestamp, body2, location);
if (body1 != body2) {
body2.reportConnectionErrors(timestamp, body1, location);
}
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Map_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
IType portType1;
IType portType2;
PortTypeBody body1 = null;
PortTypeBody body2 = null;
boolean cref1IsTestcomponents = false;
boolean cref1IsSystem = false;
boolean cref2IsTestcomponent = false;
boolean cref2IsSystem = false;
portType1 = Port_Utility.checkConnectionEndpoint(timestamp, this, componentReference1, portReference1, true);
if (portType1 != null) {
body1 = ((Port_Type) portType1).getPortBody();
if (body1.isInternal()) {
componentReference1.getLocation().reportSemanticWarning(MessageFormat.format("Port type `{0}'' was marked as `internal''", portType1.getTypename()));
}
// sets the referenced assignment of this reference
portReference1.getRefdAssignment(timestamp, false);
}
if (componentReference1 != null) {
final IValue configReference1 = componentReference1.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
if (Value_type.EXPRESSION_VALUE.equals(configReference1.getValuetype())) {
switch(((Expression_Value) configReference1).getOperationType()) {
case MTC_COMPONENT_OPERATION:
cref1IsTestcomponents = true;
break;
case SELF_COMPONENT_OPERATION:
cref1IsTestcomponents = true;
break;
case COMPONENT_CREATE_OPERATION:
cref1IsTestcomponents = true;
break;
case SYSTEM_COMPONENT_OPERATION:
cref1IsSystem = true;
break;
default:
break;
}
}
}
portType2 = Port_Utility.checkConnectionEndpoint(timestamp, this, componentReference2, portReference2, true);
if (portType2 != null) {
body2 = ((Port_Type) portType2).getPortBody();
if (body2.isInternal()) {
componentReference2.getLocation().reportSemanticWarning(MessageFormat.format("Port type `{0}'' was marked as `internal''", portType2.getTypename()));
}
// sets the referenced assignment of this reference
portReference2.getRefdAssignment(timestamp, false);
}
if (componentReference2 != null) {
final IValue configReference2 = componentReference2.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
if (Value_type.EXPRESSION_VALUE.equals(configReference2.getValuetype())) {
switch(((Expression_Value) configReference2).getOperationType()) {
case MTC_COMPONENT_OPERATION:
cref2IsTestcomponent = true;
break;
case SELF_COMPONENT_OPERATION:
cref2IsTestcomponent = true;
break;
case COMPONENT_CREATE_OPERATION:
cref2IsTestcomponent = true;
break;
case SYSTEM_COMPONENT_OPERATION:
cref2IsSystem = true;
break;
default:
break;
}
}
}
lastTimeChecked = timestamp;
if (cref1IsTestcomponents && cref2IsTestcomponent) {
location.reportSemanticError(BOTHENDSARETESTCOMPONENTPORTS);
return;
}
if (cref1IsSystem && cref2IsSystem) {
location.reportSemanticError(BOTHENDSARESYSTEMPORTS);
return;
}
if (body1 == null || body2 == null || portType1 == null || portType2 == null) {
return;
}
if (cref1IsTestcomponents || cref2IsSystem) {
if (!body1.isMappable(timestamp, body2)) {
location.reportSemanticError(MessageFormat.format(INCONSISTENTMAPPING1, portType1.getTypename(), portType2.getTypename()));
body1.reportMappingErrors(timestamp, body2);
}
} else if (cref2IsTestcomponent || cref1IsSystem) {
if (!body2.isMappable(timestamp, body1)) {
location.reportSemanticError(MessageFormat.format(INCONSISTENTMAPPING2, portType1.getTypename(), portType2.getTypename()));
body2.reportMappingErrors(timestamp, body1);
}
} else {
// we don't know which one is the system port
if (!body1.isMappable(timestamp, body2) && !body2.isMappable(timestamp, body1)) {
location.reportSemanticError(MessageFormat.format(INCONSISTENTMAPPING3, portType1.getTypename(), portType2.getTypename()));
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_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;
}
Aggregations