Commit c900fa7d authored by Kristof Szabados's avatar Kristof Szabados
Browse files

bugfix: indexes were not checked

parent 74746fef
......@@ -471,11 +471,18 @@ public final class SequenceOf_Type extends AbstractOfType implements IReferencea
IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
IValue indexLast = index.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (indexLast.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(indexLast.getValuetype())) {
IType tempType = TypeFactory.createType(Type_type.TYPE_INTEGER);
tempType.check(timestamp);
indexLast.setMyGovernor(tempType);
IValue temporalValue = tempType.checkThisValueRef(timestamp, indexLast);
tempType.checkThisValue(timestamp, temporalValue, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE,
true, false, true, false, false));
if (indexLast.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(temporalValue.getValuetype())) {
checkHoles = false;
} else {
BigInteger tempIndex = ((Integer_Value) indexLast).getValueValue();
BigInteger tempIndex = ((Integer_Value) temporalValue).getValueValue();
if (tempIndex.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) == 1) {
index.getLocation().reportSemanticError(MessageFormat.format(
"A integer value less than `{0}'' was expected for indexing type `{1}'' instead of `{2}''",
......@@ -637,7 +644,15 @@ public final class SequenceOf_Type extends AbstractOfType implements IReferencea
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
IValue lastValue = indexValue.getValueRefdLast(timestamp, chain);
chain.release();
if (Value_type.INTEGER_VALUE.equals(lastValue.getValuetype())) {
IType tempType = TypeFactory.createType(Type_type.TYPE_INTEGER);
tempType.check(timestamp);
lastValue.setMyGovernor(tempType);
IValue temporalValue = tempType.checkThisValueRef(timestamp, lastValue);
tempType.checkThisValue(timestamp, temporalValue, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE,
true, false, true, false, false));
if (!temporalValue.getIsErroneous(timestamp) && Value_type.INTEGER_VALUE.equals(temporalValue.getValuetype())) {
long index = ((Integer_Value) lastValue).getValue();
if (index > Integer.MAX_VALUE) {
indexValue.getLocation().reportSemanticError(
......@@ -654,9 +669,6 @@ public final class SequenceOf_Type extends AbstractOfType implements IReferencea
indexMap.put(index, i);
}
}
} else {
indexValue.getLocation().reportSemanticError(INTEGERINDEXEXPECTED);
indexValue.setIsErroneous(true);
}
templateComponent.setMyGovernor(getOfType());
......
......@@ -1892,7 +1892,6 @@ public class AST_tests {
markersToCheck.add(new MarkerToCheck("A non-negative integer value was expected for indexing type `@specific_template_tests.myrecordofType' instead of `-1'", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("An integer value less than `2,147,483,647' was expected for indexing type `@specific_template_tests.myrecordofType' instead of `99,999,999,999,999,999'", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("Duplicate index value `1' for component `4' and `2'", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("The index should be an integer value", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("There is no visible definition with name `t' in module `specific_template_tests'", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 5;
markersToCheck.add(new MarkerToCheck("The default timer duration should be a float value", lineNum, IMarker.SEVERITY_ERROR));
......@@ -4546,7 +4545,6 @@ public class AST_tests {
markersToCheck.add(new MarkerToCheck("An integer value less than `2,147,483,647' was expected for indexing type `@template_assignment_tests.myrecordofType' instead of `99,999,999,999,999,999'", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("Duplicate index value `1' for component `4' and `2'", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("Reference to a value was expected instead of timer `TL_t'", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("The index should be an integer value", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("There are fewer (1) elements than it is allowed by the length restriction (at least 2)", ++lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("There are more ( 6) elements than it is allowed by the length restriction (5)", ++lineNum, IMarker.SEVERITY_ERROR));
lineNum += 23;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment