Skip to content

Commit 69e225f

Browse files
committed
Fixed issue with large numeric attribtue values; SMT conversion now also considers features from attributes
1 parent ad5bd62 commit 69e225f

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

src/main/java/de/vill/conversion/ConvertSMTLevel.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.google.common.collect.Sets;
44
import de.vill.model.*;
55
import de.vill.model.constraint.*;
6+
import de.vill.model.expression.AggregateFunctionExpression;
7+
import de.vill.model.expression.BinaryExpression;
68
import de.vill.model.expression.Expression;
79
import de.vill.model.expression.LiteralExpression;
810

@@ -68,9 +70,14 @@ private Set<Feature> getFeaturesInEquation(ExpressionConstraint equation) {
6870

6971
private Set<Feature> getFeaturesInExpression(Expression expression) {
7072
Set<Feature> featuresInEquation = new HashSet<>();
71-
if (expression instanceof LiteralExpression && ((LiteralExpression) expression).getContent() instanceof Feature) {
72-
featuresInEquation.add((Feature) ((LiteralExpression) expression).getContent());
73-
} else {
73+
if (expression instanceof LiteralExpression) {
74+
LiteralExpression literalExpression = (LiteralExpression) expression;
75+
if (literalExpression.getContent() instanceof Feature) {
76+
featuresInEquation.add((Feature) ((LiteralExpression) expression).getContent());
77+
} else if (literalExpression.getContent() instanceof Attribute<?>) {
78+
featuresInEquation.add(((Attribute<?>) literalExpression.getContent()).getFeature());
79+
}
80+
} else {
7481
for (Expression subExpression : expression.getExpressionSubParts()) {
7582
featuresInEquation.addAll(getFeaturesInExpression(subExpression));
7683
}

src/main/java/de/vill/main/UVLListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public void exitValueAttribute(UVLJavaParser.ValueAttributeContext ctx) {
267267
Attribute<Boolean> attribute = new Attribute<>(attributeName, Boolean.parseBoolean(ctx.value().getText().replace("'", "")), feature);
268268
attributeStack.peek().put(attributeName, attribute);
269269
} else if (ctx.value().INTEGER() != null) {
270-
Attribute<Integer> attribute = new Attribute<>(attributeName, Integer.parseInt(ctx.value().getText().replace("'", "")), feature);
270+
Attribute<Long> attribute = new Attribute<>(attributeName, Long.parseLong(ctx.value().getText().replace("'", "")), feature);
271271
attributeStack.peek().put(attributeName, attribute);
272272
} else if (ctx.value().FLOAT() != null) {
273273
Attribute<Double> attribute = new Attribute<>(attributeName, Double.parseDouble(ctx.value().getText().replace("'", "")), feature);

src/main/java/de/vill/model/building/FeatureModelBuilder.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import de.vill.exception.ParseError;
44
import de.vill.model.*;
55
import de.vill.model.constraint.Constraint;
6+
import de.vill.model.constraint.LiteralConstraint;
67

78
import java.util.List;
89
import java.util.Map;
@@ -135,4 +136,22 @@ public Set<LanguageLevel> getLanguageLevels() {
135136
return fmInConstruction.getUsedLanguageLevels();
136137
}
137138

139+
public LiteralConstraint createFeatureLiteral(String name) {
140+
if (fmInConstruction.getFeatureMap().containsKey(name)) {
141+
return new LiteralConstraint(fmInConstruction.getFeatureMap().get(name));
142+
} else {
143+
System.err.println("Tried to reference " + name + " but feature with that name does not exist");
144+
return null;
145+
}
146+
}
147+
148+
public GlobalAttribute createGlobalAttribute(String name) {
149+
GlobalAttribute toCreate = new GlobalAttribute(name, fmInConstruction);
150+
if (toCreate.getType() == null) {
151+
System.err.println("Tried to reference " + name + " but attribute with that name does not exist");
152+
return null;
153+
}
154+
return toCreate;
155+
}
156+
138157
}

0 commit comments

Comments
 (0)