/** Check if two formals are unique */ bool FunctionTable::isDistinctFormal(const ArgumentRules& x, const ArgumentRules& y) const { /* Check that all labels are unique in both sets of argument rules */ for (size_t i=0; i<x.size(); i++) { for (size_t j=i+1; j < x.size(); j++) { if (x[i].getArgumentLabel().size() != 0 && x[j].getArgumentLabel().size() != 0) { if (x[i].getArgumentLabel() == x[j].getArgumentLabel()) { return false; } } } } for (size_t i=0; i<y.size(); i++) { for (size_t j=i+1; j<y.size(); j++) { if (y[i].getArgumentLabel().size() != 0 && y[j].getArgumentLabel().size() != 0) { if (y[i].getArgumentLabel() == y[j].getArgumentLabel()) { return false; } } } } /* Check that types are different for at least one argument without default values */ size_t i; for (i=0; i<x.size() && i<y.size(); i++) { if ( !(x[i].hasDefault() == true && y[i].hasDefault() == true) && !x[i].isEllipsis() && !y[i].isEllipsis() && (x[i].getArgumentTypeSpec() != y[i].getArgumentTypeSpec() || x[i].getArgumentDagNodeType() != y[i].getArgumentDagNodeType() )) { return true; } } for (size_t j=i; j<x.size(); j++) { if (x[j].hasDefault() == false && !x[j].isEllipsis()) { return true; } } for (size_t j=i; j<y.size(); j++) { if (y[j].hasDefault() == false && !y[j].isEllipsis()) { return true; } } return false; }
/** Check if two formals are unique */ bool FunctionTable::isDistinctFormal(const ArgumentRules& x, const ArgumentRules& y) const { /* Check that all labels are unique in both sets of argument rules */ for (size_t i=0; i<x.size(); i++) { for (size_t j=i+1; j < x.size(); j++) { if (x[i].getArgumentLabel().size() != 0 && x[j].getArgumentLabel().size() != 0) if (x[i].getArgumentLabel() == x[j].getArgumentLabel()) return false; } } for (size_t i=0; i<y.size(); i++) { for (size_t j=i+1; j<y.size(); j++) { if (y[i].getArgumentLabel().size() != 0 && y[j].getArgumentLabel().size() != 0) if (y[i].getArgumentLabel() == y[j].getArgumentLabel()) return false; } } /* Check that the same labels are not used for different positions */ for (size_t i=0; i<x.size(); i++) { const std::string& xLabel = x[i].getArgumentLabel(); if (xLabel.size() == 0) continue; for (size_t j=0; j<y.size(); j++) { const std::string& yLabel = y[j].getArgumentLabel(); if (yLabel.size() == 0) continue; if (xLabel == yLabel && i != j) return false; } } /* Check that types are different for at least one argument without default values */ size_t i; for (i=0; i<x.size() && i<y.size(); i++) { if ( !(x[i].hasDefault() == true && y[i].hasDefault() == true) && !x[i].isEllipsis() && !y[i].isEllipsis() && x[i].getArgumentTypeSpec() != y[i].getArgumentTypeSpec()) return true; } for (size_t j=i; j<x.size(); j++) { if (x[j].hasDefault() == false && !x[j].isEllipsis()) return true; } for (size_t j=i; j<y.size(); j++) { if (y[j].hasDefault() == false && !y[j].isEllipsis()) return true; } return false; }