Skip to content

Commit 3e18e7a

Browse files
committed
Simplified the JavaUnboxingTypeVisitor
1 parent 63d4298 commit 3e18e7a

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ void handleReturnValue(TypeID original, TypeID actual) {
285285
private void handleGenericReturnValue(TypeID actual) {
286286
if (CompilerUtils.isPrimitive(actual)) {
287287
getJavaWriter().checkCast(context.getInternalName(new OptionalTypeID(actual)));
288-
actual.accept(actual, unboxingTypeVisitor);
288+
actual.accept( unboxingTypeVisitor);
289289
} else {
290290
Type asmType = Type.getType(context.getType(actual).getDescriptor());
291291
getJavaWriter().checkCast(asmType);
@@ -329,7 +329,7 @@ public Void visitCheckNull(CheckNullExpression expression) {
329329
javaWriter.aThrow();
330330
javaWriter.label(end);
331331

332-
expression.type.accept(expression.type, optionalUnwrappingTypeVisitor);
332+
expression.type.accept(optionalUnwrappingTypeVisitor);
333333

334334
return null;
335335
}
@@ -344,7 +344,7 @@ public Void visitCoalesce(CoalesceExpression expression) {
344344
expression.right.accept(this);
345345
expression.right.type.accept(boxingTypeVisitor);
346346
javaWriter.label(end);
347-
expression.type.accept(expression.type, unboxingTypeVisitor);
347+
expression.type.accept(unboxingTypeVisitor);
348348
return null;
349349
}
350350

JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaForeachWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private void downCast(int typeNumber, Type t) {
235235
TypeID type = statement.loopVariables[typeNumber].type;
236236
if (CompilerUtils.isPrimitive(type)) {
237237
javaWriter.checkCast(statementVisitor.context.getInternalName(new OptionalTypeID(type)));
238-
type.accept(type, unboxingTypeVisitor);
238+
type.accept(unboxingTypeVisitor);
239239
} else {
240240
javaWriter.checkCast(t);
241241
}

JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaMethodBytecodeCompiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private void handleTypeArguments(JavaNativeMethod method, CallArguments argument
273273
private void handleGenericReturnValue(TypeID actual) {
274274
if (CompilerUtils.isPrimitive(actual)) {
275275
javaWriter.checkCast(context.getInternalName(new OptionalTypeID(actual)));
276-
actual.accept(actual, unboxingTypeVisitor);
276+
actual.accept(unboxingTypeVisitor);
277277
} else {
278278
javaWriter.checkCast(context.getInternalName(actual));
279279
}

JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaUnboxingTypeVisitor.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.openzen.zenscript.javashared.JavaClass;
55
import org.openzen.zenscript.javashared.JavaNativeMethod;
66

7-
public class JavaUnboxingTypeVisitor implements TypeVisitorWithContext<TypeID, Void, RuntimeException> {
7+
public class JavaUnboxingTypeVisitor implements TypeVisitor<Void> {
88

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

3434

3535
@Override
36-
public Void visitBasic(TypeID context, BasicTypeID basic) throws RuntimeException {
36+
public Void visitBasic(BasicTypeID basic) {
3737
final JavaNativeMethod method;
3838

3939
switch (basic) {
@@ -83,55 +83,55 @@ public Void visitBasic(TypeID context, BasicTypeID basic) throws RuntimeExceptio
8383
}
8484

8585
@Override
86-
public Void visitArray(TypeID context, ArrayTypeID array) throws RuntimeException {
86+
public Void visitArray(ArrayTypeID array) {
8787
//NO-OP
8888
return null;
8989
}
9090

9191
@Override
92-
public Void visitAssoc(TypeID context, AssocTypeID assoc) throws RuntimeException {
92+
public Void visitAssoc(AssocTypeID assoc) {
9393
//NO-OP
9494
return null;
9595
}
9696

9797
@Override
98-
public Void visitGenericMap(TypeID context, GenericMapTypeID map) throws RuntimeException {
98+
public Void visitGenericMap(GenericMapTypeID map) {
9999
//NO-OP
100100
return null;
101101
}
102102

103103
@Override
104-
public Void visitIterator(TypeID context, IteratorTypeID iterator) throws RuntimeException {
104+
public Void visitIterator(IteratorTypeID iterator) {
105105
//NO-OP
106106
return null;
107107
}
108108

109109
@Override
110-
public Void visitFunction(TypeID context, FunctionTypeID function) throws RuntimeException {
110+
public Void visitFunction(FunctionTypeID function) {
111111
//NO-OP
112112
return null;
113113
}
114114

115115
@Override
116-
public Void visitDefinition(TypeID context, DefinitionTypeID definition) throws RuntimeException {
116+
public Void visitDefinition(DefinitionTypeID definition) {
117117
//NO-OP
118118
return null;
119119
}
120120

121121
@Override
122-
public Void visitGeneric(TypeID context, GenericTypeID generic) throws RuntimeException {
122+
public Void visitGeneric(GenericTypeID generic) {
123123
//NO-OP
124124
return null;
125125
}
126126

127127
@Override
128-
public Void visitRange(TypeID context, RangeTypeID range) throws RuntimeException {
128+
public Void visitRange(RangeTypeID range) {
129129
//NO-OP
130130
return null;
131131
}
132132

133133
@Override
134-
public Void visitOptional(TypeID context, OptionalTypeID type) throws RuntimeException {
134+
public Void visitOptional(OptionalTypeID type) {
135135
//NO-OP
136136
return null;
137137
}

0 commit comments

Comments
 (0)