Search in sources :

Example 11 with BridgingNamedNode

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

the class DecodeExpression method checkFirstExpressionOperand.

private void checkFirstExpressionOperand(final CompilationTimeStamp timestamp) {
    final Assignment temporalAssignment = reference1.getRefdAssignment(timestamp, true);
    if (temporalAssignment == null) {
        setIsErroneous(true);
        return;
    }
    switch(temporalAssignment.getAssignmentType()) {
        case A_CONST:
        case A_EXT_CONST:
        case A_MODULEPAR:
        case A_TEMPLATE:
            reference1.getLocation().reportSemanticError(MessageFormat.format("Reference to `{0}'' cannot be used as the first operand of the `decvalue'' operation", temporalAssignment.getAssignmentName()));
            setIsErroneous(true);
            break;
        case A_VAR:
        case A_PAR_VAL:
        case A_PAR_VAL_IN:
        case A_PAR_VAL_OUT:
        case A_PAR_VAL_INOUT:
            break;
        case A_VAR_TEMPLATE:
        case A_PAR_TEMP_IN:
        case A_PAR_TEMP_OUT:
        case A_PAR_TEMP_INOUT:
            {
                final Referenced_Template template = new Referenced_Template(reference1);
                template.setMyScope(getMyScope());
                template.setFullNameParent(new BridgingNamedNode(this, ".<operand>"));
                final ITTCN3Template last = template.getTemplateReferencedLast(timestamp);
                if (!Template_type.SPECIFIC_VALUE.equals(last.getTemplatetype()) && last != template) {
                    reference1.getLocation().reportSemanticError(MessageFormat.format("Specific value template was expected instead of `{0}''", last.getTemplateTypeName()));
                    setIsErroneous(true);
                    return;
                }
                break;
            }
        default:
            reference1.getLocation().reportSemanticError(MessageFormat.format("Reference to `{0}'' cannot be used as the first operand of the `decvalue' operation", temporalAssignment.getAssignmentName()));
            setIsErroneous(true);
            return;
    }
    final IType temporalType = temporalAssignment.getType(timestamp).getFieldType(timestamp, reference1, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
    if (temporalType == null) {
        setIsErroneous(true);
        return;
    }
    if (temporalType.getTypeRefdLast(timestamp).getTypetype() != Type_type.TYPE_BITSTRING) {
        if (!isErroneous) {
            reference1.getLocation().reportSemanticError(OPERANDERROR1);
            setIsErroneous(true);
        }
        return;
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Referenced_Template(org.eclipse.titan.designer.AST.TTCN3.templates.Referenced_Template) BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode) IType(org.eclipse.titan.designer.AST.IType)

Example 12 with BridgingNamedNode

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

the class SubType method addTtcnLength.

private boolean addTtcnLength(final CompilationTimeStamp timestamp, final LengthRestriction lengthRestriction, final int restrictionIndex) {
    lengthRestriction.setMyScope(myOwner.getMyScope());
    final BridgingNamedNode bridge = new BridgingNamedNode(myOwner, myOwner.getFullName() + ".<length_restriction_" + restrictionIndex + ">");
    lengthRestriction.setFullNameParent(bridge);
    lengthRestriction.check(timestamp, Expected_Value_type.EXPECTED_CONSTANT);
    IValue lower = null, upper = null;
    if (lengthRestriction instanceof SingleLenghtRestriction) {
        lower = ((SingleLenghtRestriction) lengthRestriction).getRestriction(timestamp);
        if (lower == null || lower.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(lower.getValuetype()) || lower.isUnfoldable(timestamp)) {
            return false;
        }
        if (!checkBoundaryValid(lower, "length restriction value")) {
            return false;
        }
        final SizeLimit boundaryLimit = new SizeLimit(((Integer_Value) lower).getValueValue());
        return setTtcnLength(boundaryLimit, boundaryLimit);
    }
    lower = ((RangeLenghtRestriction) lengthRestriction).getLowerValue(timestamp);
    if (lower == null || lower.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(lower.getValuetype()) || lower.isUnfoldable(timestamp)) {
        return false;
    }
    if (!checkBoundaryValid(lower, "lower boundary")) {
        return false;
    }
    upper = ((RangeLenghtRestriction) lengthRestriction).getUpperValue(timestamp);
    if (upper != null) {
        if (upper.getMyScope() == null) {
            upper.setMyScope(myOwner.getMyScope());
        }
        if (upper.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(upper.getValuetype()) || upper.isUnfoldable(timestamp)) {
            return false;
        }
        if (!checkBoundaryValid(upper, "upper boundary")) {
            return false;
        }
        return setTtcnLength(new SizeLimit(((Integer_Value) lower).getValueValue()), new SizeLimit(((Integer_Value) upper).getValueValue()));
    }
    // upper is infinity
    return setTtcnLength(new SizeLimit(((Integer_Value) lower).getValueValue()), SizeLimit.MAXIMUM);
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode) SingleLenghtRestriction(org.eclipse.titan.designer.AST.TTCN3.templates.SingleLenghtRestriction)

Example 13 with BridgingNamedNode

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

the class IsChoosenExpression method checkExpressionOperands.

/**
 * Checks the parameters of the expression and if they are valid in
 * their position in the expression or not.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param expectedValue
 *                the kind of value expected.
 * @param referenceChain
 *                a reference chain to detect cyclic references.
 */
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (lastTimeoperandsChecked != null && !lastTimeoperandsChecked.isLess(timestamp)) {
        return;
    }
    lastTimeoperandsChecked = timestamp;
    value = null;
    identifier = null;
    if (reference == null || reference.getSubreferences().size() < 2) {
        setIsErroneous(true);
        return;
    }
    final Reference tempReference = reference.newInstance();
    tempReference.setFullNameParent(this);
    tempReference.setMyScope(getMyScope());
    final ISubReference subreference = tempReference.removeLastSubReference();
    if (Subreference_type.fieldSubReference.equals(subreference.getReferenceType())) {
        identifier = ((FieldSubReference) subreference).getId();
    } else {
        setIsErroneous(true);
        return;
    }
    final Assignment assignment = tempReference.getRefdAssignment(timestamp, true);
    if (assignment == null) {
        setIsErroneous(true);
        return;
    }
    IType governor;
    switch(assignment.getAssignmentType()) {
        case A_CONST:
        case A_EXT_CONST:
        case A_MODULEPAR:
        case A_VAR:
        case A_PAR_VAL:
        case A_PAR_VAL_IN:
        case A_PAR_VAL_OUT:
        case A_PAR_VAL_INOUT:
            {
                value = new Referenced_Value(tempReference);
                value.setLocation(tempReference.getLocation());
                value.setMyScope(getMyScope());
                final BridgingNamedNode tempNamedNode = new BridgingNamedNode(this, OPERAND);
                value.setFullNameParent(tempNamedNode);
                governor = value.getExpressionGovernor(timestamp, expectedValue);
                if (governor == null) {
                    setIsErroneous(true);
                } else {
                    value.setMyGovernor(governor);
                    final IValue tempValue2 = governor.checkThisValueRef(timestamp, value);
                    if (tempValue2.getIsErroneous(timestamp)) {
                        setIsErroneous(true);
                    }
                }
                break;
            }
        case A_TEMPLATE:
        case A_VAR_TEMPLATE:
        case A_PAR_TEMP_IN:
        case A_PAR_TEMP_OUT:
        case A_PAR_TEMP_INOUT:
            {
                template = new Referenced_Template(tempReference);
                template.setLocation(tempReference.getLocation());
                template.setMyScope(getMyScope());
                final BridgingNamedNode tempNamedNode = new BridgingNamedNode(this, OPERAND);
                template.setFullNameParent(tempNamedNode);
                if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) || Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
                    governor = template.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
                } else {
                    governor = template.getExpressionGovernor(timestamp, expectedValue);
                }
                if (governor == null) {
                    setIsErroneous(true);
                } else {
                    template.setMyGovernor(governor);
                    final TTCN3Template last = template.getTemplateReferencedLast(timestamp, referenceChain);
                    if (last.getIsErroneous(timestamp)) {
                        setIsErroneous(true);
                    }
                }
                if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue) && !Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
                    if (Expected_Value_type.EXPECTED_CONSTANT.equals(expectedValue)) {
                        template.getLocation().reportSemanticError(MessageFormat.format(CONSTANTREFERENCEEXPECTED, assignment.getDescription()));
                    } else {
                        template.getLocation().reportSemanticError(MessageFormat.format(STATICREFERENCEEXPECTED, assignment.getDescription()));
                    }
                    setIsErroneous(true);
                }
                break;
            }
        default:
            tempReference.getLocation().reportSemanticError(MessageFormat.format(VALUETEMPLATEEXPECTED, assignment.getDescription()));
            setIsErroneous(true);
            return;
    }
    if (governor != null) {
        governor = governor.getTypeRefdLast(timestamp);
        if (!governor.getIsErroneous(timestamp)) {
            CompField field = null;
            switch(governor.getTypetype()) {
                case TYPE_ASN1_CHOICE:
                    if (((ASN1_Choice_Type) governor).hasComponentWithName(identifier)) {
                        field = ((ASN1_Choice_Type) governor).getComponentByName(identifier);
                    }
                    break;
                case TYPE_TTCN3_CHOICE:
                    if (((TTCN3_Choice_Type) governor).hasComponentWithName(identifier.getName())) {
                        field = ((TTCN3_Choice_Type) governor).getComponentByName(identifier.getName());
                    }
                    break;
                case TYPE_OPENTYPE:
                    if (((Open_Type) governor).hasComponentWithName(identifier)) {
                        field = ((Open_Type) governor).getComponentByName(identifier);
                    }
                    break;
                case TYPE_ANYTYPE:
                    if (((Anytype_Type) governor).hasComponentWithName(identifier.getName())) {
                        field = ((Anytype_Type) governor).getComponentByName(identifier.getName());
                    }
                    break;
                default:
                    location.reportSemanticError(MessageFormat.format(OPERANDERROR, governor.getTypename()));
                    setIsErroneous(true);
                    return;
            }
            if (null == field) {
                location.reportSemanticError(MessageFormat.format(MISSINGFIELD, governor.getTypename(), identifier.getDisplayName()));
                setIsErroneous(true);
            }
        }
    }
}
Also used : Open_Type(org.eclipse.titan.designer.AST.ASN1.types.Open_Type) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value) BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode) IType(org.eclipse.titan.designer.AST.IType) Anytype_Type(org.eclipse.titan.designer.AST.TTCN3.types.Anytype_Type) Assignment(org.eclipse.titan.designer.AST.Assignment) ASN1_Choice_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type) ISubReference(org.eclipse.titan.designer.AST.ISubReference) IValue(org.eclipse.titan.designer.AST.IValue) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Referenced_Template(org.eclipse.titan.designer.AST.TTCN3.templates.Referenced_Template) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template) TTCN3_Choice_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type)

