Fixed the query functions not comparing data values at all for their return values.

Also made them accept RValue as well and added some test cases for them
and for the overloader bug i fixed last time.
This commit is contained in:
TomyLobo
2013-09-25 00:35:04 +02:00
parent 0f764187d0
commit e2f1abd7e4
2 changed files with 77 additions and 7 deletions

View File

@ -377,18 +377,23 @@ public final class Functions {
}
private static double queryInternal(LValue type, LValue data, double typeId, double dataValue) throws EvaluationException {
private static double queryInternal(RValue type, RValue data, double typeId, double dataValue) throws EvaluationException {
// Compare to input values and determine return value
final double ret = typeId == type.getValue() && typeId == type.getValue() ? 1.0 : 0.0;
final double ret = (typeId == type.getValue() && dataValue == data.getValue()) ? 1.0 : 0.0;
type.assign(typeId);
data.assign(dataValue);
if (type instanceof LValue) {
((LValue) type).assign(typeId);
}
if (data instanceof LValue) {
((LValue) data).assign(dataValue);
}
return ret;
}
@Dynamic
public static double query(RValue x, RValue y, RValue z, LValue type, LValue data) throws EvaluationException {
public static double query(RValue x, RValue y, RValue z, RValue type, RValue data) throws EvaluationException {
final double xp = x.getValue();
final double yp = y.getValue();
final double zp = z.getValue();
@ -403,7 +408,7 @@ public final class Functions {
}
@Dynamic
public static double queryAbs(RValue x, RValue y, RValue z, LValue type, LValue data) throws EvaluationException {
public static double queryAbs(RValue x, RValue y, RValue z, RValue type, RValue data) throws EvaluationException {
final double xp = x.getValue();
final double yp = y.getValue();
final double zp = z.getValue();
@ -418,7 +423,7 @@ public final class Functions {
}
@Dynamic
public static double queryRel(RValue x, RValue y, RValue z, LValue type, LValue data) throws EvaluationException {
public static double queryRel(RValue x, RValue y, RValue z, RValue type, RValue data) throws EvaluationException {
final double xp = x.getValue();
final double yp = y.getValue();
final double zp = z.getValue();