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 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
#include "StatementVisitor.hpp"
|
33 |
|
|
#include <ast/statements/GuardedCommand.hpp>
|
34 |
|
|
#include <ast/statements/SeqBlock.hpp>
|
35 |
|
|
#include <ast/statements/NondetBlock.hpp>
|
36 |
|
|
#include <ast/statements/PrioBlock.hpp>
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
namespace Ast {
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
StatementVisitor::StatementVisitor(CallContext* context):
|
43 |
|
|
m_context(context)
|
44 |
|
|
{}
|
45 |
|
|
|
46 |
|
|
StatementVisitor::~StatementVisitor()
|
47 |
|
|
{}
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
void StatementVisitor::visitSub(AstElement* subElement, AstElement* parent) {
|
51 |
|
|
if (subElement == nullptr)
|
52 |
|
|
return;
|
53 |
|
|
visitAstElement(subElement, parent);
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
void StatementVisitor::visitAstElement(AstElement* element, AstElement* ){
|
57 |
|
|
switch (element->nodeType()) {
|
58 |
|
|
case AstNodeTypeEnum::expression:
|
59 |
|
|
case AstNodeTypeEnum::identifier:
|
60 |
|
|
case AstNodeTypeEnum::type:
|
61 |
|
|
error();
|
62 |
|
|
break;
|
63 |
|
|
case AstNodeTypeEnum::statement:
|
64 |
|
|
static_cast<Statement*>(element)->accept(*this);
|
65 |
|
|
break;
|
66 |
|
|
default:
|
67 |
|
|
m_context->logError("Internal error. Unknown AST type.");
|
68 |
|
|
abort();
|
69 |
|
|
}
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
void StatementVisitor::error() {
|
73 |
|
|
m_context -> logError("Internal error. This visitor only supports statements.");
|
74 |
|
|
abort();
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
void StatementVisitor::visit(TypeIdentifier* ) { error(); };
|
79 |
|
|
void StatementVisitor::visit(EnumIdentifier* ) { error(); };
|
80 |
|
|
|
81 |
|
|
void StatementVisitor::visit(AttributeIdentifier* ) { error(); };
|
82 |
|
|
void StatementVisitor::visit(LocalVariableIdentifier* ) { error(); };
|
83 |
|
|
void StatementVisitor::visit(ParameterIdentifier* ) { error(); };
|
84 |
|
|
void StatementVisitor::visit(ExpressionVariableIdentifier* ) { error(); };
|
85 |
|
|
void StatementVisitor::visit(MethodIdentifier* ) { error(); };
|
86 |
|
|
void StatementVisitor::visit(NamedActionIdentifier* ) { error(); };
|
87 |
|
|
void StatementVisitor::visit(Module* ) { error(); };
|
88 |
|
|
void StatementVisitor::visit(ConstantIdentifier* ) { error(); };
|
89 |
|
|
void StatementVisitor::visit(UnspecIdentifierBlock* ) { error(); };
|
90 |
|
|
void StatementVisitor::visit(SeqIdentifierBlock* ) { error(); };
|
91 |
|
|
void StatementVisitor::visit(NondetIdentifierBlock* ) { error(); };
|
92 |
|
|
void StatementVisitor::visit(PrioIdentifierBlock* ) { error(); };
|
93 |
|
|
void StatementVisitor::visit(MainModule* ) { error(); };
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
void StatementVisitor::visit(IntType* ) { error(); };
|
97 |
|
|
void StatementVisitor::visit(BoolType* ) { error(); };
|
98 |
|
|
void StatementVisitor::visit(EnumType* ) { error(); };
|
99 |
|
|
void StatementVisitor::visit(ListType* ) { error(); };
|
100 |
|
|
void StatementVisitor::visit(TupleType* ) { error(); };
|
101 |
|
|
void StatementVisitor::visit(NullType* ) { error(); };
|
102 |
|
|
void StatementVisitor::visit(PointerType* ) { error(); };
|
103 |
|
|
void StatementVisitor::visit(FunctionType* ) { error(); };
|
104 |
|
|
void StatementVisitor::visit(ActionSystemType* ) { error(); };
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
void StatementVisitor::visit(GuardedCommand* guardedCommand) {
|
108 |
|
|
visitSub(guardedCommand->body(), guardedCommand);
|
109 |
|
|
};
|
110 |
|
|
|
111 |
|
|
void StatementVisitor::visit(Call* ) { };
|
112 |
|
|
void StatementVisitor::visit(Assignment* ) { };
|
113 |
|
|
void StatementVisitor::visit(SeqBlock* seqBlock) {
|
114 |
|
|
for (auto& s: seqBlock->statements())
|
115 |
|
|
visitSub(s, seqBlock);
|
116 |
|
|
};
|
117 |
|
|
void StatementVisitor::visit(NondetBlock* nondetBlock) {
|
118 |
|
|
for (auto& s: nondetBlock->statements())
|
119 |
|
|
visitSub(s, nondetBlock);
|
120 |
|
|
};
|
121 |
|
|
void StatementVisitor::visit(PrioBlock* prioBlock) {
|
122 |
|
|
for (auto& s: prioBlock->statements())
|
123 |
|
|
visitSub(s, prioBlock);
|
124 |
|
|
};
|
125 |
|
|
void StatementVisitor::visit(Skip* ) { };
|
126 |
|
|
void StatementVisitor::visit(Break* ) { };
|
127 |
|
|
void StatementVisitor::visit(Abort* ) { };
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
void StatementVisitor::visit(TernaryOperator* ) { error(); };
|
131 |
|
|
void StatementVisitor::visit(BinaryOperator* ) { error(); };
|
132 |
|
|
void StatementVisitor::visit(UnaryOperator* ) { error(); };
|
133 |
|
|
void StatementVisitor::visit(ExistsQuantifier* ) { error(); };
|
134 |
|
|
void StatementVisitor::visit(ForallQuantifier* ) { error(); };
|
135 |
|
|
void StatementVisitor::visit(ListConstructor* ) { error(); };
|
136 |
|
|
void StatementVisitor::visit(SetConstructor* ) { error(); };
|
137 |
|
|
void StatementVisitor::visit(TupleConstructor* ) { error(); };
|
138 |
|
|
void StatementVisitor::visit(ObjectConstructor* ) { error(); };
|
139 |
|
|
void StatementVisitor::visit(BoolValueExpression* ) { error(); };
|
140 |
|
|
void StatementVisitor::visit(IntValueExpression* ) { error(); };
|
141 |
|
|
void StatementVisitor::visit(RefValueExpression* ) { error(); };
|
142 |
|
|
void StatementVisitor::visit(IdentifierExpression* ) { error(); };
|
143 |
|
|
void StatementVisitor::visit(TypeExpression* ) { error(); };
|
144 |
|
|
void StatementVisitor::visit(TupleMapAccessExpression* ) { error(); };
|
145 |
|
|
void StatementVisitor::visit(CallExpression* ) { error(); };
|
146 |
|
|
void StatementVisitor::visit(AccessExpression* ) { error(); };
|
147 |
|
|
|
148 |
|
|
} |