diff --git a/Clava-JS/src-api/clava/ClavaJoinPoints.ts b/Clava-JS/src-api/clava/ClavaJoinPoints.ts index 14d5f0a42..7eff4e398 100644 --- a/Clava-JS/src-api/clava/ClavaJoinPoints.ts +++ b/Clava-JS/src-api/clava/ClavaJoinPoints.ts @@ -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)) ) ); @@ -244,7 +242,7 @@ export default class ClavaJoinPoints { ClavaJavaTypes.AstFactory.call( functionName, unwrapJoinPoint($returnType), - ...flattenArgsArray(callArgs).map(unwrapJoinPoint) + flattenArgsArray(callArgs).map(unwrapJoinPoint) ) ); } diff --git a/ClavaLaraApi/src-lara/clava/clava/ClavaJoinPoints.js b/ClavaLaraApi/src-lara/clava/clava/ClavaJoinPoints.js index 630e5dada..b5f19a87d 100644 --- a/ClavaLaraApi/src-lara/clava/clava/ClavaJoinPoints.js +++ b/ClavaLaraApi/src-lara/clava/clava/ClavaJoinPoints.js @@ -124,10 +124,7 @@ export default class ClavaJoinPoints { * @param callArgs - The arguments of the function. */ static call($function, ...callArgs) { - return wrapJoinPoint(ClavaJavaTypes.AstFactory.callFromFunction(unwrapJoinPoint($function), - // TODO: Made this change without testing. Similar case to scope() - //...unwrapJoinPoint(flattenArgsArray(callArgs)) - unwrapJoinPoint(flattenArgsArray(callArgs)))); + return wrapJoinPoint(ClavaJavaTypes.AstFactory.callFromFunction(unwrapJoinPoint($function), unwrapJoinPoint(flattenArgsArray(callArgs)))); } /** * Creates a new join point 'call'. @@ -137,7 +134,7 @@ export default class ClavaJoinPoints { * @param callArgs - The arguments of the function. */ static callFromName(functionName, $returnType, ...callArgs) { - return wrapJoinPoint(ClavaJavaTypes.AstFactory.call(functionName, unwrapJoinPoint($returnType), ...flattenArgsArray(callArgs).map(unwrapJoinPoint))); + return wrapJoinPoint(ClavaJavaTypes.AstFactory.call(functionName, unwrapJoinPoint($returnType), flattenArgsArray(callArgs).map(unwrapJoinPoint))); } /** * Creates a new join point 'switch' diff --git a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/ACxxWeaverJoinPoint.java b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/ACxxWeaverJoinPoint.java index 25b5d7f82..c47c96a75 100644 --- a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/ACxxWeaverJoinPoint.java +++ b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/ACxxWeaverJoinPoint.java @@ -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())); @@ -1292,7 +1292,7 @@ public AJoinPoint setLastChildImpl(AJoinPoint value) { } // Otherwise, replace node - var lastChild =getLastChildImpl(); + var lastChild = getLastChildImpl(); lastChild.replaceWith(value); return lastChild; } diff --git a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/ACudaKernelCall.java b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/ACudaKernelCall.java index b2287a944..c33e7b6b8 100644 --- a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/ACudaKernelCall.java +++ b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/ACudaKernelCall.java @@ -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}); } @@ -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}); } diff --git a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AFunction.java b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AFunction.java index ffb2977cf..e159fdfbf 100644 --- a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AFunction.java +++ b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AFunction.java @@ -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}); } @@ -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}); } @@ -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}); } diff --git a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AJoinPoint.java b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AJoinPoint.java index 3d69cae68..4748e799e 100644 --- a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AJoinPoint.java +++ b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AJoinPoint.java @@ -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}); } @@ -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}); } @@ -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}); } diff --git a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AOmp.java b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AOmp.java index 9df994e84..cae08389e 100644 --- a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AOmp.java +++ b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AOmp.java @@ -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}); } @@ -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); } @@ -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}); } @@ -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}); } @@ -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}); } @@ -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}); } @@ -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}); } diff --git a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AProgram.java b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AProgram.java index 47880e777..785c37f38 100644 --- a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AProgram.java +++ b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AProgram.java @@ -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); } diff --git a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AType.java b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AType.java index 1862caf68..34a8d31e6 100644 --- a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AType.java +++ b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/joinpoints/AType.java @@ -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}); } diff --git a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/weaver/ACxxWeaver.java b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/weaver/ACxxWeaver.java index 5dc605d74..07b753885 100644 --- a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/weaver/ACxxWeaver.java +++ b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/abstracts/weaver/ACxxWeaver.java @@ -10,7 +10,7 @@ /** * Abstract Weaver Implementation for CxxWeaver
Since the generated abstract classes are always overwritten, their implementation should be done by extending those abstract classes with user-defined classes.
-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. */ diff --git a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/importable/AstFactory.java b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/importable/AstFactory.java index 12a01d24b..daf330835 100644 --- a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/importable/AstFactory.java +++ b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/importable/AstFactory.java @@ -150,8 +150,12 @@ public static AExpression exprLiteral(String code, AJoinPoint type) { return CxxJoinpoints.create(CxxWeaver.getFactory().literalExpr(code, astType), AExpression.class); } - public static AExpression cxxConstructExpr(AType type, AJoinPoint... constructorArguments) { - List exprArgs = Arrays.stream(constructorArguments) + public static AExpression cxxConstructExpr(AType type, Object[] constructorArguments) { + return cxxConstructExpr(type, SpecsCollections.asListT(AJoinPoint.class, constructorArguments)); + } + + public static AExpression cxxConstructExpr(AType type, List constructorArguments) { + List exprArgs = constructorArguments.stream() .map(arg -> (Expr) arg.getNode()) .collect(Collectors.toList()); @@ -174,19 +178,24 @@ public static ACall callFromFunction(AFunction function, List args) { Type returnType = (Type) typeJp.getNode(); DeclRefExpr declRef = CxxWeaver.getFactory().declRefExpr(functionName, returnType); - List argTypes = Arrays.stream(args) + List argTypes = args.stream() .map(arg -> ((Typable) arg.getNode()).getType()) .collect(Collectors.toList()); FunctionProtoType type = CxxWeaver.getFactory().functionProtoType(returnType, argTypes); - List exprArgs = Arrays.stream(args) + List exprArgs = args.stream() .map(arg -> (Expr) arg.getNode()) .collect(Collectors.toList()); @@ -357,7 +366,9 @@ public static AStatement switchStmt(AExpression condition, AStatement body) { return CxxJoinpoints.create(switchStmt, AStatement.class); } - public static AStatement switchStmt(AExpression condition, AExpression[] cases) { + public static AStatement switchStmt(AExpression condition, Object[] casesArray) { + var cases = SpecsCollections.cast(casesArray, AExpression.class); + if (cases.length % 2 != 0) { ClavaLog.info("The number of join points for the cases must be even (expression-stmt pairs)"); return null; @@ -469,11 +480,16 @@ public static AStatement returnStmt() { return CxxJoinpoints.create(CxxWeaver.getFactory().returnStmt(), AStatement.class); } - public static AFunctionType functionType(AType returnTypeJp, AType... argTypesJps) { + public static AFunctionType functionType(AType returnTypeJp, Object[] argTypesJps) { + return functionType(returnTypeJp, SpecsCollections.asListT(AType.class, argTypesJps)); + } + + + public static AFunctionType functionType(AType returnTypeJp, List argTypesJps) { Type returnType = (Type) returnTypeJp.getNode(); - List argTypes = Arrays.stream(argTypesJps) + List argTypes = argTypesJps.stream() .map(arg -> ((Type) arg.getNode())) .collect(Collectors.toList()); @@ -488,12 +504,16 @@ public static AFunction functionDeclFromType(String functionName, AFunctionType AFunction.class); } - public static AFunction functionDecl(String functionName, AType returnTypeJp, AJoinPoint... namedDeclJps) { + public static AFunction functionDecl(String functionName, AType returnTypeJp, Object[] namedDeclJps) { + return functionDecl(functionName, returnTypeJp, SpecsCollections.asListT(AJoinPoint.class, namedDeclJps)); + } + + public static AFunction functionDecl(String functionName, AType returnTypeJp, List namedDeclJps) { Type returnType = (Type) returnTypeJp.getNode(); // Get the arg types and create the parameters - List argTypes = new ArrayList<>(namedDeclJps.length); + List argTypes = new ArrayList<>(namedDeclJps.size()); List params = new ArrayList<>(); for (AJoinPoint namedDeclJp : namedDeclJps) { @@ -618,6 +638,10 @@ public static ACast cStyleCast(AType type, AExpression expr) { return CxxJoinpoints.create(cast, ACast.class); } + public static AClass classDecl(String className, Object[] fields) { + return classDecl(className, SpecsCollections.asListT(AField.class, fields)); + } + /** * Creates a join point representing a new class. * @@ -625,8 +649,8 @@ public static ACast cStyleCast(AType type, AExpression expr) { * @param joinpoint * @return */ - public static AClass classDecl(String className, AField... fields) { - var fieldsNodes = Arrays.stream(fields).map(field -> (FieldDecl) field.getNode()) + public static AClass classDecl(String className, List fields) { + var fieldsNodes = fields.stream().map(field -> (FieldDecl) field.getNode()) .collect(Collectors.toList()); var classDecl = CxxWeaver.getFactory().cxxRecordDecl(className, fieldsNodes); @@ -726,8 +750,12 @@ public static AExprStmt exprStmt(AExpression expr) { * @param joinpoint * @return */ - public static ADeclStmt declStmt(ADecl... decls) { - var declNodes = Arrays.stream(decls).map(decl -> (Decl) decl.getNode()) + public static ADeclStmt declStmt(Object[] decls) { + return declStmt(SpecsCollections.asListT(ADecl.class, decls)); + } + + public static ADeclStmt declStmt(List decls) { + var declNodes = decls.stream().map(decl -> (Decl) decl.getNode()) .collect(Collectors.toList()); var declStmt = CxxWeaver.getFactory().declStmt(declNodes);