Search in sources :

Example 16 with ISubReference

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

the class Charstring_Value method getReferencedSubValue.

@Override
public /**
 * {@inheritDoc}
 */
IValue getReferencedSubValue(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final IReferenceChain refChain) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return this;
    }
    final IType type = myGovernor.getTypeRefdLast(timestamp);
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            {
                final Value arrayIndex = ((ArraySubReference) subreference).getValue();
                final IValue valueIndex = arrayIndex.getValueRefdLast(timestamp, refChain);
                if (!valueIndex.isUnfoldable(timestamp)) {
                    if (Value_type.INTEGER_VALUE.equals(valueIndex.getValuetype())) {
                        final int index = ((Integer_Value) valueIndex).intValue();
                        return getStringElement(index, arrayIndex.getLocation());
                    }
                    arrayIndex.getLocation().reportSemanticError(ArraySubReference.INTEGERINDEXEXPECTED);
                    return null;
                }
                return null;
            }
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), type.getTypename()));
            return null;
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(ParameterisedSubReference.INVALIDVALUESUBREFERENCE);
            return null;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            return null;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) IValue(org.eclipse.titan.designer.AST.IValue) Value(org.eclipse.titan.designer.AST.Value) ISO2022String_Value(org.eclipse.titan.designer.AST.ASN1.values.ISO2022String_Value) IValue(org.eclipse.titan.designer.AST.IValue) IType(org.eclipse.titan.designer.AST.IType)

Example 17 with ISubReference

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

the class Choice_Value method getReferencedSubValue.

@Override
public /**
 * {@inheritDoc}
 */
IValue getReferencedSubValue(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final IReferenceChain refChain) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return this;
    }
    final IType type = myGovernor.getTypeRefdLast(timestamp);
    if (type.getIsErroneous(timestamp)) {
        return null;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDVALUESUBREFERENCE, type.getTypename()));
            return null;
        case fieldSubReference:
            final Identifier fieldId = ((FieldSubReference) subreference).getId();
            switch(type.getTypetype()) {
                case TYPE_TTCN3_CHOICE:
                    if (!((TTCN3_Choice_Type) type).hasComponentWithName(fieldId.getName())) {
                        subreference.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTFIELD, fieldId.getDisplayName(), type.getTypename()));
                        return null;
                    }
                    break;
                case TYPE_ASN1_CHOICE:
                    if (!((ASN1_Choice_Type) type).hasComponentWithName(fieldId)) {
                        subreference.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTFIELD, fieldId.getDisplayName(), type.getTypename()));
                        return null;
                    }
                    break;
                case TYPE_OPENTYPE:
                    if (!((Open_Type) type).hasComponentWithName(fieldId)) {
                        subreference.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTFIELD, fieldId.getDisplayName(), type.getTypename()));
                        return null;
                    }
                    break;
                default:
                    return null;
            }
            if (name.getDisplayName().equals(fieldId.getDisplayName())) {
                return value.getReferencedSubValue(timestamp, reference, actualSubReference + 1, refChain);
            }
            if (!reference.getUsedInIsbound()) {
                subreference.getLocation().reportSemanticError(MessageFormat.format(INACTIVEFIELD, fieldId.getDisplayName(), type.getTypename(), name.getDisplayName()));
            }
            return null;
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(ParameterisedSubReference.INVALIDVALUESUBREFERENCE);
            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) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) IType(org.eclipse.titan.designer.AST.IType)

Example 18 with ISubReference

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

the class Choice_Value method evaluateIspresent.

@Override
public /**
 * {@inheritDoc}
 */
