
class Ctor;

/** Interface for HILTI constructors. */
class Concept : public hilti::util::type_erasure::ConceptBase {
public:
    Concept() = default;
    Concept(const Concept&) = default;
    Concept(Concept&&) = default;
    virtual ~Concept() = default;
    /** Returns the HILTI `Type` of the constructor's value. */
    virtual const Type& type() const = 0;
    /**
* Returns true if the constructor's value is a value that will never
* change.
*/
    virtual bool isConstant() const = 0;
    /** Returns true if the ctor can be the target of an assignment. */
    virtual bool isLhs() const = 0;
    /**
* Returns true if, when evaluated as RHS, the ctor will yield a
* temporary value.
*/
    virtual bool isTemporary() const = 0;
    /**
* Returns true if the constructor's HILTI value is equivalent to another
* one.
*/
    virtual bool isEqual(const Ctor& other) const = 0;
    /** Implements the `Node` interface. */
    virtual hilti::node::Properties properties() const = 0;
    /** Implements the `Node` interface. */
    virtual const std::vector<hilti::Node>& children() const = 0;
    /** Implements the `Node` interface. */
    virtual std::vector<hilti::Node>& children()  = 0;
    /** Implements the `Node` interface. */
    virtual const Meta& meta() const = 0;
    /** Implements the `Node` interface. */
    virtual void setMeta(Meta m)  = 0;
    /** Implements the `Node` interface. */
    virtual bool pruneWalk() const = 0;
    Concept& operator=(const Concept&) = default;
    Concept& operator=(Concept&&) = default;
    virtual Ctor _clone() const = 0;
    virtual hilti::IntrusivePtr<Concept> _clone_ptr() const = 0;
private:
    
};

template<typename T>
using ModelBase = hilti::util::type_erasure::ModelBase<T, Concept>;

template<class T>
class Model : public ModelBase<T> {
public:
    using ModelBase<T>::ModelBase;
    using ModelBase<T>::data;

    const Type& type() const final;
    bool isConstant() const final;
    bool isLhs() const final;
    bool isTemporary() const final;
    bool isEqual(const Ctor& other) const final;
    hilti::node::Properties properties() const final;
    const std::vector<hilti::Node>& children() const final;
    std::vector<hilti::Node>& children()  final;
    const Meta& meta() const final;
    void setMeta(Meta m)  final;
    bool pruneWalk() const final;
    Ctor _clone() const final;
    hilti::IntrusivePtr<Concept> _clone_ptr() const final;
};

using ErasedBase = hilti::util::type_erasure::ErasedBase<trait::isCtor, Concept, Model>;

class Ctor : public ErasedBase, public trait::isNode {
public:
    using ErasedBase::ErasedBase;

    Ctor() noexcept = default;
    Ctor(Ctor&&) noexcept = default;
    Ctor& operator=(Ctor&&) = default;
    ~Ctor() override = default;
    Ctor(const Ctor& other) = default;
    Ctor& operator=(const Ctor& other) = default;

    const Type& type() const;
    bool isConstant() const;
    bool isLhs() const;
    bool isTemporary() const;
    bool isEqual(const Ctor& other) const;
    hilti::node::Properties properties() const;
    const std::vector<hilti::Node>& children() const;
    std::vector<hilti::Node>& children() ;
    const Meta& meta() const;
    void setMeta(Meta m) ;
    bool pruneWalk() const;
    Ctor _clone() const;

    hilti::IntrusivePtr<Concept> _clone_ptr() const;

protected:
    
};

template<typename T>
const Type& Model<T>::type() const { return data().type(); }

template<typename T>
bool Model<T>::isConstant() const { return data().isConstant(); }

template<typename T>
bool Model<T>::isLhs() const { return data().isLhs(); }

template<typename T>
bool Model<T>::isTemporary() const { return data().isTemporary(); }

template<typename T>
bool Model<T>::isEqual(const Ctor& other) const { return data().isEqual(other); }

template<typename T>
hilti::node::Properties Model<T>::properties() const { return data().properties(); }

template<typename T>
const std::vector<hilti::Node>& Model<T>::children() const { return data().children(); }

template<typename T>
std::vector<hilti::Node>& Model<T>::children()  { return data().children(); }

template<typename T>
const Meta& Model<T>::meta() const { return data().meta(); }

template<typename T>
void Model<T>::setMeta(Meta m)  { return data().setMeta(m); }

template<typename T>
bool Model<T>::pruneWalk() const { return data().pruneWalk(); }

template<typename T>
Ctor Model<T>::_clone() const { return T(data()); }

template<typename T>
hilti::IntrusivePtr<Concept> Model<T>::_clone_ptr() const {
    if constexpr ( std::is_base_of<hilti::util::type_erasure::trait::Singleton, T>::value )
        return nullptr;
    else
        return hilti::make_intrusive<Model>(T(data()));
}

inline const Type& Ctor::type() const { return data()->type(); }

inline bool Ctor::isConstant() const { return data()->isConstant(); }

inline bool Ctor::isLhs() const { return data()->isLhs(); }

inline bool Ctor::isTemporary() const { return data()->isTemporary(); }

inline bool Ctor::isEqual(const Ctor& other) const { return data()->isEqual(other); }

inline hilti::node::Properties Ctor::properties() const { return data()->properties(); }

inline const std::vector<hilti::Node>& Ctor::children() const { return data()->children(); }

inline std::vector<hilti::Node>& Ctor::children()  { return data()->children(); }

inline const Meta& Ctor::meta() const { return data()->meta(); }

inline void Ctor::setMeta(Meta m)  { return data()->setMeta(std::move(m)); }

inline bool Ctor::pruneWalk() const { return data()->pruneWalk(); }

inline Ctor Ctor::_clone() const { return data() ? data()->_clone() : Ctor(); }

inline hilti::IntrusivePtr<Concept> Ctor::_clone_ptr() const {
    if ( data() )
        return data()->_clone_ptr();
    else
        return nullptr;
}



