Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Fortran-JS/src-api/Joinpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -850,6 +864,7 @@ const JoinpointMapper = {
subscript: Subscript,
useStatement: UseStatement,
binaryOperator: BinaryOperator,
call: Call,
designator: Designator,
entityDecl: EntityDecl,
executableStatement: ExecutableStatement,
Expand Down
4 changes: 4 additions & 0 deletions FortranWeaver/resources/fortran/weaverspecs/artifacts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,8 @@
<artifact class="subscript">
<attribute name="expr" type="expr"/>
</artifact>

<artifact class="call">
<attribute name="callee" type="dataRef"/>
</artifact>
</artifacts>
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,6 @@
<joinpoint class="sectionSubscript" tooltip="Represent a generic subscript for an array"/>

<joinpoint class="subscript" tooltip="Represent an integer subscript for an array" extends="sectionSubscript"/>

<joinpoint class="call" tooltip="Represents a call to a function/subroutine." extends="expr"/>
</joinpoints>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
235 changes: 235 additions & 0 deletions FortranWeaver/src/pt/up/fe/specs/fortran/weaver/FortranWeaver.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading