1 |
7
|
krennw
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
2
|
krennw
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
#pragma once
|
27 |
|
|
|
28 |
|
|
#include <ast/expressions/TypeConstructionExpression.hpp>
|
29 |
|
|
#include <ast/IAstVisitor.hpp>
|
30 |
|
|
#include <ast/types/ActionSystemType.hpp>
|
31 |
|
|
#include <deque>
|
32 |
|
|
#include <cstdint>
|
33 |
|
|
#include <string>
|
34 |
|
|
|
35 |
|
|
namespace Ast {
|
36 |
|
|
|
37 |
|
|
class ObjectConstructor final
|
38 |
|
|
: public TypeConstructionExpression
|
39 |
|
|
{
|
40 |
|
|
protected:
|
41 |
|
|
ActionSystemInstanceList::size_type m_currentInstance;
|
42 |
|
|
ActionSystemInstanceList m_instances;
|
43 |
|
|
std::string m_fixedObjectName;
|
44 |
|
|
|
45 |
|
|
ObjectConstructor():
|
46 |
|
|
TypeConstructionExpression(ExpressionKind::ObjectConstr),
|
47 |
|
|
m_currentInstance (0),
|
48 |
|
|
m_instances(),
|
49 |
|
|
m_fixedObjectName ("")
|
50 |
|
|
{};
|
51 |
|
|
ObjectConstructor(const ObjectConstructor &toCopy):
|
52 |
|
|
TypeConstructionExpression(toCopy),
|
53 |
|
|
m_currentInstance(toCopy.m_currentInstance),
|
54 |
|
|
m_instances(toCopy.m_instances),
|
55 |
|
|
m_fixedObjectName (toCopy.m_fixedObjectName)
|
56 |
|
|
{};
|
57 |
|
|
|
58 |
|
|
static ObjectConstructor* create(ExpressionKind){return new ObjectConstructor();}
|
59 |
|
|
static ObjectConstructor* createCopy(const ObjectConstructor& toCopy){return new ObjectConstructor(toCopy);}
|
60 |
|
|
public:
|
61 |
|
|
friend class Ast;
|
62 |
|
|
friend class Expression;
|
63 |
|
|
|
64 |
|
|
void init(std::int32_t line, std::int32_t pos,
|
65 |
|
|
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef,
|
66 |
|
|
ActionSystemInstanceList* instanceList, std::uint32_t currentInstance, const char* name)
|
67 |
|
|
{
|
68 |
|
|
TypeConstructionExpression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
|
69 |
|
|
m_instances = std::move(*instanceList);
|
70 |
|
|
m_currentInstance = currentInstance;
|
71 |
|
|
m_fixedObjectName = name == nullptr ? "" : name;
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
std::uint32_t currentInstance() const {return (std::uint32_t) m_currentInstance;};
|
76 |
|
|
ActionSystemInstanceList& instances() {return m_instances;};
|
77 |
|
|
std::string givenObjectName() {return m_fixedObjectName;};
|
78 |
|
|
void resetCurrentInstance() {m_currentInstance = 0;};
|
79 |
|
|
|
80 |
|
|
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
|
81 |
|
|
void addInstance(ActionSystemInstance* anInstance) {m_instances.push_back(anInstance);};
|
82 |
|
|
ActionSystemInstance* GetNextInstance() {
|
83 |
|
|
ActionSystemInstance* result = m_instances[m_currentInstance];
|
84 |
|
|
m_currentInstance++;
|
85 |
|
|
return result;
|
86 |
|
|
};
|
87 |
|
|
};
|
88 |
|
|
} |