Search in sources :

Example 6 with TypeSet

use of org.eclipse.titan.designer.AST.TTCN3.types.TypeSet in project titan.EclipsePlug-ins by eclipse.

the class Raise_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    final Port_Type portType = Port_Utility.checkPortReference(timestamp, this, portReference);
    IType signature = Port_Utility.checkSignatureReference(timestamp, signatureReference);
    if (portType != null) {
        final PortTypeBody portTypeBody = portType.getPortBody();
        final TypeSet inSignatures = portTypeBody.getInSignatures();
        if (OperationModes.OP_Message.equals(portTypeBody.getOperationMode())) {
            portReference.getLocation().reportSemanticError(MessageFormat.format(RAISEONPORT, portType.getTypename()));
        } else if (inSignatures != null) {
            if (signature != null) {
                if (!inSignatures.hasType(timestamp, signature)) {
                    portReference.getLocation().reportSemanticError(MessageFormat.format(SIGNATURENOTPRESENT, signature.getTypename(), portType.getTypename()));
                }
            } else if (inSignatures.getNofTypes() == 1) {
                signature = inSignatures.getTypeByIndex(0).getTypeRefdLast(timestamp);
            }
        } else {
            portReference.getLocation().reportSemanticError(MessageFormat.format(NOINCOMINGSIGNATURES, portType.getTypename()));
        }
    }
    IType exception = null;
    boolean exceptionDetermined = false;
    if (signature != null) {
        final SignatureExceptions exceptions = ((Signature_Type) signature).getSignatureExceptions();
        if (exceptions == null) {
            signatureReference.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREWITHOUTEXCEPTIONS, signature.getTypename()));
        } else {
            if (exceptions.getNofExceptions() == 1) {
                exception = exceptions.getExceptionByIndex(0);
            } else {
                exception = Port_Utility.getOutgoingType(timestamp, parameter);
                if (exception == null) {
                    parameter.getLocation().reportSemanticError(UNKNOWNEXCEPTIONTYPE);
                } else {
                    final int nofCompatibleTypes = exceptions.getNofCompatibleExceptions(timestamp, exception);
                    if (nofCompatibleTypes == 0) {
                        parameter.getLocation().reportSemanticError(MessageFormat.format(TYPENOTONEXCEPTIONLIST, exception.getTypename(), signature.getTypename()));
                    } else if (nofCompatibleTypes > 1) {
                        parameter.getLocation().reportSemanticError(MessageFormat.format(AMBIGUOUSEXCEPTION, exception.getTypename(), signature.getTypename()));
                    }
                }
            }
            exceptionDetermined = true;
        }
    }
    if (!exceptionDetermined) {
        exception = Port_Utility.getOutgoingType(timestamp, parameter);
    }
    if (exception != null) {
        parameter.check(timestamp, exception);
        exception = exception.getTypeRefdLast(timestamp);
        switch(exception.getTypetype()) {
            case TYPE_SIGNATURE:
                parameter.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREEXCEPTION, exception.getTypename()));
                break;
            case TYPE_PORT:
                parameter.getLocation().reportSemanticError(MessageFormat.format(PORTEXCEPTION, exception.getTypename()));
                break;
            case TYPE_DEFAULT:
                parameter.getLocation().reportSemanticError(MessageFormat.format(DEFAULTEXCEPTION, exception.getTypename()));
                break;
            default:
                break;
        }
    }
    parameter.getTemplateBody().checkSpecificValue(timestamp, false);
    Port_Utility.checkToClause(timestamp, this, portType, toClause);
    lastTimeChecked = timestamp;
}
Also used : SignatureExceptions(org.eclipse.titan.designer.AST.TTCN3.types.SignatureExceptions) 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 7 with TypeSet

use of org.eclipse.titan.designer.AST.TTCN3.types.TypeSet in project titan.EclipsePlug-ins by eclipse.

the class Receive_Port_Statement method checkReceivingStatement.

/**
 * Checks a port receiving statement.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param origin
 *                the original statement.
 * @param statementName
 *                the name of the original statement.
 * @param portReference
 *                the port reference.
 * @param receiveParameter
 *                the receiving parameter.
 * @param fromClause
 *                the from clause of the statement
 * @param redirectValue
 *                the redirection value of the statement.
 * @param redirectSender
 *                the sender redirection of the statement.
 */
