nany
funcdef.hxx
1 #pragma once
2 #include "funcdef.h"
3 
4 
5 namespace ny {
6 
7 
8 inline Funcdef::Funcdef(const AnyString& name)
9  : name(name) {
10 }
11 
12 
13 inline bool Funcdef::hasReturnType() const {
14  return not rettype.isVoid();
15 }
16 
17 
18 inline bool Funcdef::hasParameters() const {
19  return not parameters.empty();
20 }
21 
22 
25 }
26 
27 
28 inline void Funcdef::resetReturnType(const CLID& clid) {
29  rettype = clid;
30 }
31 
32 
33 inline void Funcdef::appendParameter(const CLID& clid) {
34  assert(not clid.isVoid() and "invalid classdef id");
35  parameters.push_back(std::make_pair(AnyString(), clid));
36 }
37 
38 
39 inline void Funcdef::appendParameter(const AnyString& name, const CLID& clid) {
40  assert(not clid.isVoid() and "invalid classdef id");
41  parameters.push_back(std::make_pair(name, clid));
42 }
43 
44 
45 inline bool Funcdef::isOperator() const {
46  assert(not name.empty() and "invalid funcdef name");
47  return (not name.empty()) and name[0] == '@';
48 }
49 
50 inline bool Funcdef::isFunc() const {
51  assert(not name.empty() and "invalid funcdef name");
52  return (not name.empty()) and name[0] != '@';
53 }
54 
55 
56 inline bool Funcdef::isPartiallyResolved() const {
57  return (atom != nullptr) or (not overloads.empty());
58 }
59 
60 
61 inline bool Funcdef::isFullyResolved() const {
62  return (atom != nullptr);
63 }
64 
65 
66 } // namespace ny
bool hasParameters() const
Get if the funcdef has parameters.
Definition: funcdef.hxx:18
void appendParameter(const CLID &)
Append an unamed parameter.
Definition: funcdef.hxx:33
bool isPartiallyResolved() const
Get if the funcdef is resolved or has overloads.
Definition: funcdef.hxx:56
void resetReturnType(const CLID &)
Reset the return type.
Definition: funcdef.hxx:28
Definition: clid.h:11
ClassdefOverloads overloads
Overloads.
Definition: funcdef.h:73
bool isVoid() const
Get if the clid is valid (aka != 0)
Definition: clid.hxx:21
Definition: ast.cpp:6
CLID clid
clid
Definition: funcdef.h:65
CLID rettype
Return type (null means void)
Definition: funcdef.h:67
const AnyString name
Name of the func or the operator.
Definition: funcdef.h:63
bool isOperator() const
Is operator ?
Definition: funcdef.hxx:45
void reclassToVoid()
update to 'void'
Definition: clid.hxx:39
bool isFunc() const
Is a function ?
Definition: funcdef.hxx:50
std::vector< std::pair< AnyString, CLID > > parameters
parameters (name if name parameter, type)
Definition: funcdef.h:69
bool hasReturnType() const
Get if the funcdef has a return type (&#39;void&#39; otherwise)
Definition: funcdef.hxx:13
bool isFullyResolved() const
Get if the funcdef is fully resolved.
Definition: funcdef.hxx:61
void resetReturnTypeToVoid()
Reset the return type to void.
Definition: funcdef.hxx:23