use of org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type in project titan.EclipsePlug-ins by eclipse.
the class VariableList_Parameter_Redirect method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final Signature_Type signature, final boolean isOut) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
this.checkErroneous(timestamp);
if (signature == null) {
return;
}
final SignatureFormalParameterList parameterList = signature.getParameterList();
if (parameterList.getNofParameters() == 0) {
getLocation().reportSemanticError(MessageFormat.format(SIGNATUREWITHOUTPARAMETERS, signature.getTypename()));
checkErroneous(timestamp);
return;
}
final int nofVariableEntries = entries.getNofEntries();
final int nofParameters = isOut ? parameterList.getNofOutParameters() : parameterList.getNofInParameters();
if (nofVariableEntries != nofParameters) {
getLocation().reportSemanticError(MessageFormat.format("Too {0} variable entries compared to the number of {1}/inout parameters in signature `{2}'': {3} was expected instead of {4}", (nofVariableEntries > nofParameters) ? "many" : "few", isOut ? "out" : "in", signature.getTypename(), nofParameters, nofVariableEntries));
}
for (int i = 0; i < nofVariableEntries; i++) {
final Variable_Entry entry = entries.getEntryByIndex(i);
if (i < nofParameters) {
final SignatureFormalParameter parameter = isOut ? parameterList.getOutParameterByIndex(i) : parameterList.getInParameterByIndex(i);
checkVariableReference(timestamp, entry.getReference(), parameter.getType());
} else {
checkVariableReference(timestamp, entry.getReference(), null);
}
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Signature_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.TTCN3.types.Signature_Type in project titan.EclipsePlug-ins by eclipse.
the class AssignmentList_Parameter_Redirect method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final Signature_Type signature, final boolean isOut) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
final SignatureFormalParameterList parameterList = signature.getParameterList();
if (parameterList.getNofParameters() == 0) {
getLocation().reportSemanticError(MessageFormat.format(SIGNATUREWITHOUTPARAMETERS, signature.getTypename()));
checkErroneous(timestamp);
return;
}
boolean errorFlag = false;
final HashMap<String, Parameter_Assignment> parameterMap = new HashMap<String, Parameter_Assignment>();
for (int i = 0, size = assignments.getNofParameterAssignments(); i < size; i++) {
final Parameter_Assignment assignment = assignments.getParameterAssignmentByIndex(i);
final String name = assignment.getIdentifier().getName();
if (parameterMap.containsKey(name)) {
assignment.getLocation().reportSemanticError(MessageFormat.format("Duplicate redirect for parameter `{0}''", assignment.getIdentifier().getDisplayName()));
final Location otherLocation = parameterMap.get(name).getLocation();
otherLocation.reportSemanticWarning(MessageFormat.format("A variable entry for parameter `{0}'' is already given here", assignment.getIdentifier().getDisplayName()));
errorFlag = true;
} else {
parameterMap.put(name, assignment);
}
if (parameterList.hasParameterWithName(name)) {
final SignatureFormalParameter parameterTemplate = parameterList.getParameterByName(name);
if (isOut) {
if (SignatureFormalParameter.ParamaterDirection.PARAM_IN == parameterTemplate.getDirection()) {
final String message = MessageFormat.format("Parameter `{0}'' of signature `{1}'' has `in'' direction", assignment.getIdentifier().getDisplayName(), signature.getTypename());
assignment.getLocation().reportSemanticError(message);
errorFlag = true;
}
} else {
if (SignatureFormalParameter.ParamaterDirection.PARAM_OUT == parameterTemplate.getDirection()) {
final String message = MessageFormat.format("Parameter `{0}'' of signature `{1}'' has `out'' direction", assignment.getIdentifier().getDisplayName(), signature.getTypename());
assignment.getLocation().reportSemanticError(message);
errorFlag = true;
}
}
checkVariableReference(timestamp, assignment.getReference(), parameterTemplate.getType());
} else {
assignment.getLocation().reportSemanticError(MessageFormat.format("Signature `{0}'' does not have parameter named `{1}''", signature.getTypename(), assignment.getIdentifier().getDisplayName()));
errorFlag = true;
checkVariableReference(timestamp, assignment.getReference(), null);
}
}
if (!errorFlag) {
// converting the AssignmentList to VariableList
final Variable_Entries variableEntries = new Variable_Entries();
final int upperLimit = isOut ? parameterList.getNofOutParameters() : parameterList.getNofInParameters();
for (int i = 0; i < upperLimit; i++) {
final SignatureFormalParameter parameter = isOut ? parameterList.getOutParameterByIndex(i) : parameterList.getInParameterByIndex(i);
final String name = parameter.getIdentifier().getName();
if (parameterMap.containsKey(name)) {
variableEntries.add(new Variable_Entry(parameterMap.get(name).getReference()));
} else {
variableEntries.add(new Variable_Entry());
}
}
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type in project titan.EclipsePlug-ins by eclipse.
the class PortTypeBody method checkUserAttribute.
/**
* Checks the attributes for the specific case when the port is of user type.
*
* @param timestamp the time stamp of the actual semantic check cycle.
*/
private void checkUserAttribute(final CompilationTimeStamp timestamp) {
if (providerReference == null) {
return;
}
providerType = null;
PortTypeBody providerBody = null;
final Assignment assignment = providerReference.getRefdAssignment(timestamp, true);
if (assignment != null) {
if (Assignment_type.A_TYPE.semanticallyEquals(assignment.getAssignmentType())) {
final IType type = assignment.getType(timestamp).getTypeRefdLast(timestamp);
if (Type_type.TYPE_PORT.equals(type.getTypetype())) {
providerType = type;
providerBody = ((Port_Type) type).getPortBody();
} else {
providerReference.getLocation().reportSemanticError(MessageFormat.format("Type reference `{0}'' does not refer to a port type", providerReference.getDisplayName()));
}
} else {
providerReference.getLocation().reportSemanticError(MessageFormat.format("Reference `{0}'' does not refer to a type", providerReference.getDisplayName()));
}
}
// checking the consistency of attributes in this and provider_body
if (providerBody != null && !TestPortAPI_type.TP_INTERNAL.equals(testportType)) {
if (!PortType_type.PT_PROVIDER.equals(providerBody.portType)) {
providerReference.getLocation().reportSemanticError(MessageFormat.format("The referenced port type `{0}'' must have the `provider'' attribute", providerType.getTypename()));
}
switch(providerBody.testportType) {
case TP_REGULAR:
if (TestPortAPI_type.TP_ADDRESS.equals(testportType)) {
providerReference.getLocation().reportSemanticError(MessageFormat.format("Attribute `address'' cannot be used because the provider port type `{0}''" + " does not have attribute `address''", providerType.getTypename()));
}
break;
case TP_INTERNAL:
providerReference.getLocation().reportSemanticError(MessageFormat.format("Missing attribute `internal''. Provider port type `{0}'' has attribute `internal''," + " which must be also present here", providerType.getTypename()));
break;
case TP_ADDRESS:
break;
default:
break;
}
// inherit the test port API type from the provider
testportType = providerBody.testportType;
}
// check the incoming mappings
if (inMappings != null && inMappings.getNofMappings() != 0) {
inMappings.check(timestamp);
if (providerBody != null) {
if (providerBody.inMessages != null) {
// check if all source types are present on the `in' list of the provider
for (int i = 0, size = inMappings.getNofMappings(); i < size; i++) {
final Type sourceType = inMappings.getMappingByIndex(i).getSourceType();
// }
if (sourceType != null && !providerBody.inMessages.hasType(timestamp, sourceType)) {
sourceType.getLocation().reportSemanticError(MessageFormat.format("Source type `{0}'' of the `in'' mapping is not present " + "on the list of incoming messages in provider port type `{1}''", sourceType.getTypename(), providerType.getTypename()));
}
}
// check if all types of the `in' list of the provider are handled by the mappings
for (int i = 0, size = providerBody.inMessages.getNofTypes(); i < size; i++) {
final IType messageType = providerBody.inMessages.getTypeByIndex(i);
if (!inMappings.hasMappingForType(timestamp, messageType)) {
inMappings.getLocation().reportSemanticError(MessageFormat.format("Incoming message type `{0}'' of provider port type `{1}'' is not handled by the incoming mappings", messageType.getTypename(), providerType.getTypename()));
inMappings.hasMappingForType(timestamp, messageType);
}
}
} else {
inMappings.getLocation().reportSemanticError(MessageFormat.format("Invalid incoming mappings. Provider port type `{0}' does not have incoming message types'", providerType.getTypename()));
}
}
// checking target types
for (int i = 0, size = inMappings.getNofMappings(); i < size; i++) {
final TypeMapping mapping = inMappings.getMappingByIndex(i);
for (int j = 0, nofTargets = mapping.getNofTargets(); j < nofTargets; j++) {
final Type targetType = mapping.getTargetByIndex(j).getTargetType();
if (targetType != null && (inMessages == null || !inMessages.hasType(timestamp, targetType))) {
targetType.getLocation().reportSemanticError(MessageFormat.format("Target type `{0}'' of the `in'' mapping is not present on the list of incoming messages in user port type `{1}''", targetType.getTypename(), myType.getTypename()));
}
}
}
} else if (providerBody != null && providerBody.inMessages != null) {
location.reportSemanticError(MessageFormat.format("Missing `in'' mappings to handle the incoming message types of provider port type `{0}''", providerType.getTypename()));
}
if (outMappings != null && outMappings.getNofMappings() != 0) {
outMappings.check(timestamp);
if (outMessages != null) {
// check if all source types are present on the `in' list of the provider
for (int i = 0, size = outMappings.getNofMappings(); i < size; i++) {
final Type sourceType = outMappings.getMappingByIndex(i).getSourceType();
if (sourceType != null && !outMessages.hasType(timestamp, sourceType)) {
sourceType.getLocation().reportSemanticError(MessageFormat.format("Source type `{0}'' of the `out'' mapping is not present on the list of outgoing messages in user port type `{1}''", sourceType.getTypename(), myType.getTypename()));
}
}
// check if all types of the `in' list of the provider are handled by the mappings
for (int i = 0, size = outMessages.getNofTypes(); i < size; i++) {
final IType messageType = outMessages.getTypeByIndex(i);
if (!outMappings.hasMappingForType(timestamp, messageType)) {
outMappings.getLocation().reportSemanticError(MessageFormat.format("Outgoing message type `{0}'' of user port type `{1}'' is not handled by the outgoing mappings", messageType.getTypename(), myType.getTypename()));
}
}
} else {
outMappings.getLocation().reportSemanticError(MessageFormat.format("Invalid outgoing mappings. User port type `{0}'' does not have outgoing message types", myType.getTypename()));
}
// checking target types
if (providerBody != null) {
for (int i = 0, size = outMappings.getNofMappings(); i < size; i++) {
final TypeMapping mapping = outMappings.getMappingByIndex(i);
for (int j = 0, nofTargets = mapping.getNofTargets(); j < nofTargets; j++) {
final Type targetType = mapping.getTargetByIndex(j).getTargetType();
if (targetType != null && (providerBody.outMessages == null || !providerBody.outMessages.hasType(timestamp, targetType))) {
targetType.getLocation().reportSemanticError(MessageFormat.format("Target type `{0}'' of the `out'' mapping is not present " + "on the list of outgoing messages in provider port type `{1}''", targetType.getTypename(), providerType.getTypename()));
}
}
}
}
} else if (outMessages != null) {
location.reportSemanticError(MessageFormat.format("Missing `out'' mapping to handle the outgoing message types of user port type `{0}''", myType.getTypename()));
}
// checking the compatibility of signature lists
if (providerBody == null) {
return;
}
if (inSignatures != null) {
for (int i = 0, size = inSignatures.getNofTypes(); i < size; i++) {
final IType signatureType = inSignatures.getTypeByIndex(i);
if (providerBody.inSignatures == null || !providerBody.inSignatures.hasType(timestamp, signatureType)) {
final IType last = signatureType.getTypeRefdLast(timestamp);
if (!last.getIsErroneous(timestamp) && Type_type.TYPE_SIGNATURE.equals(last.getTypetype())) {
final Signature_Type lastSignature = (Signature_Type) last;
if (!lastSignature.isNonblocking() || lastSignature.getSignatureExceptions() != null) {
signatureType.getLocation().reportSemanticError(MessageFormat.format("Incoming signature `{0}'' of user port type `{1}'' is not present on the list " + "of incoming signatures in provider port type `{2}''", signatureType.getTypename(), myType.getTypename(), providerType.getTypename()));
}
}
}
}
}
if (providerBody.inSignatures != null) {
for (int i = 0, size = providerBody.inSignatures.getNofTypes(); i < size; i++) {
final IType signatureType = providerBody.inSignatures.getTypeByIndex(i);
if (inSignatures == null || !inSignatures.hasType(timestamp, signatureType)) {
location.reportSemanticError(MessageFormat.format("Incoming signature `{0}'' of provider port type `{1}'' " + "is not present on the list of incoming signatures in user port type `{2}''", signatureType.getTypename(), providerType.getTypename(), myType.getTypename()));
}
}
}
if (outSignatures != null) {
for (int i = 0, size = outSignatures.getNofTypes(); i < size; i++) {
final IType signatureType = outSignatures.getTypeByIndex(i);
if (providerBody.outSignatures == null || !providerBody.outSignatures.hasType(timestamp, signatureType)) {
signatureType.getLocation().reportSemanticError(MessageFormat.format("Outgoing signature `{0}'' of user port type `{1}'' is not present " + "on the list of outgoing signatures in provider port type `{2}''", signatureType.getTypename(), myType.getTypename(), providerType.getTypename()));
}
}
}
if (providerBody.outSignatures != null) {
for (int i = 0, size = providerBody.outSignatures.getNofTypes(); i < size; i++) {
final IType signatureType = providerBody.outSignatures.getTypeByIndex(i);
if (outSignatures == null || !outSignatures.hasType(timestamp, signatureType)) {
final IType last = signatureType.getTypeRefdLast(timestamp);
if (!last.getIsErroneous(timestamp) && Type_type.TYPE_SIGNATURE.equals(last.getTypetype())) {
final Signature_Type lastSignature = (Signature_Type) last;
if (!lastSignature.isNonblocking() || lastSignature.getSignatureExceptions() != null) {
location.reportSemanticError(MessageFormat.format("Outgoing signature `{0}'' of provider port type `{1}'' is not present " + "on the list of outgoing signatures in user port type `{2}''", signatureType.getTypename(), providerType.getTypename(), myType.getTypename()));
}
}
}
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type in project titan.EclipsePlug-ins by eclipse.
the class Named_Template_List method generateCodeInit.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeInit(final JavaGenData aData, final StringBuilder source, final String name) {
if (lastTimeBuilt != null && !lastTimeBuilt.isLess(aData.getBuildTimstamp())) {
return;
}
lastTimeBuilt = aData.getBuildTimstamp();
if (asValue != null) {
asValue.generateCodeInit(aData, source, name);
return;
}
if (myGovernor == null) {
return;
}
// FIXME actually a bit more complex
final IType type = myGovernor.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
if (type == null) {
return;
}
if (namedTemplates.getNofTemplates() == 0) {
aData.addBuiltinTypeImport("TitanNull_Type");
source.append(MessageFormat.format("{0}.assign(TitanNull_Type.NULL_VALUE);\n", name));
}
// else is not needed as the loop will not run
for (int i = 0; i < namedTemplates.getNofTemplates(); i++) {
final NamedTemplate namedTemplate = namedTemplates.getTemplateByIndex(i);
final String fieldName = namedTemplate.getName().getName();
// FIXME handle needs_temp_ref case
final String generatedFieldName = FieldSubReference.getJavaGetterName(fieldName);
final TTCN3Template template = namedTemplate.getTemplate();
if (template.needsTemporaryReference()) {
Type fieldType;
switch(type.getTypetype()) {
case TYPE_SIGNATURE:
fieldType = ((Signature_Type) type).getParameterByName(fieldName).getType();
break;
case TYPE_TTCN3_SEQUENCE:
fieldType = ((TTCN3_Sequence_Type) type).getComponentByName(fieldName).getType();
break;
case TYPE_TTCN3_SET:
fieldType = ((TTCN3_Set_Type) type).getComponentByName(fieldName).getType();
break;
case TYPE_ASN1_SEQUENCE:
fieldType = ((ASN1_Sequence_Type) type).getComponentByName(new Identifier(Identifier_type.ID_NAME, fieldName)).getType();
break;
case TYPE_ASN1_SET:
fieldType = ((ASN1_Set_Type) type).getComponentByName(new Identifier(Identifier_type.ID_NAME, fieldName)).getType();
break;
case TYPE_ASN1_CHOICE:
fieldType = ((ASN1_Choice_Type) type).getComponentByName(new Identifier(Identifier_type.ID_NAME, fieldName)).getType();
break;
case TYPE_TTCN3_CHOICE:
fieldType = ((TTCN3_Choice_Type) type).getComponentByName(fieldName).getType();
break;
case TYPE_OPENTYPE:
fieldType = ((Open_Type) type).getComponentByName(new Identifier(Identifier_type.ID_NAME, fieldName)).getType();
break;
case TYPE_ANYTYPE:
fieldType = ((Anytype_Type) type).getComponentByName(fieldName).getType();
break;
default:
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while processing named template list `" + getFullName() + "''");
return;
}
final String tempId = aData.getTemporaryVariableName();
source.append("{\n");
source.append(MessageFormat.format("{0} {1} = {2}.get{3}();\n", fieldType.getGenNameTemplate(aData, source, myScope), tempId, name, generatedFieldName));
template.generateCodeInit(aData, source, tempId);
source.append("}\n");
} else {
final String embeddedName = MessageFormat.format("{0}.get{1}()", name, generatedFieldName);
template.generateCodeInit(aData, source, embeddedName);
}
}
if (lengthRestriction != null) {
if (getCodeSection() == CodeSectionType.CS_POST_INIT) {
lengthRestriction.reArrangeInitCode(aData, source, myScope.getModuleScope());
}
lengthRestriction.generateCodeInit(aData, source, name);
}
if (isIfpresent) {
source.append(name);
source.append(".set_ifPresent();\n");
}
}
Aggregations