Search in sources :

Example 16 with Type

use of org.eclipse.titan.designer.AST.Type in project titan.EclipsePlug-ins by eclipse.

the class Open_Type method checkThisTemplate.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisTemplate(final CompilationTimeStamp timestamp, final ITTCN3Template template, final boolean isModified, final boolean implicitOmit, final Assignment lhs) {
    registerUsage(template);
    template.setMyGovernor(this);
    if (getIsErroneous(timestamp)) {
        return false;
    }
    boolean selfReference = false;
    if (Template_type.NAMED_TEMPLATE_LIST.equals(template.getTemplatetype())) {
        final Named_Template_List namedTemplateList = (Named_Template_List) template;
        final int nofTemplates = namedTemplateList.getNofTemplates();
        if (nofTemplates != 1) {
            template.getLocation().reportSemanticError(ONEFIELDEXPECTED);
        }
        for (int i = 0; i < nofTemplates; i++) {
            final NamedTemplate namedTemplate = namedTemplateList.getTemplateByIndex(i);
            final Identifier name = namedTemplate.getName();
            final CompField field = getComponentByName(name);
            if (field == null) {
                namedTemplate.getLocation().reportSemanticError(MessageFormat.format(REFERENCETONONEXISTENTFIELD, name.getDisplayName(), getFullName()));
            } else {
                final Type fieldType = field.getType();
                if (fieldType != null && !fieldType.getIsErroneous(timestamp)) {
                    ITTCN3Template namedTemplateTemplate = namedTemplate.getTemplate();
                    namedTemplateTemplate.setMyGovernor(fieldType);
                    namedTemplateTemplate = fieldType.checkThisTemplateRef(timestamp, namedTemplateTemplate);
                    final Completeness_type completeness = namedTemplateList.getCompletenessConditionChoice(timestamp, isModified, name);
                    selfReference |= namedTemplateTemplate.checkThisTemplateGeneric(timestamp, fieldType, Completeness_type.MAY_INCOMPLETE.equals(completeness), false, false, true, implicitOmit, lhs);
                }
            }
        }
    } else {
        template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName(), getTypename()));
    }
    if (template.getLengthRestriction() != null) {
        template.getLocation().reportSemanticError(MessageFormat.format(LENGTHRESTRICTIONNOTALLOWED, getTypename()));
    }
    return selfReference;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Completeness_type(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type) IASN1Type(org.eclipse.titan.designer.AST.ASN1.IASN1Type) Type(org.eclipse.titan.designer.AST.Type) ASN1Type(org.eclipse.titan.designer.AST.ASN1.ASN1Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) NamedTemplate(org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Named_Template_List(org.eclipse.titan.designer.AST.TTCN3.templates.Named_Template_List) TableConstraint(org.eclipse.titan.designer.AST.ASN1.TableConstraint)

Example 17 with Type

use of org.eclipse.titan.designer.AST.Type in project titan.EclipsePlug-ins by eclipse.

the class Selection_Type method checkRecursions.

@Override
public /**
 * {@inheritDoc}
 */
void checkRecursions(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    if (referenceChain.add(this)) {
        final IReferenceChain tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
        final Type type = getTypeRefd(timestamp, tempReferenceChain);
        tempReferenceChain.release();
        if (null != type && !type.getIsErroneous(timestamp) && !this.equals(type)) {
            type.checkRecursions(timestamp, referenceChain);
        }
    }
}
Also used : IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) IASN1Type(org.eclipse.titan.designer.AST.ASN1.IASN1Type) Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) Type(org.eclipse.titan.designer.AST.Type) ASN1Type(org.eclipse.titan.designer.AST.ASN1.ASN1Type) IType(org.eclipse.titan.designer.AST.IType) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

Example 18 with Type

use of org.eclipse.titan.designer.AST.Type in project titan.EclipsePlug-ins by eclipse.

