use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Port in project titan.EclipsePlug-ins by eclipse.
the class FormalParameter method checkActualParameterPort.
/**
* Checks if the actual parameter paired with this formal parameter is
* semantically correct as a port parameter.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param actualParameter
* the template instance assigned as actual parameter to
* this formal parameter
* @param expectedValue
* the value kind expected from the actual parameter.
*
* @return the actual parameter created from the value, or null if there
* was an error.
*/
private ActualParameter checkActualParameterPort(final CompilationTimeStamp timestamp, final TemplateInstance actualParameter, final Expected_Value_type expectedValue) {
final Type parameterType = actualParameter.getType();
if (parameterType != null) {
parameterType.getLocation().reportSemanticWarning("Explicit type specification is useless for a port parameter");
actualParameter.checkType(timestamp, type);
}
final Reference derivedReference = actualParameter.getDerivedReference();
if (derivedReference != null) {
derivedReference.getLocation().reportSemanticError("An in-line modified temlate cannot be used as port parameter");
actualParameter.checkDerivedReference(timestamp, type);
}
final ITTCN3Template parameterTemplate = actualParameter.getTemplateBody();
if (!(parameterTemplate instanceof SpecificValue_Template) || !((SpecificValue_Template) parameterTemplate).isReference()) {
actualParameter.getLocation().reportSemanticError("Reference to a port or port parameter was expected for a port parameter");
final ActualParameter temp = new Value_ActualParameter(null);
temp.setIsErroneous();
return temp;
}
final Reference reference = ((SpecificValue_Template) parameterTemplate).getReference();
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment == null) {
final ActualParameter temp = new Value_ActualParameter(null);
temp.setIsErroneous();
return temp;
}
Type referredType;
switch(assignment.getAssignmentType()) {
case A_PORT:
final ArrayDimensions dimensions = ((Def_Port) assignment).getDimensions();
if (dimensions != null) {
dimensions.checkIndices(timestamp, reference, "port", false, expectedValue);
} else if (reference.getSubreferences().size() > 1) {
reference.getLocation().reportSemanticError(MessageFormat.format(SUBREFERENCEERROR1, assignment.getDescription()));
}
referredType = ((Def_Port) assignment).getType(timestamp);
break;
case A_PAR_PORT:
if (reference.getSubreferences().size() > 1) {
reference.getLocation().reportSemanticError(MessageFormat.format(SUBREFERENCEERROR3, assignment.getDescription()));
}
referredType = ((FormalParameter) assignment).getType(timestamp);
break;
default:
reference.getLocation().reportSemanticError(MessageFormat.format(PORTEXPECTED, assignment.getDescription()));
final ActualParameter temp = new Value_ActualParameter(null);
temp.setIsErroneous();
return temp;
}
if (referredType != null && type != null && !type.isIdentical(timestamp, referredType)) {
reference.getLocation().reportSemanticError(MessageFormat.format(TYPEMISMATCH, type.getTypename(), referredType.getTypename()));
}
return new Referenced_ActualParameter(reference);
}
Aggregations