This commit is contained in:
Wizjany 2011-10-26 16:50:46 -04:00
parent 8797d8ac3c
commit 699807665d
19 changed files with 175 additions and 110 deletions

View File

@ -39,9 +39,9 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
"worldedit.reload", "worldedit.reload",
"worldedit.selection", "worldedit.selection",
"worlds.creative.worldedit.region"}); "worlds.creative.worldedit.region"});
section.setProperty("permissions.groups.admins.permissions", new String[]{"*"}); section.setProperty("permissions.groups.admins.permissions", new String[] {"*"});
section.setProperty("permissions.users.sk89q.permissions", new String[]{"worldedit"}); section.setProperty("permissions.users.sk89q.permissions", new String[] {"worldedit"});
section.setProperty("permissions.users.sk89q.groups", new String[]{"admins"}); section.setProperty("permissions.users.sk89q.groups", new String[] {"admins"});
return section; return section;
} }

View File

@ -38,7 +38,6 @@ public class DinnerPermsResolver implements PermissionsResolver {
} }
public static PermissionsResolver factory(Server server, YAMLProcessor config) { public static PermissionsResolver factory(Server server, YAMLProcessor config) {
return new DinnerPermsResolver(server); return new DinnerPermsResolver(server);
} }

View File

@ -139,8 +139,7 @@ public class CommandContext {
// If it is a value flag, read another argument and add it // If it is a value flag, read another argument and add it
this.valueFlags.put(flagName, argList.get(nextArg++)); this.valueFlags.put(flagName, argList.get(nextArg++));
} } else {
else {
booleanFlags.add(flagName); booleanFlags.add(flagName);
} }
} }

View File

@ -721,7 +721,7 @@ public class YAMLNode {
return null; return null;
} else if (o instanceof Number) { } else if (o instanceof Number) {
return ((Number)o).intValue(); return ((Number)o).intValue();
} else { } else {
return null; return null;
} }
} }
@ -737,7 +737,7 @@ public class YAMLNode {
return null; return null;
} else if (o instanceof Number) { } else if (o instanceof Number) {
return ((Number)o).doubleValue(); return ((Number)o).doubleValue();
} else { } else {
return null; return null;
} }
} }

View File

