Moved megabuf to the Functions class

This commit is contained in:
TomyLobo 2013-09-21 18:22:18 +02:00
parent aef3b0024a
commit 4fa5daf974
2 changed files with 8 additions and 6 deletions

View File

@ -29,6 +29,7 @@
import com.sk89q.worldedit.expression.parser.Parser;
import com.sk89q.worldedit.expression.runtime.Constant;
import com.sk89q.worldedit.expression.runtime.EvaluationException;
import com.sk89q.worldedit.expression.runtime.Functions;
import com.sk89q.worldedit.expression.runtime.RValue;
import com.sk89q.worldedit.expression.runtime.ReturnException;
import com.sk89q.worldedit.expression.runtime.Variable;
@ -63,7 +64,7 @@ public class Expression {
private final Map<String, RValue> variables = new HashMap<String, RValue>();
private final String[] variableNames;
private RValue root;
private final Map<Integer, double[]> megabuf = new HashMap<Integer, double[]>();
private final Functions functions = new Functions();
public static Expression compile(String expression, String... variableNames) throws ExpressionException {
return new Expression(expression, variableNames);
@ -153,7 +154,7 @@ private void popInstance() {
}
}
public Map<Integer, double[]> getMegabuf() {
return megabuf;
public Functions getFunctions() {
return functions;
}
}

View File

@ -277,6 +277,7 @@ public static double swap(LValue x, LValue y) throws EvaluationException {
private static final Map<Integer, double[]> gmegabuf = new HashMap<Integer, double[]>();
private final Map<Integer, double[]> megabuf = new HashMap<Integer, double[]>();
private static double[] getSubBuffer(Map<Integer, double[]> megabuf, Integer key) {
double[] ret = megabuf.get(key);
@ -306,18 +307,18 @@ public static double gmegabuf(RValue index, double value) throws EvaluationExcep
@Dynamic
public static double megabuf(RValue index) throws EvaluationException {
return getBufferItem(Expression.getInstance().getMegabuf(), (int) index.getValue());
return getBufferItem(Expression.getInstance().getFunctions().megabuf, (int) index.getValue());
}
@Dynamic
public static double megabuf(RValue index, double value) throws EvaluationException {
return setBufferItem(Expression.getInstance().getMegabuf(), (int) index.getValue(), value);
return setBufferItem(Expression.getInstance().getFunctions().megabuf, (int) index.getValue(), value);
}
@Dynamic
public static double closest(RValue x, RValue y, RValue z, RValue index, RValue count, RValue stride) throws EvaluationException {
return findClosest(
Expression.getInstance().getMegabuf(),
Expression.getInstance().getFunctions().megabuf,
x.getValue(),
y.getValue(),
z.getValue(),