Skip to content

Commit

Permalink
[ClavaWeaver] Clear Clava data objects on rebuild(), $file.rebuild() #41
Browse files Browse the repository at this point in the history
  • Loading branch information
joaobispo committed Oct 22, 2021
1 parent 3721fd1 commit 5ccbbf2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 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 @@ -21,6 +21,7 @@
import org.lara.interpreter.weaver.ast.AstMethods;
import org.lara.interpreter.weaver.interf.AGear;
import org.lara.interpreter.weaver.interf.JoinPoint;
import org.lara.interpreter.weaver.interf.WeaverEngine;
import org.lara.interpreter.weaver.options.WeaverOption;
import org.lara.language.specification.LanguageSpecification;
import org.lara.language.specification.dsl.LanguageSpecificationV2;
Expand Down Expand Up @@ -1369,6 +1370,11 @@ public DataStore getConfig() {

public TranslationUnit rebuildFile(TranslationUnit tUnit) {

// Clear data object for the ids of this file
var ids = tUnit.getDescendantsAndSelfStream().map(node -> node.getId())
.collect(Collectors.joining("', '", "'", "'"));
WeaverEngine.getThreadLocalWeaver().getScriptEngine().eval("_clearClavaDataCache([" + ids + "]);");

// Write current tree to a temporary folder
File tempFolder = REBUILD_WEAVING_FOLDERS.get().next();

Expand Down Expand Up @@ -1608,6 +1614,9 @@ public void rebuildAst(boolean update) {
// Creating an app automatically pushes the App in the Context
context.popApp();

// Clear data
WeaverEngine.getThreadLocalWeaver().getScriptEngine().eval("_clearClavaDataCache();");

// if (update) {
// // Top app is the one we want, pop the app before that one
// weaverData.popAst();
Expand Down

0 comments on commit 5ccbbf2

Please sign in to comment.