Skip to content
Snippets Groups Projects
Commit 80eae58e authored by Johannes Mey's avatar Johannes Mey
Browse files

remove a lot of redundand code. eval without an assignment is now just eval with a null assignment.

parent 3d9d14f5
No related branches found
No related tags found
No related merge requests found
aspect eval {
uncache Clause.checkUsing(Request request, Resource resource);
syn boolean Clause.checkUsing(Request request, Resource resource) = checkUsing(simpleAssignment(request, resource));
syn double Expression.evalAsDouble();
eq LiteralExpression.evalAsDouble() = getValue();
eq ParenthesizedExpression.evalAsDouble() = getExpression().evalAsDouble();
eq AddExpression.evalAsDouble() = getLeft().evalAsDouble() + getRight().evalAsDouble();
eq SubExpression.evalAsDouble() = getLeft().evalAsDouble() - getRight().evalAsDouble();
eq MultExpression.evalAsDouble() = getLeft().evalAsDouble() * getRight().evalAsDouble();
eq DivExpression.evalAsDouble() = getLeft().evalAsDouble() / getRight().evalAsDouble();
eq PowerExpression.evalAsDouble() = Math.pow(getLeft().evalAsDouble(), getRight().evalAsDouble());
syn double Designator.evalAsDouble();
eq QualifiedNameDesignator.evalAsDouble() {
throw new EvalutationException("This attribute should not be called because a QualifiedNameDesignator is a temporary node!");
}
eq SoftwareDesignator.evalAsDouble() {
throw new EvalutationException("TODO implement ParentResourceDesignator.evalAsDouble()");
}
eq PropertyResourceDesignator.evalAsDouble() {
if (inRequiringClause()) {
// TODO
}
throw new EvalutationException("TODO implement PropertyResourceDesignator.evalAsDouble()");
}
eq MetaParameterDesignator.evalAsDouble() {
throw new EvalutationException("TODO implement MetaParameterDesignator.evalAsDouble()");
}
uncache Clause.evalUsing(Request request, Resource target);
syn double Clause.evalUsing(Request request, Resource target) = evalUsing(simpleAssignment(request, target));
......@@ -42,6 +13,9 @@ aspect eval {
uncache Expression.evalUsing(Assignment assignment);
syn double Expression.evalUsing(Assignment assignment);
uncache Expression.eval();
syn double Expression.eval() = evalUsing(null);
eq LiteralExpression.evalUsing(Assignment assignment) = getValue();
eq ParenthesizedExpression.evalUsing(Assignment assignment) = getExpression().evalUsing(assignment);
......@@ -106,7 +80,7 @@ aspect eval {
for (CurrentResourceValue crv : rRef.getRef().getCurrentResourceValueList()) {
if (crv.getPropertyRef().getRef() == this.getPropertyRef().getRef()) {
resourceValues.add(crv);
RealInterval newInterval = new RealInterval(crv.getValue().evalAsDouble());
RealInterval newInterval = new RealInterval(crv.getValue().eval());
if (realInterval == null) {
realInterval = newInterval;
} else {
......
......@@ -428,7 +428,7 @@ aspect Navigation {
syn double Resource.getCurrentValueByPropertyName(String name) {
for (CurrentResourceValue value: getCurrentResourceValueList()) {
if (value.getPropertyRef().getRef().name().equals(name)) {
return value.getValue().evalAsDouble();
return value.getValue().eval();
}
}
throw new EvalutationException("Did not find a value for a property '" + name + "'");
......@@ -439,7 +439,7 @@ aspect Navigation {
syn double Resource.getCurrentValueByProperty(Property property) {
for (CurrentResourceValue value: getCurrentResourceValueList()) {
if (value.getPropertyRef().getRef() == property) {
return value.getValue().evalAsDouble();
return value.getValue().eval();
}
}
throw new EvalutationException("Did not find a value for a property '" + property.name() + "'");
......@@ -450,7 +450,7 @@ aspect Navigation {
syn double Request.getConstraintValueByName(String name) {
for (Clause clause: getConstraintList()) {
if (clause.getDesignator().simpleName().equals(name)) {
return clause.getExpression().evalAsDouble();
return clause.getExpression().eval();
}
}
throw new EvalutationException("Did not find a constraint '" + name + "'");
......@@ -465,7 +465,7 @@ aspect Navigation {
&& designator.isPropertyResourceDesignator()
&& designator.asPropertyResourceDesignator().getInstanceRef().getRef().referringResourceType().equals(type)
&& designator.simpleName().equals(propertyName)) {
return clause.getExpression().evalAsDouble();
return clause.getExpression().eval();
}
}
throw new EvalutationException("Did not find a requiring clause for designator '" + propertyName + "'");
......@@ -480,7 +480,7 @@ aspect Navigation {
&& designator.asPropertyResourceDesignator().getInstanceRef().getRef().referringResourceType().equals(type)
&& designator.simpleName().equals(propertyName)) {
if (i==index) {
return clause.getExpression().evalAsDouble();
return clause.getExpression().eval();
} else {
i++;
}
......
......@@ -104,7 +104,7 @@ aspect eval {
for (CurrentResourceValue crv : rRef.getRef().getCurrentResourceValueList()) {
if (crv.getPropertyRef().getRef() == this.getPropertyRef().getRef()) {
resourceValues.add(crv);
RealInterval newInterval = new RealInterval(crv.getValue().evalAsDouble());
RealInterval newInterval = new RealInterval(crv.getValue().eval());
if (realInterval == null) {
realInterval = newInterval;
} else {
......
......@@ -206,29 +206,4 @@ aspect AI {
return result;
}
syn RealInterval Expression.evalAsInterval();
eq LiteralExpression.evalAsInterval() = new RealInterval(getValue());
eq ParenthesizedExpression.evalAsInterval() = getExpression().evalAsInterval();
eq AddExpression.evalAsInterval() = IAMath.add(getLeft().evalAsInterval(),getRight().evalAsInterval());
eq SubExpression.evalAsInterval() = IAMath.sub(getLeft().evalAsInterval(), getRight().evalAsInterval());
eq MultExpression.evalAsInterval() = IAMath.mul(getLeft().evalAsInterval(), getRight().evalAsInterval());
eq DivExpression.evalAsInterval() = IAMath.div(getLeft().evalAsInterval(), getRight().evalAsInterval());
eq PowerExpression.evalAsInterval() = IAMath.power(getLeft().evalAsInterval(), getRight().evalAsInterval());
// syn RealInterval Designator.evalAsInterval();
eq QualifiedNameDesignator.evalAsInterval() {
throw new EvalutationException("This attribute should not be called because a QualifiedNameDesignator is a temporary node!");
}
eq SoftwareDesignator.evalAsInterval() {
throw new EvalutationException("TODO implement ParentResourceDesignator.evalAsDouble()");
}
eq PropertyResourceDesignator.evalAsInterval() {
throw new EvalutationException("TODO implement PropertyResourceDesignator.evalAsDouble()");
}
eq MetaParameterDesignator.evalAsInterval() {
throw new EvalutationException("TODO implement MetaParameterDesignator.evalAsDouble()");
}
}
\ No newline at end of file
......@@ -47,7 +47,7 @@ public abstract class ModelSerializer {
public Object createCurrentResourceValue(CurrentResourceValue crv) {
return createVertex("CurrentResourceValue", MapCreator.of(
e("Value", crv.getValue().evalAsDouble())));
e("Value", crv.getValue().eval())));
}
public Object createMetaParameter(MetaParameter metaParameter) {
......
......@@ -580,7 +580,7 @@ public class ScenarioGenerator {
if (clause.isRequiringClause()) {
if (clause.getDesignator().isSoftwareDesignator()) {
if (clause.getDesignator().asSoftwareDesignator().getInstanceRef().getRef() == requiredInstance) {
newQualityValue = (int) clause.getExpression().evalAsDouble();
newQualityValue = (int) clause.getExpression().eval();
}
}
}
......@@ -595,9 +595,9 @@ public class ScenarioGenerator {
if (clause.isProvidingClause()
&& clause.getDesignator().simpleName().equals("quality")) {
if (logger.isTraceEnabled()) {
logger.trace("set quality value from {} to {}", clause.getExpression().evalAsDouble(), quality);
logger.trace("set quality value from {} to {}", clause.getExpression().eval(), quality);
}
clause.setExpression(new LiteralExpression(Math.max((int) clause.getExpression().evalAsDouble(), quality)));
clause.setExpression(new LiteralExpression(Math.max((int) clause.getExpression().eval(), quality)));
}
}
......@@ -637,7 +637,7 @@ public class ScenarioGenerator {
if (value.getPropertyRef().getRef().getName().getName().equals("frequency")) {
computeMapping.addMapping(new ResourceMapping(cpuInstance[currentCpu], sub, new List<>()));
if (logger.isTraceEnabled()) {
logger.trace("set frequency value from {} to {}", value.getValue().evalAsDouble(), frequencyValue[currentCpu]);
logger.trace("set frequency value from {} to {}", value.getValue().eval(), frequencyValue[currentCpu]);
}
value.setValue(new LiteralExpression(frequencyValue[currentCpu]));
currentCpu++;
......@@ -654,7 +654,7 @@ public class ScenarioGenerator {
if (value.getPropertyRef().getRef().getName().getName().equals("throughput")) {
computeMapping.addMapping(new ResourceMapping(networkInstance, sub, new List<>()));
if (logger.isTraceEnabled()) {
logger.trace("set throughput value from {} to {}", value.getValue().evalAsDouble(), networkThroughputValue);
logger.trace("set throughput value from {} to {}", value.getValue().eval(), networkThroughputValue);
}
value.setValue(new LiteralExpression(networkThroughputValue));
}
......@@ -678,6 +678,4 @@ public class ScenarioGenerator {
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment