8 #include <hilti/ast/expressions/coerced.h> 9 #include <hilti/ast/expressions/member.h> 10 #include <hilti/ast/operators/common.h> 11 #include <hilti/ast/types/any.h> 12 #include <hilti/ast/types/integer.h> 13 #include <hilti/ast/types/unknown.h> 15 #include <spicy/ast/types/bitfield.h> 19 namespace bitfield::detail {
30 static inline void checkName(
const Expression& op0,
const Expression& op1, Node& n) {
31 auto id = memberExpression(op1).id().local();
33 if (
const auto& f = op0.type().as<type::Bitfield>().bits(
id); ! f )
34 n.addError(hilti::util::fmt(
"bitfield type does not have attribute '%s'",
id));
37 static inline Type itemType(
const Expression& op0,
const Expression& op1) {
38 if (
auto st = op0.type().tryAs<type::Bitfield>() ) {
39 if (
const auto& f = st->bits(memberExpression(op1).
id().local()) )
48 BEGIN_OPERATOR_CUSTOM(bitfield, Member)
51 return type::DocOnly(
"<field type>");
53 return detail::itemType(ops[0], ops[1]);
56 bool isLhs()
const {
return false; }
57 auto priority()
const {
return hilti::operator_::Priority::Normal; }
59 const std::vector<hilti::operator_::Operand>& operands()
const {
60 static std::vector<hilti::operator_::Operand> _operands =
61 {{{}, type::constant(type::Bitfield(type::Wildcard())),
false, {},
"bitfield"},
62 {{}, type::Member(type::Wildcard()),
false, {},
"<attribute>"}};
67 detail::checkName(i.op0(), i.op1(), p.
node);
70 std::string doc()
const {
72 Retrieves the value of a bitfield's attribute. This is the value of the 73 corresponding bits inside the underlying integer value, shifted to the very
Definition: visitor-types.h:28
E node
Definition: visitor-types.h:33
Definition: bitfield.h:17