Goose  Artifact [06ec8e0b8a]

Artifact 06ec8e0b8ad3d477c8a124c248261d41ec0f54047a00d7bb4a6e164db432498e:

  • File bs/eir/vecgenerator.cpp — part of check-in [a4f1ada98c] at 2021-09-15 21:24:51 on branch trunk —
    • VecOfLength() will now match vectors of compatible length, taking repetition terms into account
    • Vector unification and typechecking rules now handle vectors of variable lengths
    (user: achavasse size: 658)

#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::fixedPartFinished() const
    {
        return m_index >= m_cont.terms().size();
    }

    const Term& VecGenerator::operator()()
    {
        if( m_cont.repetitionTerm() && m_index >= m_cont.terms().size() )
        {
            ++m_index;
            return *m_cont.repetitionTerm();
        }

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