[ClavaLaraApi] Adds Clava.findJp()
@@ -61,10 +61,40 @@ Clava.runClava = function(args) {
return ClavaWeaverLauncher.execute(args);
}
+/**
+ * Creates a clone of the current AST and pushes the clone to the top of the current AST stack.
+ */
Clava.pushAst = function() {
call PushAst();
}
+/**
+ * Discards the AST at the top of the current AST stack.
+ */
Clava.popAst = function() {
call PopAst();
}
+
+
+/**
+ * Looks for a join point in the current AST.
+ *
+ * @param $jp a join point from any AST
+ * @return the equivalent join point from the AST at the top of the current AST stack
+ */
+Clava.findJp = function($jp) {
+ // Get file
+ $file = $jp.ancestor("file");
+ if($file === undefined) {
+ info("Could not find a file for '" + $jp + "'", "Clava.findJp");
+ return undefined;
+ }
+
+ var $newJp = LowLevelApi.findJp($file.filepath, $jp.astId);
+ if($newJp === null) {
+ info("Could not find the given '" + $jp + "' in the current AST", "Clava.findJp");
+ return undefined;
+ }
+
+ return $newJp;
+}
