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