5 #include <hilti/ast/operators/common.h> 6 #include <hilti/ast/types/bool.h> 7 #include <hilti/ast/types/integer.h> 8 #include <hilti/ast/types/set.h> 9 #include <hilti/ast/types/void.h> 10 #include <hilti/base/util.h> 15 STANDARD_OPERATOR_1(set::iterator, Deref, operator_::dereferencedType(0),
16 type::constant(type::set::Iterator(type::Wildcard())),
17 "Returns the set element that the iterator refers to.");
18 STANDARD_OPERATOR_1(set::iterator, IncrPostfix, operator_::sameTypeAs(0,
"iterator<set<*>>"),
19 type::set::Iterator(type::Wildcard()),
20 "Advances the iterator by one set element, returning the previous position.");
21 STANDARD_OPERATOR_1(set::iterator, IncrPrefix, operator_::sameTypeAs(0,
"iterator<set<*>>"),
22 type::set::Iterator(type::Wildcard()),
23 "Advances the iterator by one set element, returning the new position.");
24 STANDARD_OPERATOR_2(set::iterator, Equal, type::Bool(), type::constant(type::set::Iterator(type::Wildcard())),
25 operator_::sameTypeAs(0,
"iterator<set<*>>"),
26 "Returns true if two sets iterators refer to the same location.");
27 STANDARD_OPERATOR_2(set::iterator, Unequal, type::Bool(), type::constant(type::set::Iterator(type::Wildcard())),
28 operator_::sameTypeAs(0,
"iterator<set<*>>"),
29 "Returns true if two sets iterators refer to different locations.");
31 STANDARD_OPERATOR_1(
set, Size, type::UnsignedInteger(64), type::constant(type::Set(type::Wildcard())),
32 "Returns the number of elements a set contains.");
33 STANDARD_OPERATOR_2(
set, Equal, type::Bool(), type::constant(type::Set(type::Wildcard())),
34 operator_::sameTypeAs(0,
"set<*>"),
"Compares two sets element-wise.");
35 STANDARD_OPERATOR_2(
set, Unequal, type::Bool(), type::constant(type::Set(type::Wildcard())),
36 operator_::sameTypeAs(0,
"set<*>"),
"Compares two sets element-wise.");
37 STANDARD_OPERATOR_2(
set, In, type::Bool(), type::Any(), type::constant(type::Set(type::Wildcard())),
38 "Returns true if an element is part of the set.");
39 STANDARD_OPERATOR_2(
set, Add, type::Void(), type::Set(type::Wildcard()), operator_::constantElementType(0,
"element"),
40 "Adds an element to the set.")
41 STANDARD_OPERATOR_2(set, Delete, type::Void(), type::Set(type::Wildcard()),
42 operator_::constantElementType(0, "element"), "Removes an element from the set.")
44 BEGIN_METHOD(set, Clear)
45 auto signature()
const {
46 return Signature{.self = type::Set(type::Wildcard()),
47 .result = type::Void(),
51 Removes all elements from the set.