Search in sources :

Example 11 with ActualParameterList

use of org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList in project titan.EclipsePlug-ins by eclipse.

the class Reference method checkActivateArgument.

/**
 * Checks whether this is a correct altstep activation reference.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 *
 * @return true if the altstep reference is correct, false otherwise.
 */
public final boolean checkActivateArgument(final CompilationTimeStamp timestamp) {
    final Assignment assignment = getRefdAssignment(timestamp, true);
    if (assignment == null) {
        return false;
    }
    if (!Assignment_type.A_ALTSTEP.semanticallyEquals(assignment.getAssignmentType())) {
        getLocation().reportSemanticError(MessageFormat.format(ALTSTEPEXPECTED, assignment.getDescription()));
        setIsErroneous(true);
        return false;
    }
    if (myScope != null) {
        myScope.checkRunsOnScope(timestamp, assignment, this, "activate");
    }
    if (!subReferences.isEmpty()) {
        if (Subreference_type.parameterisedSubReference.equals(subReferences.get(0).getReferenceType())) {
            final ActualParameterList actualParameters = ((ParameterisedSubReference) subReferences.get(0)).getActualParameters();
            final FormalParameterList formalParameterList = ((Def_Altstep) assignment).getFormalParameterList();
            if (formalParameterList != null) {
                return formalParameterList.checkActivateArgument(timestamp, actualParameters, assignment.getDescription());
            }
        }
    }
    return false;
}
Also used : IParameterisedAssignment(org.eclipse.titan.designer.AST.TTCN3.definitions.IParameterisedAssignment) ASN1Assignment(org.eclipse.titan.designer.AST.ASN1.ASN1Assignment) FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) Def_Altstep(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep)

Example 12 with ActualParameterList

use of org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList in project titan.EclipsePlug-ins by eclipse.

the class ParameterisedSubReference method checkParameters.

public boolean checkParameters(final CompilationTimeStamp timestamp, final FormalParameterList formalParameterList) {
    actualParameters = new ActualParameterList();
    final boolean isErroneous = formalParameterList.checkActualParameterList(timestamp, parsedParameters, actualParameters);
    actualParameters.setFullNameParent(this);
    actualParameters.setMyScope(myScope);
    return isErroneous;
}
Also used : ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)

Example 13 with ActualParameterList

use of org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList in project titan.EclipsePlug-ins by eclipse.

the class ActivateDereferedExpression method checkExpressionOperands.

/**
 * Checks the parameters of the expression and if they are valid in
 * their position in the expression or not.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param expectedValue
 *                the kind of value expected.
 * @param referenceChain
 *                a reference chain to detect cyclic references.
 */
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    value.setLoweridToReference(timestamp);
    IType type = value.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (type != null) {
        type = type.getTypeRefdLast(timestamp);
    }
    if (type == null || type.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return;
    }
    if (!Type_type.TYPE_ALTSTEP.equals(type.getTypetype())) {
        value.getLocation().reportSemanticError(MessageFormat.format(ALTSTEPEXPECTED, type.getTypename()));
        setIsErroneous(true);
        return;
    }
    actualParameters = new ActualParameterList();
    final FormalParameterList formalParameterList = ((Altstep_Type) type).getFormalParameters();
    if (formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameters)) {
        setIsErroneous(true);
        return;
    }
    actualParameters.setFullNameParent(this);
    actualParameters.setMyScope(getMyScope());
    if (!formalParameterList.checkActivateArgument(timestamp, actualParameters, createStringRepresentation())) {
        setIsErroneous(true);
    }
    checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) Altstep_Type(org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 14 with ActualParameterList

use of org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList in project titan.EclipsePlug-ins by eclipse.

the class ApplyExpression method checkExpressionOperands.

/**
 * Checks the parameters of the expression and if they are valid in
 * their position in the expression or not.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param expectedValue
 *                the kind of value expected.
 * @param referenceChain
 *                a reference chain to detect cyclic references.
 */
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    IType type = null;
    if (value != null) {
        value.setLoweridToReference(timestamp);
        type = value.getExpressionGovernor(timestamp, expectedValue);
    }
    if (type == null || type.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return;
    }
    type = type.getTypeRefdLast(timestamp);
    if (!Type_type.TYPE_FUNCTION.equals(type.getTypetype())) {
        value.getLocation().reportSemanticError(MessageFormat.format(VALUEXPECTED3, type.getTypename()));
        setIsErroneous(true);
        return;
    }
    if (myScope != null) {
        myScope.checkRunsOnScope(timestamp, type, this, "call");
    }
    actualParameters = new ActualParameterList();
    final FormalParameterList formalParameterList = ((Function_Type) type).getFormalParameters();
    if (!formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameters)) {
        actualParameters.setFullNameParent(this);
        actualParameters.setMyScope(getMyScope());
    }
    switch(expectedValue) {
        case EXPECTED_CONSTANT:
            getLocation().reportSemanticError(EVALUATABLEEXPECTED);
            setIsErroneous(true);
            break;
        case EXPECTED_STATIC_VALUE:
            getLocation().reportSemanticError(STATICEXPECTED);
            setIsErroneous(true);
            break;
        default:
            break;
    }
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) Function_Type(org.eclipse.titan.designer.AST.TTCN3.types.Function_Type) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) IType(org.eclipse.titan.designer.AST.IType)

