Search in sources :

Example 1 with PrototypeAttribute

use of org.eclipse.titan.designer.AST.TTCN3.attributes.PrototypeAttribute in project titan.EclipsePlug-ins by eclipse.

the class Def_Extfunction method analyzeExtensionAttributes.

/**
 * Convert and check the encoding attributes applied to this external
 * function.
 *
 * @param timestamp
 *                the timestamp of the actual build cycle.
 */
public void analyzeExtensionAttributes(final CompilationTimeStamp timestamp) {
    final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp);
    SingleWithAttribute attribute;
    List<AttributeSpecification> specifications = null;
    for (int i = 0, size = realAttributes.size(); i < 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, size = specifications.size(); i < 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);
        }
    }
    ExtensionAttribute extensionAttribute;
    for (int i = 0, size = attributes.size(); i < size; i++) {
        extensionAttribute = attributes.get(i);
        switch(extensionAttribute.getAttributeType()) {
            case PROTOTYPE:
                if (EncodingPrototype_type.NONE.equals(prototype)) {
                    prototype = ((PrototypeAttribute) extensionAttribute).getPrototypeType();
                } else {
                    location.reportSemanticError("duplicate attribute `prototype'.");
                }
                break;
            case ENCODE:
                switch(functionEncodingType) {
                    case MANUAL:
                        break;
                    case ENCODE:
                        location.reportSemanticError("duplicate attribute `encode'.");
                        break;
                    case DECODE:
                        location.reportSemanticError("`decode' and `encode' attributes cannot be used at the same time.");
                        break;
                    default:
                        break;
                }
                encodingType = ((EncodeAttribute) extensionAttribute).getEncodingType();
                encodingOptions = ((EncodeAttribute) extensionAttribute).getOptions();
                functionEncodingType = ExternalFunctionEncodingType_type.ENCODE;
                break;
            case DECODE:
                switch(functionEncodingType) {
                    case MANUAL:
                        break;
                    case ENCODE:
                        location.reportSemanticError("`decode' and `encode' attributes cannot be used at the same time.");
                        break;
                    case DECODE:
                        location.reportSemanticError("duplicate attribute `decode'.");
                        break;
                    default:
                        break;
                }
                encodingType = ((DecodeAttribute) extensionAttribute).getEncodingType();
                encodingOptions = ((DecodeAttribute) extensionAttribute).getOptions();
                functionEncodingType = ExternalFunctionEncodingType_type.DECODE;
                break;
            case ERRORBEHAVIOR:
                if (errorBehaviorList == null) {
                    errorBehaviorList = ((ErrorBehaviorAttribute) extensionAttribute).getErrrorBehaviorList();
                } else {
                    errorBehaviorList.addAllBehaviors(((ErrorBehaviorAttribute) extensionAttribute).getErrrorBehaviorList());
                }
                break;
            case PRINTING:
                if (printingType == null) {
                    printingType = ((PrintingAttribute) extensionAttribute).getPrintingType();
                } else {
                    location.reportSemanticError("duplicate attribute `printing'.");
                }
                break;
            default:
                break;
        }
    }
}
Also used : AttributeSpecification(org.eclipse.titan.designer.AST.TTCN3.attributes.AttributeSpecification) ArrayList(java.util.ArrayList) SingleWithAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute) ExtensionAttributeAnalyzer(org.eclipse.titan.designer.parsers.extensionattributeparser.ExtensionAttributeAnalyzer) Qualifiers(org.eclipse.titan.designer.AST.TTCN3.attributes.Qualifiers) ExtensionAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.ExtensionAttribute)

Example 2 with PrototypeAttribute

use of org.eclipse.titan.designer.AST.TTCN3.attributes.PrototypeAttribute in project titan.EclipsePlug-ins by eclipse.

the class Def_Function method analyzeExtensionAttributes.

/**
 * Convert and check the encoding attributes applied to this function.
 *
 * @param timestamp
 *                the timestamp of the actual build cycle.
 */
public void analyzeExtensionAttributes(final CompilationTimeStamp timestamp) {
    final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp);
    SingleWithAttribute attribute;
    List<AttributeSpecification> specifications = null;
    for (int i = 0, size = realAttributes.size(); i < 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>();
    for (int i = 0, size = specifications.size(); i < size; i++) {
        final AttributeSpecification specification = specifications.get(i);
        final ExtensionAttributeAnalyzer analyzer = new ExtensionAttributeAnalyzer();
        analyzer.parse(specification);
        final List<ExtensionAttribute> temp = analyzer.getAttributes();
        if (temp != null) {
            attributes.addAll(temp);
        }
    }
    for (int i = 0, size = attributes.size(); i < size; i++) {
        final ExtensionAttribute extensionAttribute = attributes.get(i);
        if (ExtensionAttribute_type.PROTOTYPE.equals(extensionAttribute.getAttributeType())) {
            final PrototypeAttribute realAttribute = (PrototypeAttribute) extensionAttribute;
            if (EncodingPrototype_type.NONE.equals(prototype)) {
                prototype = realAttribute.getPrototypeType();
            } else {
                realAttribute.getLocation().reportSingularSemanticError("Duplicate attribute `prototype'");
            }
        }
    }
}
Also used : AttributeSpecification(org.eclipse.titan.designer.AST.TTCN3.attributes.AttributeSpecification) PrototypeAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.PrototypeAttribute) ArrayList(java.util.ArrayList) SingleWithAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute) ExtensionAttributeAnalyzer(org.eclipse.titan.designer.parsers.extensionattributeparser.ExtensionAttributeAnalyzer) Qualifiers(org.eclipse.titan.designer.AST.TTCN3.attributes.Qualifiers) ExtensionAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.ExtensionAttribute)

Aggregations

ArrayList (java.util.ArrayList)2 AttributeSpecification (org.eclipse.titan.designer.AST.TTCN3.attributes.AttributeSpecification)2 ExtensionAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.ExtensionAttribute)2 Qualifiers (org.eclipse.titan.designer.AST.TTCN3.attributes.Qualifiers)2 SingleWithAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute)2 ExtensionAttributeAnalyzer (org.eclipse.titan.designer.parsers.extensionattributeparser.ExtensionAttributeAnalyzer)2 PrototypeAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.PrototypeAttribute)1