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);
}
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;
}
Aggregations