Spicy
list.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
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/list.h>
9 #include <hilti/ast/types/void.h>
10 #include <hilti/base/util.h>
11 
12 namespace hilti {
13 namespace operator_ {
14 
15 STANDARD_OPERATOR_1(list::iterator, Deref, operator_::dereferencedType(0),
16  type::constant(type::list::Iterator(type::Wildcard())),
17  "Returns the list element that the iterator refers to.");
18 STANDARD_OPERATOR_1(list::iterator, IncrPostfix, operator_::sameTypeAs(0, "iterator<list<*>>"),
19  type::list::Iterator(type::Wildcard()),
20  "Advances the iterator by one list element, returning the previous position.");
21 STANDARD_OPERATOR_1(list::iterator, IncrPrefix, operator_::sameTypeAs(0, "iterator<list<*>>"),
22  type::list::Iterator(type::Wildcard()),
23  "Advances the iterator by one list element, returning the new position.");
24 STANDARD_OPERATOR_2(list::iterator, Equal, type::Bool(), type::constant(type::list::Iterator(type::Wildcard())),
25  operator_::sameTypeAs(0, "iterator<list<*>>"),
26  "Returns true if two lists iterators refer to the same location.");
27 STANDARD_OPERATOR_2(list::iterator, Unequal, type::Bool(), type::constant(type::list::Iterator(type::Wildcard())),
28  operator_::sameTypeAs(0, "iterator<list<*>>"),
29  "Returns true if two lists iterators refer to different locations.");
30 
31 STANDARD_OPERATOR_1(list, Size, type::UnsignedInteger(64), type::constant(type::List(type::Wildcard())),
32  "Returns the number of elements a list contains.");
33 STANDARD_OPERATOR_2(list, Equal, type::Bool(), type::constant(type::List(type::Wildcard())),
34  operator_::sameTypeAs(0, "list<*>"), "Compares two lists element-wise.");
35 STANDARD_OPERATOR_2(list, Unequal, type::Bool(), type::constant(type::List(type::Wildcard())),
36  operator_::sameTypeAs(0, "list<*>"), "Compares two lists element-wise.");
37 
38 } // namespace operator_
39 
40 } // namespace hilti