the class FunctionTypeMappingTarget method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp, final Type source) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    functionReferenced = null;
    extfunctionReferenced = null;
    if (functionReference == null) {
        return;
    }
    final Assignment assignment = functionReference.getRefdAssignment(timestamp, false);
    if (assignment == null) {
        return;
    }
    assignment.check(timestamp);
    EncodingPrototype_type referencedPrototype;
    Type inputType;
    Type outputType;
    switch(assignment.getAssignmentType()) {
        case A_FUNCTION:
        case A_FUNCTION_RVAL:
        case A_FUNCTION_RTEMP:
            functionReferenced = (Def_Function) assignment;
            referencedPrototype = functionReferenced.getPrototype();
            inputType = functionReferenced.getInputType();
            outputType = functionReferenced.getOutputType();
            break;
        case A_EXT_FUNCTION:
        case A_EXT_FUNCTION_RVAL:
        case A_EXT_FUNCTION_RTEMP:
            extfunctionReferenced = (Def_Extfunction) assignment;
            referencedPrototype = extfunctionReferenced.getPrototype();
            inputType = extfunctionReferenced.getInputType();
            outputType = extfunctionReferenced.getOutputType();
            break;
        default:
            functionReference.getLocation().reportSemanticError(MessageFormat.format("Reference to a function or external function was expected instead of {0}", assignment.getDescription()));
            return;
    }
    if (EncodingPrototype_type.NONE.equals(referencedPrototype)) {
        functionReference.getLocation().reportSemanticError(MessageFormat.format("The referenced {0} does not have `prototype'' attribute", assignment.getDescription()));
        return;
    }
    if (inputType != null && source != null && !source.isIdentical(timestamp, inputType)) {
        final String message = MessageFormat.format("The input type of {0} must be the same as the source type of the mapping: `{1}'' was expected instead of `{2}''", assignment.getDescription(), source.getTypename(), inputType.getTypename());
        source.getLocation().reportSemanticError(message);
    }
    if (outputType != null && !targetType.isIdentical(timestamp, outputType)) {
        final String message = MessageFormat.format("The output type of {0} must be the same as the target type of the mapping: `{1}'' was expected instead of `{2}''", assignment.getDescription(), targetType.getTypename(), outputType.getTypename());
        targetType.getLocation().reportSemanticError(message);
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Type(org.eclipse.titan.designer.AST.Type) EncodingPrototype_type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function.EncodingPrototype_type)

Example 19 with Type

use of org.eclipse.titan.designer.AST.Type in project titan.EclipsePlug-ins by eclipse.

the class Anytype_Type method analyzeExtensionAttributes.

/**
 * Convert and check the anytype attributes applied to the module of this type.
 *
 * @param timestamp
 *                the timestamp of the actual build cycle.
 */
private void analyzeExtensionAttributes(final CompilationTimeStamp timestamp) {
    clear();
    final TTCN3Module myModule = (TTCN3Module) getMyScope().getModuleScope();
    final WithAttributesPath moduleAttributePath = myModule.getAttributePath();
    if (moduleAttributePath == null) {
        return;
    }
    final List<SingleWithAttribute> realAttributes = moduleAttributePath.getRealAttributes(timestamp);
    SingleWithAttribute attribute;
    List<AttributeSpecification> specifications = null;
    for (int i = 0; i < realAttributes.size(); i++) {
        attribute = realAttributes.get(i);
        if (Attribute_Type.Extension_Attribute.equals(attribute.getAttributeType())) {
            final Qualifiers qualifiers = attribute.getQualifiers();
            if (qualifiers == null || qualifiers.getNofQualifiers() == 0) {
                if (specifications == null) {
                    specifications = new ArrayList<AttributeSpecification>();
                }
                specifications.add(attribute.getAttributeSpecification());
            }
        }
    }
    if (specifications == null) {
        return;
    }
    final List<ExtensionAttribute> attributes = new ArrayList<ExtensionAttribute>();
    AttributeSpecification specification;
    for (int i = 0; i < specifications.size(); i++) {
        specification = specifications.get(i);
        final ExtensionAttributeAnalyzer analyzer = new ExtensionAttributeAnalyzer();
        analyzer.parse(specification);
        final List<ExtensionAttribute> temp = analyzer.getAttributes();
        if (temp != null) {
            attributes.addAll(temp);
        }
    }
    final Scope definitionsScope = myModule.getDefinitions();
    ExtensionAttribute extensionAttribute;
    for (int i = 0; i < attributes.size(); i++) {
        extensionAttribute = attributes.get(i);
        if (ExtensionAttribute_type.ANYTYPE.equals(extensionAttribute.getAttributeType())) {
            final AnytypeAttribute anytypeAttribute = (AnytypeAttribute) extensionAttribute;
            for (int j = 0; j < anytypeAttribute.getNofTypes(); j++) {
                final Type tempType = anytypeAttribute.getType(j);
                String fieldName;
                Identifier identifier = null;
                if (Type_type.TYPE_REFERENCED.equals(tempType.getTypetype())) {
                    final Reference reference = ((Referenced_Type) tempType).getReference();
                    identifier = reference.getId();
                    fieldName = identifier.getTtcnName();
                } else {
                    fieldName = tempType.getTypename();
                    identifier = new Identifier(Identifier_type.ID_TTCN, fieldName);
                }
                tempType.setMyScope(definitionsScope);
                addComp(new CompField(identifier, tempType, false, null));
            }
        }
    }
}
Also used : WithAttributesPath(org.eclipse.titan.designer.AST.TTCN3.attributes.WithAttributesPath) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) ArrayList(java.util.ArrayList) SingleWithAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute) AnytypeAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.AnytypeAttribute) ExtensionAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.ExtensionAttribute) AttributeSpecification(org.eclipse.titan.designer.AST.TTCN3.attributes.AttributeSpecification) Attribute_Type(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute.Attribute_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) Scope(org.eclipse.titan.designer.AST.Scope) ExtensionAttributeAnalyzer(org.eclipse.titan.designer.parsers.extensionattributeparser.ExtensionAttributeAnalyzer) Qualifiers(org.eclipse.titan.designer.AST.TTCN3.attributes.Qualifiers)