public static void checkReceivingStatement(final CompilationTimeStamp timestamp, final Statement origin, final String statementName, final Reference portReference, final TemplateInstance receiveParameter, final TemplateInstance fromClause, final Reference redirectValue, final Reference redirectSender) {
    final Port_Type portType = Port_Utility.checkPortReference(timestamp, origin, portReference);
    if (receiveParameter == null) {
        if (portType != null && Type_type.TYPE_PORT.equals(portType.getTypetype())) {
            final PortTypeBody body = portType.getPortBody();
            if (OperationModes.OP_Procedure.equals(body.getOperationMode())) {
                portReference.getLocation().reportSemanticError(MessageFormat.format(MESSAGEBASEOPERATIONONPROCEDUREPORT, statementName, portType.getTypename()));
            } else if (body.getInMessages() == null) {
                portReference.getLocation().reportSemanticError(MessageFormat.format(NOINCOMINGMESSAGETYPES, portType.getTypename()));
            }
        }
        if (redirectValue != null) {
            redirectValue.getLocation().reportSemanticError(VALUEREDIRECTWITHOUTRECEIVEPARAMETER);
            Port_Utility.checkValueRedirect(timestamp, redirectValue, null);
        }
    } else {
        // determine the type of the incoming message
        IType messageType = null;
        boolean messageTypeDetermined = false;
        final boolean[] valueRedirectChecked = new boolean[] { false };
        if (portType != null) {
            // the port type is known
            final PortTypeBody portTypeBody = portType.getPortBody();
            final TypeSet inMessages = portTypeBody.getInMessages();
            if (OperationModes.OP_Procedure.equals(portTypeBody.getOperationMode())) {
                portReference.getLocation().reportSemanticError(MessageFormat.format(RECEIVEONPORT, statementName, portType.getTypename()));
            } else if (inMessages != null) {
                if (inMessages.getNofTypes() == 1) {
                    messageType = inMessages.getTypeByIndex(0);
                } else {
                    messageType = Port_Utility.getIncomingType(timestamp, receiveParameter, redirectValue, valueRedirectChecked);
                    if (messageType == null) {
                        receiveParameter.getLocation().reportSemanticError(UNKNOWNINCOMINGMESSAGE);
                    } else {
                        final int nofCompatibleTypes = inMessages.getNofCompatibleTypes(timestamp, messageType);
                        if (nofCompatibleTypes == 0) {
                            receiveParameter.getLocation().reportSemanticError(MessageFormat.format(TYPENOTPRESENT, messageType.getTypename(), portType.getTypename()));
                        } else if (nofCompatibleTypes > 1) {
                            receiveParameter.getLocation().reportSemanticError(MessageFormat.format(TYPEISAMBIGUOUS, messageType.getTypename(), portType.getTypename()));
                        }
                    }
                }
                messageTypeDetermined = true;
            } else {
                portReference.getLocation().reportSemanticError(MessageFormat.format(NOINCOMINGMESSAGETYPES, portType.getTypename()));
            }
        } else if (portReference == null) {
            // any port
            receiveParameter.getLocation().reportSemanticError(MessageFormat.format(ANYPORTWITHPARAMETER, statementName));
            if (redirectValue != null) {
                redirectValue.getLocation().reportSemanticError(MessageFormat.format(RECEIVEWITHVALUEREDIRECT, statementName));
            }
        }
        if (!messageTypeDetermined) {
            messageType = Port_Utility.getIncomingType(timestamp, receiveParameter, redirectValue, valueRedirectChecked);
        }
        if (messageType != null) {
            receiveParameter.check(timestamp, messageType);
            if (!valueRedirectChecked[0]) {
                Port_Utility.checkValueRedirect(timestamp, redirectValue, messageType);
            }
        }
    }
    Port_Utility.checkFromClause(timestamp, origin, portType, fromClause, redirectSender);
}
Also used : 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 8 with TypeSet

use of org.eclipse.titan.designer.AST.TTCN3.types.TypeSet in project titan.EclipsePlug-ins by eclipse.

