[ClavaWeaver] Disables replacement of method prototypes with implementations
This is already being handled in Selector._addJps, and produces unwanted results (i.e. if there is both a prototype and an implementations, returns both, as implementations);
@@ -24,10 +24,8 @@ import org.lara.interpreter.weaver.interf.WeaverEngine;
import pt.up.fe.specs.clava.ClavaNode;
import pt.up.fe.specs.clava.ast.decl.CXXMethodDecl;
-import pt.up.fe.specs.clava.ast.decl.CXXRecordDecl;
import pt.up.fe.specs.clava.ast.decl.FunctionDecl;
import pt.up.fe.specs.clava.utils.NullNode;
-import pt.up.fe.specs.util.SpecsCheck;
public class ClavaAstMethods extends TreeNodeAstMethods<ClavaNode> {
@@ -41,7 +39,7 @@ public class ClavaAstMethods extends TreeNodeAstMethods<ClavaNode> {
@Override
protected Object[] getChildrenImpl(ClavaNode node) {
- final List<Object> childrenList = Arrays.asList(node.getChildren());
+ // final List<Object> childrenList = Arrays.asList(node.getChildren());
var children = node.getChildren().stream()
// Filter null nodes
@@ -51,9 +49,14 @@ public class ClavaAstMethods extends TreeNodeAstMethods<ClavaNode> {
.toArray();
/* */
+
+ // This is already being handled in Selector._addJps
+ /*
if (node instanceof CXXRecordDecl) {
replaceForMethodImplementations(children);
}
+ */
+
/* */
return children;
@@ -67,6 +70,7 @@ public class ClavaAstMethods extends TreeNodeAstMethods<ClavaNode> {
return getChildrenImpl(node).length;
}
+ /*
protected static boolean lclFilter(ClavaNode node) {
// Function
if (node instanceof FunctionDecl) {
@@ -87,40 +91,28 @@ public class ClavaAstMethods extends TreeNodeAstMethods<ClavaNode> {
return definition.get() == node;
}
- /*
- // Classes
- if (node instanceof CXXRecordDecl) {
-
- if (node.get(TagDecl.IS_COMPLETE_DEFINITION))
- return true;
- var definition = node.get(CXXRecordDecl.RECORD_DEFINITION);
- if (definition.isPresent() && definition.get() == node)
- return false;
-
- else
- return true;
-
- }
- */
// No other cases
return true;
}
-
+ */
protected static Object replaceMethodImplementation(Object child, List<Object> childrenList) {
// check if CXXMethodDecl
- if (!(child instanceof CXXMethodDecl)) return child;
+ if (!(child instanceof CXXMethodDecl))
+ return child;
CXXMethodDecl method = (CXXMethodDecl) child;
// if has body, do nothing
- if (method.hasBody()) return child;
+ if (method.hasBody())
+ return child;
// if implementation is equal, do nothing
Optional<FunctionDecl> implementationOptional = method.getImplementation();
- if (!implementationOptional.isPresent() || method.equals(implementationOptional.get())) return child;
+ if (!implementationOptional.isPresent() || method.equals(implementationOptional.get()))
+ return child;
FunctionDecl implementation = implementationOptional.get();
@@ -138,7 +130,8 @@ public class ClavaAstMethods extends TreeNodeAstMethods<ClavaNode> {
.map(impl -> impl.get().getCode())
.anyMatch(code -> code.equals(implementation.getCode()));
- if (isAlreadyInMethodsList) return child;
+ if (isAlreadyInMethodsList)
+ return child;
// System.out.println("replacing impl for => " + node.getDeclName() + "." + method.getDeclName());
@@ -194,5 +187,4 @@ public class ClavaAstMethods extends TreeNodeAstMethods<ClavaNode> {
return children;
}
-
}