Example 14 with BridgingNamedNode

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

the class PortTypeBody method addUserAttribute.

/**
 * Marks that this port type body belongs to a user port.
 * Also sets all mappings using the provided data.
 *
 * @param providerReference the reference pointing to the provider port
 * @param inMappings the incoming mappings.
 * @param outMappings the outgoing mappings.
 */
public void addUserAttribute(final Reference providerReference, final TypeMappings inMappings, final TypeMappings outMappings) {
    portType = PortType_type.PT_USER;
    this.providerReference = providerReference;
    this.providerReference.setFullNameParent(new BridgingNamedNode(this, ".<provider_ref>"));
    this.providerReference.setMyScope(myType.getMyScope());
    providerType = null;
    this.inMappings = inMappings;
    if (inMappings != null) {
        this.inMappings.setFullNameParent(new BridgingNamedNode(this, ".<inMappings>"));
        this.inMappings.setMyScope(myType.getMyScope());
    }
    this.outMappings = outMappings;
    if (outMappings != null) {
        this.outMappings.setFullNameParent(new BridgingNamedNode(this, ".<outMappings>"));
        this.outMappings.setMyScope(myType.getMyScope());
    }
}
Also used : BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode)

Example 15 with BridgingNamedNode

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

the class ComponentTypeBody method collectExtensionAttributes.

