Goose  Artifact [8c80f164ec]

Artifact 8c80f164ecbca47f2a2ab5e81ead1aeb40c163c1f03c1ca98acd1f835bb5bdc1:

  • File bs/builtins/types/struct/builder.h — part of check-in [75a719c020] at 2024-03-14 23:23:27 on branch trunk —
    • add type wrapper for unresolved compile time identifier, move undefined identifier handling to dropValue() of those
    • implemented dot operator for structs
    • fixed struct lazy parsing
    • implemented some tests for structs default construction
    • fixed struct default ctor generation
    (user: zlodo size: 1346)

#ifndef GOOSE_BUILTINS_TYPES_STRUCT_BUILDER_H
#define GOOSE_BUILTINS_TYPES_STRUCT_BUILDER_H

namespace goose::builtins
{
    class StructBuilder
    {
        public:
            template< typename I >
            StructBuilder( I&& identity ) :
                m_identity( forward< I >( identity ) )
            {
                m_defaultCtorCFG->createBB();
                m_defaultCtorCFG->setCurrentBB( m_defaultCtorCFG->entryBB() );
            }

            const auto& identity() const { return m_identity; }
            const auto& defaultCtorCFG() const { return m_defaultCtorCFG; }

            template< typename T >
            void declareMemberVar( const Context& c, StringId name, T&& type, LocationId loc );

            template< typename T, typename V >
            void declareMemberVar( const Context& c, StringId name, T&& type, LocationId loc, V&& init );

            bool finalize( const Context& c, const Value& st ) const;

        private:
            Term m_identity;
            ptr< cir::CFG > m_defaultCtorCFG = make_shared< cir::CFG >( 0 );

            struct MemberVar
            {
                optional< Value > init;
                Term m_type;
                StringId name;
                LocationId loc;
            };

            llvm::SmallVector< MemberVar, 8 > m_memberVars;
    };

}

#endif