Search in sources :

Example 16 with TemplateInstance

use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.

the class Getreply_Statement method checkGetreply.

public static void checkGetreply(final CompilationTimeStamp timestamp, final Statement source, final String statementName, final Reference portReference, final TemplateInstance parameter, final TemplateInstance valueMatch, final TemplateInstance fromClause, final Reference redirectValue, final Parameter_Redirect redirectParameter, final Reference redirectSender) {
    final Port_Type portType = Port_Utility.checkPortReference(timestamp, source, portReference);
    if (parameter == null) {
        if (portType != null) {
            final PortTypeBody body = portType.getPortBody();
            if (!body.getreplyAllowed(timestamp)) {
                if (OperationModes.OP_Message.equals(body.getOperationMode())) {
                    portReference.getLocation().reportSemanticError(MessageFormat.format(GETREPLYONMESSAGEPORT, statementName, portType.getTypename()));
                } else {
                    portReference.getLocation().reportSemanticError(MessageFormat.format(GETREPLYNOTSUPPORTEDONPORT, portType.getTypename()));
                }
            }
        }
        if (redirectValue != null) {
            redirectValue.getLocation().reportSemanticError(VALUEREDIRECTWITHOUTSIGNATURE);
            Port_Utility.checkValueRedirect(timestamp, redirectValue, null);
        }
        if (redirectParameter != null) {
            // true?
            redirectParameter.check(timestamp, null, true);
            redirectParameter.getLocation().reportSemanticError(PARAMETERREDIRECTWITHOUTSIGNATURE);
        }
    } else {
        IType signature = null;
        boolean signatureDetermined = false;
        if (portType != null) {
            final PortTypeBody body = portType.getPortBody();
            if (OperationModes.OP_Message.equals(body.getOperationMode())) {
                portReference.getLocation().reportSemanticError(MessageFormat.format(GETREPLYONMESSAGEPORT, statementName, portType.getTypename()));
            } else if (body.getreplyAllowed(timestamp)) {
                final TypeSet outSignatures = body.getOutSignatures();
                if (outSignatures.getNofTypes() == 1) {
                    signature = outSignatures.getTypeByIndex(0);
                } else {
                    signature = Port_Utility.getOutgoingType(timestamp, parameter);
                    if (signature == null) {
                        parameter.getLocation().reportSemanticError(UNKNOWNSIGNATURETYPE);
                    } else {
                        if (!outSignatures.hasType(timestamp, signature)) {
                            parameter.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREMISSING, signature.getTypename(), portType.getTypename()));
                        }
                    }
                }
                signatureDetermined = true;
            } else {
                portReference.getLocation().reportSemanticError(MessageFormat.format(GETREPLYNOTSUPPORTEDONPORT, portType.getTypename()));
            }
        } else if (portReference == null) {
            // the statement refers to any port or there was
            // a syntax error
            parameter.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHPARAMETER, statementName));
            if (valueMatch != null) {
                valueMatch.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHVALUEMATCH, statementName));
            }
            if (redirectValue != null) {
                redirectValue.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHVALUEREDIRECTION, statementName));
            }
            if (redirectParameter != null) {
                redirectParameter.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHPARAMETERREDIRECTION, statementName));
            }
        }
        if (!signatureDetermined) {
            signature = Port_Utility.getOutgoingType(timestamp, parameter);
        }
        if (signature != null) {
            parameter.check(timestamp, signature);
            signature = signature.getTypeRefdLast(timestamp);
            Type returnType = null;
            switch(signature.getTypetype()) {
                case TYPE_SIGNATURE:
                    {
                        final Signature_Type signatureType = (Signature_Type) signature;
                        if (signatureType.isNonblocking()) {
                            final String message = MessageFormat.format(NONBLOCKINGSIGNATURE, statementName, signatureType.getTypename());
                            source.getLocation().reportSemanticError(message);
                        } else {
                            returnType = signatureType.getSignatureReturnType();
                        }
                        if (redirectParameter != null) {
                            redirectParameter.check(timestamp, signatureType, true);
                        }
                        if (returnType == null) {
                            if (valueMatch != null) {
                                valueMatch.getLocation().reportSemanticError(MessageFormat.format(VALUEMATCHWITHOUTRETURNTYPE, signature.getTypename()));
                            }
                            if (redirectValue != null) {
                                final String message = MessageFormat.format(VALUEREDIRECTWITHOUTRETURNTYPE, signature.getTypename());
                                redirectValue.getLocation().reportSemanticError(message);
                            }
                        }
                        break;
                    }
                default:
                    parameter.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREEXPECTED, signature.getTypename()));
                    if (redirectParameter != null) {
                        redirectParameter.checkErroneous(timestamp);
                    }
                    break;
            }
            if (valueMatch != null) {
                if (returnType != null) {
                    valueMatch.check(timestamp, returnType);
                }
            }
            Port_Utility.checkValueRedirect(timestamp, redirectValue, returnType);
        }
    }
    Port_Utility.checkFromClause(timestamp, source, portType, fromClause, redirectSender);
}
Also used : Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) Port_Type(org.eclipse.titan.designer.AST.TTCN3.types.Port_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) TypeSet(org.eclipse.titan.designer.AST.TTCN3.types.TypeSet) Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) Port_Type(org.eclipse.titan.designer.AST.TTCN3.types.Port_Type) PortTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody) IType(org.eclipse.titan.designer.AST.IType)

