use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Clear_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 (portType != null && !portType.getPortBody().hasQueue(timestamp)) {
portReference.getLocation().reportSemanticError(MessageFormat.format(QUEUELESSPORT, portType.getTypename()));
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Connect_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(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 Port_Utility method checkConnectionEndpoint.
/**
* Checks a reference to see if it really references a valid component
* type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param source
* the statement to report an error to, in case it is in
* a control part.
* @param componentReference
* the reference of the component to be checked.
* @param portReference
* the reference to a port of the component to be
* checked.
* @param allowSystem
* tells if the system component should be allowed or not
* as an endpoint.
*
* @return the referenced component type, or null if there were
* problems.
*/
public static IType checkConnectionEndpoint(final CompilationTimeStamp timestamp, final Statement source, final Value componentReference, final PortReference portReference, final boolean allowSystem) {
final IType componentType = checkComponentReference(timestamp, source, componentReference, true, allowSystem);
if (portReference == null) {
return componentType;
}
if (componentType == null) {
// the component type can not be determined
final List<ISubReference> subreferences = portReference.getSubreferences();
if (subreferences.size() > 1) {
// check array indices
for (int i = 0; i < subreferences.size(); i++) {
final ISubReference subreference = subreferences.get(i);
if (subreference instanceof ArraySubReference) {
final Value value = ((ArraySubReference) subreference).getValue();
value.setLoweridToReference(timestamp);
final Type_type temporalType1 = value.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(temporalType1) {
case TYPE_INTEGER:
{
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last1 = value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, referenceChain);
referenceChain.release();
if (!last1.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last1.getValuetype())) {
if (((Integer_Value) last1).signum() < 0) {
value.getLocation().reportSemanticError(ArraySubReference.NATIVEINTEGEREXPECTED);
value.setIsErroneous(true);
}
}
break;
}
case TYPE_UNDEFINED:
value.setIsErroneous(true);
break;
default:
if (!value.getIsErroneous(timestamp)) {
value.getLocation().reportSemanticError(ArraySubReference.INTEGERINDEXEXPECTED);
value.setIsErroneous(true);
}
break;
}
}
}
}
return null;
}
final ComponentTypeBody componentBody = ((Component_Type) componentType).getComponentBody();
portReference.setBaseScope(componentBody);
portReference.setComponent((Component_Type) componentType);
// for compatibility
portReference.getRefdAssignment(timestamp, false);
final Identifier portIdentifier = portReference.getId();
if (!componentBody.hasLocalAssignmentWithId(portIdentifier)) {
portReference.getLocation().reportSemanticError(MessageFormat.format(NOPORTWITHNAME, componentType.getTypename(), portIdentifier.getDisplayName()));
return null;
}
final Assignment assignment = componentBody.getLocalAssignmentById(portIdentifier);
if (assignment == null) {
return null;
}
if (!Assignment_type.A_PORT.semanticallyEquals(assignment.getAssignmentType())) {
portReference.getLocation().reportSemanticError(MessageFormat.format(DEFINITIONNOTPORT, portIdentifier.getDisplayName(), componentType.getTypename(), assignment.getAssignmentName()));
return null;
}
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("Port `{0}'' is not an array. The reference cannot have field or array sub-references", portIdentifier.getDisplayName()));
}
Port_Type portType = ((Def_Port) assignment).getType(timestamp);
if (portType != null) {
final PortTypeBody portBody = portType.getPortBody();
if (PortType_type.PT_USER.equals(portBody.getPortType())) {
final IType providerType = portBody.getProviderType();
if (providerType instanceof Port_Type) {
portType = (Port_Type) providerType;
}
}
}
return portType;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkFromClause.
/**
* Checks a from clause reference and a sender redirect to see if they
* really references valid component types.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param source
* the source statement to report errors to.
* @param portType
* the type of the port used in the statement. Used to
* find the address type in effect.
* @param fromClause
* the from clause to check
* @param redirectSender
* the sender redirect to check.
*/
public static void checkFromClause(final CompilationTimeStamp timestamp, final Statement source, final Port_Type portType, final TemplateInstance fromClause, final Reference redirectSender) {
IType addressType = null;
if (portType != null) {
addressType = portType.getPortBody().getAddressType(timestamp);
} else if (source != null && source.getMyStatementBlock() != null) {
final Module module = source.getMyStatementBlock().getModuleScope();
if (module != null && module_type.TTCN3_MODULE.equals(module.getModuletype())) {
addressType = ((TTCN3Module) module).getAddressType(timestamp);
}
}
boolean senderRedirectChecked = false;
IType fromClauseType = null;
if (fromClause != null) {
fromClauseType = fromClause.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
ITTCN3Template templateBody = fromClause.getTemplateBody();
if (fromClauseType == null) {
if (addressType != null) {
templateBody = addressType.checkThisTemplateRef(timestamp, templateBody);
} else {
templateBody = templateBody.setLoweridToReference(timestamp);
}
fromClauseType = templateBody.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
}
if (fromClauseType == null) {
fromClauseType = checkSenderRedirect(timestamp, addressType, redirectSender);
senderRedirectChecked = true;
}
if (fromClauseType == null) {
// trying to figure out whether the template is
// a component reference or an SUT address
boolean isComponentReference;
if (Type_type.TYPE_COMPONENT.equals(templateBody.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_TEMPLATE))) {
isComponentReference = true;
} else {
switch(templateBody.getTemplatetype()) {
case SPECIFIC_VALUE:
// treat 'null' as component
// reference
isComponentReference = Value_type.TTCN3_NULL_VALUE.equals(((SpecificValue_Template) templateBody).getSpecificValue().getValuetype());
break;
case ANY_VALUE:
case ANY_OR_OMIT:
isComponentReference = true;
break;
default:
isComponentReference = false;
break;
}
}
if (isComponentReference) {
// the argument is a component
// reference: get a pool type
fromClauseType = TypeFactory.createType(Type_type.TYPE_COMPONENT);
} else if (addressType != null) {
// the argument is not a component
// reference: try the address type
fromClauseType = addressType;
}
}
if (fromClauseType != null) {
fromClause.check(timestamp, fromClauseType);
if (addressType == null || !addressType.isCompatible(timestamp, fromClauseType, null, null, null)) {
// from_clause_type must be a component
// type
final IType last = fromClauseType.getTypeRefdLast(timestamp);
if (last.getIsErroneous(timestamp)) {
fromClauseType = null;
} else if (Type_type.TYPE_COMPONENT.equals(last.getTypetype())) {
if (Template_type.SPECIFIC_VALUE.equals(templateBody.getTemplatetype())) {
checkComponentReference(timestamp, source, ((SpecificValue_Template) templateBody).getSpecificValue(), true, true);
}
} else {
final String message = MessageFormat.format("The type of the template should be a component type {0} instead of `{1}''", (addressType == null) ? "" : "or the `address' type ", fromClauseType.getTypename());
fromClause.getLocation().reportSemanticError(message);
fromClauseType = null;
}
}
} else {
fromClause.getLocation().reportSemanticError("Cannot determine the type of the template");
}
}
if (!senderRedirectChecked) {
final IType senderRedirectType = checkSenderRedirect(timestamp, addressType, redirectSender);
if (fromClauseType != null && senderRedirectType != null && !fromClauseType.isIdentical(timestamp, senderRedirectType)) {
final String message = MessageFormat.format("The types in `from'' clause and `sender'' redirect are not the same: `{0}'' was expected instead of `{1}''", fromClauseType.getTypename(), senderRedirectType.getTypename());
senderRedirectType.getLocation().reportSemanticError(message);
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Port_Type in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkToClause.
/**
* Checks a to clause reference to see if it really references valid
* component type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param source
* the source statement of this check.
* @param portType
* the type of the port used in the statement. Used to
* find the address type in effect.
* @param toClause
* the to clause to check
*/
public static void checkToClause(final CompilationTimeStamp timestamp, final Statement source, final Port_Type portType, final IValue toClause) {
if (toClause == null) {
return;
}
IType addressType = null;
if (portType != null) {
addressType = portType.getPortBody().getAddressType(timestamp);
} else if (source != null) {
final Module module = source.getMyStatementBlock().getModuleScope();
if (module != null && module_type.TTCN3_MODULE.equals(module.getModuletype())) {
addressType = ((TTCN3Module) module).getAddressType(timestamp);
}
}
if (addressType == null) {
checkComponentReference(timestamp, source, toClause, true, true);
} else {
// detect possible enumerated values (address may be an
// enumerated type)
final IValue temp = addressType.checkThisValueRef(timestamp, toClause);
// try to figure out whether the argument is a component
// reference or an SUT address
boolean isAddress;
final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (governor == null) {
isAddress = !Type_type.TYPE_COMPONENT.equals(temp.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE));
} else {
isAddress = addressType.isCompatible(timestamp, governor, null, null, null);
}
if (isAddress) {
addressType.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
} else {
checkComponentReference(timestamp, source, temp, true, true);
}
}
}
Aggregations