Example 20 with Type

use of org.eclipse.titan.designer.AST.Type in project titan.EclipsePlug-ins by eclipse.

the class Anytype_Type method checkThisTemplate.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisTemplate(final CompilationTimeStamp timestamp, final ITTCN3Template template, final boolean isModified, final boolean implicitOmit, final Assignment lhs) {
    registerUsage(template);
    template.setMyGovernor(this);
    if (getIsErroneous(timestamp)) {
        return false;
    }
    boolean selfReference = false;
    if (Template_type.NAMED_TEMPLATE_LIST.equals(template.getTemplatetype())) {
        final Named_Template_List namedTemplateList = (Named_Template_List) template;
        final int nofTemplates = namedTemplateList.getNofTemplates();
        if (nofTemplates != 1) {
            template.getLocation().reportSemanticError(ONEFIELDEXPECTED);
        }
        for (int i = 0; i < nofTemplates; i++) {
            final NamedTemplate namedTemplate = namedTemplateList.getTemplateByIndex(i);
            final Identifier name = namedTemplate.getName();
            final CompField field = compFieldMap.getCompWithName(name);
            if (field != null) {
                final Type fieldType = field.getType();
                ITTCN3Template namedTemplateTemplate = namedTemplate.getTemplate();
                namedTemplateTemplate.setMyGovernor(fieldType);
                namedTemplateTemplate = fieldType.checkThisTemplateRef(timestamp, namedTemplateTemplate);
                final Completeness_type completeness = namedTemplateList.getCompletenessConditionChoice(timestamp, isModified, name);
                selfReference |= namedTemplateTemplate.checkThisTemplateGeneric(timestamp, fieldType, Completeness_type.MAY_INCOMPLETE.equals(completeness), false, false, true, implicitOmit, lhs);
            }
        }
    } else {
        template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName(), getTypename()));
    }
    if (template.getLengthRestriction() != null) {
        template.getLocation().reportSemanticError(MessageFormat.format(LENGTHRESTRICTIONNOTALLOWED, getTypename()));
    }
    return selfReference;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Completeness_type(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type) Attribute_Type(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute.Attribute_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) NamedTemplate(org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate) Named_Template_List(org.eclipse.titan.designer.AST.TTCN3.templates.Named_Template_List)

Aggregations

Type (org.eclipse.titan.designer.AST.Type)69 IType (org.eclipse.titan.designer.AST.IType)56 Identifier (org.eclipse.titan.designer.AST.Identifier)35 IValue (org.eclipse.titan.designer.AST.IValue)13 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)13 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)12 HashMap (java.util.HashMap)11 IASN1Type (org.eclipse.titan.designer.AST.ASN1.IASN1Type)11 ISubReference (org.eclipse.titan.designer.AST.ISubReference)10 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)9 NamedTemplate (org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate)9 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)8 Reference (org.eclipse.titan.designer.AST.Reference)8 SubType (org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType)8 Attribute_Type (org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute.Attribute_Type)7 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)6 ASN1_Set_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type)6 TTCN3_Choice_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type)6 TTCN3_Sequence_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type)6 NamedValue (org.eclipse.titan.designer.AST.TTCN3.values.NamedValue)6