Goose  Artifact [c719270db3]

Artifact c719270db3e6801de22c8f90da11aa23d05eaeda8b45dd90eed3bdb29c3a626c:

  • File bs/cir/binaryop.h — 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: 938)

#ifndef GOOSE_CIR_BINARYINSTR_H
#define GOOSE_CIR_BINARYINSTR_H

namespace goose::cir
{
    class BinaryOp
    {
        public:
            template< typename L, typename R >
            BinaryOp( L&& lhs, R&& rhs ) :
                m_lhs( forward< L >( lhs ) ),
                m_rhs( forward< R >( rhs ) )
            {}

            const auto& lhs() const { return m_lhs; }
            const auto& rhs() const { return m_rhs; }

            bool canBeExecuted() const;
            bool canBeEagerlyEvaluated() const;

        private:
            eir::Value m_lhs;
            eir::Value m_rhs;
    };

    class BinaryOpSameTypes : public BinaryOp
    {
        public:
            template< typename L, typename R >
            BinaryOpSameTypes( L&& l, R&& r ) :
                BinaryOp( forward< L >( l ), forward< R >( r ) )
            {
                assert( lhs().type() == rhs().type() );
            }
    };
}

#endif