Example 17 with TemplateInstance

use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.

the class Getcall_Statement method checkGetcallStatement.

public static void checkGetcallStatement(final CompilationTimeStamp timestamp, final Statement statement, final String statementName, final Reference portReference, final TemplateInstance parameter, final TemplateInstance fromClause, final Parameter_Redirect redirect, final Reference redirectSender) {
    final Port_Type portType = Port_Utility.checkPortReference(timestamp, statement, portReference);
    if (parameter == null) {
        if (portType != null) {
            final PortTypeBody body = portType.getPortBody();
            if (OperationModes.OP_Message.equals(body.getOperationMode())) {
                portReference.getLocation().reportSemanticError(MessageFormat.format(MESSAGEBASEDPORT, statementName, portType.getTypename()));
            } else if (body.getInSignatures() == null) {
                portReference.getLocation().reportSemanticError(MessageFormat.format(NOINSIGNATURES, portType.getTypename()));
            }
        }
        if (redirect != null) {
            redirect.getLocation().reportSemanticError(REDIRECTWITHOUTSIGNATURE);
            redirect.checkErroneous(timestamp);
        }
    } else {
        IType signature = null;
        boolean signatureDetermined = false;
        if (portType != null) {
            final PortTypeBody body = portType.getPortBody();
            final TypeSet inSignatures = body.getInSignatures();
            if (OperationModes.OP_Message.equals(body.getOperationMode())) {
                portReference.getLocation().reportSemanticError(MessageFormat.format(MESSAGEBASEDPORT, statementName, portType.getTypename()));
            } else if (inSignatures != null) {
                if (inSignatures.getNofTypes() == 1) {
                    signature = inSignatures.getTypeByIndex(0);
                } else {
                    signature = Port_Utility.getOutgoingType(timestamp, parameter);
                    if (signature == null) {
                        parameter.getLocation().reportSemanticError(UNKNOWNSIGNATURETYPE);
                    } else {
                        if (!inSignatures.hasType(timestamp, signature)) {
                            parameter.getLocation().reportSemanticError(MessageFormat.format(SIGNATURENOTPRESENT, signature.getTypename(), portType.getTypename()));
                        }
                    }
                }
                signatureDetermined = true;
            } else {
                portReference.getLocation().reportSemanticError(MessageFormat.format(NOINSIGNATURES, portType.getTypename()));
            }
        } else if (portReference == null) {
            // any port is referenced, or there was a syntax
            // error
            parameter.getLocation().reportSemanticError(MessageFormat.format(ANYWITHPARAMETER, statementName));
            if (redirect != null) {
                redirect.getLocation().reportSemanticError(MessageFormat.format(ANYWITHREDIRECT, statementName));
            }
        }
        if (!signatureDetermined) {
            signature = Port_Utility.getOutgoingType(timestamp, parameter);
        }
        if (signature != null) {
            parameter.check(timestamp, signature);
            signature = signature.getTypeRefdLast(timestamp);
            switch(signature.getTypetype()) {
                case TYPE_SIGNATURE:
                    ((Signature_Type) signature).checkThisTemplate(timestamp, parameter.getTemplateBody(), false, false, null);
                    if (redirect != null) {
                        redirect.check(timestamp, (Signature_Type) signature, false);
                    }
                    break;
                default:
                    parameter.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREPARAMETEREXPECTED, signature.getTypename()));
                    if (redirect != null) {
                        redirect.checkErroneous(timestamp);
                    }
                    break;
            }
        }
    }
    Port_Utility.checkFromClause(timestamp, statement, portType, fromClause, redirectSender);
}
Also used : TypeSet(org.eclipse.titan.designer.AST.TTCN3.types.TypeSet) Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) Port_Type(org.eclipse.titan.designer.AST.TTCN3.types.Port_Type) PortTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody) IType(org.eclipse.titan.designer.AST.IType)

