Skip to content

Commit

Permalink
Merge pull request #171 from specs-feup/fix/issue_168
Browse files Browse the repository at this point in the history
[ClavaWeaver] Closes #168
  • Loading branch information
joaobispo authored Oct 24, 2024
2 parents e7f8957 + 51f452c commit 60cdfb7
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 59 deletions.
4 changes: 1 addition & 3 deletions Clava-JS/src-api/clava/ClavaJoinPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ export default class ClavaJoinPoints {
return wrapJoinPoint(
ClavaJavaTypes.AstFactory.callFromFunction(
unwrapJoinPoint($function),
// TODO: Made this change without testing. Similar case to scope()
//...unwrapJoinPoint(flattenArgsArray(callArgs))
unwrapJoinPoint(flattenArgsArray(callArgs))
)
);
Expand All @@ -244,7 +242,7 @@ export default class ClavaJoinPoints {
ClavaJavaTypes.AstFactory.call(
functionName,
unwrapJoinPoint($returnType),
...flattenArgsArray(callArgs).map(unwrapJoinPoint)
flattenArgsArray(callArgs).map(unwrapJoinPoint)
)
);
}
Expand Down
7 changes: 2 additions & 5 deletions ClavaLaraApi/src-lara/clava/clava/ClavaJoinPoints.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ private AJoinPoint toJpToBeInserted(String code) {

return CxxJoinpoints.create(CxxWeaver.getSnippetParser().parseStmt(code));
}

