Search in sources :

Example 6 with IReferencingType

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

the class UnusedStartedRefFuncRetVal method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof Start_Referenced_Component_Statement) {
        final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
        final Start_Referenced_Component_Statement s = (Start_Referenced_Component_Statement) node;
        final Value dereferredValue = s.getDereferredValue();
        if (dereferredValue == null) {
            return;
        }
        switch(dereferredValue.getValuetype()) {
            case EXPRESSION_VALUE:
                if (Operation_type.REFERS_OPERATION.equals(((Expression_Value) dereferredValue).getOperationType())) {
                    return;
                }
                break;
            case TTCN3_NULL_VALUE:
            case FAT_NULL_VALUE:
                return;
            default:
                break;
        }
        IType type = dereferredValue.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        if (type != null) {
            type = type.getTypeRefdLast(timestamp);
        }
        if (type == null || type.getIsErroneous(timestamp)) {
            return;
        }
        if (!(type instanceof Function_Type)) {
            return;
        }
        final Function_Type functionType = (Function_Type) type;
        if (functionType.isRunsOnSelf()) {
            return;
        }
        if (!functionType.isStartable(timestamp)) {
            return;
        }
        final IType returnType = functionType.getReturnType();
        if (returnType == null) {
            return;
        }
        if (functionType.returnsTemplate()) {
            return;
        }
        IType lastType = returnType;
        boolean returnTypeCorrect = false;
        while (!returnTypeCorrect) {
            if (lastType.hasDoneAttribute()) {
                returnTypeCorrect = true;
                break;
            }
            if (lastType instanceof IReferencingType) {
                final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                final IType refd = ((IReferencingType) lastType).getTypeRefd(timestamp, refChain);
                refChain.release();
                if (lastType != refd) {
                    lastType = refd;
                } else {
                    break;
                }
            } else {
                break;
            }
        }
        if (!returnTypeCorrect) {
            final String msg = MessageFormat.format(PROBLEM, functionType.getTypename(), returnType.getTypename());
            problems.report(dereferredValue.getLocation(), msg);
        }
    }
}
Also used : IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) CompilationTimeStamp(org.eclipse.titan.designer.parsers.CompilationTimeStamp) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Value(org.eclipse.titan.designer.AST.Value) Expression_Value(org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value) Function_Type(org.eclipse.titan.designer.AST.TTCN3.types.Function_Type) Start_Referenced_Component_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Start_Referenced_Component_Statement) IType(org.eclipse.titan.designer.AST.IType)

Example 7 with IReferencingType

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

the class Selection_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 type = this;
    while (null != type && type instanceof IReferencingType && !type.getIsErroneous(timestamp)) {
        type = ((IReferencingType) type).getTypeRefd(timestamp, tempReferenceChain);
    }
    if (newChain) {
        tempReferenceChain.release();
    }
    return type;
}
Also used : IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) IType(org.eclipse.titan.designer.AST.IType)

Example 8 with IReferencingType

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

the class External_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 t = this;
    while (t != null && t instanceof IReferencingType && !t.getIsErroneous(timestamp)) {
        t = ((IReferencingType) t).getTypeRefd(timestamp, tempReferenceChain);
    }
    if (newChain) {
        tempReferenceChain.release();
    }
    if (t != null && t.getIsErroneous(timestamp)) {
        setIsErroneous(true);
    }
    return t;
}
Also used : IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) IType(org.eclipse.titan.designer.AST.IType)

Example 9 with IReferencingType

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

the class Start_Component_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    final Component_Type componentType = Port_Utility.checkComponentReference(timestamp, this, componentReference, false, false);
    final Assignment assignment = functionInstanceReference.getRefdAssignment(timestamp, true);
    if (assignment == null) {
        return;
    }
    switch(assignment.getAssignmentType()) {
        case A_FUNCTION:
        case A_FUNCTION_RTEMP:
        case A_FUNCTION_RVAL:
            break;
        default:
            functionInstanceReference.getLocation().reportSemanticError(MessageFormat.format(REFERENCETOFUNCTIONWASEXPECTED, assignment.getDescription()));
            return;
    }
    final Def_Function function = (Def_Function) assignment;
    if (!function.checkStartable(timestamp, getLocation())) {
        return;
    }
    final IType runsOnType = function.getRunsOnType(timestamp);
    if (componentType == null || runsOnType == null) {
        return;
    }
    if (!runsOnType.isCompatible(timestamp, componentType, null, null, null)) {
        componentReference.getLocation().reportSemanticError(MessageFormat.format(COMPONENTTYPEMISMATCH, componentType.getTypename(), function.getDescription(), runsOnType.getTypename()));
    }
    switch(function.getAssignmentType()) {
        case A_FUNCTION_RTEMP:
            functionInstanceReference.getLocation().reportSemanticWarning(MessageFormat.format(TEMPLATERETURN, function.getFullName(), function.getType(timestamp).getTypename()));
            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 message = MessageFormat.format(RETURNWITHOUTDONE, function.getDescription(), function.getType(timestamp).getTypename());
                    functionInstanceReference.getLocation().reportSemanticWarning(message);
                }
                break;
            }
        default:
            break;
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) 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 10 with IReferencingType

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

the class Done_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    Port_Utility.checkComponentReference(timestamp, this, componentreference, false, false);
    if (componentreference == null) {
        lastTimeChecked = timestamp;
        return;
    }
    if (doneMatch != null) {
        final boolean[] valueRedirectChecked = new boolean[] { false };
        final IType returnType = Port_Utility.getIncomingType(timestamp, doneMatch, redirect, valueRedirectChecked);
        if (returnType == null) {
            doneMatch.getLocation().reportSemanticError("Cannot determine the return type for value returning done");
        } else {
            IType lastType = returnType;
            boolean returnTypeCorrect = false;
            while (!returnTypeCorrect) {
                if (lastType.hasDoneAttribute()) {
                    returnTypeCorrect = true;
                    break;
                }
                if (lastType instanceof IReferencingType) {
                    final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                    final IType refd = ((IReferencingType) lastType).getTypeRefd(timestamp, refChain);
                    refChain.release();
                    if (lastType != refd) {
                        lastType = refd;
                    } else {
                        break;
                    }
                } else {
                    break;
                }
            }
            if (!returnTypeCorrect) {
                location.reportSemanticError(MessageFormat.format("Return type `{0}'' does not have `done'' extension attibute", returnType.getTypename()));
                returnType.setIsErroneous(true);
            }
            doneMatch.check(timestamp, returnType);
            if (!valueRedirectChecked[0]) {
                Port_Utility.checkValueRedirect(timestamp, redirect, returnType);
            }
        }
    } else if (redirect != null) {
        redirect.getLocation().reportSemanticError("Redirect cannot be used for the return value without a matching template");
        Port_Utility.checkValueRedirect(timestamp, redirect, null);
        redirect.setUsedOnLeftHandSide();
    }
    lastTimeChecked = timestamp;
}
Also used : IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) 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