root / trunk / compiler / cppAst / ast / AstElement.hpp @ 5
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 <base/TiresiasObject.hpp> |
28 |
#include <ast/Ast.hpp> // pull in Ast |
29 |
#include <ast/IAstVisitor.hpp> |
30 |
#include <ast/IScope.hpp> |
31 |
#include <ast/AstAnnotation.hpp> |
32 |
|
33 |
namespace Ast {
|
34 |
|
35 |
enum class AstNodeTypeEnum : std::uint8_t { |
36 |
type, |
37 |
identifier, |
38 |
expression, |
39 |
statement |
40 |
}; |
41 |
|
42 |
class AstElement: |
43 |
public Base::TiresiasObject
|
44 |
{ |
45 |
protected:
|
46 |
const AstNodeTypeEnum m_astNodeType; // byte @ +1 byte |
47 |
AstAnnotation* m_astAnnotation; |
48 |
|
49 |
protected:
|
50 |
AstElement(AstNodeTypeEnum nodeType): |
51 |
Base::TiresiasObject(), |
52 |
m_astNodeType(nodeType), |
53 |
m_astAnnotation(nullptr)
|
54 |
{} |
55 |
|
56 |
public:
|
57 |
~AstElement(){ |
58 |
delete m_astAnnotation;
|
59 |
}; |
60 |
|
61 |
|
62 |
// AstElement* Ast::internalCreate(std::uint8_t typeId) {
|
63 |
// AstElement* result = ((create)static_astVTable[0][typeId])();
|
64 |
// m_allocatedAstObjects.push_back(result);
|
65 |
// return result;
|
66 |
// }
|
67 |
|
68 |
AstAnnotation* getAnnotation() {return m_astAnnotation;}
|
69 |
void setAnnotation(AstAnnotation* annotation) {m_astAnnotation = annotation;}
|
70 |
|
71 |
AstNodeTypeEnum nodeType() const {return m_astNodeType;}; |
72 |
|
73 |
virtual IScope* asScope(){return nullptr;} |
74 |
virtual void accept(IAstVisitor& visitor) = 0; |
75 |
}; |
76 |
|
77 |
} |