Skip to content

Commit

Permalink
feat(objectionary#344): naive attempt to fix the problem with Constru…
Browse files Browse the repository at this point in the history
…ctors transformation
  • Loading branch information
volodya-lombrozo committed Aug 2, 2024
1 parent 2b37e3b commit 0ec0500
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
import java.util.Collections;
import java.util.List;
import org.eolang.opeo.ast.AstNode;
import org.eolang.opeo.ast.Attributes;
import org.eolang.opeo.ast.Constructor;
import org.eolang.opeo.ast.Duplicate;
import org.eolang.opeo.ast.Labeled;
import org.eolang.opeo.ast.NewAddress;
import org.eolang.opeo.ast.Super;
import org.eolang.opeo.ast.This;
import org.eolang.opeo.decompilation.DecompilerState;
Expand Down Expand Up @@ -80,14 +84,37 @@ public void handle(final DecompilerState state) {
);
Collections.reverse(args);
final AstNode target = state.stack().pop();
if (InvokespecialHandler.isThis(target)) {
final boolean istarget = InvokespecialHandler.isThis(target);
if (istarget) {
state.stack().push(
new Super(target, args, descriptor, type, name)
);
} else if (this.isNewAddress(target)) {
state.stack().push(
new Constructor(
target,
new Attributes().descriptor(descriptor).interfaced(interfaced),
args
)
);

} else {
state.stack().push(
new Super(target, args, descriptor, type, name)
);
// state.stack().push(
// new Super(target, args, descriptor, type, name)
// );
}
}

private boolean isNewAddress(final AstNode target) {
if (target instanceof NewAddress) {
return true;
} else if (target instanceof Duplicate) {
return this.isNewAddress(((Duplicate) target).origin());
} else {
return false;
}
}

Expand Down

0 comments on commit 0ec0500

Please sign in to comment.