Example 18 with TemplateInstance

use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.

the class Call_Statement method checkCallBody.

/**
 * Checks the response and exception handling part of a call operation.
 *
 * @param timestamp
 *                the timestamp of the actual build cycle.
 * @param portType
 *                the port type of the actual call statement.
 * @param signature
 *                the signature type of the actual call statement.
 */
private void checkCallBody(final CompilationTimeStamp timestamp, final Port_Type portType, final IType signature) {
    boolean hasCatchTimeout = false;
    for (int i = 0; i < altGuards.getNofAltguards(); i++) {
        final AltGuard altGuard = altGuards.getAltguardByIndex(i);
        if (!altguard_type.AG_OP.equals(altGuard.getType())) {
            continue;
        }
        final Statement statement = ((Operation_Altguard) altGuard).getGuardStatement();
        if (Statement_type.S_CATCH.equals(statement.getType())) {
            ((Catch_Statement) statement).setCallSettings(true, timerValue != null);
            hasCatchTimeout |= ((Catch_Statement) statement).hasTimeout();
        }
    }
    altGuards.setMyLaicStmt(altGuards, null);
    altGuards.setMyAltguards(altGuards);
    altGuards.check(timestamp);
    if (portType != null) {
        // operation.
        for (int i = 0; i < altGuards.getNofAltguards(); i++) {
            final AltGuard altguard = altGuards.getAltguardByIndex(i);
            if (!altguard_type.AG_OP.equals(altguard.getType())) {
                continue;
            }
            final Statement statement = ((Operation_Altguard) altguard).getGuardStatement();
            if (statement.getIsErroneous()) {
                continue;
            }
            switch(statement.getType()) {
                case S_GETREPLY:
                    {
                        final Reference tempPortReference = ((Getreply_Statement) statement).getPortReference();
                        if (tempPortReference == null) {
                            final String message = MessageFormat.format("The `{0}'' operation must refer to the same port as the previous `call'' statement: `{1}'' was expected instead of `any port''", statement.getStatementName(), portReference.getId().getDisplayName());
                            statement.getLocation().reportSemanticError(message);
                        } else if (!portReference.getId().equals(tempPortReference.getId())) {
                            final String message = MessageFormat.format("The `{0}'' operation refers to a different port than the previous `call'' statement: `{1}'' was expected instead of `{2}''", statement.getStatementName(), portReference.getId().getDisplayName(), tempPortReference.getId().getDisplayName());
                            tempPortReference.getLocation().reportSemanticError(message);
                        }
                        final TemplateInstance instance = ((Getreply_Statement) statement).getReceiveParameter();
                        if (instance != null) {
                            final IType tempSignature = instance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
                            if (tempSignature != null && signature != null && !signature.isCompatible(timestamp, tempSignature, null, null, null)) {
                                final String message = MessageFormat.format(GETRPELYTOWRONGSIGNATURE, signature.getTypename(), tempSignature.getTypename());
                                instance.getLocation().reportSemanticError(message);
                            }
                        }
                        break;
                    }
                case S_CATCH:
                    final Reference tempPortReference = ((Catch_Statement) statement).getPortReference();
                    if (tempPortReference == null) {
                        final String message = MessageFormat.format("The `{0}'' operation must refer to the same port as the previous `call'' statement: `{1}'' was expected instead of `any port''", statement.getStatementName(), portReference.getId().getDisplayName());
                        statement.getLocation().reportSemanticError(message);
                    } else if (!portReference.getId().equals(tempPortReference.getId())) {
                        final String message = MessageFormat.format("The `{0}'' operation refers to a different port than the previous `call'' statement: `{1}'' was expected instead of `{2}''", statement.getStatementName(), portReference.getId().getDisplayName(), tempPortReference.getId().getDisplayName());
                        tempPortReference.getLocation().reportSemanticError(message);
                    }
                    final Signature_Type tempSignature = ((Catch_Statement) statement).getSignatureType();
                    if (tempSignature != null && signature != null && !signature.isCompatible(timestamp, tempSignature, null, null, null)) {
                        final String message = MessageFormat.format("The `catch'' operation refers to a different signature than the previous `call'' statement: `{0}'' was expected instead of `{1}''", signature.getTypename(), tempSignature.getTypename());
                        statement.getLocation().reportSemanticError(message);
                    }
                    break;
                default:
                    break;
            }
        }
    }
    if (timerValue != null && !hasCatchTimeout) {
        location.reportSemanticWarning("The call operation has a timer, but the timeout expection is not cought");
    }
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) TemplateInstance(org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance) IType(org.eclipse.titan.designer.AST.IType)

