Search in sources :

Example 1 with SignatureException

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

the class Signature_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String genName = getGenNameOwn();
    final ArrayList<SignatureParameter> parameters = new ArrayList<SignatureParameter>();
    for (int i = 0; i < formalParList.getNofParameters(); i++) {
        final SignatureFormalParameter formalPar = formalParList.getParameterByIndex(i);
        final Type type = formalPar.getType();
        SignatureGenerator.signatureParamaterDirection direction;
        switch(formalPar.getDirection()) {
            case PARAM_OUT:
                direction = signatureParamaterDirection.PAR_OUT;
                break;
            case PARAM_INOUT:
                direction = signatureParamaterDirection.PAR_INOUT;
                break;
            default:
                direction = signatureParamaterDirection.PAR_IN;
                break;
        }
        final SignatureParameter temp = new SignatureParameter(direction, type.getGenNameValue(aData, source, myScope), type.getGenNameTemplate(aData, source, myScope), formalPar.getIdentifier().getName());
        parameters.add(temp);
    }
    SignatureReturnType signatueReturnType = null;
    if (returnType != null) {
        signatueReturnType = new SignatureReturnType(returnType.getGenNameValue(aData, source, myScope), returnType.getGenNameTemplate(aData, source, myScope));
    }
    final ArrayList<SignatureException> signatureExceptions = new ArrayList<SignatureGenerator.SignatureException>();
    if (exceptions != null) {
        for (int i = 0; i < exceptions.getNofExceptions(); i++) {
            final Type exceptionType = exceptions.getExceptionByIndex(i);
            final IType last = exceptionType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
            final SignatureException temp = new SignatureException(last.getGenNameValue(aData, source, myScope), last.getGenNameTemplate(aData, source, myScope), last.getFullName());
            signatureExceptions.add(temp);
        }
    }
    final SignatureDefinition def = new SignatureDefinition(genName, getFullName(), parameters, signatueReturnType, noBlock, signatureExceptions);
    SignatureGenerator.generateClasses(aData, source, def);
    if (hasDoneAttribute()) {
        generateCodeDone(aData, source);
    }
    if (subType != null) {
        subType.generateCode(aData, source);
    }
    generateCodeForCodingHandlers(aData, source);
}
Also used : SignatureDefinition(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureDefinition) ArrayList(java.util.ArrayList) SignatureException(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureException) IType(org.eclipse.titan.designer.AST.IType) SignatureReturnType(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureReturnType) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) SignatureParameter(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureParameter) SignatureGenerator.signatureParamaterDirection(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.signatureParamaterDirection) SignatureReturnType(org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureReturnType)

Example 2 with SignatureException

use of org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureException 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)

Aggregations

IType (org.eclipse.titan.designer.AST.IType)2 ArrayList (java.util.ArrayList)1 PortTypeBody (org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody)1 Port_Type (org.eclipse.titan.designer.AST.TTCN3.types.Port_Type)1 SignatureExceptions (org.eclipse.titan.designer.AST.TTCN3.types.SignatureExceptions)1 SignatureDefinition (org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureDefinition)1 SignatureException (org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureException)1 SignatureParameter (org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureParameter)1 SignatureReturnType (org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.SignatureReturnType)1 SignatureGenerator.signatureParamaterDirection (org.eclipse.titan.designer.AST.TTCN3.types.SignatureGenerator.signatureParamaterDirection)1 Signature_Type (org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type)1 TypeSet (org.eclipse.titan.designer.AST.TTCN3.types.TypeSet)1 Type (org.eclipse.titan.designer.AST.Type)1