Search in sources :

Example 26 with IType

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

the class Notused_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:
            subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDVALUESUBREFERENCE, type.getTypename()));
            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) IType(org.eclipse.titan.designer.AST.IType)

Example 27 with IType

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

the class ObjectIdentifierComponent method checkDefdValueOID.

/**
 * Checks the defined value form in an OID component.
 *
 * @param timestamp the timestamp of the actual compilation cycle.
 * @param refChain the reference chain used to detect cyclic references.
 * @param state the state of checking.
 *
 * @param the new state after this check was done.
 */
private oidState_type checkDefdValueOID(final CompilationTimeStamp timestamp, final IReferenceChain refChain, final oidState_type state) {
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue value = definedValue.getValueRefdLast(timestamp, referenceChain);
    referenceChain.release();
    if (value.getIsErroneous(timestamp)) {
        return oidState_type.LATER;
    }
    switch(value.getValuetype()) {
        case INTEGER_VALUE:
            final ObjectIdentifierComponent temp = new ObjectIdentifierComponent(null, definedValue);
            temp.setFullNameParent(this);
            temp.setMyScope(myScope);
            return temp.checkNumberFormOID(timestamp, state);
        case OBJECTID_VALUE:
            if (!oidState_type.START.equals(state)) {
                definedValue.getLocation().reportSemanticError("INTEGER or RELATIVE-OID value was expected");
            }
            ((ObjectIdentifier_Value) value).checkOID(timestamp, refChain);
            return oidState_type.LATER;
        case RELATIVEOBJECTIDENTIFIER_VALUE:
            switch(state) {
                case ITU_REC:
                    return oidState_type.LATER;
                case LATER:
                    return oidState_type.LATER;
                default:
                    definedValue.getLocation().reportSemanticError(MessageFormat.format("RELATIVE-OID value cannot be used as the {0} component of an OBJECTIDENTIFIER value", oidState_type.START.equals(state) ? "first" : "second"));
                    return oidState_type.LATER;
            }
        case REFERENCED_VALUE:
            {
                final Reference reference = ((Referenced_Value) value).getReference();
                final Assignment assignment = reference.getRefdAssignment(timestamp, false);
                final IType type = assignment.getType(timestamp).getTypeRefdLast(timestamp);
                if (type.getTypetype() == Type_type.TYPE_INTEGER) {
                // FIXME implement handling of the variable form
                } else {
                    definedValue.getLocation().reportSemanticError("INTEGER variable was expected");
                }
                return oidState_type.LATER;
            }
        default:
            if (oidState_type.START.equals(state)) {
                definedValue.getLocation().reportSemanticError("INTEGER or OBJECT IDENTIFIER value was expected for the first component");
            } else {
                definedValue.getLocation().reportSemanticError("INTEGER or RELATIVE-OID value was expected");
            }
            return oidState_type.LATER;
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) Defined_Reference(org.eclipse.titan.designer.AST.ASN1.Defined_Reference) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) RelativeObjectIdentifier_Value(org.eclipse.titan.designer.AST.ASN1.values.RelativeObjectIdentifier_Value) IType(org.eclipse.titan.designer.AST.IType)

Example 28 with IType

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

the class ObjectIdentifier_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:
            subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDVALUESUBREFERENCE, type.getTypename()));
            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) IType(org.eclipse.titan.designer.AST.IType)

Example 29 with IType

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

the class Array_Value method evaluateIsbound.

@Override
public /**
 * {@inheritDoc}
 */
boolean evaluateIsbound(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) || !Type_type.TYPE_ARRAY.equals(type.getTypetype())) {
        return false;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            final Value arrayIndex = ((ArraySubReference) subreference).getValue();
            IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
            final IValue valueIndex = arrayIndex.getValueRefdLast(timestamp, referenceChain);
            referenceChain.release();
            if (valueIndex.isUnfoldable(timestamp)) {
                return false;
            }
            if (Value_type.INTEGER_VALUE.equals(valueIndex.getValuetype())) {
                final int index = ((Integer_Value) valueIndex).intValue();
                if (isIndexed()) {
                    for (int i = 0; i < values.getNofIndexedValues(); i++) {
                        IValue indexedValue = values.getIndexedValueByIndex(i).getIndex().getValue();
                        referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                        indexedValue = indexedValue.getValueRefdLast(timestamp, referenceChain);
                        referenceChain.release();
                        if (Value_type.INTEGER_VALUE.equals(indexedValue.getValuetype()) && ((Integer_Value) indexedValue).intValue() == index) {
                            return values.getIndexedValueByIndex(i).getValue().evaluateIsbound(timestamp, reference, actualSubReference + 1);
                        }
                    }
                    arrayIndex.getLocation().reportSemanticError(MessageFormat.format(NOINDEX, index, values.getFullName()));
                } else if (index < 0 || index >= values.getNofValues()) {
                // the error was already reported
                } else {
                    return values.getValueByIndex(index).evaluateIsbound(timestamp, reference, actualSubReference + 1);
                }
                return false;
            }
            return false;
        case fieldSubReference:
            return false;
        case parameterisedSubReference:
            return false;
        default:
            return false;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) IType(org.eclipse.titan.designer.AST.IType) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Example 30 with IType

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

the class Array_Value method setGenNameRecursive.

@Override
public /**
 * {@inheritDoc}
 */
void setGenNameRecursive(final String parameterGenName) {
    super.setGenNameRecursive(parameterGenName);
    IType governor = myGovernor;
    if (governor == null) {
        governor = getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
    }
    if (governor == null) {
        governor = myLastSetGovernor;
    }
    if (governor == null) {
        return;
    }
    final IType type = governor.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
    if (!Type_type.TYPE_ARRAY.equals(type.getTypetype())) {
        return;
    }
    final long offset = ((Array_Type) type).getDimension().getOffset();
    if (isIndexed()) {
        for (int i = 0; i < values.getNofIndexedValues(); i++) {
            final StringBuilder embeddedName = new StringBuilder(parameterGenName);
            embeddedName.append(".getAt(").append(offset + i).append(')');
            values.getIndexedValueByIndex(i).getValue().setGenNameRecursive(embeddedName.toString());
        }
    } else {
        for (int i = 0; i < values.getNofValues(); i++) {
            final StringBuilder embeddedName = new StringBuilder(parameterGenName);
            embeddedName.append(".getAt(").append(offset + i).append(')');
            values.getValueByIndex(i).setGenNameRecursive(embeddedName.toString());
        }
    }
}
Also used : IType(org.eclipse.titan.designer.AST.IType)

Aggregations

IType (org.eclipse.titan.designer.AST.IType)414 IValue (org.eclipse.titan.designer.AST.IValue)94 ISubReference (org.eclipse.titan.designer.AST.ISubReference)82 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)65 Identifier (org.eclipse.titan.designer.AST.Identifier)49 Assignment (org.eclipse.titan.designer.AST.Assignment)40 Value (org.eclipse.titan.designer.AST.Value)34 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)33 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)27 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)21 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)21 Reference (org.eclipse.titan.designer.AST.Reference)21 Type (org.eclipse.titan.designer.AST.Type)20 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)18 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)17 ArrayList (java.util.ArrayList)16 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)15 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)14 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)14 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)13