nany
signature.hxx
1 #pragma once
2 #include "signature.h"
3 
4 
5 namespace ny {
6 
7 
8 inline uint Signature::Parameters::size() const {
9  return (uint) m_types.size();
10 }
11 
12 
13 inline bool Signature::Parameters::empty() const {
14  return m_types.empty();
15 }
16 
17 
18 inline Signature::Paramtype& Signature::Parameters::operator [] (uint index) {
19  assert(index < m_types.size());
20  return m_types[index];
21 }
22 
23 
24 inline const Signature::Paramtype& Signature::Parameters::operator [] (uint index) const {
25  assert(index < m_types.size());
26  return m_types[index];
27 }
28 
29 
30 inline bool Signature::operator != (const Signature& rhs) const {
31  return not (*this == rhs);
32 }
33 
34 
35 inline bool Signature::Paramtype::operator == (const Signature::Paramtype& rhs) const {
36  return (kind == rhs.kind and atom == rhs.atom and qualifiers == rhs.qualifiers);
37 }
38 
39 
40 inline bool Signature::Paramtype::operator != (const Signature::Paramtype& rhs) const {
41  return not (operator == (rhs));
42 }
43 
44 
45 inline bool Signature::operator == (const Signature& rhs) const {
46  return (parameters == rhs.parameters and tmplparams == rhs.tmplparams);
47 }
48 
49 
50 } // namespace ny
51 
52 
53 namespace std {
54 
55 
56 template<> struct hash<ny::Signature> {
58  using result_type = std::size_t;
59 
60  result_type operator() (const argument_type& signature) const {
61  return signature.hash();
62  }
63 };
64 
65 
66 } // namespace std
67 
68 
69 namespace Yuni {
70 namespace Extension {
71 namespace CString {
72 
73 
74 template<class YString>
75 class Append<YString, ny::Signature> final {
76 public:
77  static void Perform(String& out, const ny::Signature& rhs);
78 };
79 
80 
81 } // namespace CString
82 } // namespace Extension
83 } // namespace Yuni
84 
85 
86 std::ostream& operator << (std::ostream& out, const ny::Signature& rhs);
Definition: signature.h:17
Parameters parameters
Function parameters (func (a, b , c))
Definition: signature.h:60
Definition: signature.cpp:9
Definition: signature.h:15
Definition: signature.hxx:53
Definition: ast.cpp:6
Atom * atom
Atom attached to it, if any (kind == nyt_any)
Definition: signature.h:21
nytype_t kind
Kind of the parameter.
Definition: signature.h:19
size_t hash() const
Get the hash of this singature.
Definition: signature.cpp:75
uint size() const
The total number of parameters.
Definition: signature.hxx:8
bool empty() const
Get if empty.
Definition: signature.hxx:13
Qualifiers qualifiers
Qualifiers (ref, const...)
Definition: signature.h:23
Parameters tmplparams
Template parameters.
Definition: signature.h:62