private static boolean isCallToNamedFunction(Expr expr, String functionName) { return expr instanceof FunctionCallExpr && ((FunctionCallExpr) expr).getCallee() .equals(functionName); }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { super.visitFunctionCallExpr(functionCallExpr); calledFunctions.add(functionCallExpr.getCallee()); }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { out.append(functionCallExpr.getCallee() + "("); boolean first = true; for (Expr e : functionCallExpr.getArgs()) { if (!first) { out.append(", "); } first = false; visit(e); } out.append(")"); }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { super.visitFunctionCallExpr(functionCallExpr); final String enclosingFunctionName = enclosingFunction.getPrototype().getName(); final String calledFunctionName = functionCallExpr.getCallee(); assert callsIndirectly.containsKey(enclosingFunctionName); if (!callsIndirectly.containsKey(calledFunctionName)) { return; } for (String function : callsIndirectly.keySet()) { if (callsIndirectly.get(function).contains(enclosingFunctionName)) { callsIndirectly.get(function).addAll(callsIndirectly .get(calledFunctionName)); } } }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { if (!TyperHelper.getBuiltins(shadingLanguageVersion) .containsKey(functionCallExpr.getCallee())) { // Assume that any call to a non-builtin might have a side-effect. predicateHolds(); } super.visitFunctionCallExpr(functionCallExpr); }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { super.visitFunctionCallExpr(functionCallExpr); if (enclosingFunction.isPresent()) { addCallGraphEdge(enclosingFunction.get().getPrototype().getName(), functionCallExpr.getCallee()); } }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { super.visitFunctionCallExpr(functionCallExpr); if (functionCallExpr.getCallee().equals(functionDefinition.getPrototype().getName())) { // As we only apply this reduction opportunity if the function name is not overloaded, // this has to be a call to the relevant function. functionCallExpr.removeArg(paramIndex); } }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { super.visitFunctionCallExpr(functionCallExpr); List<FunctionPrototype> candidateBuiltins = TyperHelper.getBuiltins(shadingLanguageVersion) .get(functionCallExpr.getCallee()); if (candidateBuiltins != null) { for (FunctionPrototype prototype : candidateBuiltins) { if (prototypeMatches(prototype, functionCallExpr)) { types.put(functionCallExpr, prototype.getReturnType()); } } } Set<FunctionPrototype> candidateUserDefined = userDefinedFunctions.get(functionCallExpr.getCallee()); if (candidateUserDefined != null) { for (FunctionPrototype prototype : candidateUserDefined) { if (prototypeMatches(prototype, functionCallExpr)) { types.put(functionCallExpr, prototype.getReturnType()); } } } }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { functionCallExpr.setCallee(applyFunctionNameMapping(functionCallExpr.getCallee())); super.visitFunctionCallExpr(functionCallExpr); }
private Set<FunctionPrototype> findPossibleMatchesForCall(FunctionCallExpr functionCallExpr) { Set<FunctionPrototype> candidates = declaredFunctions.stream() .filter(proto -> proto.getName().equals(functionCallExpr.getCallee())) .filter(proto -> proto.getNumParameters() == functionCallExpr.getNumArgs()) .collect(Collectors.toSet()); for (int i = 0; i < functionCallExpr.getNumArgs(); i++) { if (!typer.hasType(functionCallExpr.getArg(i))) { // If we don't have a type for this argument, we're OK with any function prototype's type continue; } final int currentIndex = i; // Capture i in final variable so it can be used in lambda. candidates = candidates.stream().filter(proto -> typer.lookupType(functionCallExpr.getArg(currentIndex)).getWithoutQualifiers() .equals(proto.getParameters().get(currentIndex).getType().getWithoutQualifiers())) .collect(Collectors.toSet()); } return candidates; }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { if (inPotentiallyLiveContext()) { functionsCalledFromPotentiallyLiveContext.add(functionCallExpr.getCallee()); } if (MacroNames.isFuzzed(functionCallExpr)) { injectionTracker.enterFuzzedMacro(); } super.visitFunctionCallExpr(functionCallExpr); if (MacroNames.isFuzzed(functionCallExpr)) { injectionTracker.exitFuzzedMacro(); } }
return; final String callee = ((FunctionCallExpr) be.getRhs()).getCallee(); if (!callee.startsWith(Constants.OUTLINED_FUNCTION_PREFIX)) { return;
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { FunctionPrototype bestMatch = null; for (FunctionPrototype candidate : typer.getPrototypes(functionCallExpr.getCallee())) { if (candidate.getNumParameters() == functionCallExpr.getNumArgs()) { if (bestMatch == null || callMatchesPrototype(functionCallExpr, candidate)) {
/** * Determines whether the given statement came from a live code injection. * * @param stmt A statement to be analysed * @return Whether the statement is injected live code or not */ public static boolean isSimpleLiveCodeInjection(Stmt stmt) { if (!(stmt instanceof ExprStmt)) { return false; } final Expr expr = ((ExprStmt) stmt).getExpr(); if (expr instanceof BinaryExpr) { if (!((BinaryExpr) expr).getOp().isSideEffecting()) { return false; } return isLiveInjectionVariableReference(((BinaryExpr) expr).getLhs()); } if (expr instanceof UnaryExpr) { if (!((UnaryExpr) expr).getOp().isSideEffecting()) { return false; } return isLiveInjectionVariableReference(((UnaryExpr) expr).getExpr()); } if (expr instanceof FunctionCallExpr) { return ((FunctionCallExpr) expr).getCallee().startsWith(Constants.LIVE_PREFIX); } return false; }
private boolean functionMatches(FunctionDefinition declaration) { final FunctionPrototype prototype = declaration.getPrototype(); if (!prototype.getName().equals(call.getCallee())) { return false; } if (prototype.getNumParameters() != call.getNumArgs()) { return false; } for (int i = 0; i < prototype.getNumParameters(); i++) { if (typer.lookupType(call.getArg(i)) == null) { continue; } if (!typer.lookupType(call.getArg(i)).getWithoutQualifiers() .equals(prototype.getParameter(i).getType().getWithoutQualifiers())) { return false; } } return true; }
switch (maybeFce.get().getCallee()) { case "sin": assert maybeFce.get().getNumArgs() == 1;
== VoidType.VOID ? Optional.empty() : Optional.of(call.getCallee() + "_inline_return_value_" + idGenerator.freshId());