Example 19 with TemplateInstance

use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.

the class Catch_Statement method checkCatch.

public static void checkCatch(final CompilationTimeStamp timestamp, final Statement statement, final String statementName, final Reference portReference, final Reference signatureReference, final TemplateInstance parameter, final boolean timeout, final TemplateInstance fromClause, final Reference redirectValue, final Reference redirectSender) {
    final Port_Type portType = Port_Utility.checkPortReference(timestamp, statement, portReference);
    if (signatureReference == null) {
        if (timeout) {
            if (portReference == null) {
                statement.getLocation().reportSemanticError(TIMEOUTONANYPORT);
            } else {
                if (portType != null) {
                    final PortTypeBody body = portType.getPortBody();
                    // in the compiler
                    if (OperationModes.OP_Message.equals(body.getOperationMode())) {
                        portReference.getLocation().reportSemanticError(MessageFormat.format(TIMEOUTONMESSAGEPORT, portType.getTypename()));
                    } else if (!body.getreplyAllowed(timestamp)) {
                        portReference.getLocation().reportSemanticError(MessageFormat.format(TIMEOUTWITHOUTOUTSIGNATURES, portType.getTypename()));
                    }
                }
            }
            if (statement instanceof Catch_Statement) {
                final Catch_Statement catchStatement = (Catch_Statement) statement;
                if (!catchStatement.inCall) {
                    statement.getLocation().reportSemanticError(TIMEOUTNOTPERMITTED1);
                } else if (!catchStatement.callHasTimer) {
                    statement.getLocation().reportSemanticError(TIMEOUTNOTPERMITTED2);
                }
            }
            if (fromClause != null) {
                fromClause.getLocation().reportSemanticError(TIMEOUTWITHFROM);
            }
            if (redirectSender != null) {
                redirectSender.getLocation().reportSemanticError(TIMEOUTWITHSENDERREDIRECT);
            }
        } else {
            if (portType != null) {
                final PortTypeBody body = portType.getPortBody();
                if (OperationModes.OP_Message.equals(body.getOperationMode())) {
                    portReference.getLocation().reportSemanticError(MessageFormat.format(MESSAGEPORT, statementName, portType.getTypename()));
                } else if (!body.catchAllowed(timestamp)) {
                    portReference.getLocation().reportSemanticError(MessageFormat.format(PORTWITHOUTEXCEPTIONSUPPORT, portType.getTypename()));
                }
            }
        }
        if (redirectValue != null) {
            redirectValue.getLocation().reportSemanticError(VALUEREDIRECTWITHOUTPARAMETER);
            Port_Utility.checkValueRedirect(timestamp, redirectValue, null);
        }
    } else {
        Signature_Type signature = Port_Utility.checkSignatureReference(timestamp, signatureReference);
        if (portType != null) {
            final PortTypeBody body = portType.getPortBody();
            if (OperationModes.OP_Message.equals(body.getOperationMode())) {
                portReference.getLocation().reportSemanticError(MessageFormat.format(MESSAGEPORT, statementName, portType.getTypename()));
            } else if (body.catchAllowed(timestamp)) {
                final TypeSet outSignatures = body.getOutSignatures();
                if (signature != null) {
                    if (!outSignatures.hasType(timestamp, signature)) {
                        signatureReference.getLocation().reportSemanticError(MessageFormat.format(MISSINGSIGNATURE, signature.getTypename(), portType.getTypename()));
                    }
                } else if (outSignatures.getNofTypes() == 1) {
                    signature = (Signature_Type) outSignatures.getTypeByIndex(0).getTypeRefdLast(timestamp);
                }
            } else {
                portReference.getLocation().reportSemanticError(MessageFormat.format(PORTWITHOUTEXCEPTIONSUPPORT, portType.getTypename()));
            }
        } else if (portReference == null) {
            if (parameter != null) {
                parameter.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHPARAMETER, statementName));
            }
            if (redirectValue != null) {
                redirectValue.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHVALUEREDIRECT, statementName));
            }
        }
        // the receive parameter must also be present
        IType exceptionType = null;
        boolean exceptionTypeDetermined = false;
        final boolean[] valueRedirectChecked = new boolean[] { false };
        if (signature != null) {
            final SignatureExceptions exceptions = signature.getSignatureExceptions();
            if (exceptions == null) {
                signatureReference.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREWITHOUTEXCEPTIONS, signature.getTypename()));
            } else {
                if (exceptions.getNofExceptions() == 1) {
                    exceptionType = exceptions.getExceptionByIndex(0);
                } else if (parameter != null) {
                    exceptionType = Port_Utility.getIncomingType(timestamp, parameter, redirectValue, valueRedirectChecked);
                    if (exceptionType == null) {
                        parameter.getLocation().reportSemanticError(UNKNOWNEXCEPTIONTYPE);
                    } else {
                        final int nofCompatibleTypes = exceptions.getNofCompatibleExceptions(timestamp, exceptionType);
                        if (nofCompatibleTypes == 0) {
                            final String message = MessageFormat.format(MISSINGEXCEPTIONTYPE, exceptionType.getTypename(), signature.getTypename());
                            parameter.getLocation().reportSemanticError(message);
                        } else if (nofCompatibleTypes > 1) {
                            final String message = MessageFormat.format(AMBIGUOUSEXCEPTIONTYPE, exceptionType.getTypename(), signature.getTypename());
                            parameter.getLocation().reportSemanticError(message);
                        }
                    }
                }
                exceptionTypeDetermined = true;
            }
        }
        if (!exceptionTypeDetermined) {
            exceptionType = Port_Utility.getIncomingType(timestamp, parameter, redirectValue, valueRedirectChecked);
        }
        if (exceptionType != null && parameter != null) {
            parameter.check(timestamp, exceptionType);
            if (!valueRedirectChecked[0]) {
                Port_Utility.checkValueRedirect(timestamp, redirectValue, exceptionType);
            }
            exceptionType = exceptionType.getTypeRefdLast(timestamp);
            switch(exceptionType.getTypetype()) {
                case TYPE_SIGNATURE:
                    parameter.getLocation().reportSemanticError(MessageFormat.format(EXCEPTIONPARAMEXPECTED1, exceptionType.getTypename()));
                    break;
                case TYPE_PORT:
                    parameter.getLocation().reportSemanticError(MessageFormat.format(EXCEPTIONPARAMEXPECTED2, exceptionType.getTypename()));
                    break;
                case TYPE_DEFAULT:
                    parameter.getLocation().reportSemanticError(EXCEPTIONPARAMEXPECTED3);
                    break;
                default:
                    // accept it
                    break;
            }
        }
    }
    Port_Utility.checkFromClause(timestamp, statement, portType, fromClause, redirectSender);
}
Also used : SignatureExceptions(org.eclipse.titan.designer.AST.TTCN3.types.SignatureExceptions) Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) TypeSet(org.eclipse.titan.designer.AST.TTCN3.types.TypeSet) Port_Type(org.eclipse.titan.designer.AST.TTCN3.types.Port_Type) PortTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody) IType(org.eclipse.titan.designer.AST.IType)

