Revision 2
Added by Willibald K. over 9 years ago
trunk/compiler/cppAst/ast/expressions/AccessExpression.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/BinaryOperator.hpp> |
|
29 |
#include <ast/IAstVisitor.hpp> |
|
30 |
|
|
31 |
namespace Ast { |
|
32 |
|
|
33 |
class AccessExpression final |
|
34 |
: public BinaryOperator |
|
35 |
{ |
|
36 |
protected: |
|
37 |
AccessExpression(): |
|
38 |
BinaryOperator(ExpressionKind::Access) |
|
39 |
{}; |
|
40 |
AccessExpression(const AccessExpression &toCopy): |
|
41 |
BinaryOperator(toCopy) |
|
42 |
{}; |
|
43 |
|
|
44 |
static AccessExpression* create(ExpressionKind){return new AccessExpression();} |
|
45 |
static AccessExpression* createCopy(const AccessExpression& toCopy){return new AccessExpression(toCopy);} |
|
46 |
public: |
|
47 |
friend class Ast; |
|
48 |
friend class Expression; |
|
49 |
|
|
50 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
|
51 |
}; |
|
52 |
} |
trunk/compiler/cppAst/ast/expressions/BinaryOperator.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/Expression.hpp> |
|
29 |
#include <ast/IAstVisitor.hpp> |
|
30 |
|
|
31 |
namespace Ast { |
|
32 |
|
|
33 |
class BinaryOperator |
|
34 |
: public Expression |
|
35 |
{ |
|
36 |
protected: |
|
37 |
Expression* m_left; |
|
38 |
Expression* m_right; |
|
39 |
|
|
40 |
BinaryOperator(ExpressionKind kind): |
|
41 |
Expression(kind), |
|
42 |
m_left (nullptr), |
|
43 |
m_right (nullptr) |
|
44 |
{}; |
|
45 |
BinaryOperator(const BinaryOperator& toCopy): |
|
46 |
Expression(toCopy), |
|
47 |
m_left (toCopy.m_left), |
|
48 |
m_right (toCopy.m_right) |
|
49 |
{}; |
|
50 |
|
|
51 |
static BinaryOperator* create(ExpressionKind k) {return new BinaryOperator(k);} |
|
52 |
static BinaryOperator* createCopy(const BinaryOperator& toCopy) {return new BinaryOperator(toCopy);} |
|
53 |
public: |
|
54 |
friend class Ast; |
|
55 |
friend class Expression; |
|
56 |
|
|
57 |
void init(std::int32_t line, std::int32_t pos, |
|
58 |
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, |
|
59 |
SymbolTable* symbTabRef, Expression* left, Expression* right) |
|
60 |
{ |
|
61 |
Expression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef); |
|
62 |
m_left = left; |
|
63 |
m_right = right; |
|
64 |
} |
|
65 |
|
|
66 |
|
|
67 |
Expression* left() {return m_left;}; |
|
68 |
Expression* right(){return m_right;}; |
|
69 |
void setRightChild(Expression* child) {m_right = child;}; |
|
70 |
void setLeftChild(Expression* child) {m_left = child;}; |
|
71 |
|
|
72 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
|
73 |
}; |
|
74 |
} |
trunk/compiler/cppAst/ast/expressions/CallExpression.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/UnaryOperator.hpp> |
|
29 |
#include <ast/IAstVisitor.hpp> |
|
30 |
#include <deque> |
|
31 |
#include <ast/IScope.hpp> |
|
32 |
|
|
33 |
namespace Ast { |
|
34 |
|
|
35 |
class CallExpression final |
|
36 |
: public UnaryOperator |
|
37 |
{ |
|
38 |
private: |
|
39 |
ExpressionList m_arguments; |
|
40 |
IScope* m_callScope; |
|
41 |
|
|
42 |
CallExpression(): |
|
43 |
UnaryOperator(ExpressionKind::Call), |
|
44 |
m_arguments (), |
|
45 |
m_callScope (nullptr) |
|
46 |
{}; |
|
47 |
CallExpression(const CallExpression &toCopy): |
|
48 |
UnaryOperator(toCopy), |
|
49 |
m_arguments (toCopy.m_arguments), |
|
50 |
m_callScope (toCopy.m_callScope) |
|
51 |
{}; |
|
52 |
|
|
53 |
static CallExpression* create(ExpressionKind) {return new CallExpression();} |
|
54 |
static CallExpression* createCopy(const CallExpression& toCopy) {return new CallExpression(toCopy);} |
|
55 |
public: |
|
56 |
friend class Ast; |
|
57 |
friend class Expression; |
|
58 |
|
|
59 |
void init(std::int32_t line, std::int32_t pos, |
|
60 |
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef, |
|
61 |
Expression* child, ExpressionList* argumentList, IScope* scopeRef) |
|
62 |
{ |
|
63 |
UnaryOperator::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef,child); |
|
64 |
m_arguments = std::move(*argumentList); |
|
65 |
m_callScope = scopeRef; |
|
66 |
} |
|
67 |
|
|
68 |
ExpressionList& arguments() {return m_arguments;}; |
|
69 |
IScope* scope() {return m_callScope;}; |
|
70 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
|
71 |
//void setArguments(ExpressionList& newArgs) {m_arguments = newArgs;}; |
|
72 |
}; |
|
73 |
} |
trunk/compiler/cppAst/ast/expressions/ExistsQuantifier.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/Quantifier.hpp> |
|
29 |
#include <ast/IAstVisitor.hpp> |
|
30 |
|
|
31 |
namespace Ast { |
|
32 |
|
|
33 |
class ExistsQuantifier final |
|
34 |
: public Quantifier |
|
35 |
{ |
|
36 |
protected: |
|
37 |
ExistsQuantifier(): |
|
38 |
Quantifier(ExpressionKind::exists) |
|
39 |
{}; |
|
40 |
ExistsQuantifier(const ExistsQuantifier &toCopy): |
|
41 |
Quantifier(toCopy) |
|
42 |
{}; |
|
43 |
|
|
44 |
static ExistsQuantifier* create(ExpressionKind) {return new ExistsQuantifier();} |
|
45 |
static ExistsQuantifier* createCopy(const ExistsQuantifier& toCopy) {return new ExistsQuantifier(toCopy);} |
|
46 |
public: |
|
47 |
friend class Ast; |
|
48 |
friend class Expression; |
|
49 |
|
|
50 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
|
51 |
}; |
|
52 |
|
|
53 |
} |
trunk/compiler/cppAst/ast/expressions/Expression.cpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
#include "Expression.hpp" |
|
26 |
#include <ast/expressions/TernaryOperator.hpp> |
|
27 |
#include <ast/expressions/BinaryOperator.hpp> |
|
28 |
#include <ast/expressions/UnaryOperator.hpp> |
|
29 |
#include <ast/expressions/ForallQuantifier.hpp> |
|
30 |
#include <ast/expressions/ExistsQuantifier.hpp> |
|
31 |
#include <ast/expressions/ListConstructor.hpp> |
|
32 |
#include <ast/expressions/TupleConstructor.hpp> |
|
33 |
#include <ast/expressions/ObjectConstructor.hpp> |
|
34 |
#include <ast/expressions/IdentifierExpression.hpp> |
|
35 |
#include <ast/expressions/TypeExpression.hpp> |
|
36 |
#include <ast/expressions/TupleMapAccessExpression.hpp> |
|
37 |
#include <ast/expressions/CallExpression.hpp> |
|
38 |
#include <ast/expressions/AccessExpression.hpp> |
|
39 |
#include <ast/expressions/ValueExpression.hpp> |
|
40 |
#include <ast/expressions/SetConstructor.hpp> |
|
41 |
#include <ast/expressions/TupleMapAccessExpression.hpp> |
|
42 |
#include <ast/expressions/CallExpression.hpp> |
|
43 |
#include <ast/expressions/AccessExpression.hpp> |
|
44 |
|
|
45 |
namespace Ast { |
|
46 |
|
|
47 |
|
|
48 |
static void abstractError(ExpressionKind ) { |
|
49 |
throw new Base::NotImplementedException(); |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
Base::FuncPtr Expression::s_exprVmt [2][EXPRESSIONKIND_NR_ITEMS] = |
|
55 |
{ |
|
56 |
{ |
|
57 |
/* conditional = 0, */ (Base::FuncPtr) &TernaryOperator::create, |
|
58 |
/* domresby = 1, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
59 |
/* domresto = 2, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
60 |
/* rngresby = 3, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
61 |
/* rngresto = 4, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
62 |
/* munion = 5, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
63 |
/* conc = 6, */ (Base::FuncPtr) &BinaryOperator::create, |
|
64 |
/* diff = 7, */ (Base::FuncPtr) &BinaryOperator::create, |
|
65 |
/* inter = 8, */ (Base::FuncPtr) &BinaryOperator::create, |
|
66 |
/* elemin = 9, */ (Base::FuncPtr) &BinaryOperator::create, |
|
67 |
/* notelemin = 10, */ (Base::FuncPtr) &BinaryOperator::create, |
|
68 |
/* subset = 11, */ (Base::FuncPtr) &BinaryOperator::create, |
|
69 |
/* _union = 12, */ (Base::FuncPtr) &BinaryOperator::create, |
|
70 |
/* div = 13, */ (Base::FuncPtr) &BinaryOperator::create, |
|
71 |
/* greater = 14, */ (Base::FuncPtr) &BinaryOperator::create, |
|
72 |
/* greaterequal = 15, */ (Base::FuncPtr) &BinaryOperator::create, |
|
73 |
/* idiv = 16, */ (Base::FuncPtr) &BinaryOperator::create, |
|
74 |
/* less = 17, */ (Base::FuncPtr) &BinaryOperator::create, |
|
75 |
/* lessequal = 18, */ (Base::FuncPtr) &BinaryOperator::create, |
|
76 |
/* minus = 19, */ (Base::FuncPtr) &BinaryOperator::create, |
|
77 |
/* mod = 20, */ (Base::FuncPtr) &BinaryOperator::create, |
|
78 |
/* pow = 21, */ (Base::FuncPtr) &BinaryOperator::create, |
|
79 |
/* prod = 22, */ (Base::FuncPtr) &BinaryOperator::create, |
|
80 |
/* sum = 23, */ (Base::FuncPtr) &BinaryOperator::create, |
|
81 |
/* _and = 24, */ (Base::FuncPtr) &BinaryOperator::create, |
|
82 |
/* biimplies = 25, */ (Base::FuncPtr) &BinaryOperator::create, |
|
83 |
/* implies = 26, */ (Base::FuncPtr) &BinaryOperator::create, |
|
84 |
/* _or = 27, */ (Base::FuncPtr) &BinaryOperator::create, |
|
85 |
/* equal = 28, */ (Base::FuncPtr) &BinaryOperator::create, |
|
86 |
/* notequal = 29, */ (Base::FuncPtr) &BinaryOperator::create, |
|
87 |
/* seqmod_mapoverride = 30, */ (Base::FuncPtr) &abstractError, |
|
88 |
/* dom = 31, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
89 |
/* range = 32, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
90 |
/* merge = 33, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
91 |
/* card = 34, */ (Base::FuncPtr) &UnaryOperator::create, |
|
92 |
/* dconc = 35, */ (Base::FuncPtr) &UnaryOperator::create, |
|
93 |
/* dinter = 36, */ (Base::FuncPtr) &UnaryOperator::create, |
|
94 |
/* dunion = 37, */ (Base::FuncPtr) &UnaryOperator::create, |
|
95 |
/* elems = 38, */ (Base::FuncPtr) &UnaryOperator::create, |
|
96 |
/* head = 39, */ (Base::FuncPtr) &UnaryOperator::create, |
|
97 |
/* inds = 40, */ (Base::FuncPtr) &UnaryOperator::create, |
|
98 |
/* len = 41, */ (Base::FuncPtr) &UnaryOperator::create, |
|
99 |
/* tail = 42, */ (Base::FuncPtr) &UnaryOperator::create, |
|
100 |
/* unminus = 43, */ (Base::FuncPtr) &UnaryOperator::create, |
|
101 |
/* unplus = 44, */ (Base::FuncPtr) &UnaryOperator::create, |
|
102 |
/* _not = 45, */ (Base::FuncPtr) &UnaryOperator::create, |
|
103 |
/* abs = 46, */ (Base::FuncPtr) &UnaryOperator::create, |
|
104 |
/* forall = 47, */ (Base::FuncPtr) &ForallQuantifier::create, |
|
105 |
/* exists = 48, */ (Base::FuncPtr) &ExistsQuantifier::create, |
|
106 |
/* ListConstr = 49, */ (Base::FuncPtr) &ListConstructor::create, |
|
107 |
/* SetConstr = 50, */ (Base::FuncPtr) &SetConstructor::create, |
|
108 |
/* MapConstr = 51, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
109 |
/* TupleConstr = 52, */ (Base::FuncPtr) &TupleConstructor::create, |
|
110 |
/* ObjectConstr = 53, */ (Base::FuncPtr) &ObjectConstructor::create, |
|
111 |
/* QValConstr = 54, */ (Base::FuncPtr) &abstractError, |
|
112 |
/* Identifier = 55, */ (Base::FuncPtr) &IdentifierExpression::create, |
|
113 |
/* UnresolvedIdentifier = 56, */ (Base::FuncPtr) &abstractError, |
|
114 |
/* Type = 57, */ (Base::FuncPtr) &TypeExpression::create, |
|
115 |
/* TupleMapAccess = 58, */ (Base::FuncPtr) &TupleMapAccessExpression::create, |
|
116 |
/* Call = 59, */ (Base::FuncPtr) &CallExpression::create, |
|
117 |
/* Access = 60, */ (Base::FuncPtr) &AccessExpression::create, |
|
118 |
/* Primed = 61, */ (Base::FuncPtr) &abstractError, |
|
119 |
/* Cast = 62, */ (Base::FuncPtr) &UnaryOperator::create, |
|
120 |
/* foldLR = 63, */ (Base::FuncPtr) &TernaryOperator::create, |
|
121 |
/* foldRL = 64, */ (Base::FuncPtr) &abstractError, |
|
122 |
/* Value_Integer = 65, */ (Base::FuncPtr) &IntValueExpression::create, |
|
123 |
/* Value_Bool = 66, */ (Base::FuncPtr) &BoolValueExpression::create, |
|
124 |
/* Value_Reference = 67, */ (Base::FuncPtr) &RefValueExpression::create |
|
125 |
}, |
|
126 |
{ |
|
127 |
/* conditional = 0, */ (Base::FuncPtr) &TernaryOperator::createCopy, |
|
128 |
/* domresby = 1, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
129 |
/* domresto = 2, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
130 |
/* rngresby = 3, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
131 |
/* rngresto = 4, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
132 |
/* munion = 5, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
133 |
/* conc = 6, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
134 |
/* diff = 7, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
135 |
/* inter = 8, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
136 |
/* elemin = 9, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
137 |
/* notelemin = 10, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
138 |
/* subset = 11, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
139 |
/* _union = 12, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
140 |
/* div = 13, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
141 |
/* greater = 14, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
142 |
/* greaterequal = 15, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
143 |
/* idiv = 16, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
144 |
/* less = 17, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
145 |
/* lessequal = 18, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
146 |
/* minus = 19, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
147 |
/* mod = 20, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
148 |
/* pow = 21, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
149 |
/* prod = 22, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
150 |
/* sum = 23, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
151 |
/* _and = 24, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
152 |
/* biimplies = 25, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
153 |
/* implies = 26, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
154 |
/* _or = 27, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
155 |
/* equal = 28, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
156 |
/* notequal = 29, */ (Base::FuncPtr) &BinaryOperator::createCopy, |
|
157 |
/* seqmod_mapoverride = 30, */ (Base::FuncPtr) &abstractError, |
|
158 |
/* dom = 31, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
159 |
/* range = 32, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
160 |
/* merge = 33, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
161 |
/* card = 34, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
162 |
/* dconc = 35, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
163 |
/* dinter = 36, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
164 |
/* dunion = 37, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
165 |
/* elems = 38, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
166 |
/* head = 39, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
167 |
/* inds = 40, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
168 |
/* len = 41, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
169 |
/* tail = 42, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
170 |
/* unminus = 43, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
171 |
/* unplus = 44, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
172 |
/* _not = 45, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
173 |
/* abs = 46, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
174 |
/* forall = 47, */ (Base::FuncPtr) &ForallQuantifier::createCopy, |
|
175 |
/* exists = 48, */ (Base::FuncPtr) &ExistsQuantifier::createCopy, |
|
176 |
/* ListConstr = 49, */ (Base::FuncPtr) &ListConstructor::createCopy, |
|
177 |
/* SetConstr = 50, */ (Base::FuncPtr) &SetConstructor::createCopy, |
|
178 |
/* MapConstr = 51, */ (Base::FuncPtr) &abstractError, // ops on maps not supported |
|
179 |
/* TupleConstr = 52, */ (Base::FuncPtr) &TupleConstructor::createCopy, |
|
180 |
/* ObjectConstr = 53, */ (Base::FuncPtr) &ObjectConstructor::createCopy, |
|
181 |
/* QValConstr = 54, */ (Base::FuncPtr) &abstractError, |
|
182 |
/* Identifier = 55, */ (Base::FuncPtr) &IdentifierExpression::createCopy, |
|
183 |
/* UnresolvedIdentifier = 56, */ (Base::FuncPtr) &abstractError, |
|
184 |
/* Type = 57, */ (Base::FuncPtr) &TypeExpression::createCopy, |
|
185 |
/* TupleMapAccess = 58, */ (Base::FuncPtr) &TupleMapAccessExpression::createCopy, |
|
186 |
/* Call = 59, */ (Base::FuncPtr) &CallExpression::createCopy, |
|
187 |
/* Access = 60, */ (Base::FuncPtr) &AccessExpression::createCopy, |
|
188 |
/* Primed = 61, */ (Base::FuncPtr) &abstractError, |
|
189 |
/* Cast = 62, */ (Base::FuncPtr) &UnaryOperator::createCopy, |
|
190 |
/* foldLR = 63, */ (Base::FuncPtr) &TernaryOperator::createCopy, |
|
191 |
/* foldRL = 64, */ (Base::FuncPtr) &abstractError, |
|
192 |
/* Value_Integer = 65, */ (Base::FuncPtr) &IntValueExpression::createCopy, |
|
193 |
/* Value_Bool = 66, */ (Base::FuncPtr) &BoolValueExpression::createCopy, |
|
194 |
/* Value_Reference = 67, */ (Base::FuncPtr) &RefValueExpression::createCopy |
|
195 |
} |
|
196 |
}; |
|
197 |
|
|
198 |
|
|
199 |
Expression* Expression::createVirtual(ExpressionKind k) { |
|
200 |
return (std::uint8_t)k < EXPRESSIONKIND_NR_ITEMS ? ((ConstrPtr)s_exprVmt[0][(std::uint8_t)k])(k) : nullptr; |
|
201 |
} |
|
202 |
|
|
203 |
Expression* Expression::createVirtual(const Expression& toCopy) { |
|
204 |
std::uint8_t kind ((std::uint8_t)toCopy.kind()); |
|
205 |
return ((CopyConstrPtr)s_exprVmt[1][kind])(toCopy); |
|
206 |
} |
|
207 |
|
|
208 |
void Expression::accept(IAstVisitor& ) { |
|
209 |
throw new Base::NotImplementedException(); |
|
210 |
}; |
|
211 |
|
|
212 |
} |
trunk/compiler/cppAst/ast/expressions/Expression.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <base/TiresiasObject.hpp> |
|
29 |
#include <ast/AstElement.hpp> |
|
30 |
#include <ast/types/Type.hpp> |
|
31 |
#include <cstdint> |
|
32 |
#include <ast/Containers.hpp> |
|
33 |
#include <ast/IAstVisitor.hpp> |
|
34 |
#include <base/Exceptions.hpp> |
|
35 |
|
|
36 |
|
|
37 |
namespace Ast { |
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* You must not change the assigned values as this |
|
42 |
* needs to be kept in sync with the definitions in Argos! |
|
43 |
*/ |
|
44 |
enum class ExpressionKind : std::uint8_t |
|
45 |
{ |
|
46 |
/*tern.*/ |
|
47 |
conditional = 0, |
|
48 |
/*map binary*/ |
|
49 |
domresby = 1, domresto = 2, rngresby = 3, rngresto = 4, munion = 5, |
|
50 |
/*set/list binary*/ |
|
51 |
conc = 6, diff = 7, inter = 8, elemin = 9, notelemin = 10, subset = 11, _union = 12, |
|
52 |
/*numeric binary*/ |
|
53 |
div = 13, greater = 14, greaterequal = 15, idiv = 16, less = 17, lessequal = 18, |
|
54 |
minus = 19, mod = 20, pow = 21, prod = 22, sum = 23, |
|
55 |
/*bool binary*/ |
|
56 |
_and = 24, biimplies = 25, implies = 26, _or = 27, |
|
57 |
/*other binary*/ |
|
58 |
equal = 28, notequal = 29, seqmod_mapoverride = 30, |
|
59 |
/*map unary*/ |
|
60 |
dom = 31, range = 32, merge = 33, |
|
61 |
/*set/list unary*/ |
|
62 |
card = 34, dconc = 35, dinter = 36, dunion = 37, elems = 38, head = 39, |
|
63 |
inds = 40, len = 41, tail = 42, |
|
64 |
/*unary numberic*/ |
|
65 |
unminus = 43, unplus = 44, _not = 45, abs = 46, |
|
66 |
/*unary quantors*/ |
|
67 |
forall = 47, exists = 48, |
|
68 |
/*Constructors*/ |
|
69 |
ListConstr = 49, SetConstr = 50, MapConstr = 51, TupleConstr = 52, ObjectConstr = 53, QValConstr = 54, |
|
70 |
/* identifier */ |
|
71 |
Identifier = 55, |
|
72 |
UnresolvedIdentifier = 56, |
|
73 |
Type = 57, |
|
74 |
/* tuple access and method call */ |
|
75 |
TupleMapAccess = 58, Call = 59, |
|
76 |
/* point operator */ |
|
77 |
Access = 60, |
|
78 |
/* primed */ |
|
79 |
Primed = 61, |
|
80 |
/* cast */ |
|
81 |
Cast = 62, |
|
82 |
/* fold */ |
|
83 |
foldLR = 63, |
|
84 |
foldRL = 64, |
|
85 |
|
|
86 |
/* values */ |
|
87 |
Value_Integer = 65, |
|
88 |
Value_Bool = 66, |
|
89 |
Value_Reference = 67, |
|
90 |
|
|
91 |
EXPRESSIONKIND_LAST_ITEM = Value_Reference |
|
92 |
}; |
|
93 |
|
|
94 |
#define EXPRESSIONKIND_NR_ITEMS ((std::uint8_t)ExpressionKind::EXPRESSIONKIND_LAST_ITEM + 1) |
|
95 |
|
|
96 |
|
|
97 |
class Expression: |
|
98 |
public AstElement |
|
99 |
{ |
|
100 |
protected: |
|
101 |
typedef Expression* (*ConstrPtr)(ExpressionKind k); |
|
102 |
typedef Expression* (*CopyConstrPtr) (const Expression& toCopy); |
|
103 |
|
|
104 |
ExpressionKind m_kind; |
|
105 |
Type* m_type; |
|
106 |
std::int32_t m_line; |
|
107 |
std::int32_t m_pos; |
|
108 |
SymbolTable* m_freeVariables; |
|
109 |
FunctionIdentifierList m_callTargets; |
|
110 |
|
|
111 |
Expression(ExpressionKind kind): |
|
112 |
AstElement(AstNodeTypeEnum::expression), |
|
113 |
m_kind(kind), |
|
114 |
m_type (nullptr), |
|
115 |
m_line (-1), |
|
116 |
m_pos (-1), |
|
117 |
m_freeVariables (nullptr) |
|
118 |
{} |
|
119 |
Expression(const Expression& toCopy): |
|
120 |
AstElement(AstNodeTypeEnum::expression), |
|
121 |
m_kind (toCopy.m_kind), |
|
122 |
m_type (toCopy.m_type), |
|
123 |
m_line (toCopy.m_line), |
|
124 |
m_pos (toCopy.m_pos), |
|
125 |
m_freeVariables (toCopy.m_freeVariables) |
|
126 |
{} |
|
127 |
~Expression() |
|
128 |
{} |
|
129 |
|
|
130 |
static Base::FuncPtr s_exprVmt [2][EXPRESSIONKIND_NR_ITEMS]; |
|
131 |
static Expression* createVirtual(ExpressionKind k); |
|
132 |
static Expression* createVirtual(const Expression& toCopy); |
|
133 |
public: |
|
134 |
friend class Ast; |
|
135 |
|
|
136 |
void init( |
|
137 |
std::int32_t line, |
|
138 |
std::int32_t pos, |
|
139 |
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, |
|
140 |
SymbolTable* symbTabRef) |
|
141 |
{ |
|
142 |
m_line = line; |
|
143 |
m_pos = pos; |
|
144 |
m_type = typeRef; |
|
145 |
m_callTargets.clear(); |
|
146 |
if (callTargetsIdentifierListRef != nullptr) { |
|
147 |
for (auto& id: *callTargetsIdentifierListRef) { |
|
148 |
IdentifierKind kind = id->kind(); |
|
149 |
if (kind != IdentifierKind::MethodIdentifier && |
|
150 |
kind != IdentifierKind::NamedActionIdentifier) |
|
151 |
{ |
|
152 |
throw new Base::InvalidArgumentException("Calltargets must be methods or actions."); |
|
153 |
} |
|
154 |
m_callTargets.push_back((FunctionIdentifier*)id); |
|
155 |
} |
|
156 |
} |
|
157 |
m_freeVariables = symbTabRef; |
|
158 |
} |
|
159 |
|
|
160 |
|
|
161 |
ExpressionKind kind() const { return m_kind; }; |
|
162 |
Type* type() const { return m_type; }; |
|
163 |
std::int32_t line() const { return m_line; }; |
|
164 |
std::int32_t pos() const { return m_pos; }; |
|
165 |
SymbolTable* freeVariables() { return m_freeVariables; }; |
|
166 |
FunctionIdentifierList& callTargets() { return m_callTargets; }; |
|
167 |
|
|
168 |
void accept(IAstVisitor& visitor) override; |
|
169 |
}; |
|
170 |
|
|
171 |
} |
trunk/compiler/cppAst/ast/expressions/ForallQuantifier.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/Quantifier.hpp> |
|
29 |
#include <ast/IAstVisitor.hpp> |
|
30 |
|
|
31 |
namespace Ast { |
|
32 |
|
|
33 |
class ForallQuantifier final |
|
34 |
: public Quantifier |
|
35 |
{ |
|
36 |
protected: |
|
37 |
ForallQuantifier(): |
|
38 |
Quantifier(ExpressionKind::forall) |
|
39 |
{}; |
|
40 |
ForallQuantifier(const ForallQuantifier& toCopy): |
|
41 |
Quantifier(toCopy) |
|
42 |
{}; |
|
43 |
|
|
44 |
static ForallQuantifier* create(ExpressionKind) {return new ForallQuantifier();}; |
|
45 |
static ForallQuantifier* createCopy(const ForallQuantifier& toCopy) {return new ForallQuantifier(toCopy);}; |
|
46 |
public: |
|
47 |
friend class Ast; |
|
48 |
friend class Expression; |
|
49 |
|
|
50 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
|
51 |
}; |
|
52 |
} |
trunk/compiler/cppAst/ast/expressions/IdentifierExpression.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/LeafExpression.hpp> |
|
29 |
#include <ast/identifiers/Identifier.hpp> |
|
30 |
|
|
31 |
namespace Ast { |
|
32 |
|
|
33 |
class IdentifierExpression |
|
34 |
: public LeafExpression |
|
35 |
{ |
|
36 |
protected: |
|
37 |
bool m_self; |
|
38 |
Identifier* m_identifier; |
|
39 |
|
|
40 |
IdentifierExpression(): |
|
41 |
LeafExpression(LeafTypeEnum::identifier, ExpressionKind::Identifier), |
|
42 |
m_self (false), |
|
43 |
m_identifier (nullptr) |
|
44 |
{}; |
|
45 |
IdentifierExpression(const IdentifierExpression &toCopy): |
|
46 |
LeafExpression(toCopy), |
|
47 |
m_self (toCopy.m_self), |
|
48 |
m_identifier (toCopy.m_identifier) |
|
49 |
{}; |
|
50 |
|
|
51 |
static IdentifierExpression* create(ExpressionKind){return new IdentifierExpression();} |
|
52 |
static IdentifierExpression* createCopy(const IdentifierExpression& toCopy) {return new IdentifierExpression(toCopy);} |
|
53 |
public: |
|
54 |
friend class Ast; |
|
55 |
friend class Expression; |
|
56 |
|
|
57 |
void init(std::int32_t line, std::int32_t pos, |
|
58 |
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, |
|
59 |
SymbolTable* symbTabRef, Identifier* identifierRef, bool isSelf) |
|
60 |
{ |
|
61 |
LeafExpression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef); |
|
62 |
m_identifier = identifierRef; |
|
63 |
m_self = isSelf; |
|
64 |
} |
|
65 |
|
|
66 |
Identifier* identifier() {return m_identifier;}; |
|
67 |
bool isSelf() const {return m_self;}; |
|
68 |
void setIsSelf(bool newValue) {m_self = newValue;}; |
|
69 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
|
70 |
void setIdentifier(Identifier* newIdentifier) {m_identifier = newIdentifier;}; |
|
71 |
}; |
|
72 |
} |
trunk/compiler/cppAst/ast/expressions/LeafExpression.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/Expression.hpp> |
|
29 |
|
|
30 |
namespace Ast { |
|
31 |
|
|
32 |
enum class LeafTypeEnum { |
|
33 |
unset = 0, |
|
34 |
_bool = 1, |
|
35 |
integer = 2, |
|
36 |
real = 3, |
|
37 |
chr = 4, |
|
38 |
qval = 5, |
|
39 |
reference = 6, |
|
40 |
identifier = 7, |
|
41 |
type = 8, |
|
42 |
complex = 9 |
|
43 |
}; |
|
44 |
|
|
45 |
class LeafExpression |
|
46 |
: public Expression |
|
47 |
{ |
|
48 |
protected: |
|
49 |
LeafTypeEnum m_valueType; |
|
50 |
|
|
51 |
LeafExpression(LeafTypeEnum lt, ExpressionKind kind): |
|
52 |
Expression(kind), |
|
53 |
m_valueType (lt) |
|
54 |
{}; |
|
55 |
LeafExpression(const LeafExpression &toCopy): |
|
56 |
Expression(toCopy), |
|
57 |
m_valueType (toCopy.m_valueType) |
|
58 |
{}; |
|
59 |
public: |
|
60 |
~LeafExpression() override {}; |
|
61 |
|
|
62 |
LeafTypeEnum valueType() const {return m_valueType;}; |
|
63 |
}; |
|
64 |
} |
trunk/compiler/cppAst/ast/expressions/ListConstructor.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/TypeConstructionExpression.hpp> |
|
29 |
#include <ast/IScope.hpp> |
|
30 |
#include <deque> |
|
31 |
#include <ast/SymbolTable.hpp> |
|
32 |
#include <base/Exceptions.hpp> |
|
33 |
#include <string> |
|
34 |
#include <ast/IAstVisitor.hpp> |
|
35 |
|
|
36 |
namespace Ast { |
|
37 |
|
|
38 |
class ListConstructor final |
|
39 |
: public TypeConstructionExpression |
|
40 |
, public IScope |
|
41 |
{ |
|
42 |
protected: |
|
43 |
ExpressionList m_elements; |
|
44 |
IScope* m_parentScope; |
|
45 |
SymbolTable* m_comprehensionVars; |
|
46 |
Expression* m_comprehension; |
|
47 |
bool m_hasComprehension; |
|
48 |
|
|
49 |
ListConstructor(): |
|
50 |
TypeConstructionExpression(ExpressionKind::ListConstr), |
|
51 |
m_elements(), |
|
52 |
m_parentScope(nullptr), |
|
53 |
m_comprehensionVars(nullptr), |
|
54 |
m_comprehension(nullptr), |
|
55 |
m_hasComprehension(false) |
|
56 |
{}; |
|
57 |
ListConstructor(const ListConstructor &toCopy): |
|
58 |
TypeConstructionExpression(toCopy), |
|
59 |
m_elements(toCopy.m_elements), |
|
60 |
m_parentScope(toCopy.m_parentScope), |
|
61 |
m_comprehensionVars(toCopy.m_comprehensionVars), |
|
62 |
m_comprehension(toCopy.m_comprehension), |
|
63 |
m_hasComprehension(toCopy.m_hasComprehension) |
|
64 |
{}; |
|
65 |
|
|
66 |
static ListConstructor* create(ExpressionKind){return new ListConstructor();} |
|
67 |
static ListConstructor* createCopy(const ListConstructor& toCopy){return new ListConstructor(toCopy);} |
|
68 |
public: |
|
69 |
friend class Ast; |
|
70 |
friend class Expression; |
|
71 |
|
|
72 |
void init(std::int32_t line, std::int32_t pos, |
|
73 |
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef, |
|
74 |
ExpressionList* exprList, SymbolTable *symTab, IScope* parentScope, |
|
75 |
Expression* comprehension, bool hasComprehension) |
|
76 |
{ |
|
77 |
TypeConstructionExpression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef); |
|
78 |
m_elements = std::move(*exprList); |
|
79 |
m_parentScope = parentScope; |
|
80 |
m_comprehensionVars = symTab; |
|
81 |
m_comprehension = comprehension; |
|
82 |
m_hasComprehension = hasComprehension; |
|
83 |
} |
|
84 |
|
|
85 |
|
|
86 |
ExpressionList& elements() {return m_elements;}; |
|
87 |
Expression* comprehension() {return m_comprehension;}; |
|
88 |
bool hasComprehension() {return m_hasComprehension;}; |
|
89 |
SymbolTable* comprehensionVariables() {return m_comprehensionVars;}; |
|
90 |
|
|
91 |
void addElement(Expression* anElement) {m_elements.push_back(anElement);}; |
|
92 |
void setComprehension(Expression* comprehension) {m_comprehension = comprehension;}; |
|
93 |
void setHasComprehension(bool flag) {m_hasComprehension = flag;}; |
|
94 |
|
|
95 |
Identifier* resolveIdentifier(const std::string& aName) const override { return m_comprehensionVars->get(aName); }; |
|
96 |
IScope* getParentScope() const override {return m_parentScope;}; |
|
97 |
std::string getScopeName() const override {return "";} |
|
98 |
void setParentScope(IScope* parentScope) override {m_parentScope = parentScope;}; |
|
99 |
void addIdentifier(Identifier* anIdentifier, void* ) override {m_comprehensionVars->addIdentifier(anIdentifier);}; |
|
100 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
|
101 |
// void setElements(std::deque<Expression*>& newElements) {}; |
|
102 |
|
|
103 |
IScope* asScope() final {return (IScope*) this;} |
|
104 |
}; |
|
105 |
} |
trunk/compiler/cppAst/ast/expressions/ObjectConstructor.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
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 |
/*std::int32_t*/ 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 |
} |
trunk/compiler/cppAst/ast/expressions/Quantifier.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/UnaryOperator.hpp> |
|
29 |
#include <ast/IScope.hpp> |
|
30 |
#include <ast/SymbolTable.hpp> |
|
31 |
#include <base/Exceptions.hpp> |
|
32 |
#include <string> |
|
33 |
#include <ast/identifiers/Identifier.hpp> |
|
34 |
|
|
35 |
namespace Ast { |
|
36 |
|
|
37 |
class Quantifier |
|
38 |
: public UnaryOperator |
|
39 |
, public IScope |
|
40 |
{ |
|
41 |
protected: |
|
42 |
SymbolTable* m_symbols; |
|
43 |
IScope* m_parentScope; |
|
44 |
|
|
45 |
Quantifier(ExpressionKind kind): |
|
46 |
UnaryOperator(kind), |
|
47 |
m_symbols (nullptr), |
|
48 |
m_parentScope (nullptr) |
|
49 |
{} |
|
50 |
Quantifier(const Quantifier &toCopy): |
|
51 |
UnaryOperator(toCopy), |
|
52 |
m_symbols (toCopy.m_symbols), |
|
53 |
m_parentScope (toCopy.m_parentScope) |
|
54 |
{} |
|
55 |
public: |
|
56 |
~Quantifier() override {} |
|
57 |
|
|
58 |
void init(std::int32_t line, std::int32_t pos, |
|
59 |
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef, |
|
60 |
Expression* child, SymbolTable* symTabRef, IScope* scopeRef) |
|
61 |
{ |
|
62 |
UnaryOperator::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef,child); |
|
63 |
m_symbols = symTabRef; |
|
64 |
m_parentScope = scopeRef; |
|
65 |
} |
|
66 |
|
|
67 |
SymbolTable* symbols() {return m_symbols;}; |
|
68 |
Identifier* resolveIdentifier(const std::string& aName) const override { return m_symbols->get(aName); }; |
|
69 |
IScope* getParentScope() const override {return m_parentScope;}; |
|
70 |
std::string getScopeName() const override {return "";} |
|
71 |
void setParentScope(IScope* parentScope) override {m_parentScope = parentScope;}; |
|
72 |
void addIdentifier(Identifier* anIdentifier, void* ) override {m_symbols->addIdentifier(anIdentifier);}; |
|
73 |
}; |
|
74 |
} |
trunk/compiler/cppAst/ast/expressions/SetConstructor.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/TypeConstructionExpression.hpp> |
|
29 |
#include <ast/IScope.hpp> |
|
30 |
#include <ast/expressions/Expression.hpp> |
|
31 |
#include <ast/IAstVisitor.hpp> |
|
32 |
#include <ast/SymbolTable.hpp> |
|
33 |
#include <base/Exceptions.hpp> |
|
34 |
#include <ast/identifiers/Identifier.hpp> |
|
35 |
#include <deque> |
|
36 |
|
|
37 |
namespace Ast { |
|
38 |
|
|
39 |
class SetConstructor final |
|
40 |
: public TypeConstructionExpression |
|
41 |
, public IScope |
|
42 |
{ |
|
43 |
protected: |
|
44 |
ExpressionList m_items; |
|
45 |
SymbolTable* m_comprehensionVars; |
|
46 |
IScope* m_parentScope; |
|
47 |
Expression* m_comprehension; |
|
48 |
bool m_hasComprehension; |
|
49 |
|
|
50 |
SetConstructor(): |
|
51 |
TypeConstructionExpression(ExpressionKind::SetConstr), |
|
52 |
m_items (), |
|
53 |
m_comprehensionVars (nullptr), |
|
54 |
m_parentScope (nullptr), |
|
55 |
m_comprehension (nullptr), |
|
56 |
m_hasComprehension (false) |
|
57 |
{}; |
|
58 |
SetConstructor(const SetConstructor &toCopy): |
|
59 |
TypeConstructionExpression(toCopy), |
|
60 |
m_items (toCopy.m_items), |
|
61 |
m_comprehensionVars (toCopy.m_comprehensionVars), |
|
62 |
m_parentScope (toCopy.m_parentScope), |
|
63 |
m_comprehension (toCopy.m_comprehension), |
|
64 |
m_hasComprehension (toCopy.m_hasComprehension) |
|
65 |
{}; |
|
66 |
|
|
67 |
static SetConstructor* create(ExpressionKind) {return new SetConstructor();} |
|
68 |
static SetConstructor* createCopy(const SetConstructor& toCopy) {return new SetConstructor(toCopy);} |
|
69 |
public: |
|
70 |
friend class Ast; |
|
71 |
friend class Expression; |
|
72 |
|
|
73 |
void init(std::int32_t line, std::int32_t pos, |
|
74 |
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef, |
|
75 |
ExpressionList* exprList, SymbolTable *symTab, IScope* parentScope, |
|
76 |
Expression* comprehension, bool hasComprehension) |
|
77 |
{ |
|
78 |
TypeConstructionExpression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef); |
|
79 |
m_items = std::move(*exprList); |
|
80 |
m_parentScope = parentScope; |
|
81 |
m_comprehensionVars = symTab; |
|
82 |
m_comprehension = comprehension; |
|
83 |
m_hasComprehension = hasComprehension; |
|
84 |
} |
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
ExpressionList& items() {return m_items;} |
|
89 |
Expression* comprehension() {return m_comprehension;} |
|
90 |
bool hasComprehension() const {return m_hasComprehension;}; |
|
91 |
SymbolTable* comprehensionVariables() {return m_comprehensionVars;}; |
|
92 |
|
|
93 |
void addItem(Expression* anItem) {m_items.push_back(anItem);}; |
|
94 |
void setComprehension(Expression* anExpr) {m_comprehension = anExpr;}; |
|
95 |
void setHasComprehension(bool flag) {m_hasComprehension = flag;}; |
|
96 |
Identifier* resolveIdentifier(const string& aName) const override {return m_comprehensionVars->get(aName);}; |
|
97 |
IScope* getParentScope() const override {return m_parentScope;}; |
|
98 |
std::string getScopeName() const override {return "";} |
|
99 |
void setParentScope(IScope* parentScope) override {m_parentScope = parentScope;}; |
|
100 |
void addIdentifier(Identifier* anIdentifier, void* ) override {m_comprehensionVars->addIdentifier(anIdentifier);}; |
|
101 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
|
102 |
//void setItems(ExpressionList& newItems) {m_items = newItems;}; |
|
103 |
|
|
104 |
IScope* asScope() final {return (IScope*) this;} |
|
105 |
}; |
|
106 |
|
|
107 |
} |
trunk/compiler/cppAst/ast/expressions/TernaryOperator.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/Expression.hpp> |
|
29 |
#include <ast/IScope.hpp> |
|
30 |
|
|
31 |
namespace Ast { |
|
32 |
|
|
33 |
class TernaryOperator final |
|
34 |
: public Expression |
|
35 |
{ |
|
36 |
protected: |
|
37 |
Expression* m_left; |
|
38 |
Expression* m_mid; |
|
39 |
Expression* m_right; |
|
40 |
IScope* m_definingScope; |
|
41 |
|
|
42 |
TernaryOperator(ExpressionKind kind): |
|
43 |
Expression(kind), |
|
44 |
m_left (nullptr), |
|
45 |
m_mid (nullptr), |
|
46 |
m_right(nullptr), |
|
47 |
m_definingScope (nullptr) |
|
48 |
{} |
|
49 |
TernaryOperator(const TernaryOperator& toCopy): |
|
50 |
Expression(toCopy), |
|
51 |
m_left (toCopy.m_left), |
|
52 |
m_mid (toCopy.m_mid), |
|
53 |
m_right(toCopy.m_right), |
|
54 |
m_definingScope (toCopy.m_definingScope) |
|
55 |
{} |
|
56 |
|
|
57 |
static TernaryOperator* create(ExpressionKind k){return new TernaryOperator(k);} |
|
58 |
static TernaryOperator* createCopy(const TernaryOperator& toCopy){return new TernaryOperator(toCopy);} |
|
59 |
public: |
|
60 |
friend class Ast; |
|
61 |
friend class Expression; |
|
62 |
|
|
63 |
void init(std::int32_t line, std::int32_t pos, |
|
64 |
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, |
|
65 |
SymbolTable* symbTabRef, Expression* left, Expression* mid, |
|
66 |
Expression* right, IScope* defScopeRef) |
|
67 |
{ |
|
68 |
Expression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef); |
|
69 |
m_left = left; |
|
70 |
m_mid = mid; |
|
71 |
m_right = right; |
|
72 |
m_definingScope = defScopeRef; |
|
73 |
} |
|
74 |
|
|
75 |
|
|
76 |
Expression* left() {return m_left;}; |
|
77 |
Expression* mid() {return m_mid;}; |
|
78 |
Expression* right() {return m_right;}; |
|
79 |
IScope* definingScope() {return m_definingScope;}; |
|
80 |
|
|
81 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
|
82 |
void setLeftChild(Expression* newExpression) {m_left = newExpression;}; |
|
83 |
void setMidChild(Expression* newExpression) {m_mid = newExpression;}; |
|
84 |
void setRightChild(Expression* newExpression) {m_right = newExpression;}; |
|
85 |
}; |
|
86 |
} |
trunk/compiler/cppAst/ast/expressions/TupleConstructor.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/TypeConstructionExpression.hpp> |
|
29 |
#include <ast/IAstVisitor.hpp> |
|
30 |
#include <ast/identifiers/Identifier.hpp> |
|
31 |
#include <deque> |
|
32 |
|
|
33 |
namespace Ast { |
|
34 |
|
|
35 |
class TupleConstructor final |
|
36 |
: public TypeConstructionExpression |
|
37 |
{ |
|
38 |
protected: |
|
39 |
ExpressionList m_values; |
|
40 |
Identifier* m_tupleType; |
|
41 |
bool m_matcher; |
|
42 |
|
|
43 |
TupleConstructor(): |
|
44 |
TypeConstructionExpression(ExpressionKind::TupleConstr), |
|
45 |
m_values(), |
|
46 |
m_tupleType(nullptr), |
|
47 |
m_matcher(false) |
|
48 |
{}; |
|
49 |
TupleConstructor(const TupleConstructor &toCopy): |
|
50 |
TypeConstructionExpression(toCopy), |
|
51 |
m_values(toCopy.m_values), |
|
52 |
m_tupleType(toCopy.m_tupleType), |
|
53 |
m_matcher(toCopy.m_matcher) |
|
54 |
{}; |
|
55 |
|
|
56 |
static TupleConstructor* create(ExpressionKind) {return new TupleConstructor();} |
|
57 |
static TupleConstructor* createCopy(const TupleConstructor& toCopy) {return new TupleConstructor(toCopy);} |
|
58 |
public: |
|
59 |
friend class Ast; |
|
60 |
friend class Expression; |
|
61 |
|
|
62 |
void init(std::int32_t line, std::int32_t pos, |
|
63 |
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef, |
|
64 |
ExpressionList* exprList, Identifier* tupleTypeId, bool isMatcher) |
|
65 |
{ |
|
66 |
TypeConstructionExpression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef); |
|
67 |
m_values = std::move(*exprList); |
|
68 |
m_tupleType = tupleTypeId, |
|
69 |
m_matcher = isMatcher; |
|
70 |
} |
|
71 |
|
|
72 |
ExpressionList& values() {return m_values;} |
|
73 |
Identifier* tupleType() {return m_tupleType;}; |
|
74 |
bool isMatcher() {return m_matcher;} |
|
75 |
|
|
76 |
void setIsMatcher(bool newVal) {m_matcher = newVal;}; |
|
77 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
|
78 |
//void setTupleValues(ExpressionList& values) {m_values = values;}; |
|
79 |
}; |
|
80 |
} |
trunk/compiler/cppAst/ast/expressions/TupleMapAccessExpression.hpp | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* OOAS Compiler - C++ AST |
|
4 |
* |
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology. |
|
6 |
* All rights reserved. |
|
7 |
* |
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. |
|
9 |
* |
|
10 |
* If you modify the file please update the list of contributors below to in- |
|
11 |
* clude your name. Please also stick to the coding convention of using TABs |
|
12 |
* to do the basic (block-level) indentation and spaces for anything after |
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious |
|
14 |
* what this means.) Also, remove all trailing whitespace. |
|
15 |
* |
|
16 |
* Contributors: |
|
17 |
* Willibald Krenn (AIT) |
|
18 |
* Stephan Zimmerer (AIT) |
|
19 |
* Christoph Czurda (AIT) |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#pragma once |
|
27 |
|
|
28 |
#include <ast/expressions/UnaryOperator.hpp> |
|
29 |
#include <ast/IAstVisitor.hpp> |
|
30 |
|
|
31 |
namespace Ast { |
|
32 |
|
|
33 |
class TupleMapAccessExpression final |
|
34 |
: public UnaryOperator |
|
35 |
{ |
|
36 |
protected: |
|
37 |
Expression* m_argument; |
|
38 |
|
|
39 |
TupleMapAccessExpression(): |
|
40 |
UnaryOperator(ExpressionKind::TupleMapAccess), |
|
41 |
m_argument (nullptr) |
|
42 |
{}; |
|
43 |
TupleMapAccessExpression(const TupleMapAccessExpression &toCopy): |
|
44 |
UnaryOperator(toCopy), |
|
45 |
m_argument (toCopy.m_argument) |
|
46 |
{}; |
|
47 |
|
|
48 |
static TupleMapAccessExpression* create(ExpressionKind){return new TupleMapAccessExpression();} |
|
49 |
static TupleMapAccessExpression* createCopy(const TupleMapAccessExpression& toCopy){return new TupleMapAccessExpression(toCopy);} |
|
50 |
public: |
|
51 |
friend class Ast; |
|
52 |
friend class Expression; |
|
53 |
|
|
54 |
void init(std::int32_t line, std::int32_t pos, |
|
55 |
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef, |
|
56 |
Expression* child, Expression* arg) |
|
57 |
{ |
|
58 |
UnaryOperator::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef,child); |
Also available in: Unified diff
initial import of ooasCompiler