Search in sources :

Example 21 with FormalParameterList

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

the class FunctionContext method process_internal.

@Override
protected void process_internal() {
    final Def_Function func = getNode();
    final FormalParameterList fpl = func.getFormalParameterList();
    final ParameterListVisitor vis = new ParameterListVisitor();
    fpl.accept(vis);
    paramIds = vis.getResult();
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)

Example 22 with FormalParameterList

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

the class T3Doc method getCommentStringBasedOnReference.

public static String getCommentStringBasedOnReference(final DeclarationCollector declarationCollector, final List<DeclarationCollectionHelper> collected, final IEditorPart targetEditor, final IRegion hoverRegion, final IReferenceParser referenceParser, final ITextViewer textViewer) {
    if (!T3Doc.isT3DocEnable()) {
        return null;
    }
    Reference ref = declarationCollector.getReference();
    if (ref == null) {
        return null;
    }
    if ((ref.getMyScope() instanceof NamedBridgeScope || ref.getMyScope() instanceof FormalParameterList) && !collected.isEmpty()) {
        DeclarationCollectionHelper declaration = collected.get(0);
        if (declaration.node instanceof TTCN3_Sequence_Type || declaration.node instanceof FormalParameter) {
            final IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
            ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
            final Module tempModule = projectSourceParser.containedModule(file);
            Assignment ass = tempModule.getEnclosingAssignment(hoverRegion.getOffset());
            if (ass != null) {
                Reference reference = referenceParser.findReferenceForOpening(file, hoverRegion.getOffset(), textViewer.getDocument());
                String str = reference.getDisplayName();
                List<String> al = T3Doc.getCommentStrings(ass.getCommentLocation(), str);
                if (!al.isEmpty()) {
                    final StringBuilder sb = new StringBuilder();
                    for (String string : al) {
                        sb.append(string);
                    }
                    return sb.toString();
                }
            }
        }
    }
    return null;
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) IFile(org.eclipse.core.resources.IFile) Reference(org.eclipse.titan.designer.AST.Reference) TTCN3_Sequence_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser) DeclarationCollectionHelper(org.eclipse.titan.designer.editors.actions.DeclarationCollectionHelper) Assignment(org.eclipse.titan.designer.AST.Assignment) FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) NamedBridgeScope(org.eclipse.titan.designer.AST.NamedBridgeScope) Module(org.eclipse.titan.designer.AST.Module) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)

Example 23 with FormalParameterList

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

the class Def_Template method checkModified.

/**
 * Checks the correctness of the modification of this template done to
 * the modified one if it has any.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle
 */
private void checkModified(final CompilationTimeStamp timestamp) {
    if (baseTemplate == null) {
        return;
    }
    final IType baseType = baseTemplate.getType(timestamp);
    if (!type.isCompatible(timestamp, baseType, null, null, null)) {
        type.getLocation().reportSemanticError(MessageFormat.format(IMCOMPATIBLEBASETYPE, baseTemplate.getFullName(), baseType.getFullName(), type.getFullName()));
    }
    final FormalParameterList baseParameters = baseTemplate.getFormalParameterList(timestamp);
    final int nofBaseFps = (baseParameters == null) ? 0 : baseParameters.getNofParameters();
    final int nofLocalFps = (formalParList == null) ? 0 : formalParList.getNofParameters();
    int minFps;
    if (nofLocalFps < nofBaseFps) {
        location.reportSemanticError(MessageFormat.format(FEWERFORMALPARAMETERS, baseTemplate.getFullName(), nofBaseFps, nofLocalFps));
        minFps = nofLocalFps;
    } else {
        minFps = nofBaseFps;
    }
    for (int i = 0; i < minFps; i++) {
        final FormalParameter baseFormalpar = baseParameters.getParameterByIndex(i);
        final FormalParameter localFormalpar = formalParList.getParameterByIndex(i);
        if (baseFormalpar.getAssignmentType() != localFormalpar.getAssignmentType()) {
            localFormalpar.getLocation().reportSemanticError(MessageFormat.format(DIFFERENTPARAMETERKINDS, baseTemplate.getFullName(), baseFormalpar.getAssignmentName(), localFormalpar.getAssignmentName()));
        }
        final Type baseFpType = baseFormalpar.getType(timestamp);
        final Type localFpType = localFormalpar.getType(timestamp);
        if (!baseFpType.isCompatible(timestamp, localFpType, null, null, null)) {
            if (!localFpType.getIsErroneous(timestamp) && !baseFpType.getIsErroneous(timestamp)) {
                localFpType.getLocation().reportSemanticError(MessageFormat.format(INCOMPATIBLEBASEPARAMETERTYPE, baseTemplate.getFullName(), baseFpType.getTypename(), localFpType.getTypename()));
            }
        }
        final Identifier baseFormalparId = baseFormalpar.getIdentifier();
        final Identifier localFormalparId = localFormalpar.getIdentifier();
        if (!baseFormalparId.equals(localFormalparId)) {
            localFormalpar.getLocation().reportSemanticError(MessageFormat.format(DIFFERENTPARAMETERNAMES, baseTemplate.getFullName(), baseFormalparId.getDisplayName(), localFormalparId.getDisplayName()));
        }
    }
    body.setBaseTemplate(baseTemplate.getTemplate(timestamp));
}
Also used : CodeSectionType(org.eclipse.titan.designer.AST.GovernedSimple.CodeSectionType) Array_Type(org.eclipse.titan.designer.AST.TTCN3.types.Array_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) IType(org.eclipse.titan.designer.AST.IType)

