Search in sources :

Example 56 with CompField

use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.

the class Open_Type method checkRecursions.

@Override
public /**
 * {@inheritDoc}
 */
void checkRecursions(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    final Map<String, CompField> map = compFieldMap.getComponentFieldMap(timestamp);
    if (referenceChain.add(this) && 1 == map.size()) {
        for (CompField compField : map.values()) {
            final IType type = compField.getType();
            if (null != type) {
                referenceChain.markState();
                type.checkRecursions(timestamp, referenceChain);
                referenceChain.previousState();
            }
        }
    }
}
Also used : CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) IType(org.eclipse.titan.designer.AST.IType)

Example 57 with CompField

use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.

the class Open_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String genName = getGenNameOwn();
    final String displayName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final List<FieldInfo> fieldInfos = new ArrayList<FieldInfo>();
    boolean hasOptional = false;
    final Map<String, CompField> map = compFieldMap.getComponentFieldMap(CompilationTimeStamp.getBaseTimestamp());
    for (final CompField compField : map.values()) {
        final IType cfType = compField.getType();
        final FieldInfo fi = new FieldInfo(cfType.getGenNameValue(aData, source, getMyScope()), cfType.getGenNameTemplate(aData, source, getMyScope()), compField.getIdentifier().getName(), compField.getIdentifier().getDisplayName(), cfType.getGenNameTypeDescriptor(aData, source, myScope));
        hasOptional |= compField.isOptional();
        fieldInfos.add(fi);
    }
    for (final CompField compField : map.values()) {
        final StringBuilder tempSource = aData.getCodeForType(compField.getType().getGenNameOwn());
        compField.getType().generateCode(aData, tempSource);
    }
    UnionGenerator.generateValueClass(aData, source, genName, displayName, fieldInfos, hasOptional, getGenerateCoderFunctions(MessageEncoding_type.RAW), null);
    UnionGenerator.generateTemplateClass(aData, source, genName, displayName, fieldInfos, hasOptional);
    generateCodeForCodingHandlers(aData, source);
}
Also used : CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) ArrayList(java.util.ArrayList) FieldInfo(org.eclipse.titan.designer.AST.TTCN3.types.UnionGenerator.FieldInfo) IType(org.eclipse.titan.designer.AST.IType)

Example 58 with CompField

use of org.eclipse.titan.designer.AST.TTCN3.types.CompField 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 59 with CompField

use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.

the class ComponentsOfComponentType method trCompsof.

@Override
public /**
 * {@inheritDoc}
 */
void trCompsof(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain, final boolean isSet) {
    if (null != trCompsofTimestamp && !trCompsofTimestamp.isLess(timestamp)) {
        return;
    }
    if (null == componentsOfType) {
        return;
    }
    final IType type = componentsOfType.getTypeRefdLast(timestamp);
    if (type.getIsErroneous(timestamp)) {
        return;
    }
    CTs_EE_CTs tempCtss;
    switch(type.getTypetype()) {
        case TYPE_ASN1_SET:
            if (!isSet) {
                getLocation().reportSemanticError(MessageFormat.format(SEQUENCEEXPECTED, type.getFullName()));
                trCompsofTimestamp = timestamp;
                return;
            }
            referenceChain.markState();
            if (referenceChain.add(componentsOfType)) {
                ((ASN1_Set_Type) type).trCompsof(timestamp, referenceChain);
            }
            referenceChain.previousState();
            tempCtss = ((ASN1_Set_Type) type).components;
            break;
        case TYPE_ASN1_SEQUENCE:
            if (isSet) {
                getLocation().reportSemanticError(MessageFormat.format(SETEXPECTED, type.getFullName()));
                trCompsofTimestamp = timestamp;
                return;
            }
            referenceChain.markState();
            if (referenceChain.add(componentsOfType)) {
                ((ASN1_Sequence_Type) type).trCompsof(timestamp, referenceChain);
            }
            referenceChain.previousState();
            tempCtss = ((ASN1_Sequence_Type) type).components;
            break;
        default:
            trCompsofTimestamp = timestamp;
            return;
    }
    // emergency exit for the case of infinite recursion
    if (timestamp.equals(trCompsofTimestamp)) {
        return;
    }
    componentTypes = new ComponentTypeList();
    type.check(timestamp);
    for (int i = 0; i < tempCtss.getNofRootComps(); i++) {
        final CompField compfield = tempCtss.getRootCompByIndex(i).newInstance();
        compfield.setLocation(location);
        final RegularComponentType componentType = new RegularComponentType(compfield);
        componentType.setLocation(location);
        componentTypes.addComponentType(componentType);
    }
    componentTypes.setMyScope(componentsOfType.getMyScope());
    componentTypes.setFullNameParent(this);
    trCompsofTimestamp = timestamp;
}
Also used : CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) IType(org.eclipse.titan.designer.AST.IType)

Example 60 with CompField

use of org.eclipse.titan.designer.AST.TTCN3.types.CompField 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

IType (org.eclipse.titan.designer.AST.IType)64 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)62 Identifier (org.eclipse.titan.designer.AST.Identifier)48 ISubReference (org.eclipse.titan.designer.AST.ISubReference)32 Type (org.eclipse.titan.designer.AST.Type)26 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)19 IValue (org.eclipse.titan.designer.AST.IValue)19 ArrayList (java.util.ArrayList)10 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)10 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)10 HashMap (java.util.HashMap)9 IASN1Type (org.eclipse.titan.designer.AST.ASN1.IASN1Type)9 ASN1_Set_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type)9 SubType (org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType)9 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)8 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)8 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)8 NamedTemplate (org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate)8 Value (org.eclipse.titan.designer.AST.Value)8 Reference (org.eclipse.titan.designer.AST.Reference)6