Make scarpet internal and control flow exceptions stackless (#1392)
This commit is contained in:
1 parent
76861479e0
commit
80a5342776
5 files changed
+23
-4
No files matched your search
@@ -5,7 +5,7 @@ import carpet.utils.Messenger;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
|
||||||
public class CarpetExpressionException extends RuntimeException implements ResolvedException
|
public class CarpetExpressionException extends StacklessRuntimeException implements ResolvedException
|
||||||
{
|
{
|
||||||
public final List<FunctionValue> stack;
|
public final List<FunctionValue> stack;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package carpet.script.exception;
|
|||||||
import carpet.script.value.Value;
|
import carpet.script.value.Value;
|
||||||
|
|
||||||
/* Exception thrown to terminate execution mid expression (aka return statement) */
|
/* Exception thrown to terminate execution mid expression (aka return statement) */
|
||||||
public class ExitStatement extends RuntimeException
|
public class ExitStatement extends StacklessRuntimeException
|
||||||
{
|
{
|
||||||
public final Value retval;
|
public final Value retval;
|
||||||
public ExitStatement(Value value)
|
public ExitStatement(Value value)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/* The expression evaluators exception class. */
|
/* The expression evaluators exception class. */
|
||||||
public class ExpressionException extends RuntimeException implements ResolvedException
|
public class ExpressionException extends StacklessRuntimeException implements ResolvedException
|
||||||
{
|
{
|
||||||
public final Context context;
|
public final Context context;
|
||||||
public final Tokenizer.Token token;
|
public final Tokenizer.Token token;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/* The internal expression evaluators exception class. */
|
/* The internal expression evaluators exception class. */
|
||||||
public class InternalExpressionException extends RuntimeException
|
public class InternalExpressionException extends StacklessRuntimeException
|
||||||
{
|
{
|
||||||
public List<FunctionValue> stack = new ArrayList<>();
|
public List<FunctionValue> stack = new ArrayList<>();
|
||||||
public InternalExpressionException(String message)
|
public InternalExpressionException(String message)
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package carpet.script.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A type of {@link RuntimeException} that doesn't spend time producing and filling a stacktrace
|
||||||
|
*/
|
||||||
|
abstract class StacklessRuntimeException extends RuntimeException {
|
||||||
|
public StacklessRuntimeException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StacklessRuntimeException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Throwable fillInStackTrace() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user