use of abs.frontend.ast.ClassDecl in project abstools by abstools.
the class InferMain method shouldBeConsidered.
private boolean shouldBeConsidered(LocationTypeVariable ltv) {
ASTNode<?> node = ltv.getNode();
Decl contextDecl = node.getContextDecl();
if (contextDecl != null) {
// Don't print interface annotations in "implements/extends" clauses:
if (node instanceof InterfaceTypeUse && (contextDecl instanceof ClassDecl || contextDecl instanceof InterfaceDecl))
return false;
if (contextDecl.isClass() && !config.contains(Config.CLASSES))
return false;
if (contextDecl.isInterface() && !config.contains(Config.INTERFACES))
return false;
if (contextDecl.isFunction() && !config.contains(Config.FUNCTIONS))
return false;
}
if (node instanceof VarDecl && !config.contains(Config.LOCAL_VAR_DECLS))
return false;
if (node instanceof FieldDecl && !config.contains(Config.FIELDS))
return false;
if (ltv.getAnnotatedType() != null) {
return false;
}
return true;
}
use of abs.frontend.ast.ClassDecl in project abstools by abstools.
the class LocationTypeInferrerExtension method getFarTypes.
private List<LocationType> getFarTypes(ASTNode<?> originatingNode) {
HasCogs node = null;
String prefix = "";
if (precision == LocationTypingPrecision.GLOBAL_FAR) {
node = originatingNode.getCompilationUnit().getModel();
prefix = "G";
}
if (precision == LocationTypingPrecision.COMPILATION_UNIT_LOCAL_FAR) {
node = originatingNode.getCompilationUnit();
prefix = "U";
}
if (precision == LocationTypingPrecision.MODULE_LOCAL_FAR) {
node = originatingNode.getModuleDecl();
prefix = "M";
}
if (precision == LocationTypingPrecision.CLASS_LOCAL_FAR) {
Decl d = originatingNode.getContextDecl();
if (d instanceof ClassDecl) {
node = d;
prefix = "C";
}
Block b = originatingNode.getContextBlock();
if (b instanceof MainBlock) {
node = b;
prefix = "C";
}
}
if (precision == LocationTypingPrecision.METHOD_LOCAL_FAR) {
Block b = originatingNode.getContextBlock();
if (b != null) {
node = b;
prefix = "M";
}
}
if (node == null) {
return Collections.emptyList();
}
final List<LocationType> e = farTypes.get(node);
if (e != null) {
return e;
} else {
List<LocationType> result = new ArrayList<>();
int numberOfNewCogs = node.getNumberOfNewCogExpr();
if (numberOfNewCogs > THRESHOLD) {
numberOfNewCogs = THRESHOLD;
}
for (int i = 0; i < numberOfNewCogs; i++) {
result.add(LocationType.createParametricFar(prefix + i));
}
farTypes.put(node, result);
return result;
}
}
use of abs.frontend.ast.ClassDecl in project abstools by abstools.
the class ReachabilityInformation method isReachable.
/**
* checks if the method is reachable. It looks at the class name
* and all the interface names that are directly or indirectly
* implemented by the method's class
* @param method
* @return true if method is reachable, false otherwise
*/
public boolean isReachable(MethodImpl method) {
ClassDecl clazz = obtainOwnerClass(method);
boolean reachable = false;
if (clazz != null) {
abs.frontend.ast.List<InterfaceTypeUse> interfaces = clazz.getImplementedInterfaceUseList();
Iterator<InterfaceTypeUse> it = interfaces.iterator();
// checks if the method is reachable with its class name
reachable = reachableMethods.contains(getMethodId(clazz, method.getMethodSig()));
// implemented by its class
while (!reachable && it.hasNext()) reachable = isReachable(it.next(), method.getMethodSig());
return reachable;
} else
return false;
}
use of abs.frontend.ast.ClassDecl in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateMainBlockAST.
private MainBlock generateMainBlockAST(List<Import> list) {
final MainBlock block = new MainBlock();
DataConstructorExp empty = new DataConstructorExp("EmptySet", new List<>());
VarDeclStmt futsStatement = getVarDecl(futs, getType("Set", getFutUnitType()), empty);
block.addStmtNoTransform(futsStatement);
VarDeclStmt futStatement = getVarDecl(fut, getFutUnitType(), null);
block.addStmtNoTransform(futStatement);
Set<TypeUse> use = new HashSet<>();
for (InterfaceDecl key : tests.keySet()) {
for (ClassDecl clazz : tests.get(key)) {
use.addAll(generateTestClassImplAST(key, clazz, block));
}
}
block.addStmtNoTransform(generateWaitSyncAST());
return block;
}
use of abs.frontend.ast.ClassDecl in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateImportsAST.
private List<Import> generateImportsAST() {
List<Import> imports = new List<>();
Set<String> mn = new HashSet<>();
Set<String> qn = new HashSet<>();
for (InterfaceDecl key : tests.keySet()) {
getImportsFrom(mn, qn, key.getModuleDecl());
for (ClassDecl clazz : tests.get(key)) {
getImportsFrom(mn, qn, clazz.getModuleDecl());
}
}
for (String m : mn) {
imports.add(new StarImport(m));
}
if (!qn.isEmpty()) {
List<Name> names = new List<>();
for (String q : qn) {
names.add(new Name(q));
}
imports.add(new NamedImport(names));
}
return imports;
}
Aggregations