xo-umbrella2/xo-expression2/src/expression2/DVariable.cpp
Roland Conybeare a33f75f6f4 git subrepo clone git@github.com:Rconybea/xo-expression2.git xo-expression2
subrepo:
  subdir:   "xo-expression2"
  merged:   "9823ce36"
upstream:
  origin:   "git@github.com:Rconybea/xo-expression2.git"
  branch:   "main"
  commit:   "9823ce36"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"
2026-06-06 22:10:01 -04:00

72 lines
1.9 KiB
C++

/** @file DVariable.cpp
*
* @author Roland Conybeare, Jan 2026
**/
#include "DVariable.hpp"
#include "exprtype.hpp"
#include <xo/indentlog/print/quoted.hpp>
#include <cstddef>
namespace xo {
using xo::facet::typeseq;
namespace scm {
DVariable *
DVariable::make(obj<AAllocator> mm,
const DUniqueString * name,
const TypeRef & typeref,
Binding path)
{
void * mem = mm.alloc(typeseq::id<DVariable>(),
sizeof(DVariable));
return new (mem) DVariable(name, typeref, path);
}
DVariable::DVariable(const DUniqueString * name,
const TypeRef & typeref,
Binding path)
: name_{name}, typeref_{typeref}, path_{path}
{}
void
DVariable::assign_valuetype(TypeDescr td) noexcept
{
typeref_.resolve(td);
}
DVariable *
DVariable::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept
{
return gc.std_move_for(this);
}
void
DVariable::visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept
{
typeref_.visit_gco_children(reason, gc);
}
bool
DVariable::pretty(const ppindentinfo & ppii) const
{
using xo::print::quot;
auto name = (name_
? std::string_view(*name_)
: std::string_view(""));
return ppii.pps()->pretty_struct
(ppii,
"DVariable"
, refrtag("name", quot(name))
, refrtag("typeref", typeref_)
);
}
} /*namespace scm*/
} /*namespace xo*/
/* end DVariable.cpp */