}  for (Iterator it = gen.getFrames().iterator(); it.hasNext(); ) { QFrame qf = (QFrame) it.next(); s_log.info("frame: " + qf); s_log.info("expr: " + qf.getExpression()); s_log.info("uses: " + gen.getUses(qf.getExpression())); Expression cond = qf.getCondition(); if (cond != null) { s_log.info("cond: " + cond); s_log.info("uses: " + gen.getUses(cond)); }
    public String generate(Root root) {        Generator gen = new Generator(root);        m_query.frame(gen);        if (m_names.isEmpty()) {            return m_query.emit(gen);        }        QFrame qframe = gen.getFrame(m_query);        gen.push(qframe);        try {            for (Iterator it = m_names.iterator(); it.hasNext(); ) {                Expression e = get((String) it.next());                e.frame(gen);            }        } finally {            gen.pop();        }        s_log.info("unoptimized frame:\n" + qframe);        boolean modified;        do {            modified = false;            for (Iterator it = gen.getFrames().iterator(); it.hasNext(); ) {                QFrame qf = (QFrame) it.next();                modified |= qf.hoist();            }        } while (modified);        s_log.info("hoisted frame:\n" + qframe);        for (Iterator it = gen.getFrames().iterator(); it.hasNext(); ) {            QFrame qf = (QFrame) it.next();            qf.shrink();        }        s_log.info("shrunk frame:\n" + qframe);        StringBuffer sql = new StringBuffer();        sql.append("select ");        for (Iterator it = m_names.iterator(); it.hasNext(); ) {            String name = (String) it.next();            Expression e = get(name);            sql.append(e.emit(gen));            sql.append(" as ");            sql.append(name);            if (it.hasNext()) {                sql.append(", ");            }        }        sql.append("\nfrom ");        sql.append(qframe.emit(false));        return sql.toString();    }