Spicy
reference.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/reference.h>
8 
9 namespace hilti {
10 namespace operator_ {
11 
12 STANDARD_OPERATOR_1(strong_reference, Deref, operator_::dereferencedType(0),
13  type::constant(type::StrongReference(type::Wildcard())),
14  "Returns the referenced instance, or throws an exception if none or expired.");
15 STANDARD_OPERATOR_2(strong_reference, Equal, type::Bool(), type::constant(type::StrongReference(type::Wildcard())),
16  operator_::sameTypeAs(0), "Returns true if both operands reference the same instance.")
17 STANDARD_OPERATOR_2(strong_reference, Unequal, type::Bool(), type::constant(type::StrongReference(type::Wildcard())),
18  operator_::sameTypeAs(0), "Returns true if the two operands reference different instances.")
19 
20 STANDARD_OPERATOR_1(weak_reference, Deref, operator_::dereferencedType(0),
21  type::constant(type::WeakReference(type::Wildcard())),
22  "Returns the referenced instance, or throws an exception if none or expired.");
23 STANDARD_OPERATOR_2(weak_reference, Equal, type::Bool(), type::constant(type::WeakReference(type::Wildcard())),
24  operator_::sameTypeAs(0), "Returns true if both operands reference the same instance.")
25 STANDARD_OPERATOR_2(weak_reference, Unequal, type::Bool(), type::constant(type::WeakReference(type::Wildcard())),
26  operator_::sameTypeAs(0), "Returns true if the two operands reference different instances.")
27 
28 STANDARD_OPERATOR_1(value_reference, Deref, operator_::dereferencedType(0),
29  type::constant(type::ValueReference(type::Wildcard())),
30  "Returns the referenced instance, or throws an exception if none or expired.");
31 STANDARD_OPERATOR_2(value_reference, Equal, type::Bool(), type::constant(type::ValueReference(type::Wildcard())),
32  operator_::sameTypeAs(0), "Returns true if the values of both operands are equal.")
33 STANDARD_OPERATOR_2(value_reference, Unequal, type::Bool(), type::constant(type::ValueReference(type::Wildcard())),
34  operator_::sameTypeAs(0), "Returns true if the values of both operands are not equal.")
35 
36 } // namespace operator_
37 } // namespace hilti