Search in sources :

Example 81 with IType

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

the class Connect_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    IType portType1;
    IType portType2;
    PortTypeBody body1;
    PortTypeBody body2;
    portType1 = Port_Utility.checkConnectionEndpoint(timestamp, this, componentReference1, portReference1, false);
    if (portType1 == null) {
        body1 = null;
    } else {
        body1 = ((Port_Type) portType1).getPortBody();
    }
    portType2 = Port_Utility.checkConnectionEndpoint(timestamp, this, componentReference2, portReference2, false);
    if (portType2 == null) {
        body2 = null;
    } else {
        body2 = ((Port_Type) portType2).getPortBody();
    }
    if (portType1 == null || portType2 == null || body1 == null || body2 == null) {
        lastTimeChecked = timestamp;
        return;
    }
    if (!body1.isConnectable(timestamp, body2) || (body1 != body2 && !body2.isConnectable(timestamp, body1))) {
        location.reportSemanticError(MessageFormat.format(INCONSISTENTCONNECTION, portType1.getTypename(), portType2.getTypename()));
        body1.reportConnectionErrors(timestamp, body2, location);
        if (body1 != body2) {
            body2.reportConnectionErrors(timestamp, body1, location);
        }
    }
    lastTimeChecked = timestamp;
}
Also used : PortTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody) IType(org.eclipse.titan.designer.AST.IType)

Example 82 with IType

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

the class Qualifier method findReferences.

@Override
public /**
 * {@inheritDoc}
 */
void findReferences(final ReferenceFinder referenceFinder, final List<Hit> foundIdentifiers) {
    if (definition != null && subReferences != null) {
        // qualifiers were not semantically analyzed
        for (ISubReference sr : subReferences) {
            sr.findReferences(referenceFinder, foundIdentifiers);
        }
        if (referenceFinder.fieldId != null) {
            // we are searching for a field of a type
            final IType t = definition.getType(CompilationTimeStamp.getBaseTimestamp());
            if (t == null) {
                return;
            }
            final List<IType> typeArray = new ArrayList<IType>();
            final Reference reference = new Reference(null);
            reference.addSubReference(new FieldSubReference(definition.getIdentifier()));
            for (ISubReference sr : subReferences) {
                reference.addSubReference(sr);
            }
            reference.setLocation(location);
            reference.setMyScope(definition.getMyScope());
            final boolean success = t.getFieldTypesAsArray(reference, 1, typeArray);
            if (!success) {
                // TODO: maybe a partially erroneous reference could be searched too
                return;
            }
            if (subReferences.size() != typeArray.size()) {
                ErrorReporter.INTERNAL_ERROR();
                return;
            }
            for (int i = 0; i < subReferences.size(); i++) {
                if (typeArray.get(i) == referenceFinder.type && !(subReferences.get(i) instanceof ArraySubReference) && subReferences.get(i).getId().equals(referenceFinder.fieldId)) {
                    foundIdentifiers.add(new Hit(subReferences.get(i).getId()));
                }
            }
        }
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Hit(org.eclipse.titan.designer.AST.ReferenceFinder.Hit) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) Reference(org.eclipse.titan.designer.AST.Reference) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) ArrayList(java.util.ArrayList) IType(org.eclipse.titan.designer.AST.IType) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Example 83 with IType

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

the class ASN1_Sequence_Type method getSubrefsAsArray.

// This is the same as in ASN1_Set_type
@Override
public /**
 * {@inheritDoc}
 */
boolean getSubrefsAsArray(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final List<Integer> subrefsArray, final List<IType> typeArray) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
        return true;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDSUBREFERENCE, getTypename()));
            return false;
        case fieldSubReference:
            {
                if (components == null) {
                    return false;
                }
                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 false;
                }
                final IType fieldType = compField.getType();
                if (fieldType == null) {
                    return false;
                }
                final int fieldIndex = components.indexOf(compField);
                subrefsArray.add(fieldIndex);
                typeArray.add(this);
                return fieldType.getSubrefsAsArray(timestamp, reference, actualSubReference + 1, subrefsArray, typeArray);
            }
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
            return false;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            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) IType(org.eclipse.titan.designer.AST.IType)

Example 84 with IType

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

the class ASN1_Set_Seq_Choice_BaseType method getFieldTypesAsArray.

@Override
public /**
 * {@inheritDoc}
 */
boolean getFieldTypesAsArray(final Reference reference, final int actualSubReference, final List<IType> typeArray) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
        return true;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            return false;
        case fieldSubReference:
            {
                final Identifier id = subreference.getId();
                final CompField compField = components.getCompByName(id);
                if (compField == null) {
                    return false;
                }
                final IType fieldType = compField.getType();
                if (fieldType == null) {
                    return false;
                }
                typeArray.add(this);
                return fieldType.getFieldTypesAsArray(reference, actualSubReference + 1, typeArray);
            }
        case parameterisedSubReference:
            return false;
        default:
            return false;
    }
}
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) IType(org.eclipse.titan.designer.AST.IType)

Example 85 with IType

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

the class ASN1_Set_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String className = getGenNameOwn();
    final String classReadableName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final List<FieldInfo> namesList = new ArrayList<FieldInfo>();
    boolean hasOptional = false;
    for (int i = 0; i < components.getNofComps(); i++) {
        final CompField compField = components.getCompByIndex(i);
        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(), compField.isOptional(), false, compField.getType().getClass().getSimpleName(), cfType.getGenNameTypeDescriptor(aData, source, myScope));
        hasOptional |= compField.isOptional();
        namesList.add(fi);
    }
    for (int i = 0; i < components.getNofComps(); i++) {
        final CompField compField = components.getCompByIndex(i);
        final StringBuilder tempSource = aData.getCodeForType(compField.getType().getGenNameOwn());
        compField.getType().generateCode(aData, tempSource);
    }
    final boolean hasRaw = getGenerateCoderFunctions(MessageEncoding_type.RAW);
    RecordSetCodeGenerator.generateValueClass(aData, source, className, classReadableName, namesList, hasOptional, true, hasRaw, null);
    RecordSetCodeGenerator.generateTemplateClass(aData, source, className, classReadableName, namesList, hasOptional, true);
    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.RecordSetCodeGenerator.FieldInfo) 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