Beispiel #1
0
bool
Projection::operator==(const Projection &Other) const {
    if (isNominalKind() && Other.isNominalKind()) {
        return Other.getDecl() == Decl;
    } else {
        return !Other.isNominalKind() && Index == Other.getIndex();
    }
}
Beispiel #2
0
/// Returns true if we are accessing different fields.
static bool areProjectionsToDifferentFields(const Projection &P1,
        const Projection &P2) {
    // If operands have the same type and we are accessing different fields,
    // returns true. Operand's type is not saved in Projection. Instead we check
    // Decl's context.
    if (!P1.isNominalKind() || !P2.isNominalKind())
        return false;

    return P1.getDecl()->getDeclContext() == P2.getDecl()->getDeclContext() &&
           P1 != P2;
}
Beispiel #3
0
bool
Projection::operator<(Projection Other) const {
    // If we have a nominal kind...
    if (isNominalKind()) {
        // And Other is also nominal...
        if (Other.isNominalKind()) {
            // Just compare the value decl pointers.
            return getDeclIndex() < Other.getDeclIndex();
        }

        // Otherwise if Other is not nominal, return true since we always sort
        // decls before indices.
        return true;
    } else {
        // If this is not a nominal kind and Other is nominal, return
        // false. Nominal kinds are always sorted before non-nominal kinds.
        if (Other.isNominalKind())
            return false;

        // Otherwise, we are both index projections. Compare the indices.
        return getIndex() < Other.getIndex();
    }
}