use of org.eclipse.titan.designer.AST.TTCN3.templates.ValueList_Template in project titan.EclipsePlug-ins by eclipse.
the class Assignment_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
isErroneous = false;
selfReference = false;
templateRestriction = Restriction_type.TR_NONE;
generateRestrictionCheck = false;
if (reference == null) {
return;
}
reference.setUsedOnLeftHandSide();
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment == null || assignment.getIsErroneous()) {
isErroneous = true;
return;
}
if (template == null) {
return;
}
switch(assignment.getAssignmentType()) {
case A_PAR_VAL_IN:
((FormalParameter) assignment).useAsLValue(reference);
if (template.isValue(timestamp)) {
// TODO: isValue should be checked within the previous line! This is double check!
final IValue temporalValue = template.getValue();
checkVarAssignment(timestamp, assignment, temporalValue);
template.setMyGovernor(temporalValue.getMyGovernor());
break;
} else if (Template_type.VALUE_LIST.equals(template.getTemplatetype()) && ((ValueList_Template) template).getNofTemplates() == 1) {
// TODO: convert (x) to x to compilation!
break;
} else {
template.getLocation().reportSemanticError(TEMPLATEASSIGNMENTTOVALUE);
template.setIsErroneous(true);
return;
}
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
case A_PAR_VAL:
((FormalParameter) assignment).setWritten();
if (template.isValue(timestamp)) {
// TODO: isValue should be checked within the previous line! This is double check!
final IValue temporalValue = template.getValue();
checkVarAssignment(timestamp, assignment, temporalValue);
template.setMyGovernor(temporalValue.getMyGovernor());
break;
} else if (Template_type.VALUE_LIST.equals(template.getTemplatetype()) && ((ValueList_Template) template).getNofTemplates() == 1) {
// TODO: convert (x) to x to compilation!
break;
} else {
template.getLocation().reportSemanticError(TEMPLATEASSIGNMENTTOVALUE);
template.setIsErroneous(true);
return;
}
// break
case A_VAR:
((Def_Var) assignment).setWritten();
if (template.getIsErroneous(timestamp)) {
return;
}
final IValue temporalValue = template.getValue();
if (temporalValue != null) {
checkVarAssignment(timestamp, assignment, temporalValue);
template.setMyGovernor(temporalValue.getMyGovernor());
break;
} else if (Template_type.VALUE_LIST.equals(template.getTemplatetype()) && ((ValueList_Template) template).getNofTemplates() == 1) {
break;
} else {
template.getLocation().reportSemanticError(TEMPLATEASSIGNMENTTOVALUE);
template.setIsErroneous(true);
return;
}
case A_PAR_TEMP_IN:
((FormalParameter) assignment).useAsLValue(reference);
checkTemplateAssignment(timestamp, assignment, Expected_Value_type.EXPECTED_TEMPLATE, null);
break;
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
((FormalParameter) assignment).setWritten();
checkTemplateAssignment(timestamp, assignment, Expected_Value_type.EXPECTED_TEMPLATE, null);
break;
case A_VAR_TEMPLATE:
((Def_Var_Template) assignment).setWritten();
checkTemplateAssignment(timestamp, assignment, Expected_Value_type.EXPECTED_TEMPLATE, null);
break;
default:
reference.getLocation().reportSemanticError(MessageFormat.format(VARIABLEREFERENCEEXPECTED, assignment.getAssignmentName()));
reference.setIsErroneous(true);
isErroneous = true;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ValueList_Template in project titan.EclipsePlug-ins by eclipse.
the class Integer_Type method checkThisTemplate.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisTemplate(final CompilationTimeStamp timestamp, final ITTCN3Template template, final boolean isModified, final boolean implicitOmit, final Assignment lhs) {
registerUsage(template);
template.setMyGovernor(this);
if (getIsErroneous(timestamp)) {
return false;
}
boolean selfReference = false;
switch(template.getTemplatetype()) {
case VALUE_RANGE:
final ValueRange range = ((Value_Range_Template) template).getValueRange();
final IValue lower = checkBoundary(timestamp, range.getMin(), BOUNDARY_TYPE.LOWER);
final IValue upper = checkBoundary(timestamp, range.getMax(), BOUNDARY_TYPE.UPPER);
range.setTypeType(getTypetypeTtcn3());
// Template references are not checked.
if (lower != null && Value.Value_type.INTEGER_VALUE.equals(lower.getValuetype()) && upper != null && Value.Value_type.INTEGER_VALUE.equals(upper.getValuetype())) {
if (!getIsErroneous(timestamp) && ((Integer_Value) lower).getValue() > ((Integer_Value) upper).getValue()) {
template.getLocation().reportSemanticError(INCORRECTBOUNDARIES);
template.setIsErroneous(true);
}
}
// TODO some checks are still missing
break;
case VALUE_LIST:
final ValueList_Template temp = (ValueList_Template) template;
for (int i = 0; i < temp.getNofTemplates(); i++) {
final TTCN3Template tmp = temp.getTemplateByIndex(i);
selfReference |= checkThisTemplate(timestamp, tmp, isModified, implicitOmit, lhs);
}
break;
case ANY_OR_OMIT:
case ANY_VALUE:
// Allowed
break;
default:
template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName()));
template.setIsErroneous(true);
}
if (template.getLengthRestriction() != null) {
template.getLocation().reportSemanticError(LENGTHRESTRICTIONNOTALLOWED);
template.setIsErroneous(true);
}
return selfReference;
}
Aggregations