Skip to content

Commit

Permalink
Revert "Remove te legacy LaraCommonLanguage experiment from the project"
Browse files Browse the repository at this point in the history
This reverts commit c65182f.
  • Loading branch information
lm-sousa committed Oct 19, 2024
1 parent c65182f commit 1af9c2e
Show file tree
Hide file tree
Showing 13 changed files with 213 additions and 2 deletions.
1 change: 1 addition & 0 deletions ClavaWeaver/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry combineaccessrules="false" kind="src" path="/tdrcLibrary"/>
<classpathentry combineaccessrules="false" kind="src" path="/AntarexClavaApi"/>
<classpathentry combineaccessrules="false" kind="src" path="/LaraCommonLanguageApi"/>
<classpathentry combineaccessrules="false" kind="src" path="/LaraFramework"/>
<classpathentry combineaccessrules="false" kind="src" path="/WeaverGenerator"/>
<classpathentry combineaccessrules="false" kind="src" path="/GsonPlus"/>
Expand Down
3 changes: 2 additions & 1 deletion ClavaWeaver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies {
implementation ":tdrcLibrary"

implementation ":LanguageSpecification"
implementation ":LaraCommonLanguageApi"
implementation ":LaraFramework"
implementation ":LARAI"
implementation ":LaraUtils"
Expand Down Expand Up @@ -105,6 +106,6 @@ task clavadoc(type: JavaExec) {
'--exclude',
'_',
'--packages',
'{\'Clava API\': [\'../ClavaLaraApi/src-lara-clava/clava\'], \'LARA API\': [\'../LaraApi/src-lara-base\',\'../LaraApi}/src-lara\',\'../LARAI/src-lara\',\'../LaraExtraApi/src-lara\',\'../ClavaLaraApi/src-lara/clava\'], \'ANTAREX API\': [\'../AntarexClavaApi/src-lara/clava\']}',
'{\'Clava API\': [\'../ClavaLaraApi/src-lara-clava/clava\'], \'LARA API\': [\'../LaraApi/src-lara-base\',\'../LaraApi}/src-lara\',\'../LARAI/src-lara\',\'../LaraExtraApi/src-lara\',\'../ClavaLaraApi/src-lara/clava\'], \'LARA Common Language API\': [\'../LaraCommonLanguageApi/src-lara\'], \'ANTAREX API\': [\'../AntarexClavaApi/src-lara/clava\']}',
]
}
4 changes: 4 additions & 0 deletions ClavaWeaver/resources/clava/test/api/Code2VecTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { laraImport } from "@specs-feup/lara/api/lara/core/LaraCore.js";
laraImport("lcl.ml.Code2Vec");

new Code2Vec().printPaths();
32 changes: 32 additions & 0 deletions ClavaWeaver/resources/clava/test/api/LaraCommonLanguageTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { laraImport } from "@specs-feup/lara/api/lara/core/LaraCore.js";

laraImport("lcl.LaraCommonLanguage");
laraImport("weaver.jp.ClavaJoinPoint");
laraImport("weaver.jp.FileJp");
laraImport("weaver.Query");

var $file = Query.search("file").first();
//printlnObject($file);
console.log("line: " + $file.line);
console.log("is FileJP? : " + ($file instanceof FileJp));

var classes = Query.search("classType", "A").get();
console.log("# A classes: " + classes.length);

var classesOnlyDecl = Query.search("classType", "classOnlyDecl").get();
console.log("# onlyDecl classes: " + classesOnlyDecl.length);

var fooFunctions = Query.search("function", "foo").get();
console.log("# foo functions: " + fooFunctions.length);

var fooOnlyDeclFunctions = Query.search("function", "fooOnlyDecl").get();
console.log("# fooOnlyDecl functions: " + fooOnlyDeclFunctions.length);

var bClasses = Query.search("classType", "B").get();
console.log("# B classes: " + bClasses.length);

var cClasses = Query.search("classType", "C").get();
console.log("# C classes: " + cClasses.length);