Example 20 with TemplateInstance

use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.

the class Port_Utility method checkFromClause.

/**
 * Checks a from clause reference and a sender redirect to see if they
 * really references valid component types.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param source
 *                the source statement to report errors to.
 * @param portType
 *                the type of the port used in the statement. Used to
 *                find the address type in effect.
 * @param fromClause
 *                the from clause to check
 * @param redirectSender
 *                the sender redirect to check.
 */
public static void checkFromClause(final CompilationTimeStamp timestamp, final Statement source, final Port_Type portType, final TemplateInstance fromClause, final Reference redirectSender) {
    IType addressType = null;
    if (portType != null) {
        addressType = portType.getPortBody().getAddressType(timestamp);
    } else if (source != null && source.getMyStatementBlock() != null) {
        final Module module = source.getMyStatementBlock().getModuleScope();
        if (module != null && module_type.TTCN3_MODULE.equals(module.getModuletype())) {
            addressType = ((TTCN3Module) module).getAddressType(timestamp);
        }
    }
    boolean senderRedirectChecked = false;
    IType fromClauseType = null;
    if (fromClause != null) {
        fromClauseType = fromClause.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
        ITTCN3Template templateBody = fromClause.getTemplateBody();
        if (fromClauseType == null) {
            if (addressType != null) {
                templateBody = addressType.checkThisTemplateRef(timestamp, templateBody);
            } else {
                templateBody = templateBody.setLoweridToReference(timestamp);
            }
            fromClauseType = templateBody.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
        }
        if (fromClauseType == null) {
            fromClauseType = checkSenderRedirect(timestamp, addressType, redirectSender);
            senderRedirectChecked = true;
        }
        if (fromClauseType == null) {
            // trying to figure out whether the template is
            // a component reference or an SUT address
            boolean isComponentReference;
            if (Type_type.TYPE_COMPONENT.equals(templateBody.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_TEMPLATE))) {
                isComponentReference = true;
            } else {
                switch(templateBody.getTemplatetype()) {
                    case SPECIFIC_VALUE:
                        // treat 'null' as component
                        // reference
                        isComponentReference = Value_type.TTCN3_NULL_VALUE.equals(((SpecificValue_Template) templateBody).getSpecificValue().getValuetype());
                        break;
                    case ANY_VALUE:
                    case ANY_OR_OMIT:
                        isComponentReference = true;
                        break;
                    default:
                        isComponentReference = false;
                        break;
                }
            }
            if (isComponentReference) {
                // the argument is a component
                // reference: get a pool type
                fromClauseType = TypeFactory.createType(Type_type.TYPE_COMPONENT);
            } else if (addressType != null) {
                // the argument is not a component
                // reference: try the address type
                fromClauseType = addressType;
            }
        }
        if (fromClauseType != null) {
            fromClause.check(timestamp, fromClauseType);
            if (addressType == null || !addressType.isCompatible(timestamp, fromClauseType, null, null, null)) {
                // from_clause_type must be a component
                // type
                final IType last = fromClauseType.getTypeRefdLast(timestamp);
                if (last.getIsErroneous(timestamp)) {
                    fromClauseType = null;
                } else if (Type_type.TYPE_COMPONENT.equals(last.getTypetype())) {
                    if (Template_type.SPECIFIC_VALUE.equals(templateBody.getTemplatetype())) {
                        checkComponentReference(timestamp, source, ((SpecificValue_Template) templateBody).getSpecificValue(), true, true);
                    }
                } else {
                    final String message = MessageFormat.format("The type of the template should be a component type {0} instead of `{1}''", (addressType == null) ? "" : "or the `address' type ", fromClauseType.getTypename());
                    fromClause.getLocation().reportSemanticError(message);
                    fromClauseType = null;
                }
            }
        } else {
            fromClause.getLocation().reportSemanticError("Cannot determine the type of the template");
        }
    }
    if (!senderRedirectChecked) {
        final IType senderRedirectType = checkSenderRedirect(timestamp, addressType, redirectSender);
        if (fromClauseType != null && senderRedirectType != null && !fromClauseType.isIdentical(timestamp, senderRedirectType)) {
            final String message = MessageFormat.format("The types in `from'' clause and `sender'' redirect are not the same: `{0}'' was expected instead of `{1}''", fromClauseType.getTypename(), senderRedirectType.getTypename());
            senderRedirectType.getLocation().reportSemanticError(message);
        }
    }
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Module(org.eclipse.titan.designer.AST.Module) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)29 IType (org.eclipse.titan.designer.AST.IType)26 IValue (org.eclipse.titan.designer.AST.IValue)16 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)13 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)13 TemplateInstance (org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance)10 Reference (org.eclipse.titan.designer.AST.Reference)9 Assignment (org.eclipse.titan.designer.AST.Assignment)8 ISubReference (org.eclipse.titan.designer.AST.ISubReference)8 TTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)7 Template (org.eclipse.jface.text.templates.Template)6 Def_Var_Template (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template)6 Referenced_Template (org.eclipse.titan.designer.AST.TTCN3.templates.Referenced_Template)5 Port_Type (org.eclipse.titan.designer.AST.TTCN3.types.Port_Type)5 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)5 Type (org.eclipse.titan.designer.AST.Type)5 PortTypeBody (org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody)4 Signature_Type (org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type)4 TypeSet (org.eclipse.titan.designer.AST.TTCN3.types.TypeSet)4 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)3