Temporary pull request for experiment with join point hierarchy#217
Temporary pull request for experiment with join point hierarchy#217
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the CxxUnaryOp class to extend directly from CxxOp instead of wrapping an AOp instance, and similarly updates the abstract AUnaryOp class to extend from CxxOp rather than AOp. This simplifies the join point hierarchy by removing an unnecessary delegation layer.
Key Changes:
- Simplified inheritance structure by extending
CxxOpdirectly - Removed instance field and delegation pattern in favor of direct method calls
- Updated method implementations to use
getNode()instead of storing a field reference
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| CxxUnaryOp.java | Refactored to extend from parent's node storage instead of maintaining a separate field; updated method implementations to call getNode() |
| AUnaryOp.java | Changed from wrapping AOp to directly extending CxxOp, removing hundreds of lines of delegation code |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private final UnaryOperator unaryOp; | ||
| public class CxxUnaryOp extends AUnaryOp { | ||
|
|
||
| public CxxUnaryOp(UnaryOperator unaryOp) { |
There was a problem hiding this comment.
The constructor accepts UnaryOperator but passes it to a parent constructor expecting Operator. While UnaryOperator likely extends Operator, the type signature is misleading. Consider updating the constructor parameter type to match the parent constructor's expected type for clarity.
| public CxxUnaryOp(UnaryOperator unaryOp) { | |
| public CxxUnaryOp(pt.up.fe.specs.clava.ast.expr.Operator unaryOp) { |
| public AUnaryOp(ClavaNode op) { | ||
| super((Operator) op); |
There was a problem hiding this comment.
The constructor accepts ClavaNode but immediately casts it to Operator when calling the parent constructor. This introduces an unsafe cast that could fail at runtime if a non-Operator ClavaNode is passed. Consider changing the parameter type to Operator to make the type requirement explicit and move the type safety check to compile time.
| public AUnaryOp(ClavaNode op) { | |
| super((Operator) op); | |
| public AUnaryOp(Operator op) { | |
| super(op); |
Temporary pull request for experiment with join point hierarchy just to show a possibility, and that it passes the tests