use of abs.frontend.ast.FunctionDecl in project abstools by abstools.
the class PartialFunctionTest method assertHasFunction.
private FunctionDecl assertHasFunction(Model model, String regex) {
FunctionDecl result = getFunction(model, Pattern.compile(regex));
String errorMessage = "No expanded function with name " + regex + " created" + " (functions: " + getFunctions(model) + ")";
assertNotNull(errorMessage, result);
Decl decl = model.lookup(new KindedName(Kind.FUN, result.getName()));
assertFalse("Could not lookup function " + result.getName(), decl.isUnknown());
return result;
}
use of abs.frontend.ast.FunctionDecl in project abstools by abstools.
the class JavaGeneratorHelper method generateBuiltInFnApp.
public static void generateBuiltInFnApp(PrintStream stream, FnApp app) {
FunctionDecl d = (FunctionDecl) app.getDecl();
String name = d.getName();
if (!builtInFunctionExists(name)) {
throw new NotImplementedYetException(app, "The built in function '" + name + "' is not implemented in the Java backend.");
}
// if builtin function returns a non-builtin type, cast the returned value to that type
boolean returnsGeneratedDataType = !JavaBackend.isBuiltinDataType(app.getType());
if (returnsGeneratedDataType)
stream.print("((" + JavaBackend.getQualifiedString(app.getType()) + ")");
stream.print(ABSBuiltInFunctions.class.getName() + "." + name);
String firstArgs = null;
if (Constants.isFunctionalBreakPointFunctionName(d.getModuleDecl().getName() + "." + name))
firstArgs = generateFunctionalBreakPointArgs(app);
generateArgs(stream, firstArgs, app.getParams(), d.getTypes());
if (returnsGeneratedDataType)
stream.print(")");
}
use of abs.frontend.ast.FunctionDecl in project abstools by abstools.
the class AnnotationUtil method annotateCall.
/**
* <p>Annotates the parent Statement or Function node with an ExpansionCall annotation.</p>
*
* <p>If said node already has an annotation with the ExpansionCall type, the expansionIndex will be added to the
* existing annotation.</p>
*
* @param call the call to use as a starting point to look for a Stmt or FunctionDecl parent
* @param expansionId the ID of the called Expansion
* @throws IllegalArgumentException if there is no Stmt or FunctionDecl parent
*/
public static void annotateCall(FnApp call, int expansionId) {
Stmt parent = call.closestParent(Stmt.class);
if (parent == null) {
FunctionDecl parentFunction = call.closestParent(FunctionDecl.class);
if (parentFunction == null) {
throw new IllegalArgumentException("Function call has no parent Statement or FunctionDecl: " + call);
}
addToAnnotations(parentFunction.getAnnotations(), expansionCallType(), expansionId);
} else {
addToAnnotations(parent.getAnnotations(), expansionCallType(), expansionId);
}
}
Aggregations