@Override
public AJoinPoint replaceWithImpl(AJoinPoint node) {
return CxxJoinpoints.create(CxxActions.replace(getNode(), node.getNode(), getWeaverEngine()));
Expand Down Expand Up @@ -1292,7 +1292,7 @@ public AJoinPoint setLastChildImpl(AJoinPoint value) {
}

// Otherwise, replace node
var lastChild =getLastChildImpl();
var lastChild = getLastChildImpl();
lastChild.replaceWith(value);
return lastChild;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public void setConfigImpl(AExpression[] args) {
*
* @param args
*/
public final void setConfig(AExpression[] args) {
public final void setConfig(Object[] args) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setConfig", this, Optional.empty(), new Object[] { args});
}
this.setConfigImpl(args);
this.setConfigImpl(pt.up.fe.specs.util.SpecsCollections.cast(args, AExpression.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setConfig", this, Optional.empty(), new Object[] { args});
}
Expand All @@ -108,12 +108,12 @@ public void setConfigFromStringsImpl(String[] args) {
*
* @param args
*/
public final void setConfigFromStrings(String[] args) {
public final void setConfigFromStrings(Object[] args) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setConfigFromStrings", this, Optional.empty(), new Object[] { args});
}
this.setConfigFromStringsImpl(args);
this.setConfigFromStringsImpl(pt.up.fe.specs.util.SpecsCollections.cast(args, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setConfigFromStrings", this, Optional.empty(), new Object[] { args});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,12 +863,12 @@ public void setParamsImpl(AParam[] params) {
* Sets the parameters of the function
* @param params
*/
public final void setParams(AParam[] params) {
public final void setParams(Object[] params) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setParams", this, Optional.empty(), new Object[] { params});
}
this.setParamsImpl(params);
this.setParamsImpl(pt.up.fe.specs.util.SpecsCollections.cast(params, AParam.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setParams", this, Optional.empty(), new Object[] { params});
}
Expand All @@ -889,12 +889,12 @@ public void setParamsFromStringsImpl(String[] params) {
* Overload that accepts strings that represent type-varname pairs (e.g., int param1)
* @param params
*/
public final void setParamsFromStrings(String[] params) {
public final void setParamsFromStrings(Object[] params) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setParamsFromStrings", this, Optional.empty(), new Object[] { params});
}
this.setParamsFromStringsImpl(params);
this.setParamsFromStringsImpl(pt.up.fe.specs.util.SpecsCollections.cast(params, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setParamsFromStrings", this, Optional.empty(), new Object[] { params});
}
Expand Down Expand Up @@ -999,12 +999,12 @@ public ACall newCallImpl(AJoinPoint[] args) {
* Creates a new call to this function
* @param args
*/
public final Object newCall(AJoinPoint[] args) {
public final Object newCall(Object[] args) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "newCall", this, Optional.empty(), new Object[] { args});
}
ACall result = this.newCallImpl(args);
ACall result = this.newCallImpl(pt.up.fe.specs.util.SpecsCollections.cast(args, AJoinPoint.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "newCall", this, Optional.ofNullable(result), new Object[] { args});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ public AJoinPoint replaceWithImpl(AJoinPoint[] node) {
* Overload which accepts a list of join points
* @param node
*/
public final Object replaceWith(AJoinPoint[] node) {
public final Object replaceWith(Object[] node) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "replaceWith", this, Optional.empty(), new Object[] { node});
}
AJoinPoint result = this.replaceWithImpl(node);
AJoinPoint result = this.replaceWithImpl(pt.up.fe.specs.util.SpecsCollections.cast(node, AJoinPoint.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "replaceWith", this, Optional.ofNullable(result), new Object[] { node});
}
Expand All @@ -219,12 +219,12 @@ public AJoinPoint replaceWithStringsImpl(String[] node) {
* Overload which accepts a list of strings
* @param node
*/
public final Object replaceWithStrings(String[] node) {
public final Object replaceWithStrings(Object[] node) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "replaceWithStrings", this, Optional.empty(), new Object[] { node});
}
AJoinPoint result = this.replaceWithStringsImpl(node);
AJoinPoint result = this.replaceWithStringsImpl(pt.up.fe.specs.util.SpecsCollections.cast(node, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "replaceWithStrings", this, Optional.ofNullable(result), new Object[] { node});
}
Expand Down Expand Up @@ -673,12 +673,12 @@ public void setInlineCommentsImpl(String[] comments) {
* Sets the commented that are embedded in a node
* @param comments
*/
public final void setInlineComments(String[] comments) {
public final void setInlineComments(Object[] comments) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setInlineComments", this, Optional.empty(), new Object[] { comments});
}
this.setInlineCommentsImpl(comments);
this.setInlineCommentsImpl(pt.up.fe.specs.util.SpecsCollections.cast(comments, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setInlineComments", this, Optional.empty(), new Object[] { comments});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,12 +697,12 @@ public void setPrivateImpl(String[] newVariables) {
* Sets the variables of a private clause of an OpenMP pragma
* @param newVariables
*/
public final void setPrivate(String[] newVariables) {
public final void setPrivate(Object[] newVariables) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setPrivate", this, Optional.empty(), new Object[] { newVariables});
}
this.setPrivateImpl(newVariables);
this.setPrivateImpl(pt.up.fe.specs.util.SpecsCollections.cast(newVariables, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setPrivate", this, Optional.empty(), new Object[] { newVariables});
}
Expand All @@ -725,12 +725,12 @@ public void setReductionImpl(String kind, String[] newVariables) {
* @param kind
* @param newVariables
*/
public final void setReduction(String kind, String[] newVariables) {
public final void setReduction(String kind, Object[] newVariables) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setReduction", this, Optional.empty(), kind, newVariables);
}
this.setReductionImpl(kind, newVariables);
this.setReductionImpl(kind, pt.up.fe.specs.util.SpecsCollections.cast(newVariables, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setReduction", this, Optional.empty(), kind, newVariables);
}
Expand Down Expand Up @@ -777,12 +777,12 @@ public void setFirstprivateImpl(String[] newVariables) {
* Sets the variables of a firstprivate clause of an OpenMP pragma
* @param newVariables
*/
public final void setFirstprivate(String[] newVariables) {
public final void setFirstprivate(Object[] newVariables) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setFirstprivate", this, Optional.empty(), new Object[] { newVariables});
}
this.setFirstprivateImpl(newVariables);
this.setFirstprivateImpl(pt.up.fe.specs.util.SpecsCollections.cast(newVariables, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setFirstprivate", this, Optional.empty(), new Object[] { newVariables});
}
Expand All @@ -803,12 +803,12 @@ public void setLastprivateImpl(String[] newVariables) {
* Sets the variables of a lastprivate clause of an OpenMP pragma
* @param newVariables
*/
public final void setLastprivate(String[] newVariables) {
public final void setLastprivate(Object[] newVariables) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setLastprivate", this, Optional.empty(), new Object[] { newVariables});
}
this.setLastprivateImpl(newVariables);
this.setLastprivateImpl(pt.up.fe.specs.util.SpecsCollections.cast(newVariables, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setLastprivate", this, Optional.empty(), new Object[] { newVariables});
}
Expand All @@ -829,12 +829,12 @@ public void setSharedImpl(String[] newVariables) {
* Sets the variables of a shared clause of an OpenMP pragma
* @param newVariables
*/
public final void setShared(String[] newVariables) {
public final void setShared(Object[] newVariables) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setShared", this, Optional.empty(), new Object[] { newVariables});
}
this.setSharedImpl(newVariables);
this.setSharedImpl(pt.up.fe.specs.util.SpecsCollections.cast(newVariables, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setShared", this, Optional.empty(), new Object[] { newVariables});
}
Expand All @@ -855,12 +855,12 @@ public void setCopyinImpl(String[] newVariables) {
* Sets the variables of a copyin clause of an OpenMP pragma
* @param newVariables
*/
public final void setCopyin(String[] newVariables) {
public final void setCopyin(Object[] newVariables) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setCopyin", this, Optional.empty(), new Object[] { newVariables});
}
this.setCopyinImpl(newVariables);
this.setCopyinImpl(pt.up.fe.specs.util.SpecsCollections.cast(newVariables, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setCopyin", this, Optional.empty(), new Object[] { newVariables});
}
Expand Down Expand Up @@ -959,12 +959,12 @@ public void setScheduleModifiersImpl(String[] modifiers) {
* Sets the value of the modifiers in the schedule clause of an OpenMP pragma. Can only be called if there is already a schedule clause in the directive, otherwise throws an exception
* @param modifiers
*/
public final void setScheduleModifiers(String[] modifiers) {
public final void setScheduleModifiers(Object[] modifiers) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setScheduleModifiers", this, Optional.empty(), new Object[] { modifiers});
}
this.setScheduleModifiersImpl(modifiers);
this.setScheduleModifiersImpl(pt.up.fe.specs.util.SpecsCollections.cast(modifiers, String.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setScheduleModifiers", this, Optional.empty(), new Object[] { modifiers});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,12 +740,12 @@ public void addProjectFromGitImpl(String gitRepo, String[] libs, String path) {
* @param libs
* @param path
*/
public final void addProjectFromGit(String gitRepo, String[] libs, String path) {
public final void addProjectFromGit(String gitRepo, Object[] libs, String path) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "addProjectFromGit", this, Optional.empty(), gitRepo, libs, path);
}
this.addProjectFromGitImpl(gitRepo, libs, path);
this.addProjectFromGitImpl(gitRepo, pt.up.fe.specs.util.SpecsCollections.cast(libs, String.class), path);
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "addProjectFromGit", this, Optional.empty(), gitRepo, libs, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,12 @@ public void setTemplateArgsTypesImpl(AType[] templateArgTypes) {
* Sets the template argument types of a template type
* @param templateArgTypes
*/
public final void setTemplateArgsTypes(AType[] templateArgTypes) {
public final void setTemplateArgsTypes(Object[] templateArgTypes) {
try {
if(hasListeners()) {
eventTrigger().triggerAction(Stage.BEGIN, "setTemplateArgsTypes", this, Optional.empty(), new Object[] { templateArgTypes});
}
this.setTemplateArgsTypesImpl(templateArgTypes);
this.setTemplateArgsTypesImpl(pt.up.fe.specs.util.SpecsCollections.cast(templateArgTypes, AType.class));
if(hasListeners()) {
eventTrigger().triggerAction(Stage.END, "setTemplateArgsTypes", this, Optional.empty(), new Object[] { templateArgTypes});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Abstract Weaver Implementation for CxxWeaver<br>
Since the generated abstract classes are always overwritten, their implementation should be done by extending those abstract classes with user-defined classes.<br>
The abstract class {@link pt.up.fe.specs.clava.weaver.abstracts.ACxxWeaverJoinPoint} can be used to add user-defined methods and fields which the user intends to add for all join points and are not intended to be used in LARA aspects.
The abstract class {@link pt.up.fe.specs.clava.weaver.abstracts.ACxxWeaverJoinPoint} contains attributes and actions common to all join points.
* The implementation of the abstract methods is mandatory!
* @author Lara C.
*/
Expand Down
Loading

0 comments on commit 60cdfb7

Please sign in to comment.