Aufgrund eines Security Updates wird GitLab heute zwischen 14:00 und 14:30 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to a security update GitLab will be temporarily unavailable between 2 and 2:30 today.

Commit f8e3572d authored by Sebastian Nickels's avatar Sebastian Nickels

VariableSymbol now checks if range contains input range instead of checking for equality of ranges

parent 5dc30390
Pipeline #172302 canceled with stages
......@@ -392,10 +392,12 @@ public class VariableSymbol extends ArchitectureElementSymbol {
, getSourcePosition());
} else {
ASTElementType inputType = getInputTypes().get(0).getDomain();
if (!Utils.equals(inputType, ioDeclaration.getType().getDomain())) {
ASTElementType outputType = ioDeclaration.getType().getDomain();
if (!Utils.contains(outputType, inputType)) {
Log.error("0" + ErrorCodes.INVALID_ELEMENT_INPUT_DOMAIN + " " +
"The declared output type of '" + name + "' does not match with the actual type. " +
"Declared type: " + ioDeclaration.getType().getDomain().getName() + ". " +
"Declared type: " + outputType.getName() + ". " +
"Actual type: " + inputType.getName() + ".");
}
}
......
......@@ -199,6 +199,79 @@ public class Utils {
return true;
}
// Checks if firstType contains secondType
public static boolean contains(ASTElementType firstType, ASTElementType secondType){
if (firstType.isBoolean()) {
if (!secondType.isBoolean()) {
return false;
}
}
if (firstType.isNaturalNumber()) {
if (secondType.isWholeNumber() || secondType.isRational() || secondType.isComplex()) {
return false;
}
}
if (firstType.isWholeNumber()) {
if (secondType.isRational() || secondType.isComplex()) {
return false;
}
}
if (firstType.isRational()) {
if (secondType.isComplex()) {
return false;
}
}
if (firstType.isPresentRange()) {
if (!secondType.isPresentRange()) {
return false;
}
}
else {
return true;
}
return contains(firstType.getRange(), secondType.getRange());
}
public static boolean contains(ASTRange firstRange, ASTRange secondRange) {
if (!firstRange.hasNoLowerLimit() && secondRange.hasNoLowerLimit()) {
return false;
}
if (!firstRange.hasNoUpperLimit() && secondRange.hasNoUpperLimit()) {
return false;
}
if (!firstRange.hasNoLowerLimit() && firstRange.getStartValue().compareTo(secondRange.getStartValue()) > 0) {
return false;
}
if (!firstRange.hasNoUpperLimit() && firstRange.getEndValue().compareTo(secondRange.getEndValue()) < 0){
return false;
}
if (firstRange.isPresentStep()){
if (!secondRange.isPresentStep()) {
return false;
}
}
else {
return true;
}
if (!firstRange.getStepValue().equals(secondRange.getStepValue())){
return false;
}
// TODO: Check for different step sizes; too complex and not necessary for current use
return true;
}
public static void recursiveSetResolvingFilters(Scope scope, Collection<ResolvingFilter<? extends Symbol>> resolvingFilters){
scope.getAsMutableScope().setResolvingFilters(resolvingFilters);
for (Scope subScope : scope.getSubScopes()){
......
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