/**
 * Collects the extends extension attributes, from the with attributes assigned to the component type.
 *
 * @param timestamp the timestamp of the actual semantic check cycle
 */
private void collectExtensionAttributes(final CompilationTimeStamp timestamp) {
    if (withAttributesPath == null) {
        return;
    }
    final List<SingleWithAttribute> realAttributes = withAttributesPath.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);
        }
    }
    if (attributes.isEmpty()) {
        return;
    }
    attrExtendsReferences = new ComponentTypeReferenceList();
    for (int i = 0, size = attributes.size(); i < size; i++) {
        final ExtensionAttribute tempAttribute = attributes.get(i);
        if (ExtensionAttribute_type.EXTENDS.equals(tempAttribute.getAttributeType())) {
            final ExtensionsAttribute extensionsAttribute = (ExtensionsAttribute) tempAttribute;
            for (int j = 0, size2 = extensionsAttribute.getNofTypes(); j < size2; j++) {
                final IType tempType = extensionsAttribute.getType(j);
                if (Type_type.TYPE_REFERENCED.equals(tempType.getTypetype())) {
                    attrExtendsReferences.addReference(((Referenced_Type) tempType).getReference());
                }
            }
        }
    }
    attrExtendsReferences.setFullNameParent(new BridgingNamedNode(this, ".<extends attribute>"));
    attrExtendsReferences.setMyScope(parentScope);
}
Also used : ArrayList(java.util.ArrayList) SingleWithAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute) BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode) ExtensionAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.ExtensionAttribute) IType(org.eclipse.titan.designer.AST.IType) AttributeSpecification(org.eclipse.titan.designer.AST.TTCN3.attributes.AttributeSpecification) ExtensionsAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.ExtensionsAttribute) ExtensionAttributeAnalyzer(org.eclipse.titan.designer.parsers.extensionattributeparser.ExtensionAttributeAnalyzer) Qualifiers(org.eclipse.titan.designer.AST.TTCN3.attributes.Qualifiers)

Aggregations

BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)15 IType (org.eclipse.titan.designer.AST.IType)13 IValue (org.eclipse.titan.designer.AST.IValue)10 ISubReference (org.eclipse.titan.designer.AST.ISubReference)8 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)8 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)7 Identifier (org.eclipse.titan.designer.AST.Identifier)7 Value (org.eclipse.titan.designer.AST.Value)6 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)4 Assignment (org.eclipse.titan.designer.AST.Assignment)4 ASN1_Set_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type)3 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)3 Referenced_Template (org.eclipse.titan.designer.AST.TTCN3.templates.Referenced_Template)3 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)2 Open_Type (org.eclipse.titan.designer.AST.ASN1.types.Open_Type)2 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)2 Reference (org.eclipse.titan.designer.AST.Reference)2 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)2 TTCN3_Choice_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type)2 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)2