From 8356f5c752718128e36a65e0ffb9b2e73fc37495 Mon Sep 17 00:00:00 2001 From: Onso37 <80353484+Onso37@users.noreply.github.com> Date: Mon, 17 Aug 2026 13:45:58 +0100 Subject: [PATCH 1/2] Add call joinpoint --- .../fortran/weaverspecs/artifacts.xml | 4 + .../fortran/weaverspecs/joinPointModel.xml | 2 + .../fortran/weaver/FortranJoinpoints.java | 1 + .../specs/fortran/weaver/FortranWeaver.json | 235 ++++++++++++++++++ .../fortran/weaver/joinpoints/FCall.java | 27 ++ 5 files changed, 269 insertions(+) create mode 100644 FortranWeaver/src/pt/up/fe/specs/fortran/weaver/joinpoints/FCall.java diff --git a/FortranWeaver/resources/fortran/weaverspecs/artifacts.xml b/FortranWeaver/resources/fortran/weaverspecs/artifacts.xml index 7ce76a0d..bb4067ed 100644 --- a/FortranWeaver/resources/fortran/weaverspecs/artifacts.xml +++ b/FortranWeaver/resources/fortran/weaverspecs/artifacts.xml @@ -193,4 +193,8 @@ + + + + \ No newline at end of file diff --git a/FortranWeaver/resources/fortran/weaverspecs/joinPointModel.xml b/FortranWeaver/resources/fortran/weaverspecs/joinPointModel.xml index c4de9e3c..616d3b6e 100644 --- a/FortranWeaver/resources/fortran/weaverspecs/joinPointModel.xml +++ b/FortranWeaver/resources/fortran/weaverspecs/joinPointModel.xml @@ -107,4 +107,6 @@ + + \ No newline at end of file diff --git a/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/FortranJoinpoints.java b/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/FortranJoinpoints.java index 8ecd7a7a..acc4c682 100644 --- a/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/FortranJoinpoints.java +++ b/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/FortranJoinpoints.java @@ -104,6 +104,7 @@ public class FortranJoinpoints { JOINPOINT_FACTORY.put(ExprInitialization.class, FExprInitialization::new); JOINPOINT_FACTORY.put(Subscript.class, FSubscript::new); JOINPOINT_FACTORY.put(SectionSubscript.class, FSectionSubscript::new); + JOINPOINT_FACTORY.put(Call.class, FCall::new); JOINPOINT_FACTORY.put(FortranNode.class, FortranJoinpoints::defaultFactory); } diff --git a/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/FortranWeaver.json b/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/FortranWeaver.json index 94364748..a4996e3c 100644 --- a/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/FortranWeaver.json +++ b/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/FortranWeaver.json @@ -1486,6 +1486,241 @@ }] }] }, + { + "type": "joinpoint", + "name": "call", + "extends": "expr" , + "tooltip": "Represents a call to a function/subroutine.", + "children": [ + { + "type": "attribute", + "children": [ + { + "type": "dataRef", + "name": "callee" + }] + }, + { + "type": "attribute", + "tooltip": "Returns an array with the children of the node", + "children": [ + { + "type": "joinpoint[]", + "name": "children" + }] + }, + { + "type": "attribute", + "tooltip": "String with the code represented by this node", + "children": [ + { + "type": "String", + "name": "code" + }] + }, + { + "type": "attribute", + "tooltip": "true if the given node is a descendant of this node", + "children": [ + { + "type": "Boolean", + "name": "contains" + }, + { + "type": "joinpoint", + "name": "jp", + "defaultValue": "" + }] + }, + { + "type": "attribute", + "tooltip": "Returns an array with the descendants of the node", + "children": [ + { + "type": "joinpoint[]", + "name": "descendants" + }] + }, + { + "type": "attribute", + "tooltip": "Looks for an ancestor joinpoint name, walking back on the AST", + "children": [ + { + "type": "joinpoint", + "name": "getAncestor" + }, + { + "type": "String", + "name": "type", + "defaultValue": "" + }] + }, + { + "type": "attribute", + "tooltip": "Returns the index of this join point in relation to its parent", + "children": [ + { + "type": "int", + "name": "indexOfSelf" + }] + }, + { + "type": "attribute", + "tooltip": "Returns the node that came before this node, or undefined if there is none", + "children": [ + { + "type": "joinpoint", + "name": "leftJp" + }] + }, + { + "type": "attribute", + "tooltip": "Returns the parent node in the AST, or undefined if it is the root node", + "children": [ + { + "type": "joinpoint", + "name": "parent" + }] + }, + { + "type": "attribute", + "tooltip": "Returns the node that comes after this node, or undefined if there is none", + "children": [ + { + "type": "joinpoint", + "name": "rightJp" + }] + }, + { + "type": "attribute", + "tooltip": "Returns the 'program' join point", + "children": [ + { + "type": "program", + "name": "root" + }] + }, + { + "type": "attribute", + "tooltip": "the nodes of the scope of the current join point. If this node has a body (e.g., loop, function) corresponds to the children of the body. Otherwise, returns an empty array", + "children": [ + { + "type": "joinpoint[]", + "name": "scopeNodes" + }] + }, + { + "type": "action", + "tooltip": "Performs a copy of the node and its children, but not of the nodes in its fields", + "children": [ + { + "type": "joinpoint", + "name": "copy" + }] + }, + { + "type": "action", + "tooltip": "Performs a copy of the node and its children, including the nodes in their fields (only the first level of field nodes, this function is not recursive)", + "children": [ + { + "type": "joinpoint", + "name": "deepCopy" + }] + }, + { + "type": "action", + "tooltip": "Removes node associated to the joinpoint from the AST", + "children": [ + { + "type": "joinpoint", + "name": "detach" + }] + }, + { + "type": "action", + "tooltip": "Inserts the given join point after this join point", + "children": [ + { + "type": "joinpoint", + "name": "insertAfter" + }, + { + "type": "joinpoint", + "name": "node", + "defaultValue": "" + }] + }, + { + "type": "action", + "tooltip": "Overload which accepts a string", + "children": [ + { + "type": "joinpoint", + "name": "insertAfter" + }, + { + "type": "String", + "name": "code", + "defaultValue": "" + }] + }, + { + "type": "action", + "tooltip": "Inserts the given join point before this join point", + "children": [ + { + "type": "joinpoint", + "name": "insertBefore" + }, + { + "type": "joinpoint", + "name": "node", + "defaultValue": "" + }] + }, + { + "type": "action", + "tooltip": "Overload which accepts a string", + "children": [ + { + "type": "joinpoint", + "name": "insertBefore" + }, + { + "type": "String", + "name": "node", + "defaultValue": "" + }] + }, + { + "type": "action", + "tooltip": "Replaces this node with the given node", + "children": [ + { + "type": "joinpoint", + "name": "replaceWith" + }, + { + "type": "joinpoint", + "name": "node", + "defaultValue": "" + }] + }, + { + "type": "action", + "tooltip": "Overload which accepts a list of join points", + "children": [ + { + "type": "joinpoint", + "name": "replaceWith" + }, + { + "type": "joinpoint[]", + "name": "node", + "defaultValue": "" + }] + }] + }, { "type": "joinpoint", "name": "compilerDirective", diff --git a/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/joinpoints/FCall.java b/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/joinpoints/FCall.java new file mode 100644 index 00000000..10516bcb --- /dev/null +++ b/FortranWeaver/src/pt/up/fe/specs/fortran/weaver/joinpoints/FCall.java @@ -0,0 +1,27 @@ +package pt.up.fe.specs.fortran.weaver.joinpoints; + +import pt.up.fe.specs.fortran.ast.nodes.FortranNode; +import pt.up.fe.specs.fortran.ast.nodes.expr.Call; +import pt.up.fe.specs.fortran.weaver.FortranJoinpoints; +import pt.up.fe.specs.fortran.weaver.abstracts.joinpoints.ACall; +import pt.up.fe.specs.fortran.weaver.abstracts.joinpoints.ADataRef; + +public class FCall extends ACall { + + private final Call call; + + public FCall(Call call) { + super(new FExpr(call)); + this.call = call; + } + + @Override + public ADataRef getCalleeImpl() { + return FortranJoinpoints.create(call.getCallee(), ADataRef.class); + } + + @Override + public FortranNode getNode() { + return null; + } +} From b0da4e87fe79751f93f607304691d1c64c21435c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Afonso=20Vaz=20Os=C3=B3rio?= Date: Mon, 17 Aug 2026 13:46:58 +0100 Subject: [PATCH 2/2] Update Joinpoints.ts --- Fortran-JS/src-api/Joinpoints.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Fortran-JS/src-api/Joinpoints.ts b/Fortran-JS/src-api/Joinpoints.ts index 55783f5c..f9404952 100644 --- a/Fortran-JS/src-api/Joinpoints.ts +++ b/Fortran-JS/src-api/Joinpoints.ts @@ -42,6 +42,7 @@ type PrivateMapper = { "Subscript": typeof Subscript, "UseStatement": typeof UseStatement, "BinaryOperator": typeof BinaryOperator, + "Call": typeof Call, "Designator": typeof Designator, "EntityDecl": typeof EntityDecl, "ExecutableStatement": typeof ExecutableStatement, @@ -548,6 +549,19 @@ export class BinaryOperator extends Expr { setRight(rhs: Expr): void { return wrapJoinPoint(this._javaObject.setRight(unwrapJoinPoint(rhs))); } } + /** + * Represents a call to a function/subroutine. + */ +export class Call extends Expr { + /** + * @internal + */ + static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { + name: null, + }; + get callee(): DataRef { return wrapJoinPoint(this._javaObject.getCallee()) } +} + /** * Represents a designator */ @@ -850,6 +864,7 @@ const JoinpointMapper = { subscript: Subscript, useStatement: UseStatement, binaryOperator: BinaryOperator, + call: Call, designator: Designator, entityDecl: EntityDecl, executableStatement: ExecutableStatement,