7 #include <hilti/ast/expression.h> 8 #include <hilti/ast/types/unknown.h> 9 #include <hilti/base/util.h> 12 namespace expression {
23 constexpr util::enum_::Value<Kind> kinds[] = {{Kind::Self,
"self"}, {Kind::DollarDollar,
"$$"}, {Kind::Captures,
"$@"}};
27 constexpr
auto from_string(
const std::string_view& s) {
return util::enum_::from_string<Kind>(s, detail::kinds); }
30 constexpr
auto to_string(Kind m) {
return util::enum_::to_string(m, detail::kinds); }
42 keyword::Kind kind()
const {
return _kind; }
43 bool hasType()
const {
return _decl.has_value() || ! childs()[0].isA<
type::Unknown>(); }
46 bool isSet()
const {
return (! childs()[0].isA<type::Unknown>()) || _decl.has_value(); }
48 bool operator==(
const Keyword& other)
const {
return _kind == other._kind && type() == other.
type(); }
51 bool isLhs()
const {
return true; }
56 auto t = type::effectiveType(_decl ? (**_decl).as<
declaration::Type>().type() : childs()[0].as<Type>());
58 if ( _kind == keyword::Kind::Self )
59 t = type::removeFlags(t, type::Flag::Constant);
68 auto isEqual(
const Expression& other)
const {
return node::isEqual(
this, other); }
81 auto x = Expression(e)._clone().as<
Keyword>();
89 std::optional<NodeRef> _decl;
auto isConstant() const
Definition: keyword.h:65
std::vector< T > childs(int begin, int end) const
Definition: node.h:373
Type type() const
Definition: keyword.h:55
const Node none
Definition: node.cc:12
bool isLhs() const
Definition: keyword.h:51
Definition: expression.h:16
static Expression setType(const Keyword &e, const Type &t)
Definition: keyword.h:80
auto isEqual(const Expression &other) const
Definition: keyword.h:68
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
bool isTemporary() const
Definition: keyword.h:53
Definition: node_ref.h:44
auto properties() const
Definition: keyword.h:71
bool isSet() const
Definition: keyword.h:46