mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Improved accuracy of Function.getPosition() after optimization.
This commit is contained in:
parent
0ca66ce350
commit
ef5fba0f05
@ -76,19 +76,24 @@ public class Function extends Invokable {
|
|||||||
public Invokable optimize() throws EvaluationException {
|
public Invokable optimize() throws EvaluationException {
|
||||||
final Invokable[] optimizedArgs = new Invokable[args.length];
|
final Invokable[] optimizedArgs = new Invokable[args.length];
|
||||||
boolean optimizable = !method.isAnnotationPresent(Dynamic.class);
|
boolean optimizable = !method.isAnnotationPresent(Dynamic.class);
|
||||||
|
int position = getPosition();
|
||||||
for (int i = 0; i < args.length; ++i) {
|
for (int i = 0; i < args.length; ++i) {
|
||||||
final Invokable optimized = optimizedArgs[i] = args[i].optimize();
|
final Invokable optimized = optimizedArgs[i] = args[i].optimize();
|
||||||
|
|
||||||
if (!(optimized instanceof Constant)) {
|
if (!(optimized instanceof Constant)) {
|
||||||
optimizable = false;
|
optimizable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (optimized.getPosition() < position) {
|
||||||
|
position = optimized.getPosition();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optimizable) {
|
if (optimizable) {
|
||||||
return new Constant(getPosition(), invoke());
|
return new Constant(position, invoke());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new Function(getPosition(), method, optimizedArgs);
|
return new Function(position, method, optimizedArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user