static Code emit(Generator gen, Expression lexpr, Expression rexpr) { if (gen.hasFrame(lexpr) && gen.hasFrame(rexpr)) { QFrame lframe = gen.getFrame(lexpr); QFrame rframe = gen.getFrame(rexpr); if (!lframe.isSelect() && !rframe.isSelect()) { List lvals = lframe.getValues(); List rvals = rframe.getValues(); if (lvals.size() != rvals.size()) { throw new IllegalStateException ("signature missmatch: " + lvals + ", " + rvals); } List conds = new ArrayList(); for (int i = 0; i < lvals.size(); i++) { QValue l = (QValue) lvals.get(i); QValue r = (QValue) rvals.get(i); Code lsql = l.emit(); Code rsql = r.emit(); if (lsql.isNull()) { if (!r.isNullable()) { return Code.FALSE; } } else if (rsql.isNull()) { if (!l.isNullable()) { return Code.FALSE; } }  if (!lsql.equals(rsql)) { conds.add(emit(lsql, null, rsql, null)); } } if (conds.isEmpty()) { return Code.TRUE; } else { return Code.join(conds, " and "); } } }    Code lsql = lexpr.emit(gen); Code rsql = rexpr.emit(gen);       if (lsql.getBindings().isEmpty() && lsql.equals(rsql)) { return Code.TRUE; } else { return emit(lsql, lexpr, rsql, rexpr); }
Code emit(Generator gen) { return emit(gen, m_left, m_right);
    static Code emit(Generator gen, Expression lexpr, Expression rexpr) {        if (gen.hasFrame(lexpr) && gen.hasFrame(rexpr)) {            QFrame lframe = gen.getFrame(lexpr);            QFrame rframe = gen.getFrame(rexpr);            if (!lframe.isSelect() && !rframe.isSelect()) {                List lvals = lframe.getValues();                List rvals = rframe.getValues();                if (lvals.size() != rvals.size()) {                    throw new IllegalStateException                        ("signature missmatch: " + lvals + ", " + rvals);                }                List conds = new ArrayList();                for (int i = 0; i < lvals.size(); i++) {                    QValue l = (QValue) lvals.get(i);                    QValue r = (QValue) rvals.get(i);                    Code lsql = l.emit();                    Code rsql = r.emit();                    if (lsql.isNull()) {                        if (!r.isNullable()) {                            return Code.FALSE;                        }                    } else if (rsql.isNull()) {                        if (!l.isNullable()) {                            return Code.FALSE;                        }                    }                    if (!lsql.equals(rsql)) {                        conds.add(emit(lsql, null, rsql, null));                    }                }                if (conds.isEmpty()) {                    return Code.TRUE;                } else {                    return Code.join(conds, " and ");                }            }        }        // XXX: we can to do something smarter than this for        // multi column selects        Code lsql = lexpr.emit(gen);        Code rsql = rexpr.emit(gen);        // we need the isEmpty test because we don't want to eliminate        // redundent bind var comparison the first time a query is        // cached since the sql may not be redundent for subsequent        // query executions        if (lsql.getBindings().isEmpty() && lsql.equals(rsql)) {            return Code.TRUE;        } else {            return emit(lsql, lexpr, rsql, rexpr);        }    }