the class Call_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    final Port_Type portType = Port_Utility.checkPortReference(timestamp, this, portReference);
    if (parameter == null) {
        return;
    }
    IType signatureType = null;
    boolean signatureTypeDetermined = false;
    if (portType != null) {
        // the port type is known
        final PortTypeBody portTypeBody = portType.getPortBody();
        final TypeSet outSignatures = portTypeBody.getOutSignatures();
        if (OperationModes.OP_Message.equals(portTypeBody.getOperationMode())) {
            portReference.getLocation().reportSemanticError(MessageFormat.format(SENDONPORT, portType.getTypename()));
        } else if (outSignatures != null) {
            if (outSignatures.getNofTypes() == 1) {
                signatureType = outSignatures.getTypeByIndex(0);
            } else {
                signatureType = Port_Utility.getOutgoingType(timestamp, parameter);
                if (signatureType == null) {
                    parameter.getLocation().reportSemanticError(UNKNOWNSIGNATURE);
                } else {
                    if (!outSignatures.hasType(timestamp, signatureType)) {
                        parameter.getLocation().reportSemanticError(MessageFormat.format(TYPENOTPRESENT, signatureType.getTypename(), portType.getTypename()));
                    }
                }
            }
            signatureTypeDetermined = true;
        } else {
            portReference.getLocation().reportSemanticError(MessageFormat.format(NOOUTGOINGSIGNATURETYPES, portType.getTypename()));
        }
    }
    if (!signatureTypeDetermined) {
        signatureType = Port_Utility.getOutgoingType(timestamp, parameter);
    }
    boolean isNonblocking = false;
    if (signatureType != null) {
        parameter.check(timestamp, signatureType);
        signatureType = signatureType.getTypeRefdLast(timestamp);
        switch(signatureType.getTypetype()) {
            case TYPE_SIGNATURE:
                ((Signature_Type) signatureType).checkThisTemplate(timestamp, parameter.getTemplateBody(), false, false, null);
                isNonblocking = ((Signature_Type) signatureType).isNonblocking();
                break;
            default:
                parameter.getLocation().reportSemanticError(MessageFormat.format(CALLPARAMETERNOTSIGNATURE, signatureType.getTypename()));
                break;
        }
        if (isNonblocking) {
            if (timerValue != null) {
                timerValue.getLocation().reportSemanticError(MessageFormat.format(NONBLOCKINGWITHTIMER, signatureType.getTypename()));
            } else if (noWait) {
                location.reportSemanticError(MessageFormat.format(NONBLOCKINGWITHNOWAIT, signatureType.getTypename()));
            }
            if (altGuards != null) {
                location.reportSemanticError(MessageFormat.format(NONBLOCKINGWITHRESPONSEPART, signatureType.getTypename()));
            }
        } else if (noWait) {
            if (altGuards != null) {
                location.reportSemanticError(NOWAITWITHRESPONSEPART);
            }
        } else {
            if (!getIsErroneous() && altGuards == null) {
                location.reportSemanticError(RESPONSEPARTMISSING);
            }
        }
    }
    if (timerValue != null) {
        timerValue.setLoweridToReference(timestamp);
        final Type_type temporalType = timerValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        switch(temporalType) {
            case TYPE_REAL:
                final IValue last = timerValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
                if (Value_type.REAL_VALUE.equals(last.getValuetype()) && !last.getIsErroneous(timestamp)) {
                    final double temp = ((Real_Value) last).getValue();
                    if (temp < 0) {
                        timerValue.getLocation().reportSemanticError(MessageFormat.format(CALLTIMERNEGATIVE, temp));
                    }
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous();
                break;
            default:
                if (!isErroneous) {
                    location.reportSemanticError(FLOATTIMEREXPECTED);
                }
                break;
        }
    }
    Port_Utility.checkToClause(timestamp, this, portType, toClause);
    if (altGuards != null) {
        checkCallBody(timestamp, portType, signatureType);
    }
    lastTimeChecked = timestamp;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) 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) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) PortTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody) IType(org.eclipse.titan.designer.AST.IType) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Aggregations

IType (org.eclipse.titan.designer.AST.IType)8 PortTypeBody (org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody)8 Port_Type (org.eclipse.titan.designer.AST.TTCN3.types.Port_Type)8 TypeSet (org.eclipse.titan.designer.AST.TTCN3.types.TypeSet)8 Signature_Type (org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type)6 IValue (org.eclipse.titan.designer.AST.IValue)2 SignatureExceptions (org.eclipse.titan.designer.AST.TTCN3.types.SignatureExceptions)2 Type (org.eclipse.titan.designer.AST.Type)2 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)1 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)1 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)1