7 #include <spicy/ast/aliases.h> 8 #include <spicy/ast/engine.h> 9 #include <spicy/ast/types/unit-item.h> 10 #include <spicy/ast/types/unit.h> 23 Variable(
ID id, Type type,
const std::optional<Expression>& default_, std::optional<AttributeSet> attrs = {},
25 :
NodeBase(nodes(std::move(
id), std::move(type), default_, std::move(attrs)), std::move(m)) {}
27 const auto& id()
const {
return child<ID>(0); }
28 auto default_()
const {
return childs()[2].tryReferenceAs<Expression>(); }
31 bool isOptional()
const {
return AttributeSet::find(attributes(),
"&optional").has_value(); }
33 bool operator==(
const Variable& other)
const {
34 return id() == other.id() && itemType() == other.itemType() && default_() == other.default_() &&
35 attributes() == other.attributes();
39 Type itemType()
const {
return type::effectiveType(child<Type>(1)); }
40 auto isEqual(
const Item& other)
const {
return node::isEqual(
this, other); }
43 auto properties()
const {
return node::Properties{}; }
NodeBase(Meta meta)
Definition: node.h:325
auto & childs() const
Definition: node.h:445
Definition: variable.h:21
Definition: attribute.h:159
std::optional< Attribute > find(std::string_view tag) const
Definition: attribute.h:190
Definition: unit-item.h:19
Definition: unit-item.h:39