Skip to content

Commit

Permalink
Simplified the JavaUnboxingTypeVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
stanhebben committed Nov 15, 2024
1 parent 63d4298 commit 3e18e7a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void handleReturnValue(TypeID original, TypeID actual) {
private void handleGenericReturnValue(TypeID actual) {
if (CompilerUtils.isPrimitive(actual)) {
getJavaWriter().checkCast(context.getInternalName(new OptionalTypeID(actual)));
actual.accept(actual, unboxingTypeVisitor);
actual.accept( unboxingTypeVisitor);
} else {
Type asmType = Type.getType(context.getType(actual).getDescriptor());
getJavaWriter().checkCast(asmType);
Expand Down Expand Up @@ -329,7 +329,7 @@ public Void visitCheckNull(CheckNullExpression expression) {
javaWriter.aThrow();
javaWriter.label(end);

expression.type.accept(expression.type, optionalUnwrappingTypeVisitor);
expression.type.accept(optionalUnwrappingTypeVisitor);

return null;
}
Expand All @@ -344,7 +344,7 @@ public Void visitCoalesce(CoalesceExpression expression) {
expression.right.accept(this);
expression.right.type.accept(boxingTypeVisitor);
javaWriter.label(end);
expression.type.accept(expression.type, unboxingTypeVisitor);
expression.type.accept(unboxingTypeVisitor);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private void downCast(int typeNumber, Type t) {
TypeID type = statement.loopVariables[typeNumber].type;
if (CompilerUtils.isPrimitive(type)) {
javaWriter.checkCast(statementVisitor.context.getInternalName(new OptionalTypeID(type)));
type.accept(type, unboxingTypeVisitor);
type.accept(unboxingTypeVisitor);
} else {
javaWriter.checkCast(t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private void handleTypeArguments(JavaNativeMethod method, CallArguments argument
private void handleGenericReturnValue(TypeID actual) {
if (CompilerUtils.isPrimitive(actual)) {
javaWriter.checkCast(context.getInternalName(new OptionalTypeID(actual)));
actual.accept(actual, unboxingTypeVisitor);
actual.accept(unboxingTypeVisitor);
} else {
javaWriter.checkCast(context.getInternalName(actual));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.openzen.zenscript.javashared.JavaClass;
import org.openzen.zenscript.javashared.JavaNativeMethod;

public class JavaUnboxingTypeVisitor implements TypeVisitorWithContext<TypeID, Void, RuntimeException> {
public class JavaUnboxingTypeVisitor implements TypeVisitor<Void> {

private static final JavaNativeMethod UNBOX_BOOLEAN = JavaNativeMethod.getNativeVirtual(JavaClass.BOOLEAN, "booleanValue", "()Z");
private static final JavaNativeMethod UNBOX_BYTE = JavaNativeMethod.getNativeVirtual(JavaClass.BYTE, "byteValue", "()B");
Expand Down Expand Up @@ -33,7 +33,7 @@ private JavaUnboxingTypeVisitor(JavaWriter writer, boolean unwrapping) {


@Override
public Void visitBasic(TypeID context, BasicTypeID basic) throws RuntimeException {
public Void visitBasic(BasicTypeID basic) {
final JavaNativeMethod method;

switch (basic) {
Expand Down Expand Up @@ -83,55 +83,55 @@ public Void visitBasic(TypeID context, BasicTypeID basic) throws RuntimeExceptio
}

@Override
public Void visitArray(TypeID context, ArrayTypeID array) throws RuntimeException {
public Void visitArray(ArrayTypeID array) {
//NO-OP
return null;
}

@Override
public Void visitAssoc(TypeID context, AssocTypeID assoc) throws RuntimeException {
public Void visitAssoc(AssocTypeID assoc) {
//NO-OP
return null;
}

@Override
public Void visitGenericMap(TypeID context, GenericMapTypeID map) throws RuntimeException {
public Void visitGenericMap(GenericMapTypeID map) {
//NO-OP
return null;
}

@Override
public Void visitIterator(TypeID context, IteratorTypeID iterator) throws RuntimeException {
public Void visitIterator(IteratorTypeID iterator) {
//NO-OP
return null;
}

@Override
public Void visitFunction(TypeID context, FunctionTypeID function) throws RuntimeException {
public Void visitFunction(FunctionTypeID function) {
//NO-OP
return null;
}

@Override
public Void visitDefinition(TypeID context, DefinitionTypeID definition) throws RuntimeException {
public Void visitDefinition(DefinitionTypeID definition) {
//NO-OP
return null;
}

@Override
public Void visitGeneric(TypeID context, GenericTypeID generic) throws RuntimeException {
public Void visitGeneric(GenericTypeID generic) {
//NO-OP
return null;
}

@Override
public Void visitRange(TypeID context, RangeTypeID range) throws RuntimeException {
public Void visitRange(RangeTypeID range) {
//NO-OP
return null;
}

@Override
public Void visitOptional(TypeID context, OptionalTypeID type) throws RuntimeException {
public Void visitOptional(OptionalTypeID type) {
//NO-OP
return null;
}
Expand Down

0 comments on commit 3e18e7a

Please sign in to comment.