From 5ccbbf2006da61c68844fa5690f051ef6a09cd7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bispo?= Date: Fri, 22 Oct 2021 17:06:54 +0100 Subject: [PATCH] [ClavaWeaver] Clear Clava data objects on rebuild(), $file.rebuild() #41 --- .../src/pt/up/fe/specs/clava/weaver/CxxWeaver.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/CxxWeaver.java b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/CxxWeaver.java index fd8a6e1e2..399149e17 100644 --- a/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/CxxWeaver.java +++ b/ClavaWeaver/src/pt/up/fe/specs/clava/weaver/CxxWeaver.java @@ -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; @@ -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(); @@ -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();