Project

General

Profile

root / trunk / compiler / cppAst / ast / Containers.hpp @ 8

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
#pragma once
26

    
27
#include <ast/identifiers/ParameterIdentifier.hpp>
28
#include <ast/SymbolTable.hpp>
29
#include <base/TiresiasObject.hpp>
30
#include <ast/types/Type.hpp>
31
#include <ast/statements/Statement.hpp>
32
#include <deque>
33

    
34
namespace Ast {
35

    
36
/*
37
 * General list based on std::deque, also inherits from
38
 * TireaisObject.
39
 */
40
template<class T>
41
class TiresiasList
42
        : public std::deque<T>
43
        , public Base::TiresiasObject
44
{
45
protected:
46
        // define a default constructor
47
        TiresiasList<T>() {}
48

    
49
        // define a copy constructor that really makes a copy
50
        TiresiasList<T>(const TiresiasList<T>& toCopy) {
51
                this->insert(this->begin(), toCopy.begin(), toCopy.end());
52
        }
53

    
54
public:
55
        // define a move assignment operator that moves the lists contents
56
        TiresiasList<T>* operator= (TiresiasList<T>&& move) {
57
                this->insert(this->begin(),  std::make_move_iterator(move.begin()),  std::make_move_iterator(move.end()));
58
                return this;
59
        }
60
};
61

    
62
/*
63
 * ParameterList class.
64
 */
65
class ParameterList
66
        : public TiresiasList<ParameterIdentifier*>
67
{
68
protected:
69
        using TiresiasList<ParameterIdentifier*>::TiresiasList;
70
        friend class Ast;
71
};
72

    
73
/*
74
 * TypeList class
75
 */
76
class TypeList
77
        : public TiresiasList<Type*>
78
{
79
protected:
80
        using TiresiasList<Type*>::TiresiasList;
81
        friend class Ast;
82
};
83

    
84
/*
85
 * ExpressionList class
86
 */
87
class Expression; // forward
88

    
89
class ExpressionList
90
        : public TiresiasList<Expression*>
91
{
92
protected:
93
        using TiresiasList<Expression*>::TiresiasList;
94
        friend class Ast;
95
};
96

    
97
/*
98
 * StatementList class
99
 */
100
class StatementList
101
        : public TiresiasList<Statement*>
102
{
103
protected:
104
        using TiresiasList<Statement*>::TiresiasList;
105
        friend class Ast;
106
};
107

    
108
/*
109
 * IdentifierList class
110
 */
111
class IdentifierList
112
        : public TiresiasList<Identifier*>
113
{
114
protected:
115
        using TiresiasList<Identifier*>::TiresiasList;
116
        friend class Ast;
117
};
118

    
119

    
120
/*
121
 * FunctionIdentifierList class
122
 */
123
class FunctionIdentifier; // forward
124

    
125
class FunctionIdentifierList
126
        : public TiresiasList<FunctionIdentifier*>
127
{
128
protected:
129
        using TiresiasList<FunctionIdentifier*>::TiresiasList;
130
        friend class Ast;
131
};
132
/*
133
 * ActionSystemInstanceList class
134
 */
135

    
136
class ActionSystemInstance; // forward
137

    
138
class ActionSystemInstanceList
139
        : public TiresiasList<ActionSystemInstance*>
140
{
141
protected:
142
        using TiresiasList<ActionSystemInstance*>::TiresiasList;
143
        friend class Ast;
144
};
145

    
146

    
147
}
148

    
149
#include <ast/types/ActionSystemType.hpp>
150
#include <ast/expressions/Expression.hpp>
151
#include <ast/identifiers/FunctionIdentifier.hpp>