@ -100,6 +100,11 @@ public class EditSession {
*/ */
private boolean fastMode = false; private boolean fastMode = false;
/**
* Use fast lighting as well if using fast mode.
*/
private boolean fastLighting = false;
/** /**
* Block bag to use for getting blocks. * Block bag to use for getting blocks.
*/ */
@ -209,13 +214,13 @@ public class EditSession {
if (BlockType.usesData(type)) { if (BlockType.usesData(type)) {
if (fastMode) { if (fastMode) {
result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0); result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0, fastLighting);
} else { } else {
result = world.setTypeIdAndData(pt, type, block.getData() > -1 ? block.getData() : 0); result = world.setTypeIdAndData(pt, type, block.getData() > -1 ? block.getData() : 0);
} }
} else { } else {
if (fastMode) { if (fastMode) {
result = world.setBlockTypeFast(pt, type); result = world.setBlockTypeFast(pt, type, fastLighting);
} else { } else {
result = world.setBlockType(pt, type); result = world.setBlockType(pt, type);
} }
@ -227,8 +232,7 @@ public class EditSession {
if (blockBag == null) { if (blockBag == null) {
world.copyToWorld(pt, block); world.copyToWorld(pt, block);
} }
} } else if (block instanceof TileEntityBlock) {
else if (block instanceof TileEntityBlock) {
world.copyToWorld(pt, block); world.copyToWorld(pt, block);
} }
} }
@ -522,12 +526,30 @@ public class EditSession {
* Disable the queue. This will flush the queue. * Disable the queue. This will flush the queue.
*/ */
public void disableQueue() { public void disableQueue() {
if (queued != false) { if (queued) {
flushQueue(); flushQueue();
} }
queued = false; queued = false;
} }
/**
* Set fast lighting.
*
* @param fastLighting
*/
public void setFastLighting(boolean fastLighting) {
this.fastLighting = fastLighting;
}
/**
* Return fast lighting status.
*
* @return
*/
public boolean hasFastLighting() {
return fastLighting;
}
/** /**
* Set fast mode. * Set fast mode.
* *
@ -561,7 +583,9 @@ public class EditSession {
rawSetBlock(pt, (BaseBlock) entry.getValue()); rawSetBlock(pt, (BaseBlock) entry.getValue());
// TODO: use ChunkStore.toChunk(pt) after optimizing it. // TODO: use ChunkStore.toChunk(pt) after optimizing it.
if (fastMode) dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)); if (fastMode) {
dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4));
}
} }
// We don't want to place these blocks if other blocks were missing // We don't want to place these blocks if other blocks were missing
@ -629,7 +653,9 @@ public class EditSession {
blocks.remove(pt); blocks.remove(pt);
// TODO: use ChunkStore.toChunk(pt) after optimizing it. // TODO: use ChunkStore.toChunk(pt) after optimizing it.
if (fastMode) dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)); if (fastMode) {
dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4));
}
} }
} }
} }
@ -1794,9 +1820,24 @@ public class EditSession {
} }
/** /**
* Makes a sphere or ellipsoid. * Makes a cylinder.
* *
* @param pos Center of the sphere or ellipsoid * @param pos Center of the cylinder
* @param block The block pattern to use
* @param radius The cylinder's radius
* @param height The cylinder's up/down extent. If negative, extend downward.
* @param filled If false, only a shell will be generated.
* @return number of blocks changed
* @throws MaxChangedBlocksException
*/
public int makeCylinder(Vector pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException {
return makeCylinder(pos, block, radius, radius, height, filled);
}
/**
* Makes a cylinder.
*
* @param pos Center of the cylinder
* @param block The block pattern to use * @param block The block pattern to use
* @param radiusX The cylinder's largest north/south extent * @param radiusX The cylinder's largest north/south extent
* @param radiusZ The cylinder's largest east/west extent * @param radiusZ The cylinder's largest east/west extent
@ -1875,6 +1916,20 @@ public class EditSession {
return affected; return affected;
} }
/**
* Makes a sphere.
*
* @param pos Center of the sphere or ellipsoid
* @param block The block pattern to use
* @param radius The sphere's radius
* @param filled If false, only a shell will be generated.
* @return number of blocks changed
* @throws MaxChangedBlocksException
*/
public int makeSphere(Vector pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException {
return makeSphere(pos, block, radius, radius, radius, filled);
}
/** /**
* Makes a sphere or ellipsoid. * Makes a sphere or ellipsoid.
* *
@ -2538,8 +2593,7 @@ public class EditSession {
} }
/** /**
* @param blockBag * @param blockBag the blockBag to set
* the blockBag to set
*/ */
public void setBlockBag(BlockBag blockBag) { public void setBlockBag(BlockBag blockBag) {
this.blockBag = blockBag; this.blockBag = blockBag;

View File

@ -73,6 +73,7 @@ public class LocalSession {
private boolean beenToldVersion = false; private boolean beenToldVersion = false;
private boolean hasCUISupport = false; private boolean hasCUISupport = false;
private boolean fastMode = false; private boolean fastMode = false;
private boolean fastLighting = false;
private Mask mask; private Mask mask;
private TimeZone timezone = TimeZone.getDefault(); private TimeZone timezone = TimeZone.getDefault();
private Boolean jumptoBlock = true; private Boolean jumptoBlock = true;
@ -644,6 +645,7 @@ public class LocalSession {
new EditSession(player.getWorld(), new EditSession(player.getWorld(),
getBlockChangeLimit(), blockBag); getBlockChangeLimit(), blockBag);
editSession.setFastMode(fastMode); editSession.setFastMode(fastMode);
editSession.setFastLighting(fastLighting);
editSession.setMask(mask); editSession.setMask(mask);
return editSession; return editSession;
@ -667,6 +669,24 @@ public class LocalSession {
this.fastMode = fastMode; this.fastMode = fastMode;
} }
/**
* Checks if the session has fast lighting enabled.
*
* @return
*/
public boolean hasFastLighting() {
return fastLighting;
}
/**
* Set fast lighting.
*
* @param fastLighting
*/
public void setFastLighting(boolean fastLighting) {
this.fastLighting = fastLighting;
}
/** /**
* Get the mask. * Get the mask.
* *

View File

@ -63,6 +63,10 @@ public abstract class LocalWorld {
return setBlockType(pt, type); return setBlockType(pt, type);
} }
public boolean setBlockTypeFast(Vector pt, int type, boolean fastLighting) {
return setBlockTypeFast(pt, type);
}
/** /**
* Get block type. * Get block type.
* *
@ -100,7 +104,7 @@ public abstract class LocalWorld {
setBlockData(pt, data); setBlockData(pt, data);
return ret; return ret;
} }
/** /**
* set block type & data * set block type & data
* @param pt * @param pt
@ -113,7 +117,11 @@ public abstract class LocalWorld {
setBlockDataFast(pt, data); setBlockDataFast(pt, data);
return ret; return ret;
} }
public boolean setTypeIdAndDataFast(Vector pt, int type, int data, boolean fastLighting) {
return setTypeIdAndDataFast(pt, type, data);
}
/** /**
* Get block data. * Get block data.
* *

View File

@ -34,8 +34,8 @@ public class BukkitServerInterface extends ServerInterface {
@Override @Override
public int resolveItem(String name) { public int resolveItem(String name) {
// TODO Auto-generated method stub Material mat = Material.matchMaterial(name);
return 0; return mat == null ? 0 : mat.getId();
} }
@Override @Override

View File

@ -111,8 +111,21 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public boolean setBlockTypeFast(Vector pt, int type) { public boolean setBlockTypeFast(Vector pt, int type) {
return setBlockTypeFast(pt, type, false);
}
/**
* Set block type.
*
* @param pt
* @param type
* @param fastLighting
* @return
*/
@Override
public boolean setBlockTypeFast(Vector pt, int type, boolean fastLighting) {
final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (fastLightingAvailable) { if (fastLightingAvailable && fastLighting) {
type = type & 255; type = type & 255;
final int previousOpacity = Block_lightOpacity[type]; final int previousOpacity = Block_lightOpacity[type];
Block_lightOpacity[type] = 0; Block_lightOpacity[type] = 0;
@ -145,8 +158,13 @@ public class BukkitWorld extends LocalWorld {
*/ */
@Override @Override
public boolean setTypeIdAndDataFast(Vector pt, int type, int data){ public boolean setTypeIdAndDataFast(Vector pt, int type, int data){
return setTypeIdAndDataFast(pt, type, data, false);
}
@Override
public boolean setTypeIdAndDataFast(Vector pt, int type, int data, boolean fastLighting) {
final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (fastLightingAvailable) { if (fastLightingAvailable && fastLighting) {
type = type & 255; type = type & 255;
final int previousOpacity = Block_lightOpacity[type]; final int previousOpacity = Block_lightOpacity[type];
Block_lightOpacity[type] = 0; Block_lightOpacity[type] = 0;
@ -157,7 +175,7 @@ public class BukkitWorld extends LocalWorld {
return block.setTypeIdAndData(type, (byte) data, false); return block.setTypeIdAndData(type, (byte) data, false);
} }
/** /**
* Get block type. * Get block type.
* *
@ -788,8 +806,7 @@ public class BukkitWorld extends LocalWorld {
lightEmitters.add(chunk.getBlock(x, y, z).getState()); lightEmitters.add(chunk.getBlock(x, y, z).getState());
if (blockID == 20) { if (blockID == 20) {
blocks[index] = 0; blocks[index] = 0;
} } else {
else {
blocks[index] = 20; blocks[index] = 20;
} }
@ -808,8 +825,7 @@ public class BukkitWorld extends LocalWorld {
lightEmitter.update(true); lightEmitter.update(true);
} }
} }
} } catch (Exception e) {
catch (Exception e) {
System.out.println("Fast Mode: Could not fix lighting. Probably an incompatible version of CraftBukkit."); System.out.println("Fast Mode: Could not fix lighting. Probably an incompatible version of CraftBukkit.");
e.printStackTrace(); e.printStackTrace();
} }
@ -843,8 +859,7 @@ public class BukkitWorld extends LocalWorld {
NibbleArray_ctor = Class.forName("net.minecraft.server.NibbleArray").getConstructor(int.class, int.class); NibbleArray_ctor = Class.forName("net.minecraft.server.NibbleArray").getConstructor(int.class, int.class);
fastLightingAvailable = true; fastLightingAvailable = true;
} } catch (Throwable e) {
catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -63,6 +63,7 @@ public class GeneralCommands {
@Command( @Command(
aliases = { "/fast" }, aliases = { "/fast" },
flags = "l",
usage = "[on|off]", usage = "[on|off]",
desc = "Toggle fast mode", desc = "Toggle fast mode",
min = 0, min = 0,
@ -73,25 +74,24 @@ public class GeneralCommands {
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
boolean light = args.hasFlag('f');
String newState = args.getString(0, null); String newState = args.getString(0, null);
if (session.hasFastMode()) { Boolean dir = newState.equals("on") ? true : newState.equals("off") ? false : null;
if ("on".equals(newState)) {
player.printError("Fast mode already enabled.");
return;
}
session.setFastMode(false); boolean hadFast = session.hasFastMode();
player.print("Fast mode disabled."); boolean hadLight = session.hasFastLighting();
}
else {
if ("off".equals(newState)) {
player.printError("Fast mode already disabled.");
return;
}
session.setFastMode(true); boolean setFast = dir == null ? !hadFast : dir;
player.print("Fast mode enabled. Lighting in the affected chunks may be wrong and/or you may need to rejoin to see changes."); boolean setLight = dir == null ? !hadLight : dir;
session.setFastMode(setFast);
if (light) {
session.setFastLighting(setLight);
} }
player.print("Fast mode " + (!setFast ? "disabled." :
("enabled. You may need to rejoin to see changes"
+ (setLight ? "and lighting in affected chunks may be wrong." : "."))));
} }
@Command( @Command(

View File

@ -322,8 +322,7 @@ public class GenerationCommands {
try { try {
expression = Expression.compile(args.getJoinedStrings(1), "x", "y", "z"); expression = Expression.compile(args.getJoinedStrings(1), "x", "y", "z");
expression.optimize(); expression.optimize();
} } catch (ExpressionException e) {
catch (ExpressionException e) {
player.printError(e.getMessage()); player.printError(e.getMessage());
return; return;
} }
@ -336,15 +335,13 @@ public class GenerationCommands {
protected boolean isInside(double x, double y, double z) { protected boolean isInside(double x, double y, double z) {
try { try {
return expression.evaluate(x, y, z) > 0; return expression.evaluate(x, y, z) > 0;
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
} }
}; };
} } else if (args.hasFlag('o')) {
else if (args.hasFlag('o')) {
final Vector placement = session.getPlacementPosition(player); final Vector placement = session.getPlacementPosition(player);
final double placementX = placement.getX(); final double placementX = placement.getX();
@ -356,15 +353,13 @@ public class GenerationCommands {
protected boolean isInside(double x, double y, double z) { protected boolean isInside(double x, double y, double z) {
try { try {
return expression.evaluate(x - placementX, y - placementY, z - placementZ) > 0; return expression.evaluate(x - placementX, y - placementY, z - placementZ) > 0;
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
} }
}; };
} } else {
else {
final Vector min = region.getMinimumPoint(); final Vector min = region.getMinimumPoint();
final Vector max = region.getMaximumPoint(); final Vector max = region.getMaximumPoint();
final Vector center = max.add(min).multiply(0.5); final Vector center = max.add(min).multiply(0.5);
@ -376,8 +371,7 @@ public class GenerationCommands {
try { try {
return expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ()) > 0; return expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ()) > 0;
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }

View File

@ -194,8 +194,7 @@ public class SelectionCommands {
player.print("Chunks selected: (" player.print("Chunks selected: ("
+ min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - (" + min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - ("
+ max2D.getBlockX() + ", " + max2D.getBlockZ() + ")"); + max2D.getBlockX() + ", " + max2D.getBlockZ() + ")");
} } else {
else {
final Vector2D min2D = ChunkStore.toChunk(player.getBlockIn()); final Vector2D min2D = ChunkStore.toChunk(player.getBlockIn());
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);

View File

@ -54,8 +54,7 @@ public class ToolUtilCommands {
session.disableSuperPickAxe(); session.disableSuperPickAxe();
player.print("Super pick axe disabled."); player.print("Super pick axe disabled.");
} } else {
else {
if ("off".equals(newState)) { if ("off".equals(newState)) {
player.printError("Super pick axe already disabled."); player.printError("Super pick axe already disabled.");
return; return;

View File

@ -140,8 +140,7 @@ public class Lexer {
if (!numberPart.isEmpty()) { if (!numberPart.isEmpty()) {
try { try {
tokens.add(new NumberToken(position, Double.parseDouble(numberPart))); tokens.add(new NumberToken(position, Double.parseDouble(numberPart)));
} } catch (NumberFormatException e) {
catch (NumberFormatException e) {
throw new LexerException(position, "Number parsing failed", e); throw new LexerException(position, "Number parsing failed", e);
} }
@ -156,8 +155,7 @@ public class Lexer {
if (!identifierPart.isEmpty()) { if (!identifierPart.isEmpty()) {
if (keywords.contains(identifierPart)) { if (keywords.contains(identifierPart)) {
tokens.add(new KeywordToken(position, identifierPart)); tokens.add(new KeywordToken(position, identifierPart));
} } else {
else {
tokens.add(new IdentifierToken(position, identifierPart)); tokens.add(new IdentifierToken(position, identifierPart));
} }
@ -167,8 +165,7 @@ public class Lexer {
} }
throw new LexerException(position, "Unknown character '" + ch + "'"); throw new LexerException(position, "Unknown character '" + ch + "'");
} } while (position < expression.length());
while (position < expression.length());
return tokens; return tokens;
} }

View File

@ -100,8 +100,7 @@ public class Parser {
final Token next = peek(); final Token next = peek();
if (next.id() == '(') { if (next.id() == '(') {
halfProcessed.add(parseFunctionCall(identifierToken)); halfProcessed.add(parseFunctionCall(identifierToken));
} } else {
else {
RValue variable = variables.get(identifierToken.value); RValue variable = variables.get(identifierToken.value);
if (variable == null) { if (variable == null) {
throw new ParserException(current.getPosition(), "Variable '" + identifierToken.value + "' not found"); throw new ParserException(current.getPosition(), "Variable '" + identifierToken.value + "' not found");
@ -130,8 +129,7 @@ public class Parser {
case 'o': case 'o':
if (expressionStart) { if (expressionStart) {
halfProcessed.add(new PrefixOperator((OperatorToken) current)); halfProcessed.add(new PrefixOperator((OperatorToken) current));
} } else {
else {
halfProcessed.add(current); halfProcessed.add(current);
} }
++position; ++position;
@ -148,8 +146,7 @@ public class Parser {
if (isStatement) { if (isStatement) {
return ParserProcessors.processStatement(halfProcessed); return ParserProcessors.processStatement(halfProcessed);
} } else {
else {
return ParserProcessors.processExpression(halfProcessed); return ParserProcessors.processExpression(halfProcessed);
} }
} }
@ -195,8 +192,7 @@ public class Parser {
} }
return Functions.getFunction(identifierToken.getPosition(), identifierToken.value, args.toArray(new RValue[args.size()])); return Functions.getFunction(identifierToken.getPosition(), identifierToken.value, args.toArray(new RValue[args.size()]));
} } catch (NoSuchMethodException e) {
catch (NoSuchMethodException e) {
throw new ParserException(identifierToken.getPosition(), "Function not found", e); throw new ParserException(identifierToken.getPosition(), "Function not found", e);
} }
} }

View File

@ -134,12 +134,10 @@ public final class ParserProcessors {
for (Identifiable identifiable : input) { for (Identifiable identifiable : input) {
if (semicolonFound) { if (semicolonFound) {
rhs.addLast(identifiable); rhs.addLast(identifiable);
} } else {
else {
if (identifiable.id() == ';') { if (identifiable.id() == ';') {
semicolonFound = true; semicolonFound = true;
} } else {
else {
lhs.addLast(identifiable); lhs.addLast(identifiable);
} }
} }
@ -151,12 +149,10 @@ public final class ParserProcessors {
} }
return processExpression(lhs); return processExpression(lhs);
} } else if (lhs.isEmpty()) {
else if (lhs.isEmpty()) {
return processStatement(rhs); return processStatement(rhs);
} } else {
else { assert (semicolonFound);
assert(semicolonFound);
RValue lhsInvokable = processExpression(lhs); RValue lhsInvokable = processExpression(lhs);
RValue rhsInvokable = processStatement(rhs); RValue rhsInvokable = processStatement(rhs);
@ -193,8 +189,7 @@ public final class ParserProcessors {
} }
rhs.removeFirst(); rhs.removeFirst();
} } else {
else {
lhs.addFirst(identifiable); lhs.addFirst(identifiable);
} }
} }
@ -206,8 +201,7 @@ public final class ParserProcessors {
try { try {
return Operators.getOperator(input.get(0).getPosition(), operator, lhsInvokable, rhsInvokable); return Operators.getOperator(input.get(0).getPosition(), operator, lhsInvokable, rhsInvokable);
} } catch (NoSuchMethodException e) {
catch (NoSuchMethodException e) {
final Token operatorToken = (Token) input.get(lhs.size()); final Token operatorToken = (Token) input.get(lhs.size());
throw new ParserException(operatorToken.getPosition(), "Couldn't find operator '" + operator + "'"); throw new ParserException(operatorToken.getPosition(), "Couldn't find operator '" + operator + "'");
} }
@ -236,8 +230,7 @@ public final class ParserProcessors {
} }
lhs.removeLast(); lhs.removeLast();
} } else {
else {
rhs.addLast(identifiable); rhs.addLast(identifiable);
} }
} }
@ -249,8 +242,7 @@ public final class ParserProcessors {
try { try {
return Operators.getOperator(input.get(0).getPosition(), operator, lhsInvokable, rhsInvokable); return Operators.getOperator(input.get(0).getPosition(), operator, lhsInvokable, rhsInvokable);
} } catch (NoSuchMethodException e) {
catch (NoSuchMethodException e) {
final Token operatorToken = (Token) input.get(lhs.size()); final Token operatorToken = (Token) input.get(lhs.size());
throw new ParserException(operatorToken.getPosition(), "Couldn't find operator '" + operator + "'"); throw new ParserException(operatorToken.getPosition(), "Couldn't find operator '" + operator + "'");
} }
@ -280,19 +272,16 @@ public final class ParserProcessors {
try { try {
ret = Operators.getOperator(lastPosition, opName, ret); ret = Operators.getOperator(lastPosition, opName, ret);
continue; continue;
} } catch (NoSuchMethodException e) {
catch (NoSuchMethodException e) {
throw new ParserException(lastPosition, "No such prefix operator: " + operator); throw new ParserException(lastPosition, "No such prefix operator: " + operator);
} }
} }
} }
if (last instanceof Token) { if (last instanceof Token) {
throw new ParserException(lastPosition, "Extra token found in expression: " + last); throw new ParserException(lastPosition, "Extra token found in expression: " + last);
} } else if (last instanceof RValue) {
else if (last instanceof RValue) {
throw new ParserException(lastPosition, "Extra expression found: " + last); throw new ParserException(lastPosition, "Extra expression found: " + last);
} } else {
else {
throw new ParserException(lastPosition, "Extra element found: " + last); throw new ParserException(lastPosition, "Extra element found: " + last);
} }
} }

View File

@ -49,14 +49,12 @@ public class Function extends RValue {
public final double getValue() throws EvaluationException { public final double getValue() throws EvaluationException {
try { try {
return (Double) method.invoke(null, (Object[]) args); return (Double) method.invoke(null, (Object[]) args);
} } catch (InvocationTargetException e) {
catch (InvocationTargetException e) {
if (e.getTargetException() instanceof EvaluationException) { if (e.getTargetException() instanceof EvaluationException) {
throw (EvaluationException) e.getTargetException(); throw (EvaluationException) e.getTargetException();
} }
throw new EvaluationException(-1, "Exception caught while evaluating expression", e.getTargetException()); throw new EvaluationException(-1, "Exception caught while evaluating expression", e.getTargetException());
} } catch (IllegalAccessException e) {
catch (IllegalAccessException e) {
throw new EvaluationException(-1, "Internal error while evaluating expression", e); throw new EvaluationException(-1, "Internal error while evaluating expression", e);
} }
} }
@ -99,8 +97,7 @@ public class Function extends RValue {
if (optimizable) { if (optimizable) {
return new Constant(position, getValue()); return new Constant(position, getValue());
} } else {
else {
return new Function(position, method, optimizedArgs); return new Function(position, method, optimizedArgs);
} }
} }

View File

@ -29,8 +29,8 @@ public final class Operators {
if (lhs instanceof LValue) { if (lhs instanceof LValue) {
try { try {
return new Function(position, Operators.class.getMethod(name, LValue.class, RValue.class), lhs, rhs); return new Function(position, Operators.class.getMethod(name, LValue.class, RValue.class), lhs, rhs);
} catch (NoSuchMethodException e) {
} }
catch (NoSuchMethodException e) {}
} }
return new Function(position, Operators.class.getMethod(name, RValue.class, RValue.class), lhs, rhs); return new Function(position, Operators.class.getMethod(name, RValue.class, RValue.class), lhs, rhs);
} }
@ -39,8 +39,8 @@ public final class Operators {
if (argument instanceof LValue) { if (argument instanceof LValue) {
try { try {
return new Function(position, Operators.class.getMethod(name, LValue.class), argument); return new Function(position, Operators.class.getMethod(name, LValue.class), argument);
} catch (NoSuchMethodException e) {
} }
catch (NoSuchMethodException e) {}
} }
return new Function(position, Operators.class.getMethod(name, RValue.class), argument); return new Function(position, Operators.class.getMethod(name, RValue.class), argument);
} }

View File

@ -75,8 +75,7 @@ public class Sequence extends RValue {
for (RValue subInvokable : ((Sequence) invokable).sequence) { for (RValue subInvokable : ((Sequence) invokable).sequence) {
newSequence.add(subInvokable); newSequence.add(subInvokable);
} }
} } else {
else {
newSequence.add(invokable); newSequence.add(invokable);
} }
} }