use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template in project titan.EclipsePlug-ins by eclipse.
the class DecodeExpression method checkFirstExpressionOperand.
private void checkFirstExpressionOperand(final CompilationTimeStamp timestamp) {
final Assignment temporalAssignment = reference1.getRefdAssignment(timestamp, true);
if (temporalAssignment == null) {
setIsErroneous(true);
return;
}
switch(temporalAssignment.getAssignmentType()) {
case A_CONST:
case A_EXT_CONST:
case A_MODULEPAR:
case A_TEMPLATE:
reference1.getLocation().reportSemanticError(MessageFormat.format("Reference to `{0}'' cannot be used as the first operand of the `decvalue'' operation", temporalAssignment.getAssignmentName()));
setIsErroneous(true);
break;
case A_VAR:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
break;
case A_VAR_TEMPLATE:
case A_PAR_TEMP_IN:
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
{
final Referenced_Template template = new Referenced_Template(reference1);
template.setMyScope(getMyScope());
template.setFullNameParent(new BridgingNamedNode(this, ".<operand>"));
final ITTCN3Template last = template.getTemplateReferencedLast(timestamp);
if (!Template_type.SPECIFIC_VALUE.equals(last.getTemplatetype()) && last != template) {
reference1.getLocation().reportSemanticError(MessageFormat.format("Specific value template was expected instead of `{0}''", last.getTemplateTypeName()));
setIsErroneous(true);
return;
}
break;
}
default:
reference1.getLocation().reportSemanticError(MessageFormat.format("Reference to `{0}'' cannot be used as the first operand of the `decvalue' operation", temporalAssignment.getAssignmentName()));
setIsErroneous(true);
return;
}
final IType temporalType = temporalAssignment.getType(timestamp).getFieldType(timestamp, reference1, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
if (temporalType == null) {
setIsErroneous(true);
return;
}
if (temporalType.getTypeRefdLast(timestamp).getTypetype() != Type_type.TYPE_BITSTRING) {
if (!isErroneous) {
reference1.getLocation().reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
return;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template in project titan.EclipsePlug-ins by eclipse.
the class Return_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
genRestrictionCheck = false;
final Definition definition = myStatementBlock.getMyDefinition();
if (definition == null) {
location.reportSemanticError(USAGEINCONTROLPART);
return;
}
switch(definition.getAssignmentType()) {
case A_FUNCTION:
if (template != null) {
template.getLocation().reportSemanticError(UNEXPECTEDRETURNVALUE);
}
break;
case A_FUNCTION_RVAL:
final Type returnType = ((Def_Function) definition).getType(timestamp);
if (template == null) {
location.reportSemanticError(MessageFormat.format(MISSINGVALUE, returnType.getTypename()));
break;
}
if (!template.isValue(timestamp)) {
template.getLocation().reportSemanticError(SPECIFICVALUEEXPECTED);
break;
}
// General:
template.setMyGovernor(returnType);
final IValue value = template.getValue();
if (value != null) {
value.setMyGovernor(returnType);
returnType.checkThisValueRef(timestamp, value);
returnType.checkThisValue(timestamp, value, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
}
break;
case A_FUNCTION_RTEMP:
if (template == null) {
location.reportSemanticError(MessageFormat.format(MISSINGTEMPLATE, ((Def_Function) definition).getType(timestamp).getTypename()));
} else {
final Type returnType1 = ((Def_Function) definition).getType(timestamp);
template.setMyGovernor(returnType1);
final ITTCN3Template temporalTemplate1 = returnType1.checkThisTemplateRef(timestamp, template, Expected_Value_type.EXPECTED_TEMPLATE, null);
temporalTemplate1.checkThisTemplateGeneric(timestamp, returnType1, true, /* isModified */
true, /* allowOmit */
true, /* allowAnyOrOmit */
true, /* subCheck */
true, /* implicitOmit */
null);
genRestrictionCheck = TemplateRestriction.check(timestamp, definition, temporalTemplate1, null);
}
break;
case A_ALTSTEP:
if (template != null) {
template.getLocation().reportSemanticError(ALTSTEPRETURNINGVALUE);
}
break;
default:
location.reportSemanticError(MessageFormat.format(UNEXPETEDRETURNSTATEMENT, definition.getAssignmentName()));
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template 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.ITTCN3Template 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.ITTCN3Template 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;
}
Aggregations