Skip to content

Commit

Permalink
Cleanup: Apply some things seen during the code-review
Browse files Browse the repository at this point in the history
  • Loading branch information
kindlich committed Sep 14, 2024
1 parent 6f75deb commit e607ae4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

public class JavaFieldBytecodeCompiler implements JavaFieldCompiler<Void> {
private final JavaWriter javaWriter;
private final ExpressionVisitor<Void> expressionVisitor;
private final JavaExpressionVisitor expressionVisitor;
private final boolean pushing;

public JavaFieldBytecodeCompiler(JavaWriter javaWriter, ExpressionVisitor<Void> expressionVisitor, boolean pushing) {
public JavaFieldBytecodeCompiler(JavaWriter javaWriter, JavaExpressionVisitor expressionVisitor, boolean pushing) {
this.javaWriter = javaWriter;
this.expressionVisitor = expressionVisitor;
this.pushing = pushing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public class JavaNonPushingExpressionVisitor implements ExpressionVisitor<Void>
private final JavaBytecodeContext context;
private final JavaCompiledModule module;
private final JavaWriter javaWriter;
private final ExpressionVisitor<Void> original;
private final JavaExpressionVisitor original;
private final JavaFieldBytecodeCompiler fieldCompiler;
private final JavaMangler mangler;

public JavaNonPushingExpressionVisitor(JavaBytecodeContext context, JavaCompiledModule module, JavaWriter javaWriter, JavaMangler mangler, ExpressionVisitor<Void> original) {
public JavaNonPushingExpressionVisitor(JavaBytecodeContext context, JavaCompiledModule module, JavaWriter javaWriter, JavaMangler mangler, JavaExpressionVisitor original) {
this.context = context;
this.module = module;
this.javaWriter = javaWriter;
Expand Down Expand Up @@ -335,8 +335,7 @@ public Void visitPlatformSpecific(Expression expression) {

@Override
public Void visitModification(ModificationExpression expression) {
// Todo: fix cast
((JavaExpressionVisitor)original).modify(expression, PushOption.NONE);
original.modify(expression, PushOption.NONE);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.openzen.zenscript.javabytecode.compiler.JavaWriter;

/**
* {@link CapturedExpressionVisitor} used to inside a lambda expression.
* {@link CapturedExpressionVisitor} used to access captured values inside a lambda expression.
*/
public class JavaCapturedExpressionVisitorToAccessCapturesInsideTheLambda implements CapturedExpressionVisitor<Void> {

Expand Down Expand Up @@ -41,6 +41,7 @@ public Void visitCapturedThis(CapturedThisExpression expression) {
@Override
public Void visitCapturedParameter(CapturedParameterExpression expression) {
final int position = calculateMemberPosition(expression, this.functionExpression);

javaWriter.loadObject(0);
javaWriter.getField(lambdaClassName, this.javaMangler.mangleCapturedParameter(position, false), context.getDescriptor(expression.parameter.type));
return null;
Expand All @@ -57,7 +58,7 @@ public Void visitCapturedLocal(CapturedLocalVariableExpression expression) {

@Override
public Void visitRecaptured(CapturedClosureExpression expression) {
int position = findIndex(expression);
final int position = findIndex(expression);

javaWriter.loadObject(0);
javaWriter.getField(lambdaClassName, this.javaMangler.mangleCapturedParameter(position, false), context.getDescriptor(expression.type));
Expand Down

0 comments on commit e607ae4

Please sign in to comment.