use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method getOutgoingType.
/**
* Calculates the type of a template instance when it was to be used as
* a parameter of a send statement.
*
* @param timestamp
* the timestamp of the actual semantic check.
* @param templateInstance
* the template instance whose type needs to be
* calculated.
*
* @return the the type of a template instance when it was to be used as
* a parameter of a sending statement
*/
public static IType getOutgoingType(final CompilationTimeStamp timestamp, final TemplateInstance templateInstance) {
final IType result = templateInstance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
if (result != null) {
return result.getTypeRefdLast(timestamp);
}
ITTCN3Template template = templateInstance.getTemplateBody();
template = template.setLoweridToReference(timestamp);
return template.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method getIncomingType.
/**
* Calculates the type of a template instance when it was to be used as
* a parameter of a receiving statement (receive / trigger /
* check-receive).
*
* @param timestamp
* the timestamp of the actual build cycle.
* @param templateInstance
* the template instance whose type needs to be
* calculated.
* @param valueRedirect
* the value redirect of the receiving statement to help
* the identification of the type.
* @param valueRedirectChecked
* after the function executed this will store whether
* the execution has called the checking of value
* redirect. This has to be an array of 1 in length.
*
* @return the the type of a template instance when it was to be used as
* a parameter of a receiving statement
*/
public static IType getIncomingType(final CompilationTimeStamp timestamp, final TemplateInstance templateInstance, final Reference valueRedirect, final boolean[] valueRedirectChecked) {
IType result = templateInstance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
if (result != null) {
return result;
}
result = checkValueRedirect(timestamp, valueRedirect, null);
valueRedirectChecked[0] = true;
if (result != null) {
return result;
}
final ITTCN3Template template = templateInstance.getTemplateBody();
final ITTCN3Template temp = template.setLoweridToReference(timestamp);
return temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance 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);
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.
the class All_From_Template method checkThisTemplateParameterizedReference.
private boolean checkThisTemplateParameterizedReference(final Reference reference, final Assignment lhs) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.isEmpty() || !(subreferences.get(0) instanceof ParameterisedSubReference)) {
return false;
}
final ParameterisedSubReference subReference = (ParameterisedSubReference) subreferences.get(0);
final ActualParameterList actualParameterList = subReference.getActualParameters();
if (actualParameterList == null) {
return false;
}
final int nofParameters = actualParameterList.getNofParameters();
for (int i = 0; i < nofParameters; i++) {
Reference parameterReference = null;
final ActualParameter actualParameter = actualParameterList.getParameter(i);
if (actualParameter instanceof Template_ActualParameter) {
TemplateInstance templateInstance = ((Template_ActualParameter) actualParameter).getTemplateInstance();
ITTCN3Template template = templateInstance.getTemplateBody();
template = template.setLoweridToReference(CompilationTimeStamp.getBaseTimestamp());
if (template.getTemplatetype() == Template_type.TEMPLATE_REFD) {
parameterReference = ((Referenced_Template) template).getReference();
}
} else if (actualParameter instanceof Referenced_ActualParameter) {
parameterReference = ((Referenced_ActualParameter) actualParameter).getReference();
}
if (parameterReference != null) {
final Assignment assignment = parameterReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
if (assignment == lhs) {
return true;
}
// check their parameters as well
switch(assignment.getAssignmentType()) {
case A_TEMPLATE:
case A_FUNCTION_RVAL:
case A_FUNCTION_RTEMP:
case A_EXT_FUNCTION_RVAL:
case A_EXT_FUNCTION_RTEMP:
if (checkThisTemplateParameterizedReference(parameterReference, lhs)) {
return true;
}
break;
default:
break;
}
}
}
return false;
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.
the class LogArgument method check.
/**
* Does the semantic checking of the log argument. This is the main
* entry point.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
*/
public void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (templateInstance == null) {
return;
}
lastTimeChecked = timestamp;
isErroneous = false;
ITTCN3Template template = templateInstance.getTemplateBody();
template = template.setLoweridToReference(timestamp);
if (template.getIsErroneous(timestamp)) {
isErroneous = true;
return;
}
if (templateInstance.getType() == null && templateInstance.getDerivedReference() == null && template.isValue(timestamp)) {
final IValue value = template.getValue();
final IType gov = template.getMyGovernor();
if (gov != null) {
value.setMyGovernor(gov);
}
checkValue(timestamp, value);
} else {
IType governor = templateInstance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
if (governor == null) {
governor = template.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
}
if (governor == null) {
if (!template.getIsErroneous(timestamp)) {
getLocation().reportSemanticError("Cannot determine the type of the argument");
}
isErroneous = true;
} else {
internalLogArgument = new TemplateInstance_InternalLogArgument(templateInstance);
templateInstance.check(timestamp, governor);
}
}
}
Aggregations