Search in sources :

Example 11 with IReferencingType

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

the class UnusedStartedFuncRetVal method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof Start_Component_Statement) {
        final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
        final Start_Component_Statement s = (Start_Component_Statement) node;
        final Component_Type compType = Port_Utility.checkComponentReference(timestamp, s, s.getComponent(), false, false);
        final Assignment assignment = s.getFunctionInstanceReference().getRefdAssignment(timestamp, false);
        if (assignment == null) {
            return;
        }
        switch(assignment.getAssignmentType()) {
            case A_FUNCTION:
            case A_FUNCTION_RTEMP:
            case A_FUNCTION_RVAL:
                break;
            default:
                return;
        }
        final Def_Function function = (Def_Function) assignment;
        final IType runsOnType = function.getRunsOnType(timestamp);
        if (compType == null || runsOnType == null || !function.isStartable()) {
            return;
        }
        switch(function.getAssignmentType()) {
            case A_FUNCTION_RTEMP:
                break;
            case A_FUNCTION_RVAL:
                IType type = function.getType(timestamp);
                boolean returnTypeCorrect = false;
                while (!returnTypeCorrect) {
                    if (type.hasDoneAttribute()) {
                        returnTypeCorrect = true;
                        break;
                    }
                    if (type instanceof IReferencingType) {
                        final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                        final IType refd = ((IReferencingType) type).getTypeRefd(timestamp, refChain);
                        refChain.release();
                        if (type != refd) {
                            type = refd;
                        } else {
                            break;
                        }
                    } else {
                        break;
                    }
                }
                if (!returnTypeCorrect) {
                    final String msg = MessageFormat.format(PROBLEM, function.getDescription(), function.getType(timestamp).getTypename());
                    problems.report(s.getFunctionInstanceReference().getLocation(), msg);
                }
                break;
            default:
                break;
        }
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Start_Component_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Start_Component_Statement) IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) CompilationTimeStamp(org.eclipse.titan.designer.parsers.CompilationTimeStamp) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Component_Type(org.eclipse.titan.designer.AST.TTCN3.types.Component_Type) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function) IType(org.eclipse.titan.designer.AST.IType)

Example 12 with IReferencingType

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

the class Address_Type method getTypeRefdLast.

@Override
public /**
 * {@inheritDoc}
 */
IType getTypeRefdLast(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    final boolean newChain = null == referenceChain;
    IReferenceChain tempReferenceChain;
    if (newChain) {
        tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    } else {
        tempReferenceChain = referenceChain;
    }
    IType lastType = this;
    while (lastType != null && lastType instanceof IReferencingType && !lastType.getIsErroneous(timestamp)) {
        lastType = ((IReferencingType) lastType).getTypeRefd(timestamp, tempReferenceChain);
    }
    if (newChain) {
        tempReferenceChain.release();
    }
    if (lastType != null && lastType.getIsErroneous(timestamp)) {
        setIsErroneous(true);
    }
    return lastType;
}
Also used : IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) IType(org.eclipse.titan.designer.AST.IType)

Example 13 with IReferencingType

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

the class TTCN3Template method checkLengthRestriction.

/**
 * Checks that if there is a length restriction applied to this
 * template, it is semantically correct.
 *
 * @param timestamp
 *                the time stamp of the actual semantic check cycle.
 * @param type
 *                the type the template is being checked against.
 */
protected void checkLengthRestriction(final CompilationTimeStamp timestamp, final IType type) {
    if (lengthRestriction == null) {
        return;
    }
    lengthRestriction.setMyScope(myScope);
    lengthRestriction.check(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (type instanceof IReferencingType) {
        final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
        final IType last = ((IReferencingType) type).getTypeRefd(timestamp, refChain);
        refChain.release();
        if (!last.getIsErroneous(timestamp)) {
            checkLengthRestriction(timestamp, last);
        }
        return;
    }
    if (type.getIsErroneous(timestamp)) {
        return;
    }
    final Type_type typeType = type.getTypetypeTtcn3();
    switch(typeType) {
        case TYPE_PORT:
            // the error was already reported.
            return;
        case TYPE_ARRAY:
            lengthRestriction.checkArraySize(timestamp, ((Array_Type) type).getDimension());
            break;
        case TYPE_BITSTRING:
        case TYPE_HEXSTRING:
        case TYPE_OCTETSTRING:
        case TYPE_CHARSTRING:
        case TYPE_UCHARSTRING:
        case TYPE_SEQUENCE_OF:
        case TYPE_SET_OF:
            break;
        default:
            lengthRestriction.getLocation().reportSemanticError(MessageFormat.format("Length restriction cannot be used in template of type `{0}''", type.getTypename()));
            return;
    }
    checkTemplateSpecificLengthRestriction(timestamp, typeType);
}
Also used : IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)13 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)13 IType (org.eclipse.titan.designer.AST.IType)13 Component_Type (org.eclipse.titan.designer.AST.TTCN3.types.Component_Type)3 Assignment (org.eclipse.titan.designer.AST.Assignment)2 Identifier (org.eclipse.titan.designer.AST.Identifier)2 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)2 Function_Type (org.eclipse.titan.designer.AST.TTCN3.types.Function_Type)2 CompilationTimeStamp (org.eclipse.titan.designer.parsers.CompilationTimeStamp)2 FieldName (org.eclipse.titan.designer.AST.ASN1.Object.FieldName)1 ObjectSet_definition (org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_definition)1 Referenced_ObjectSet (org.eclipse.titan.designer.AST.ASN1.Object.Referenced_ObjectSet)1 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)1 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)1 ASN1_Set_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type)1 ObjectClassField_Type (org.eclipse.titan.designer.AST.ASN1.types.ObjectClassField_Type)1 Open_Type (org.eclipse.titan.designer.AST.ASN1.types.Open_Type)1 Named_Bits (org.eclipse.titan.designer.AST.ASN1.values.Named_Bits)1 AtNotation (org.eclipse.titan.designer.AST.AtNotation)1 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)1