Goose  Artifact [b0b45eaeee]

Artifact b0b45eaeeec6f40fa3d826f055ec4fada1b68f4b441993367c2ea7146758621e:

  • File bs/eir/vecgenerator.cpp — part of check-in [7d2def7b75] at 2020-12-27 14:40:24 on branch trunk — Renamed "ir" to "eir" (expression intermediate representation) and "llr" to "cir" (code intermediate representation) for clarity. (user: achavasse size: 660)

#include "eir.h"

namespace goose::eir
{
    bool VecGenerator::finished() const
    {
        return ( !m_cont.repetitionTerm() && m_index == m_cont.terms().size() )
            || ( m_cont.repetitionTerm() && m_index > m_cont.terms().size() );
    }
    bool VecGenerator::repeating() const { return m_cont.repetitionTerm() && m_index == m_cont.terms().size(); }

    const Term& VecGenerator::operator()()
    {
        assert( !finished() );

        if( m_cont.repetitionTerm() && m_index >= m_cont.terms().size() )
        {
            ++m_index;
            return *m_cont.repetitionTerm();
        }

        return m_cont.terms()[m_index++];
    }
}