private boolean functionIsCalled(FunctionPrototype prototype) { return calledFunctions.stream().anyMatch(proto -> proto.matches(prototype)); }
private boolean prototypeMatches(FunctionPrototype fp, List<FunctionPrototype> fs) { return !fs.stream().filter(item -> fp.matches(item)).collect(Collectors.toList()).isEmpty(); }
private List<Declaration> removeRepeatedFunctionPrototypes(List<Declaration> decls) { List<Declaration> result = new ArrayList<>(); Set<FunctionPrototype> declared = new HashSet<>(); for (Declaration d : decls) { if (d instanceof FunctionPrototype) { if (declared.stream().anyMatch(item -> item.matches((FunctionPrototype) d))) { continue; } declared.add((FunctionPrototype) d); } result.add(d); } return result; }
functionsDefinedAfterDecl.get(i).stream().filter(item -> calledFunctionNames.contains(item.getName())).filter(item -> !declared.stream().anyMatch(alreadyDeclared -> alreadyDeclared.matches(item))) .collect(Collectors.toSet()); result.addAll(toDeclare);
/** * Return true if and only if this prototype and the given prototype match exactly, * except that they differ in return type or in type qualifiers of parameters. * Thus they are too similar to be overloads of one another, yet do not match * perfectly. * * @param functionPrototype The function prototype to be checked * @return true if and only if the prototypes clash */ public boolean clashes(FunctionPrototype functionPrototype) { if (matches(functionPrototype)) { return false; } if (!getName().equals(functionPrototype.getName())) { return false; } if (getNumParameters() != functionPrototype.getNumParameters()) { return false; } for (int i = 0; i < getNumParameters(); i++) { // If parameters differ after qualifier removal then there is no clash if (!getParameters().get(i).getType().getWithoutQualifiers().equals( functionPrototype.getParameters().get(i).getType().getWithoutQualifiers())) { return false; } } // We have two functions that do not match, yet have the same names and identical // parameter types once qualifiers are ignored. This is a clash. return true; }