1 |
2
|
krennw
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
#pragma once
|
27 |
|
|
|
28 |
|
|
#include <ast/identifiers/Scope.hpp>
|
29 |
|
|
#include <ast/statements/Block.hpp>
|
30 |
|
|
#include <ast/identifiers/ParameterIdentifier.hpp>
|
31 |
|
|
#include <deque>
|
32 |
|
|
#include <ast/Containers.hpp>
|
33 |
|
|
|
34 |
|
|
namespace Ast {
|
35 |
|
|
|
36 |
|
|
class FunctionIdentifier
|
37 |
|
|
: public Scope
|
38 |
|
|
{
|
39 |
|
|
protected:
|
40 |
|
|
ParameterList m_parameter;
|
41 |
|
|
Statement* m_body;
|
42 |
|
|
|
43 |
|
|
FunctionIdentifier(IdentifierKind id):
|
44 |
|
|
Scope(id),
|
45 |
|
|
m_parameter(),
|
46 |
|
|
m_body (nullptr)
|
47 |
|
|
{};
|
48 |
|
|
FunctionIdentifier(const FunctionIdentifier& toCopy):
|
49 |
|
|
Scope(toCopy),
|
50 |
|
|
m_parameter (toCopy.m_parameter),
|
51 |
|
|
m_body (toCopy.m_body)
|
52 |
|
|
{}
|
53 |
|
|
public:
|
54 |
|
|
|
55 |
|
|
void init (std::int32_t line, std::int32_t col, const char* text,
|
56 |
|
|
IScope* scopeRef, Type* typeRef, const char* prefix,
|
57 |
|
|
ParameterList* parameterListRef, SymbolTable* symbolTableRef, Statement* bodyRef)
|
58 |
|
|
{
|
59 |
|
|
Scope::init(line,col,text,scopeRef,typeRef,prefix,symbolTableRef);
|
60 |
|
|
m_parameter = std::move(*parameterListRef);
|
61 |
|
|
m_body = bodyRef;
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
std::deque<ParameterIdentifier*>& parameter() {return m_parameter;}
|
65 |
|
|
const std::deque<ParameterIdentifier*>& parameter() const {return m_parameter;}
|
66 |
|
|
Statement* body() const {return m_body;};
|
67 |
|
|
size_t parameterCount() const {return m_parameter.size(); }
|
68 |
|
|
|
69 |
|
|
void setBody(Statement* body) {m_body = body;};
|
70 |
|
|
void addParameter(ParameterIdentifier* aParameter) {m_parameter.push_back(aParameter);};
|
71 |
|
|
std::string getScopeName() const override {return toString();}
|
72 |
|
|
};
|
73 |
|
|
} |