use of org.eclipse.titan.designer.AST.TTCN3.templates.ValueRange in project titan.EclipsePlug-ins by eclipse.
the class ASN1_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;
}
if (Template_type.VALUE_RANGE.equals(template.getTemplatetype())) {
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());
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);
}
}
// TODO: some checks are still missing
} else {
template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName()));
}
if (template.getLengthRestriction() != null) {
template.getLocation().reportSemanticError(LENGTHRESTRICTIONNOTALLOWED);
}
return false;
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ValueRange in project titan.EclipsePlug-ins by eclipse.
the class Value_Range_Template method updateSyntax.
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
throw new ReParseException();
}
if (lengthRestriction != null) {
lengthRestriction.updateSyntax(reparser, false);
reparser.updateLocation(lengthRestriction.getLocation());
}
if (baseTemplate instanceof IIncrementallyUpdateable) {
((IIncrementallyUpdateable) baseTemplate).updateSyntax(reparser, false);
reparser.updateLocation(baseTemplate.getLocation());
} else if (baseTemplate != null) {
throw new ReParseException();
}
if (valueRange != null) {
valueRange.updateSyntax(reparser, false);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ValueRange in project titan.EclipsePlug-ins by eclipse.
the class Float_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;
}
if (Template_type.VALUE_RANGE.equals(template.getTemplatetype())) {
final ValueRange range = ((Value_Range_Template) template).getValueRange();
final IValue lower = checkBoundary(timestamp, range.getMin());
final IValue upper = checkBoundary(timestamp, range.getMax());
range.setTypeType(getTypetypeTtcn3());
if (lower != null && upper != null) {
if (((Real_Value) lower).getValue() > ((Real_Value) upper).getValue()) {
template.getLocation().reportSemanticError(INCORRECTBOUNDARIES);
}
}
// TODO: some checks are still missing
} else {
template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName()));
}
if (template.getLengthRestriction() != null) {
template.getLocation().reportSemanticError(LENGTHRESTRICTIONNOTALLOWED);
}
return false;
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ValueRange 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;
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ValueRange in project titan.EclipsePlug-ins by eclipse.
the class UniversalCharstring_Type method checkThisTemplateString.
/**
* Checks if the provided template is valid for the provided type.
* <p>
* The type must be equivalent with the TTCN-3 universal charstring type
*
* @param timestamp the time stamp of the actual semantic check cycle.
* @param type the universal charstring type used for the check.
* @param template the template to be checked by the type.
* @param isModified true if the template is a modified template
*/
public static void checkThisTemplateString(final CompilationTimeStamp timestamp, final Type type, final ITTCN3Template template, final boolean isModified) {
template.setMyGovernor(type);
PatternString ps = null;
switch(template.getTemplatetype()) {
case VALUE_RANGE:
{
final ValueRange range = ((Value_Range_Template) template).getValueRange();
final IValue lower = checkBoundary(timestamp, type, range.getMin(), template, "lower");
final IValue upper = checkBoundary(timestamp, type, range.getMax(), template, "upper");
range.setTypeType(type.getTypetypeTtcn3());
if (lower != null && upper != null) {
UniversalCharstring value1;
if (Value_type.CHARSTRING_VALUE.equals(lower.getValuetype())) {
value1 = new UniversalCharstring(((Charstring_Value) lower).getValue());
} else {
value1 = ((UniversalCharstring_Value) lower).getValue();
}
UniversalCharstring value2;
if (Value_type.CHARSTRING_VALUE.equals(upper.getValuetype())) {
value2 = new UniversalCharstring(((Charstring_Value) upper).getValue());
} else {
value2 = ((UniversalCharstring_Value) upper).getValue();
}
if (value1.compareWith(value2) > 0) {
template.getLocation().reportSemanticError(INCORRECTBOUNDARIES);
}
}
break;
}
case CSTR_PATTERN:
{
// Change the pattern type
final CharString_Pattern_Template cstrpt = (CharString_Pattern_Template) template;
ps = cstrpt.getPatternstring();
ps.setPatterntype(PatternType.UNIVCHARSTRING_PATTERN);
// FIXME might need some implementation
break;
}
case USTR_PATTERN:
// FIXME implement as soon as charstring pattern templates become handled
ps = ((UnivCharString_Pattern_Template) template).getPatternstring();
break;
default:
template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName(), type.getTypename()));
break;
}
}
Aggregations