var dCalls = Query.search("classType", "D").search("call").get();
console.log("# calls in D: " + dCalls.length);
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Warning: using laraImport() for file 'JoinPointsCommonPath.js', however it does not define a variable or class 'JoinPointsCommonPath'
decl (up) file (down) decl
__________________________________
decl (up) file (down) function (down) param
__________________________________
decl (up) file (down) function (down) stmt (down) stmt (down) varDecl (down) expr
__________________________________
decl (up) file (down) function (down) stmt (down) loop (down) stmt (down) varDecl (down) expr
__________________________________
decl (up) file (down) function (down) stmt (down) loop (down) stmt (down) binary (down) varRef
__________________________________
decl (up) file (down) function (down) stmt (down) loop (down) stmt (down) binary (down) varRef
__________________________________
decl (up) file (down) function (down) stmt (down) loop (down) stmt (down) expr (down) varRef
__________________________________
decl (up) file (down) function (down) stmt (down) loop (down) stmt (down) stmt (down) expr (down) varRef
__________________________________
decl (up) file (down) function (down) stmt (down) stmt (down) varRef
__________________________________
decl (up) file (down) decl
__________________________________
decl (up) file (down) function (down) param
__________________________________
decl (up) file (down) function (down) stmt (down) stmt (down) varDecl (down) expr
__________________________________
decl (up) file (down) function (down) stmt (down) loop (down) stmt (down) varDecl (down) expr
__________________________________
decl (up) file (down) function (down) stmt (down) loop (down) stmt (down) binary (down) varRef
__________________________________
decl (up) file (down) function (down) stmt (down) loop (down) stmt (down) binary (down) varRef
__________________________________
decl (up) file (down) function (down) stmt (down) loop (down) stmt (down) expr (down) varRef
__________________________________
decl (up) file (down) function (down) stmt (down) loop (down) stmt (down) stmt (down) expr (down) varRef
__________________________________
decl (up) file (down) function (down) stmt (down) stmt (down) varRef
__________________________________
param (up) function (down) stmt (down) stmt (down) varDecl (down) expr
__________________________________
param (up) function (down) stmt (down) loop (down) stmt (down) varDecl (down) expr
__________________________________
param (up) function (down) stmt (down) loop (down) stmt (down) binary (down) varRef
__________________________________
param (up) function (down) stmt (down) loop (down) stmt (down) binary (down) varRef
__________________________________
param (up) function (down) stmt (down) loop (down) stmt (down) expr (down) varRef
__________________________________
param (up) function (down) stmt (down) loop (down) stmt (down) stmt (down) expr (down) varRef
__________________________________
param (up) function (down) stmt (down) stmt (down) varRef
__________________________________
varRef (up) binary (down) varRef
__________________________________
varRef (up) binary (down) varRef
__________________________________
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Warning: using laraImport() for file 'JoinPointsCommonPath.js', however it does not define a variable or class 'JoinPointsCommonPath'
line: 1
is FileJP? : true
# A classes: 1
# onlyDecl classes: 1
# foo functions: 1
# fooOnlyDecl functions: 1
# B classes: 1
# C classes: 1
# calls in D: 2
13 changes: 13 additions & 0 deletions ClavaWeaver/resources/clava/test/api/cpp/src/code2vec.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>
#include <math.h>

