From aba637d196082367507c6af0e62866fd21480b1f Mon Sep 17 00:00:00 2001 From: Col-E Date: Mon, 18 Sep 2023 05:52:49 -0400 Subject: [PATCH] Make argument subtypes public, add type exposure --- .../main/java/dev/xdark/ssvm/invoke/Argument.java | 6 ++++++ .../java/dev/xdark/ssvm/invoke/DoubleArgument.java | 12 +++++++++++- .../java/dev/xdark/ssvm/invoke/FloatArgument.java | 12 +++++++++++- .../main/java/dev/xdark/ssvm/invoke/IntArgument.java | 12 +++++++++++- .../java/dev/xdark/ssvm/invoke/LongArgument.java | 12 +++++++++++- .../dev/xdark/ssvm/invoke/ReferenceArgument.java | 12 +++++++++++- 6 files changed, 61 insertions(+), 5 deletions(-) diff --git a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/Argument.java b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/Argument.java index 9f31a52..7f22cca 100644 --- a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/Argument.java +++ b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/Argument.java @@ -2,6 +2,7 @@ import dev.xdark.ssvm.execution.Locals; import dev.xdark.ssvm.value.ObjectValue; +import org.objectweb.asm.Type; /** * Method argument. @@ -19,6 +20,11 @@ public interface Argument { */ int store(Locals locals, int index); + /** + * @return Argument value type. + */ + Type getType(); + /** * {@literal long} argument. * diff --git a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/DoubleArgument.java b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/DoubleArgument.java index 9a02e25..1b46ab8 100644 --- a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/DoubleArgument.java +++ b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/DoubleArgument.java @@ -1,22 +1,32 @@ package dev.xdark.ssvm.invoke; import dev.xdark.ssvm.execution.Locals; +import org.objectweb.asm.Type; /** * Int argument. * * @author xDark */ -final class DoubleArgument implements Argument { +public final class DoubleArgument implements Argument { private final double value; DoubleArgument(double value) { this.value = value; } + public double getValue() { + return value; + } + @Override public int store(Locals locals, int index) { locals.setDouble(index, value); return 2; } + + @Override + public Type getType() { + return Type.DOUBLE_TYPE; + } } diff --git a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/FloatArgument.java b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/FloatArgument.java index 5e76382..2a0cf92 100644 --- a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/FloatArgument.java +++ b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/FloatArgument.java @@ -1,22 +1,32 @@ package dev.xdark.ssvm.invoke; import dev.xdark.ssvm.execution.Locals; +import org.objectweb.asm.Type; /** * Float argument. * * @author xDark */ -final class FloatArgument implements Argument { +public final class FloatArgument implements Argument { private final float value; FloatArgument(float value) { this.value = value; } + public float getValue() { + return value; + } + @Override public int store(Locals locals, int index) { locals.setFloat(index, value); return 1; } + + @Override + public Type getType() { + return Type.FLOAT_TYPE; + } } diff --git a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/IntArgument.java b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/IntArgument.java index 7a38afe..4ecd994 100644 --- a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/IntArgument.java +++ b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/IntArgument.java @@ -1,22 +1,32 @@ package dev.xdark.ssvm.invoke; import dev.xdark.ssvm.execution.Locals; +import org.objectweb.asm.Type; /** * Int argument. * * @author xDark */ -final class IntArgument implements Argument { +public final class IntArgument implements Argument { private final int value; IntArgument(int value) { this.value = value; } + public int getValue() { + return value; + } + @Override public int store(Locals locals, int index) { locals.setInt(index, value); return 1; } + + @Override + public Type getType() { + return Type.INT_TYPE; + } } diff --git a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/LongArgument.java b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/LongArgument.java index 19f9d1a..421a1d6 100644 --- a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/LongArgument.java +++ b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/LongArgument.java @@ -1,22 +1,32 @@ package dev.xdark.ssvm.invoke; import dev.xdark.ssvm.execution.Locals; +import org.objectweb.asm.Type; /** * Long argument. * * @author xDark */ -final class LongArgument implements Argument { +public final class LongArgument implements Argument { private final long value; LongArgument(long value) { this.value = value; } + public long getValue() { + return value; + } + @Override public int store(Locals locals, int index) { locals.setLong(index, value); return 2; } + + @Override + public Type getType() { + return Type.LONG_TYPE; + } } diff --git a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/ReferenceArgument.java b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/ReferenceArgument.java index 334d43d..7f94335 100644 --- a/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/ReferenceArgument.java +++ b/ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/ReferenceArgument.java @@ -2,22 +2,32 @@ import dev.xdark.ssvm.execution.Locals; import dev.xdark.ssvm.value.ObjectValue; +import org.objectweb.asm.Type; /** * Reference argument. * * @author xDark */ -final class ReferenceArgument implements Argument { +public final class ReferenceArgument implements Argument { private final ObjectValue value; ReferenceArgument(ObjectValue value) { this.value = value; } + public ObjectValue getValue() { + return value; + } + @Override public int store(Locals locals, int index) { locals.setReference(index, value); return 1; } + + @Override + public Type getType() { + return value.getJavaClass().getType(); + } }