Skip to content

Commit

Permalink
[ClavaWeaver] Adds missing method CxxWeaver.clearAppHistory()
Browse files Browse the repository at this point in the history
  • Loading branch information
joaobispo committed Nov 7, 2024
1 parent b7fe1ee commit 076a159
Showing 1 changed file with 26 additions and 45 deletions.
71 changes: 26 additions & 45 deletions ClavaWeaver/src/pt/up/fe/specs/clava/weaver/CxxWeaver.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
package pt.up.fe.specs.clava.weaver;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.stream.Collectors;

import org.lara.interpreter.joptions.config.interpreter.LaraiKeys;
import org.lara.interpreter.profile.WeavingReport;
import org.lara.interpreter.weaver.ast.AstMethods;
Expand All @@ -29,7 +13,6 @@
import org.suikasoft.jOptions.Interfaces.DataStore;
import org.suikasoft.jOptions.storedefinition.StoreDefinition;
import org.suikasoft.jOptions.storedefinition.StoreDefinitionBuilder;

import pt.up.fe.specs.antarex.clava.AntarexClavaLaraApis;
import pt.up.fe.specs.antarex.clava.JsAntarexApiResource;
import pt.up.fe.specs.clang.ClangAstKeys;
Expand Down Expand Up @@ -60,18 +43,20 @@
import pt.up.fe.specs.lara.langspec.LangSpecsXmlParser;
import pt.up.fe.specs.lara.lcl.LaraCommonLanguageApis;
import pt.up.fe.specs.lara.unit.LaraUnitLauncher;
import pt.up.fe.specs.util.SpecsCheck;
import pt.up.fe.specs.util.SpecsCollections;
import pt.up.fe.specs.util.SpecsIo;
import pt.up.fe.specs.util.SpecsLogs;
import pt.up.fe.specs.util.SpecsSystem;
import pt.up.fe.specs.util.*;
import pt.up.fe.specs.util.collections.AccumulatorMap;
import pt.up.fe.specs.util.lazy.Lazy;
import pt.up.fe.specs.util.providers.ResourceProvider;
import pt.up.fe.specs.util.utilities.Buffer;
import pt.up.fe.specs.util.utilities.LineStream;
import pt.up.fe.specs.util.utilities.StringLines;

import java.io.File;
import java.util.*;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.stream.Collectors;

/**
* Weaver Implementation for CxxWeaver<br>
* Since the generated abstract classes are always overwritten, their implementation should be done by extending those
Expand Down Expand Up @@ -120,8 +105,8 @@ public static LanguageSpecificationV2 buildLanguageSpecification() {
"https://github.com/specs-feup/clava-benchmarks.git?folder=Rosetta");

/**
* @deprecated
* @return
* @deprecated
*/
@Deprecated
public static LanguageSpecification buildLanguageSpecificationOld() {
Expand Down Expand Up @@ -174,6 +159,7 @@ public static List<String> getDefaultFlags() {
private static final String CLAVA_API_NAME = "@specs-feup/clava";

private static final List<ResourceProvider> CLAVA_LARA_API = new ArrayList<>();

static {
CLAVA_LARA_API.addAll(LaraCommonLanguageApis.getApis());
CLAVA_LARA_API.addAll(ClavaLaraApis.getApis());
Expand Down Expand Up @@ -371,12 +357,9 @@ public boolean handlesApplicationFolder() {
/**
* Set a file/folder in the weaver if it is valid file/folder type for the weaver.
*
* @param source
* the file with the source code
* @param outputDir
* output directory for the generated file(s)
* @param args
* arguments to start the weaver
* @param source the file with the source code
* @param outputDir output directory for the generated file(s)
* @param args arguments to start the weaver
* @return true if the file type is valid
*/
@Override
Expand Down Expand Up @@ -547,13 +530,12 @@ private List<String> buildParserOptions(DataStore args) {

/**
* Updates the information relative to the current sources.
*
*
* <p>
* Creation of sources follow this rules:<br>
* 1) Single files listed in 'sources' are considered to not have a base folder (relative path is null) <br>
* 2) Source folders listed in 'sources' will have the parent folder as its base folder <br>
* 3) Source files or folders listed in 'map' will have the base folder indicated in the map
*
*/
private void updateSources(Map<File, File> map) {
// TODO: Convert all folders to files, folders become bases when in sources
Expand Down Expand Up @@ -755,7 +737,7 @@ private static String parseIncludePath(File path) {

/**
* Builds the -I argument
*
*
* @param include
* @return
*/
Expand All @@ -769,13 +751,11 @@ public App createApp(List<File> sources, List<String> parserOptions) {
}

/**
*
* @param sources
* @param parserOptions
* @param extraOptions
* options that should not be processed (e.g., header files found in folders specified by -I flags are
* automatically added to the compilation, if we want to add header folders whose header files should not
* be parsed, they can be specified here)
* @param extraOptions options that should not be processed (e.g., header files found in folders specified by -I flags are
* automatically added to the compilation, if we want to add header folders whose header files should not
* be parsed, they can be specified here)
* @return
*/
public App createApp(List<File> sources, List<String> parserOptions, List<String> extraOptions) {
Expand Down Expand Up @@ -1568,9 +1548,7 @@ private void fuzzyFix(TranslationUnit tunit, String errorOutput) {
}

/**
*
* @param update
* if true, the weaver will update its state to use the rebuilt tree instead of the original tree
* @param update if true, the weaver will update its state to use the rebuilt tree instead of the original tree
*/
public boolean rebuildAst(boolean update) {
// Check if inside apply
Expand Down Expand Up @@ -1726,10 +1704,10 @@ public boolean rebuildAst(boolean update) {

/**
* Creates a new temporary folder for weaving.
*
*
* <p>
* The folder will be deleted when the JVM exits.
*
*
* @return
*/
private static File newTemporaryWeavingFolder() {
Expand Down Expand Up @@ -1897,11 +1875,11 @@ public static SnippetParser getSnippetParser() {

/**
* Helper method which returns include folders of the source files.
*
*
* <p>
* For the temporary folder, the source folders are the children folders of the temporary folder, and the temporary
* folder itself.
*
*
* @param weavingFolder
* @return
*/
Expand All @@ -1911,7 +1889,7 @@ private Set<File> getSourceIncludeFoldersFromTempFolder(File weavingFolder) {

/**
*
*/
*/
private Set<File> getSourceIncludeFolders(File weavingFolder, boolean onlyHeaders) {
Set<File> includeFolders = new LinkedHashSet<>();
includeFolders.addAll(SpecsIo.getFolders(weavingFolder));
Expand Down Expand Up @@ -2077,4 +2055,7 @@ protected List<LaraResourceProvider> getWeaverNpmResources() {
return Arrays.asList(ClavaApiJsResource.values());
}

public void clearAppHistory() {
context.clearAppHistory();
}
}

0 comments on commit 076a159

Please sign in to comment.