Skip to content

Commit

Permalink
Make argument subtypes public, add type exposure
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Feb 3, 2024
1 parent 3116343 commit aba637d
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 5 deletions.
6 changes: 6 additions & 0 deletions ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/Argument.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dev.xdark.ssvm.execution.Locals;
import dev.xdark.ssvm.value.ObjectValue;
import org.objectweb.asm.Type;

/**
* Method argument.
Expand All @@ -19,6 +20,11 @@ public interface Argument {
*/
int store(Locals locals, int index);

/**
* @return Argument value type.
*/
Type getType();

/**
* {@literal long} argument.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
12 changes: 11 additions & 1 deletion ssvm-invoke/src/main/java/dev/xdark/ssvm/invoke/IntArgument.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit aba637d

Please sign in to comment.