Search in sources :

Example 96 with Identifier

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

the class ASN1_Set_Type method getFieldType.

// This is the same as in ASN1_Sequence_Type
@Override
public /**
 * {@inheritDoc}
 */
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
        return this;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDSUBREFERENCE, getTypename()));
            return null;
        case fieldSubReference:
            final Identifier id = subreference.getId();
            final CompField compField = components.getCompByName(id);
            if (compField == null) {
                subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.NONEXISTENTSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
                return null;
            }
            if (interruptIfOptional && compField.isOptional()) {
                return null;
            }
            final Expected_Value_type internalExpectation = (expectedIndex == Expected_Value_type.EXPECTED_TEMPLATE) ? Expected_Value_type.EXPECTED_DYNAMIC_VALUE : expectedIndex;
            return compField.getType().getFieldType(timestamp, reference, actualSubReference + 1, internalExpectation, refChain, interruptIfOptional);
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            return null;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Expected_Value_type(org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)

Example 97 with Identifier

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

the class Open_Type method checkThisValueChoice.

private boolean checkThisValueChoice(final CompilationTimeStamp timestamp, final Choice_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean strElem) {
    boolean selfReference = false;
    final Identifier name = value.getName();
    final CompField field = getComponentByName(name);
    if (field == null) {
        if (value.isAsn()) {
            value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTCHOICE, name.getDisplayName(), getFullName()));
        } else {
            value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTUNION, name.getDisplayName(), getFullName()));
        }
    } else {
        IValue alternativeValue = value.getValue();
        if (null == alternativeValue) {
            return selfReference;
        }
        final Type alternativeType = field.getType();
        alternativeValue.setMyGovernor(alternativeType);
        alternativeValue = alternativeType.checkThisValueRef(timestamp, alternativeValue);
        selfReference = alternativeType.checkThisValue(timestamp, alternativeValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, false, true, false, strElem));
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : 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) IValue(org.eclipse.titan.designer.AST.IValue) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField)

Example 98 with Identifier

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

the class Embedded_PDV_Type method getTypeRefd.

@Override
public /**
 * {@inheritDoc}
 */
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    if (null == myScope) {
        setIsErroneous(true);
        return this;
    }
    final Identifier identifier = new Identifier(Identifier_type.ID_ASN, EMBEDDED_PDV);
    final Assignments assignments = myScope.getAssignmentsScope();
    if (!assignments.hasAssignmentWithId(timestamp, identifier)) {
        setIsErroneous(true);
        return this;
    }
    final Assignment assignment = assignments.getLocalAssignmentByID(timestamp, identifier);
    if (null == assignment || null == assignment.getType(timestamp)) {
        setIsErroneous(true);
        return this;
    }
    return assignment.getType(timestamp);
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Identifier(org.eclipse.titan.designer.AST.Identifier) Assignments(org.eclipse.titan.designer.AST.Assignments)

Example 99 with Identifier

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

the class External_Type method getTypeRefd.

@Override
public /**
 * {@inheritDoc}
 */
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    if (null == myScope) {
        setIsErroneous(true);
        return this;
    }
    final Identifier identifier = new Identifier(Identifier_type.ID_ASN, "EXTERNAL");
    final Assignments assignments = myScope.getAssignmentsScope();
    if (!assignments.hasAssignmentWithId(timestamp, identifier)) {
        setIsErroneous(true);
        return this;
    }
    final Assignment assignment = assignments.getLocalAssignmentByID(timestamp, identifier);
    if (null == assignment || null == assignment.getType(timestamp)) {
        setIsErroneous(true);
        return this;
    }
    return assignment.getType(timestamp);
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Identifier(org.eclipse.titan.designer.AST.Identifier) Assignments(org.eclipse.titan.designer.AST.Assignments)

Example 100 with Identifier

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

the class Sequence_Value method checkEquality.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
    if (convertedValue != null && convertedValue != this) {
        return convertedValue.checkEquality(timestamp, other);
    }
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue last = other.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    if (!Value_type.SEQUENCE_VALUE.equals(last.getValuetype())) {
        return false;
    }
    if (myGovernor == null) {
        return false;
    }
    final Sequence_Value otherSequence = (Sequence_Value) last;
    if (values.getSize() != otherSequence.values.getSize()) {
        return false;
    }
    int nofComps = 0;
    final IType leftGovernor = myGovernor.getTypeRefdLast(timestamp);
    switch(leftGovernor.getTypetype()) {
        case TYPE_TTCN3_SEQUENCE:
            nofComps = ((TTCN3_Sequence_Type) leftGovernor).getNofComponents();
            break;
        case TYPE_ASN1_SEQUENCE:
            nofComps = ((ASN1_Sequence_Type) leftGovernor).getNofComponents(timestamp);
            break;
        default:
            return false;
    }
    CompField compField = null;
    for (int i = 0; i < nofComps; i++) {
        switch(leftGovernor.getTypetype()) {
            case TYPE_TTCN3_SEQUENCE:
                compField = ((TTCN3_Sequence_Type) leftGovernor).getComponentByIndex(i);
                break;
            case TYPE_ASN1_SEQUENCE:
                compField = ((ASN1_Sequence_Type) leftGovernor).getComponentByIndex(i);
                break;
            default:
                return false;
        }
        final Identifier fieldName = compField.getIdentifier();
        if (hasComponentWithName(fieldName)) {
            final IValue leftValue = getComponentByName(fieldName).getValue();
            if (otherSequence.hasComponentWithName(fieldName)) {
                final IValue otherValue = otherSequence.getComponentByName(fieldName).getValue();
                if ((Value_type.OMIT_VALUE.equals(leftValue.getValuetype()) && !Value_type.OMIT_VALUE.equals(otherValue.getValuetype())) || (!Value_type.OMIT_VALUE.equals(leftValue.getValuetype()) && Value_type.OMIT_VALUE.equals(otherValue.getValuetype()))) {
                    return false;
                }
                if (!leftValue.checkEquality(timestamp, otherValue)) {
                    return false;
                }
            } else {
                if (compField.hasDefault()) {
                    if (!leftValue.checkEquality(timestamp, compField.getDefault())) {
                        return false;
                    }
                } else {
                    if (!Value_type.OMIT_VALUE.equals(leftValue.getValuetype())) {
                        return false;
                    }
                }
            }
        } else {
            if (otherSequence.hasComponentWithName(fieldName)) {
                final IValue otherValue = otherSequence.getComponentByName(fieldName).getValue();
                if (compField.hasDefault()) {
                    if (Value_type.OMIT_VALUE.equals(otherValue.getValuetype())) {
                        return false;
                    }
                    if (!compField.getDefault().checkEquality(timestamp, otherValue)) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Identifier(org.eclipse.titan.designer.AST.Identifier) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

Identifier (org.eclipse.titan.designer.AST.Identifier)176 IType (org.eclipse.titan.designer.AST.IType)75 ISubReference (org.eclipse.titan.designer.AST.ISubReference)57 IValue (org.eclipse.titan.designer.AST.IValue)39 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)38 Type (org.eclipse.titan.designer.AST.Type)35 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)33 Assignment (org.eclipse.titan.designer.AST.Assignment)25 ArrayList (java.util.ArrayList)24 Location (org.eclipse.titan.designer.AST.Location)24 Reference (org.eclipse.titan.designer.AST.Reference)22 Module (org.eclipse.titan.designer.AST.Module)21 HashMap (java.util.HashMap)16 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)15 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)12 Value (org.eclipse.titan.designer.AST.Value)12 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)11 IASN1Type (org.eclipse.titan.designer.AST.ASN1.IASN1Type)10 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)10 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)10