int foo(int numIter) {

int acc = 0;

for(int i=0; i<numIter; i++) {
acc++;
}

return acc;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "lara_common_language.h"

class A;

class A {
};

void foo();

void foo();

void foo() {

for(int i=0; i < 10; i++) {
}

}

void fooOnlyDecl();

void fooOnlyDecl();

class classOnlyDecl;

class classOnlyDecl;

int main() {

return 0;
}


namespace b {

class B;

}


namespace b {

class B;

class B {
public:
void bar();
};

}

namespace c {
namespace cc {
class C;
}
}

namespace c {
namespace cc {
class C {
public:
void bar();
};
}
}


namespace d {

class D;

class D {
void bar(b::B b, c::cc::C c);
};
}

void d::D::bar(b::B b, c::cc::C c) {
b.bar();
c.bar();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class A;
2 changes: 1 addition & 1 deletion ClavaWeaver/run/ClavaWeaverDoc.launch
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="pt.up.fe.specs.clava.weaver.ClavaWeaverLauncher"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="ClavaWeaver"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-doc&#13;&#10;--output &quot;${project_loc:ClavaWeaver}/../docs/api&quot;&#13;&#10;--clean&#13;&#10;--exclude _&#13;&#10;--packages &quot;{&#13;&#10;'Clava API': ['${project_loc:ClavaLaraApi}/src-lara-clava/clava'],&#13;&#10;'LARA API': ['${project_loc:LaraApi}/src-lara-base','${project_loc:LaraApi}/src-lara','${project_loc:LARAI}/src-lara','${project_loc:LaraExtraApi}/src-lara','${project_loc:ClavaLaraApi}/src-lara/clava'],&#13;&#10;'ANTAREX API': ['${project_loc:AntarexClavaApi}/src-lara/clava']&#13;&#10;}&quot;"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-doc&#13;&#10;--output &quot;${project_loc:ClavaWeaver}/../docs/api&quot;&#13;&#10;--clean&#13;&#10;--exclude _&#13;&#10;--packages &quot;{&#13;&#10;'Clava API': ['${project_loc:ClavaLaraApi}/src-lara-clava/clava'],&#13;&#10;'LARA API': ['${project_loc:LaraApi}/src-lara-base','${project_loc:LaraApi}/src-lara','${project_loc:LARAI}/src-lara','${project_loc:LaraExtraApi}/src-lara','${project_loc:ClavaLaraApi}/src-lara/clava'],&#13;&#10;'LARA Common Language API': ['${project_loc:LaraCommonLanguageApi}/src-lara'],&#13;&#10;'ANTAREX API': ['${project_loc:AntarexClavaApi}/src-lara/clava']&#13;&#10;}&quot;"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="ClavaWeaver"/>
</launchConfiguration>
1 change: 1 addition & 0 deletions ClavaWeaver/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ includeBuild("../../specs-java-libs/XStreamPlus")
includeBuild("../../specs-java-libs/tdrcLibrary")

includeBuild("../../lara-framework/LanguageSpecification")
includeBuild("../../lara-framework/LaraCommonLanguageApi")
includeBuild("../../lara-framework/LaraFramework")
includeBuild("../../lara-framework/LARAI")
includeBuild("../../lara-framework/LaraUtils")
Expand Down
2 changes: 2 additions & 0 deletions ClavaWeaver/src/pt/up/fe/specs/clava/weaver/CxxWeaver.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import pt.up.fe.specs.clava.weaver.options.CxxWeaverOptions;
import pt.up.fe.specs.clava.weaver.utils.ClavaAstMethods;
import pt.up.fe.specs.lara.langspec.LangSpecsXmlParser;
import pt.up.fe.specs.lara.lcl.LaraCommonLanguageApis;
import pt.up.fe.specs.util.SpecsCheck;
import pt.up.fe.specs.util.SpecsCollections;
import pt.up.fe.specs.util.SpecsIo;
Expand Down Expand Up @@ -173,6 +174,7 @@ public static List<String> getDefaultFlags() {

private static final List<ResourceProvider> CLAVA_LARA_API = new ArrayList<>();
static {
CLAVA_LARA_API.addAll(LaraCommonLanguageApis.getApis());
CLAVA_LARA_API.addAll(ClavaLaraApis.getApis());
CLAVA_LARA_API.addAll(AntarexClavaLaraApis.getApis());
}
Expand Down
12 changes: 12 additions & 0 deletions ClavaWeaver/test/pt/up/fe/specs/cxxweaver/tests/CxxApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ public void testQuery() {
newTester().test("QueryTest.js", "query.cpp");
}

@Test
public void testLaraCommonLanguage() {
newTester()
.set(CxxWeaverOption.PARSE_INCLUDES)
.test("LaraCommonLanguageTest.js", "lara_common_language.cpp", "lara_common_language.h");
}

@Test
public void testClavaType() {
newTester().test("ClavaTypeTest.js");
Expand All @@ -159,6 +166,11 @@ public void testStatementDecomposer() {
newTester().test("StatementDecomposerTest.js", "stmt_decomposer.cpp");
}

@Test
public void testCode2Vec() {
newTester().test("Code2VecTest.js", "code2vec.cpp");
}

@Test
public void testSimplifyVarDeclarations() {
newTester().test("PassSimplifyVarDeclarations.js", "pass_simplify_var_declarations.cpp");
Expand Down

0 comments on commit 1af9c2e

Please sign in to comment.