Search in sources :

Example 1 with Start_Component_Statement

use of org.eclipse.titan.designer.AST.TTCN3.statements.Start_Component_Statement in project titan.EclipsePlug-ins by eclipse.

the class Unknown_Start_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    final Assignment assignment = reference.getRefdAssignment(timestamp, true);
    if (assignment == null) {
        return;
    }
    switch(assignment.getAssignmentType()) {
        case A_PORT:
        case A_PAR_PORT:
            if (value != null) {
                value.getLocation().reportSemanticError(NOARGUMENTEXPECTED);
            }
            if (realStatement == null || !Statement_type.S_START_PORT.equals(realStatement.getType())) {
                realStatement = new Start_Port_Statement(reference);
                realStatement.setMyScope(getMyScope());
                realStatement.setFullNameParent(this);
                realStatement.setLocation(location);
                realStatement.setMyStatementBlock(getMyStatementBlock(), statementIndex);
            }
            realStatement.check(timestamp);
            break;
        case A_TIMER:
        case A_PAR_TIMER:
            if (realStatement == null || !Statement_type.S_START_TIMER.equals(realStatement.getType())) {
                realStatement = new Start_Timer_Statement(reference, value);
                realStatement.setMyScope(getMyScope());
                realStatement.setFullNameParent(this);
                realStatement.setLocation(location);
                realStatement.setMyStatementBlock(getMyStatementBlock(), statementIndex);
            }
            realStatement.check(timestamp);
            break;
        case A_CONST:
        case A_EXT_CONST:
        case A_MODULEPAR:
        case A_VAR:
        case A_FUNCTION_RVAL:
        case A_EXT_FUNCTION_RVAL:
        case A_PAR_VAL:
        case A_PAR_VAL_IN:
        case A_PAR_VAL_OUT:
        case A_PAR_VAL_INOUT:
            if (value == null) {
                location.reportSemanticError(MISSINGARGUMENT);
                return;
            }
            if (!Value_type.REFERENCED_VALUE.equals(value.getValuetype())) {
                value.getLocation().reportSemanticError(FUNCTIONARGUMENTEXPECTED);
                return;
            }
            if (realStatement == null || !Statement_type.S_START_COMPONENT.equals(realStatement.getType())) {
                realStatement = new Start_Component_Statement(new Referenced_Value(reference), ((Referenced_Value) value).getReference());
                realStatement.setMyScope(getMyScope());
                realStatement.setFullNameParent(this);
                realStatement.setLocation(location);
                realStatement.setMyStatementBlock(getMyStatementBlock(), statementIndex);
            }
            realStatement.check(timestamp);
            break;
        default:
            reference.getLocation().reportSemanticError(MessageFormat.format(UNEXPECEDSTARTREFERENCE, assignment.getDescription()));
            break;
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)

Example 2 with Start_Component_Statement

use of org.eclipse.titan.designer.AST.TTCN3.statements.Start_Component_Statement 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)

Aggregations

Assignment (org.eclipse.titan.designer.AST.Assignment)2 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)1 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)1 IType (org.eclipse.titan.designer.AST.IType)1 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)1 Start_Component_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Start_Component_Statement)1 Component_Type (org.eclipse.titan.designer.AST.TTCN3.types.Component_Type)1 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)1 CompilationTimeStamp (org.eclipse.titan.designer.parsers.CompilationTimeStamp)1