3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-09-16 04:51:22 +02:00

Renamed RValue.invoke() to getValue.

Dieser Commit ist enthalten in:
TomyLobo 2011-10-29 16:03:55 +02:00
Ursprung 93f073f264
Commit e70446e82e
9 geänderte Dateien mit 65 neuen und 65 gelöschten Zeilen

Datei anzeigen

@ -67,7 +67,7 @@ public class Expression {
((Variable) invokable).value = values[i];
}
return root.invoke();
return root.getValue();
}
public void optimize() throws EvaluationException {

Datei anzeigen

@ -28,7 +28,7 @@ public final class Constant extends RValue {
}
@Override
public double invoke() {
public double getValue() {
return value;
}

Datei anzeigen

@ -38,7 +38,7 @@ public class Function extends RValue {
}
@Override
public final double invoke() throws EvaluationException {
public final double getValue() throws EvaluationException {
try {
return (Double) method.invoke(null, (Object[]) args);
}
@ -90,7 +90,7 @@ public class Function extends RValue {
}
if (optimizable) {
return new Constant(position, invoke());
return new Constant(position, getValue());
}
else {
return new Function(position, method, optimizedArgs);

Datei anzeigen

@ -30,108 +30,108 @@ public final class Functions {
public static final double sin(RValue x) throws Exception {
return Math.sin(x.invoke());
return Math.sin(x.getValue());
}
public static final double cos(RValue x) throws Exception {
return Math.cos(x.invoke());
return Math.cos(x.getValue());
}
public static final double tan(RValue x) throws Exception {
return Math.tan(x.invoke());
return Math.tan(x.getValue());
}
public static final double asin(RValue x) throws Exception {
return Math.asin(x.invoke());
return Math.asin(x.getValue());
}
public static final double acos(RValue x) throws Exception {
return Math.acos(x.invoke());
return Math.acos(x.getValue());
}
public static final double atan(RValue x) throws Exception {
return Math.atan(x.invoke());
return Math.atan(x.getValue());
}
public static final double atan2(RValue y, RValue x) throws Exception {
return Math.atan2(y.invoke(), x.invoke());
return Math.atan2(y.getValue(), x.getValue());
}
public static final double sinh(RValue x) throws Exception {
return Math.sinh(x.invoke());
return Math.sinh(x.getValue());
}
public static final double cosh(RValue x) throws Exception {
return Math.cosh(x.invoke());
return Math.cosh(x.getValue());
}
public static final double tanh(RValue x) throws Exception {
return Math.tanh(x.invoke());
return Math.tanh(x.getValue());
}
public static final double sqrt(RValue x) throws Exception {
return Math.sqrt(x.invoke());
return Math.sqrt(x.getValue());
}
public static final double cbrt(RValue x) throws Exception {
return Math.cbrt(x.invoke());
return Math.cbrt(x.getValue());
}
public static final double abs(RValue x) throws Exception {
return Math.abs(x.invoke());
return Math.abs(x.getValue());
}
public static final double min(RValue a, RValue b) throws Exception {
return Math.min(a.invoke(), b.invoke());
return Math.min(a.getValue(), b.getValue());
}
public static final double min(RValue a, RValue b, RValue c) throws Exception {
return Math.min(a.invoke(), Math.min(b.invoke(), c.invoke()));
return Math.min(a.getValue(), Math.min(b.getValue(), c.getValue()));
}
public static final double max(RValue a, RValue b) throws Exception {
return Math.max(a.invoke(), b.invoke());
return Math.max(a.getValue(), b.getValue());
}
public static final double max(RValue a, RValue b, RValue c) throws Exception {
return Math.max(a.invoke(), Math.max(b.invoke(), c.invoke()));
return Math.max(a.getValue(), Math.max(b.getValue(), c.getValue()));
}
public static final double ceil(RValue x) throws Exception {
return Math.ceil(x.invoke());
return Math.ceil(x.getValue());
}
public static final double floor(RValue x) throws Exception {
return Math.floor(x.invoke());
return Math.floor(x.getValue());
}
public static final double rint(RValue x) throws Exception {
return Math.rint(x.invoke());
return Math.rint(x.getValue());
}
public static final double round(RValue x) throws Exception {
return Math.round(x.invoke());
return Math.round(x.getValue());
}
public static final double exp(RValue x) throws Exception {
return Math.exp(x.invoke());
return Math.exp(x.getValue());
}
public static final double ln(RValue x) throws Exception {
return Math.log(x.invoke());
return Math.log(x.getValue());
}
public static final double log(RValue x) throws Exception {
return Math.log(x.invoke());
return Math.log(x.getValue());
}
public static final double log10(RValue x) throws Exception {
return Math.log10(x.invoke());
return Math.log10(x.getValue());
}
}

Datei anzeigen

@ -42,126 +42,126 @@ public final class Operators {
public static final double add(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() + rhs.invoke();
return lhs.getValue() + rhs.getValue();
}
public static final double sub(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() - rhs.invoke();
return lhs.getValue() - rhs.getValue();
}
public static final double mul(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() * rhs.invoke();
return lhs.getValue() * rhs.getValue();
}
public static final double div(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() / rhs.invoke();
return lhs.getValue() / rhs.getValue();
}
public static final double mod(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() % rhs.invoke();
return lhs.getValue() % rhs.getValue();
}
public static final double pow(RValue lhs, RValue rhs) throws EvaluationException {
return Math.pow(lhs.invoke(), rhs.invoke());
return Math.pow(lhs.getValue(), rhs.getValue());
}
public static final double neg(RValue x) throws EvaluationException {
return -x.invoke();
return -x.getValue();
}
public static final double not(RValue x) throws EvaluationException {
return x.invoke() > 0.0 ? 0.0 : 1.0;
return x.getValue() > 0.0 ? 0.0 : 1.0;
}
public static final double inv(RValue x) throws EvaluationException {
return ~(long) x.invoke();
return ~(long) x.getValue();
}
public static final double lth(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() < rhs.invoke() ? 1.0 : 0.0;
return lhs.getValue() < rhs.getValue() ? 1.0 : 0.0;
}
public static final double gth(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() > rhs.invoke() ? 1.0 : 0.0;
return lhs.getValue() > rhs.getValue() ? 1.0 : 0.0;
}
public static final double leq(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() <= rhs.invoke() ? 1.0 : 0.0;
return lhs.getValue() <= rhs.getValue() ? 1.0 : 0.0;
}
public static final double geq(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() >= rhs.invoke() ? 1.0 : 0.0;
return lhs.getValue() >= rhs.getValue() ? 1.0 : 0.0;
}
public static final double equ(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() == rhs.invoke() ? 1.0 : 0.0;
return lhs.getValue() == rhs.getValue() ? 1.0 : 0.0;
}
public static final double neq(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() != rhs.invoke() ? 1.0 : 0.0;
return lhs.getValue() != rhs.getValue() ? 1.0 : 0.0;
}
public static final double near(RValue lhs, RValue rhs) throws EvaluationException {
return almostEqual2sComplement(lhs.invoke(), rhs.invoke(), 450359963L) ? 1.0 : 0.0;
return almostEqual2sComplement(lhs.getValue(), rhs.getValue(), 450359963L) ? 1.0 : 0.0;
//return Math.abs(lhs.invoke() - rhs.invoke()) < 1e-7 ? 1.0 : 0.0;
}
public static final double or(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() > 0.0 || rhs.invoke() > 0.0 ? 1.0 : 0.0;
return lhs.getValue() > 0.0 || rhs.getValue() > 0.0 ? 1.0 : 0.0;
}
public static final double and(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.invoke() > 0.0 && rhs.invoke() > 0.0 ? 1.0 : 0.0;
return lhs.getValue() > 0.0 && rhs.getValue() > 0.0 ? 1.0 : 0.0;
}
public static final double shl(RValue lhs, RValue rhs) throws EvaluationException {
return (long) lhs.invoke() << (long) rhs.invoke();
return (long) lhs.getValue() << (long) rhs.getValue();
}
public static final double shr(RValue lhs, RValue rhs) throws EvaluationException {
return (long) lhs.invoke() >> (long) rhs.invoke();
return (long) lhs.getValue() >> (long) rhs.getValue();
}
public static final double ass(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(rhs.invoke());
return lhs.assign(rhs.getValue());
}
public static final double aadd(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(lhs.invoke() + rhs.invoke());
return lhs.assign(lhs.getValue() + rhs.getValue());
}
public static final double asub(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(lhs.invoke() - rhs.invoke());
return lhs.assign(lhs.getValue() - rhs.getValue());
}
public static final double amul(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(lhs.invoke() * rhs.invoke());
return lhs.assign(lhs.getValue() * rhs.getValue());
}
public static final double adiv(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(lhs.invoke() / rhs.invoke());
return lhs.assign(lhs.getValue() / rhs.getValue());
}
public static final double amod(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(lhs.invoke() % rhs.invoke());
return lhs.assign(lhs.getValue() % rhs.getValue());
}
public static final double aexp(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(Math.pow(lhs.invoke(), rhs.invoke()));
return lhs.assign(Math.pow(lhs.getValue(), rhs.getValue()));
}
public static final double inc(LValue x) throws EvaluationException {
return x.assign(x.invoke() + 1);
return x.assign(x.getValue() + 1);
}
public static final double dec(LValue x) throws EvaluationException {
return x.assign(x.invoke() - 1);
return x.assign(x.getValue() - 1);
}

Datei anzeigen

@ -29,7 +29,7 @@ public abstract class RValue implements Identifiable {
this.position = position;
}
public abstract double invoke() throws EvaluationException;
public abstract double getValue() throws EvaluationException;
@Override
public abstract String toString();

Datei anzeigen

@ -38,10 +38,10 @@ public class Sequence extends RValue {
}
@Override
public double invoke() throws EvaluationException {
public double getValue() throws EvaluationException {
double ret = 0;
for (RValue invokable : sequence) {
ret = invokable.invoke();
ret = invokable.getValue();
}
return ret;
}

Datei anzeigen

@ -28,7 +28,7 @@ public final class Variable extends LValue {
}
@Override
public double invoke() {
public double getValue() {
return value;
}

Datei anzeigen

@ -64,9 +64,9 @@ public class ExpressionTest {
public void testAssign() throws ExpressionException {
Expression foo = Expression.compile("{a=x} b=y; c=z", "x", "y", "z", "a", "b", "c");
foo.evaluate(2, 3, 5);
assertEquals(2, foo.getVariable("a").invoke(), 0);
assertEquals(3, foo.getVariable("b").invoke(), 0);
assertEquals(5, foo.getVariable("c").invoke(), 0);
assertEquals(2, foo.getVariable("a").getValue(), 0);
assertEquals(3, foo.getVariable("b").getValue(), 0);
assertEquals(5, foo.getVariable("c").getValue(), 0);
}
private double simpleEval(String expression) throws Exception {