Goose  Artifact [8cfc6df0d3]

Artifact 8cfc6df0d3f768da8d2cbca32fe2840940e7d3c3906f7f22b4d6ccce62f27593:

  • File bs/cir/gettemporary.h — part of check-in [bcca4c51ba] at 2021-02-02 20:46:17 on branch trunk — CIR expressions pretty printing (user: achavasse size: 1079)

#ifndef GOOSE_CIR_GETTEMPORARY_H
#define GOOSE_CIR_GETTEMPORARY_H

namespace goose::cir
{
    class GetTemporary
    {
        public:
            template< typename T >
            GetTemporary( T&& type, uint32_t index ) :
                m_type( forward< T >( type ) ),
                m_index( index )
            {}

            const auto& type() const { return m_type; }
            const auto& index() const { return m_index; }

            bool canBeExecuted() const { return true; }
            bool canBeEagerlyEvaluated() const { return true; }

            bool operator<( const GetTemporary& rhs ) const
            {
                if( m_index != rhs.m_index )
                    return m_index < rhs.m_index;
                return m_type < rhs.m_type;
            }

            friend ostream& operator<<( ostream& out, const GetTemporary& ins )
            {
                return out << "GETTEMP(" << ins.m_index << ", " << ins.m_type << ')';
            }

        private:
            eir::Term m_type;
            uint32_t m_index = 0;
    };
}

#endif