Search in sources :

Example 16 with ArraySubReference

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

the class GeneralizedTime_Type method getFieldType.

@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:
            if (subreferences.size() > actualSubReference + 1) {
                subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
                return null;
            } else if (subreferences.size() == actualSubReference + 1) {
                reference.setStringElementReferencing();
            }
            final Value indexValue = ((ArraySubReference) subreference).getValue();
            checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
            return this;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        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) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Example 17 with ArraySubReference

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

the class BitString_Type method getFieldType.

@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:
            if (subreferences.size() > actualSubReference + 1) {
                subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
                return null;
            } else if (subreferences.size() == actualSubReference + 1) {
                reference.setStringElementReferencing();
            }
            final Value indexValue = ((ArraySubReference) subreference).getValue();
            checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
            return this;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        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) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Example 18 with ArraySubReference

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

the class CharString_Type method getFieldType.

@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:
            if (subreferences.size() > actualSubReference + 1) {
                subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
                return null;
            } else if (subreferences.size() == actualSubReference + 1) {
                reference.setStringElementReferencing();
            }
            final Value indexValue = ((ArraySubReference) subreference).getValue();
            checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
            return this;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        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) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Example 19 with ArraySubReference

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

the class ASN1_Set_Seq_Choice_BaseType method resolveReference.

@Override
public /**
 * {@inheritDoc}
 */
Declaration resolveReference(final Reference reference, final int subRefIdx, final ISubReference lastSubreference) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    int actualIndex = subRefIdx;
    while (actualIndex < subreferences.size() && subreferences.get(actualIndex) instanceof ArraySubReference) {
        ++actualIndex;
    }
    if (actualIndex == subreferences.size()) {
        return null;
    }
    final Identifier fieldID = subreferences.get(actualIndex).getId();
    if (subreferences.get(actualIndex) == lastSubreference) {
        return Declaration.createInstance(getDefiningAssignment(), fieldID);
    }
    final CompField compField = getComponentByName(fieldID);
    final IType compFieldType = compField.getType().getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
    if (compFieldType instanceof IReferenceableElement) {
        final Declaration decl = ((IReferenceableElement) compFieldType).resolveReference(reference, actualIndex + 1, lastSubreference);
        return decl != null ? decl : Declaration.createInstance(getDefiningAssignment(), compField.getIdentifier());
    }
    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) Declaration(org.eclipse.titan.designer.declarationsearch.Declaration) IReferenceableElement(org.eclipse.titan.designer.AST.IReferenceableElement) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference) IType(org.eclipse.titan.designer.AST.IType)

Example 20 with ArraySubReference

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

the class BMPString_Type method getFieldType.

@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:
            if (subreferences.size() > actualSubReference + 1) {
                subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
                return null;
            } else if (subreferences.size() == actualSubReference + 1) {
                reference.setStringElementReferencing();
            }
            final Value indexValue = ((ArraySubReference) subreference).getValue();
            checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
            return this;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        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) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Aggregations

ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)47 ISubReference (org.eclipse.titan.designer.AST.ISubReference)46 IValue (org.eclipse.titan.designer.AST.IValue)42 Value (org.eclipse.titan.designer.AST.Value)39 IType (org.eclipse.titan.designer.AST.IType)19 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)11 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)11 Identifier (org.eclipse.titan.designer.AST.Identifier)5 SetOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)4 Assignment (org.eclipse.titan.designer.AST.Assignment)3 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)3 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)3 SequenceOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value)3 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)3 BigInteger (java.math.BigInteger)2 IReferenceableElement (org.eclipse.titan.designer.AST.IReferenceableElement)2 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)2 Reference (org.eclipse.titan.designer.AST.Reference)2 Array_Value (org.eclipse.titan.designer.AST.TTCN3.values.Array_Value)2 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)2