Example 24 with FormalParameterList

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

the class ExecuteDereferedExpression 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) {
    if (value != null) {
        IType type;
        value.setLoweridToReference(timestamp);
        final IValue last = value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_TEMPLATE, referenceChain);
        if (last.getIsErroneous(timestamp)) {
            type = null;
        } else {
            type = last.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
            if (type != null) {
                type = type.getTypeRefdLast(timestamp);
            }
        }
        if (type == null || type.getIsErroneous(timestamp)) {
            setIsErroneous(true);
        } else if (Type_type.TYPE_TESTCASE.equals(type.getTypetype())) {
            final FormalParameterList formalParameters = ((Testcase_Type) type).getFormalParameters();
            actualParameters = new ActualParameterList();
            final boolean isErroneous = formalParameters.checkActualParameterList(timestamp, actualParameterList, actualParameters);
            if (isErroneous) {
                setIsErroneous(true);
            }
        } else {
            value.getLocation().reportSemanticError(MessageFormat.format("Reference to a value of type testcase was expected in the argument of `derefers()'' instead of `{0}''", type.getTypename()));
            setIsErroneous(true);
        }
    }
    if (timerValue != null) {
        timerValue.setLoweridToReference(timestamp);
        final Type_type tempType = timerValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        switch(tempType) {
            case TYPE_REAL:
                final IValue last = timerValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, referenceChain);
                if (!last.isUnfoldable(timestamp)) {
                    final Real_Value real = (Real_Value) last;
                    final double i = real.getValue();
                    if (i < 0.0) {
                        timerValue.getLocation().reportSemanticError(MessageFormat.format(NEGATIVEDURATION, real.createStringRepresentation()));
                    } else if (real.isPositiveInfinity()) {
                        timerValue.getLocation().reportSemanticError(MessageFormat.format(FLOATEXPECTED, real.createStringRepresentation()));
                    }
                }
                return;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                return;
            default:
                if (!isErroneous) {
                    timerValue.getLocation().reportSemanticError(OPERANDERROR);
                    setIsErroneous(true);
                }
                return;
        }
    }
    checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, false, false);
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) IType(org.eclipse.titan.designer.AST.IType) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Aggregations

FormalParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList)22 ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)14 IType (org.eclipse.titan.designer.AST.IType)10 Assignment (org.eclipse.titan.designer.AST.Assignment)4 IValue (org.eclipse.titan.designer.AST.IValue)4 ISubReference (org.eclipse.titan.designer.AST.ISubReference)3 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)3 Identifier (org.eclipse.titan.designer.AST.Identifier)3 Def_Template (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template)3 IParameterisedAssignment (org.eclipse.titan.designer.AST.TTCN3.definitions.IParameterisedAssignment)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 ASN1Assignment (org.eclipse.titan.designer.AST.ASN1.ASN1Assignment)2 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)2 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)2 Reference (org.eclipse.titan.designer.AST.Reference)2 Def_Altstep (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep)2 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)2 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)2 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)2