use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Sequence_Type method checkCodingAttributes.
@Override
public /**
* {@inheritDoc}
*/
void checkCodingAttributes(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (refChain.contains(this)) {
return;
}
refChain.add(this);
refChain.markState();
for (int i = 0; i < getNofComponents(timestamp); i++) {
final CompField cf = getComponentByIndex(i);
cf.getType().checkCodingAttributes(timestamp, refChain);
}
refChain.previousState();
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Sequence_Type method checkThisNamedTemplateList.
private boolean checkThisNamedTemplateList(final CompilationTimeStamp timestamp, final Named_Template_List templateList, final boolean isModified, final boolean implicitOmit, final Assignment lhs) {
templateList.removeGeneratedValues();
boolean selfReference = false;
final Map<String, NamedTemplate> componentMap = new HashMap<String, NamedTemplate>();
final int nofTypeComponents = getNofComponents(timestamp);
final int nofTemplateComponents = templateList.getNofTemplates();
boolean inSync = true;
CompField lastComponentField = null;
int nextIndex = 0;
for (int i = 0; i < nofTemplateComponents; i++) {
final NamedTemplate namedTemplate = templateList.getTemplateByIndex(i);
final Identifier identifier = namedTemplate.getName();
final String templateName = identifier.getName();
if (hasComponentWithName(identifier)) {
if (componentMap.containsKey(templateName)) {
namedTemplate.getLocation().reportSemanticError(MessageFormat.format(DUPLICATETEMPLATEFIELDFIRST, identifier.getDisplayName()));
final Location tempLocation = componentMap.get(templateName).getLocation();
tempLocation.reportSemanticError(MessageFormat.format(DUPLICATETEMPLATEFIELDAGAIN, identifier.getDisplayName()));
inSync = false;
} else {
componentMap.put(templateName, namedTemplate);
}
final CompField componentField = getComponentByName(identifier);
if (inSync) {
if (isModified) {
boolean found = false;
for (int j = nextIndex; j < nofTypeComponents && !found; j++) {
final CompField componentField2 = getComponentByIndex(j);
if (templateName.equals(componentField2.getIdentifier().getName())) {
lastComponentField = componentField2;
nextIndex = j + 1;
found = true;
}
}
if (!found && lastComponentField != null) {
namedTemplate.getLocation().reportSemanticError(MessageFormat.format(INCORRECTTEMPLATEFIELDORDER, identifier.getDisplayName(), lastComponentField.getIdentifier().getDisplayName(), getFullName()));
inSync = false;
}
} else if (strictConstantCheckingSeverity) {
final CompField componentField2 = getComponentByIndex(i);
if (componentField2 != componentField) {
if (!componentField2.isOptional() || (componentField2.isOptional() && !implicitOmit)) {
namedTemplate.getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDTEMPLATEFIELD, identifier.getDisplayName(), componentField2.getIdentifier().getDisplayName()));
inSync = false;
}
}
}
}
final Type type = componentField.getType();
if (type != null && !type.getIsErroneous(timestamp)) {
ITTCN3Template componentTemplate = namedTemplate.getTemplate();
componentTemplate.setMyGovernor(type);
componentTemplate = type.checkThisTemplateRef(timestamp, componentTemplate);
boolean isOptional = componentField.isOptional();
if (!isOptional && componentField.hasDefault() && defaultAsOptional) {
isOptional = true;
}
selfReference |= componentTemplate.checkThisTemplateGeneric(timestamp, type, isModified, isOptional, isOptional, true, implicitOmit, lhs);
}
} else {
namedTemplate.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTTEMPLATEFIELDREFERENCE, identifier.getDisplayName(), getTypename()));
inSync = false;
}
}
if (!isModified && strictConstantCheckingSeverity) {
// check missing fields
for (int i = 0; i < nofTypeComponents; i++) {
final Identifier identifier = getComponentIdentifierByIndex(i);
if (!componentMap.containsKey(identifier.getName())) {
if (getComponentByIndex(i).isOptional() && implicitOmit) {
templateList.addNamedValue(new NamedTemplate(new Identifier(Identifier_type.ID_TTCN, identifier.getDisplayName()), new OmitValue_Template(), false));
} else {
templateList.getLocation().reportSemanticError(MessageFormat.format(MISSINGTEMPLATEFIELD, identifier.getDisplayName(), getTypename()));
}
}
}
}
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Set_Seq_Choice_BaseType method canHaveCoding.
@Override
public /**
* {@inheritDoc}
*/
boolean canHaveCoding(final CompilationTimeStamp timestamp, final MessageEncoding_type coding, final IReferenceChain refChain) {
if (refChain.contains(this)) {
return true;
}
refChain.add(this);
for (int i = 0; i < codingTable.size(); i++) {
final Coding_Type tempCodingType = codingTable.get(i);
if (tempCodingType.builtIn && tempCodingType.builtInCoding.equals(coding)) {
// coding already added
return true;
}
}
for (int i = 0; i < components.getNofComps(); i++) {
final CompField compField = components.getCompByIndex(i);
refChain.markState();
if (!compField.getType().getTypeRefdLast(timestamp).canHaveCoding(timestamp, coding, refChain)) {
return false;
}
refChain.previousState();
}
return true;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Set_Seq_Choice_BaseType method getFieldTypesAsArray.
@Override
public /**
* {@inheritDoc}
*/
boolean getFieldTypesAsArray(final Reference reference, final int actualSubReference, final List<IType> typeArray) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return true;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
{
final Identifier id = subreference.getId();
final CompField compField = components.getCompByName(id);
if (compField == null) {
return false;
}
final IType fieldType = compField.getType();
if (fieldType == null) {
return false;
}
typeArray.add(this);
return fieldType.getFieldTypesAsArray(reference, actualSubReference + 1, typeArray);
}
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Set_Type method checkThisValueSet.
/**
* Checks the Set_Value kind value against this type.
* <p>
* Please note, that this function can only be called once we know for
* sure that the value is of set type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param value
* the value to be checked
* @param expectedValue
* the kind of value expected here.
* @param incompleteAllowed
* wheather incomplete value is allowed or not.
* @param implicitOmit
* true if the implicit omit optional attribute was set
* for the value, false otherwise
*/
private boolean checkThisValueSet(final CompilationTimeStamp timestamp, final Set_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean implicitOmit, final boolean strElem) {
boolean selfReference = false;
final Map<String, NamedValue> componentMap = new HashMap<String, NamedValue>();
value.removeGeneratedValues();
final boolean isAsn = value.isAsn();
final int nofValueComponents = value.getNofComponents();
for (int i = 0; i < nofValueComponents; i++) {
final NamedValue namedValue = value.getSequenceValueByIndex(i);
final Identifier valueId = namedValue.getName();
if (!hasComponentWithName(valueId)) {
namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? NONEXISTENTFIELDASN1 : NONEXISTENTFIELDTTCN3, namedValue.getName().getDisplayName(), getTypename()));
} else {
if (componentMap.containsKey(valueId.getName())) {
namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? DUPLICATEFIELDAGAINASN1 : DUPLICATEFIELDAGAINTTCN3, valueId.getDisplayName()));
componentMap.get(valueId.getName()).getLocation().reportSingularSemanticError(MessageFormat.format(isAsn ? DUPLICATEFIELDFIRSTASN1 : DUPLICATEFIELDFIRSTTTCN3, valueId.getDisplayName()));
} else {
componentMap.put(valueId.getName(), namedValue);
}
final CompField componentField = getComponentByName(valueId);
final Type type = componentField.getType();
final IValue componentValue = namedValue.getValue();
if (componentValue != null) {
componentValue.setMyGovernor(type);
final IValue temporalValue = type.checkThisValueRef(timestamp, componentValue);
boolean isOptional = componentField.isOptional();
if (!isOptional && componentField.hasDefault() && defaultAsOptional) {
isOptional = true;
}
selfReference |= type.checkThisValue(timestamp, temporalValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, isOptional, true, implicitOmit, strElem));
}
}
}
if (!incompleteAllowed || strictConstantCheckingSeverity) {
final int nofTypeComponents = getNofComponents(timestamp);
CompField field;
for (int i = 0; i < nofTypeComponents; i++) {
field = getComponentByIndex(i);
final Identifier id = field.getIdentifier();
if (!componentMap.containsKey(id.getName())) {
if (field.isOptional() && implicitOmit) {
value.addNamedValue(new NamedValue(new Identifier(Identifier_type.ID_TTCN, id.getDisplayName()), new Omit_Value(), false));
} else {
value.getLocation().reportSemanticError(MessageFormat.format(isAsn ? MISSINGFIELDASN1 : MISSINGFIELDTTCN3, id.getDisplayName()));
}
}
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
Aggregations