mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 04:23:54 +00:00
Remove non-valued return
(cherry picked from commit 42e515f43523ffbfe0b28c2f3f5c342e4d4b1c1d)
This commit is contained in:
@ -34,6 +34,8 @@ import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Compiles and evaluates expressions.
|
||||
*
|
||||
@ -119,7 +121,9 @@ public class Expression {
|
||||
|
||||
Instant deadline = Instant.now().plusMillis(timeout);
|
||||
// evaluation exceptions are thrown out of this method
|
||||
return compiledExpression.execute(new ExecutionData(slots, functions, deadline));
|
||||
Double result = compiledExpression.execute(new ExecutionData(slots, functions, deadline));
|
||||
checkNotNull(result, "Expression must result in a value");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void optimize() {
|
||||
|
@ -227,19 +227,12 @@ class CompilingVisitor extends ExpressionBaseVisitor<MethodHandle> {
|
||||
|
||||
@Override
|
||||
public MethodHandle visitReturnStatement(ExpressionParser.ReturnStatementContext ctx) {
|
||||
// MH:returnValue = (ExecutionData)Double
|
||||
MethodHandle returnValue;
|
||||
if (ctx.value != null) {
|
||||
returnValue = evaluate(ctx.value).handle;
|
||||
} else {
|
||||
returnValue = defaultResult();
|
||||
}
|
||||
return MethodHandles.filterArguments(
|
||||
// take the (Double)Double return statement
|
||||
RETURN_STATEMENT_BASE,
|
||||
0,
|
||||
// map the Double back to ExecutionData via the returnValue
|
||||
returnValue
|
||||
evaluate(ctx.value).handle
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user