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 children()[2].tryAs<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 const Type& itemType()
const {
return child<Type>(1); }
40 bool isResolved()
const {
return type::isResolved(itemType()); }
41 auto isEqual(
const Item& other)
const {
return node::isEqual(
this, other); }
44 auto properties()
const {
return node::Properties{}; }
NodeBase(Meta meta)
Definition: node.h:365
const auto & children() const
Definition: node.h:470
Definition: variable.h:21
Definition: attribute.h:145
hilti::optional_ref< const Attribute > find(std::string_view tag) const
Definition: attribute.h:171
Definition: unit-item.h:19