Example 15 with ActualParameterList

use of org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList in project titan.EclipsePlug-ins by eclipse.

the class All_From_Template method checkThisTemplateParameterizedReference.

private boolean checkThisTemplateParameterizedReference(final Reference reference, final Assignment lhs) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.isEmpty() || !(subreferences.get(0) instanceof ParameterisedSubReference)) {
        return false;
    }
    final ParameterisedSubReference subReference = (ParameterisedSubReference) subreferences.get(0);
    final ActualParameterList actualParameterList = subReference.getActualParameters();
    if (actualParameterList == null) {
        return false;
    }
    final int nofParameters = actualParameterList.getNofParameters();
    for (int i = 0; i < nofParameters; i++) {
        Reference parameterReference = null;
        final ActualParameter actualParameter = actualParameterList.getParameter(i);
        if (actualParameter instanceof Template_ActualParameter) {
            TemplateInstance templateInstance = ((Template_ActualParameter) actualParameter).getTemplateInstance();
            ITTCN3Template template = templateInstance.getTemplateBody();
            template = template.setLoweridToReference(CompilationTimeStamp.getBaseTimestamp());
            if (template.getTemplatetype() == Template_type.TEMPLATE_REFD) {
                parameterReference = ((Referenced_Template) template).getReference();
            }
        } else if (actualParameter instanceof Referenced_ActualParameter) {
            parameterReference = ((Referenced_ActualParameter) actualParameter).getReference();
        }
        if (parameterReference != null) {
            final Assignment assignment = parameterReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
            if (assignment == lhs) {
                return true;
            }
            // check their parameters as well
            switch(assignment.getAssignmentType()) {
                case A_TEMPLATE:
                case A_FUNCTION_RVAL:
                case A_FUNCTION_RTEMP:
                case A_EXT_FUNCTION_RVAL:
                case A_EXT_FUNCTION_RTEMP:
                    if (checkThisTemplateParameterizedReference(parameterReference, lhs)) {
                        return true;
                    }
                    break;
                default:
                    break;
            }
        }
    }
    return false;
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) Template_ActualParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.Template_ActualParameter) ActualParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameter) Referenced_ActualParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.Referenced_ActualParameter) Template_ActualParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.Template_ActualParameter) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) Referenced_ActualParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.Referenced_ActualParameter)

Aggregations

ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)18 FormalParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList)13 IType (org.eclipse.titan.designer.AST.IType)9 ISubReference (org.eclipse.titan.designer.AST.ISubReference)6 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)6 Assignment (org.eclipse.titan.designer.AST.Assignment)5 IValue (org.eclipse.titan.designer.AST.IValue)4 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)3 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)3 TemplateInstance (org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance)3 Altstep_Type (org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type)3 Function_Type (org.eclipse.titan.designer.AST.TTCN3.types.Function_Type)3 HashMap (java.util.HashMap)2 Def_Template (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template)2 NamedParameter (org.eclipse.titan.designer.AST.TTCN3.templates.NamedParameter)2 NamedParameters (org.eclipse.titan.designer.AST.TTCN3.templates.NamedParameters)2 NotUsed_Template (org.eclipse.titan.designer.AST.TTCN3.templates.NotUsed_Template)2 TemplateInstances (org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstances)2 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)2 ASN1Assignment (org.eclipse.titan.designer.AST.ASN1.ASN1Assignment)1