boolean evaluateIspresent(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return true;
    }
    final IType type = myGovernor.getTypeRefdLast(timestamp);
    if (type.getIsErroneous(timestamp)) {
        return false;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            return false;
        case fieldSubReference:
            final Identifier fieldId = ((FieldSubReference) subreference).getId();
            switch(type.getTypetype()) {
                case TYPE_TTCN3_CHOICE:
                    if (!((TTCN3_Choice_Type) type).hasComponentWithName(fieldId.getName())) {
                        return false;
                    }
                    break;
                case TYPE_ASN1_CHOICE:
                    if (!((ASN1_Choice_Type) type).hasComponentWithName(fieldId)) {
                        return false;
                    }
                    break;
                case TYPE_OPENTYPE:
                    if (!((Open_Type) type).hasComponentWithName(fieldId)) {
                        return false;
                    }
                    break;
                default:
                    return false;
            }
            if (name.getDisplayName().equals(fieldId.getDisplayName())) {
                return value.evaluateIspresent(timestamp, reference, actualSubReference + 1);
            }
            return false;
        case parameterisedSubReference:
            return false;
        default:
            return false;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) IType(org.eclipse.titan.designer.AST.IType)

Example 19 with ISubReference

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

the class Expression_Value method getReferencedSubValue.

@Override
public final /**
 * {@inheritDoc}
 */
IValue getReferencedSubValue(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final IReferenceChain refChain) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return this;
    }
    IValue result = getValueRefdLast(timestamp, refChain);
    if (result != null && result != this) {
        result = result.getReferencedSubValue(timestamp, reference, actualSubReference, refChain);
        if (result != null && result.getIsErroneous(timestamp)) {
            setIsErroneous(true);
        }
    }
    return this;
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) IValue(org.eclipse.titan.designer.AST.IValue)

Example 20 with ISubReference

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

the class Set_Value method evaluateIspresent.

@Override
public /**
 * {@inheritDoc}
 */
boolean evaluateIspresent(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return true;
    }
    final IType type = myGovernor.getTypeRefdLast(timestamp);
    if (type.getIsErroneous(timestamp)) {
        return false;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            return false;
        case fieldSubReference:
            final Identifier fieldId = ((FieldSubReference) subreference).getId();
            switch(type.getTypetype()) {
                case TYPE_TTCN3_SET:
                    if (!((TTCN3_Set_Type) type).hasComponentWithName(fieldId.getName())) {
                        return false;
                    }
                    break;
                case TYPE_ASN1_SET:
                    if (!((ASN1_Set_Type) type).hasComponentWithName(fieldId)) {
                        return false;
                    }
                    break;
                default:
                    return false;
            }
            if (values.hasNamedValueWithName(fieldId)) {
                // we can move on with the check
                return values.getNamedValueByName(fieldId).getValue().evaluateIspresent(timestamp, reference, actualSubReference + 1);
            }
            if (Type_type.TYPE_TTCN3_SET.equals(type.getTypetype())) {
                return false;
            }
            final CompField compField = ((ASN1_Set_Type) type).getComponentByName(fieldId);
            if (compField.isOptional()) {
                // create an explicit omit value
                final Value result = new Omit_Value();
                final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
                result.setFullNameParent(bridge);
                result.setMyScope(getMyScope());
                return result.evaluateIspresent(timestamp, reference, actualSubReference + 1);
            } else if (compField.hasDefault()) {
                return compField.getDefault().evaluateIspresent(timestamp, reference, actualSubReference + 1);
            }
            return false;
        case parameterisedSubReference:
            return false;
        default:
            return false;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ASN1_Set_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type) BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

ISubReference (org.eclipse.titan.designer.AST.ISubReference)205 IType (org.eclipse.titan.designer.AST.IType)80 IValue (org.eclipse.titan.designer.AST.IValue)63 Identifier (org.eclipse.titan.designer.AST.Identifier)53 Value (org.eclipse.titan.designer.AST.Value)47 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)46 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)40 Assignment (org.eclipse.titan.designer.AST.Assignment)28 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)25 Reference (org.eclipse.titan.designer.AST.Reference)18 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)15 ArrayList (java.util.ArrayList)14 Template (org.eclipse.jface.text.templates.Template)11 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)11 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)11 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)10 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)8 Module (org.eclipse.titan.designer.AST.Module)8 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)7 ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)6