root / trunk / compiler / cppAst / ast / identifiers / EnumIdentifier.hpp @ 6
1 | 2 | krennw | /**
|
---|---|---|---|
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 <cstdint> |
||
28 | #include <ast/identifiers/ValueIdentifier.hpp> |
||
29 | #include <ast/IScope.hpp> |
||
30 | #include <ast/types/Type.hpp> |
||
31 | |||
32 | namespace Ast {
|
||
33 | |||
34 | class EnumIdentifier final |
||
35 | : public ValueIdentifier
|
||
36 | { |
||
37 | protected:
|
||
38 | std::int32_t m_value; |
||
39 | bool m_haveValue;
|
||
40 | |||
41 | EnumIdentifier() : |
||
42 | ValueIdentifier(IdentifierKind::EnumIdentifier), |
||
43 | m_value (-1),
|
||
44 | m_haveValue (false)
|
||
45 | {}; |
||
46 | |||
47 | EnumIdentifier(const EnumIdentifier& toCopy) :
|
||
48 | ValueIdentifier (toCopy), |
||
49 | m_value (toCopy.m_value), |
||
50 | m_haveValue (toCopy.m_haveValue) |
||
51 | {}; |
||
52 | |||
53 | static EnumIdentifier* create() {return new EnumIdentifier();} |
||
54 | static EnumIdentifier* createCopy(const EnumIdentifier& toCopy) {return new EnumIdentifier(toCopy);} |
||
55 | public:
|
||
56 | friend class Ast; |
||
57 | friend class Identifier; |
||
58 | |||
59 | std::int32_t value() const { return m_value; }; |
||
60 | bool haveValue() const { return m_haveValue; }; |
||
61 | |||
62 | void init(std::int32_t line, std::int32_t col, const char* text, |
||
63 | IScope* scopeRef, Type* typeRef, bool haveValue,
|
||
64 | std::int32_t value) |
||
65 | { |
||
66 | ValueIdentifier::init(line, col, text, scopeRef, typeRef); |
||
67 | m_value = value; |
||
68 | m_haveValue = haveValue; |
||
69 | } |
||
70 | |||
71 | void accept(IAstVisitor& visitor) override |
||
72 | { |
||
73 | visitor.visit(this);
|
||
74 | } |
||
75 | }; |
||
76 | } |