Project

General

Profile

root / trunk / compiler / cppAst / ast / identifiers / AttributeIdentifier.hpp @ 4

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
26
#pragma once
27
28
#include <ast/identifiers/ValueReferenceIdentifier.hpp>
29
#include <ast/expressions/Expression.hpp>
30
31
namespace Ast {
32
33
class AttributeIdentifier final
34
        : public ValueReferenceIdentifier
35
{
36
protected:
37
        bool m_isStatic;
38
        bool m_isObservable;
39
        bool m_isControllable;
40
        Expression* m_initializer;
41
42
        AttributeIdentifier():
43
                ValueReferenceIdentifier(IdentifierKind::AttributeIdentifier),
44
                m_isStatic    (false),
45
                m_isObservable (false),
46
                m_isControllable (false),
47
                m_initializer (nullptr)
48
        {}
49
50
        AttributeIdentifier(const AttributeIdentifier& toCopy) :
51
                ValueReferenceIdentifier(toCopy),
52
                m_isStatic    (toCopy.m_isStatic),
53
                m_isObservable (toCopy.m_isObservable),
54
                m_isControllable (toCopy.m_isControllable),
55
                m_initializer (toCopy.m_initializer)
56
        {}
57
58
        static AttributeIdentifier* create() {return new AttributeIdentifier();}
59
        static AttributeIdentifier* createCopy(const AttributeIdentifier& toCopy) {return new AttributeIdentifier(toCopy);}
60
public:
61
        friend class Ast;
62
        friend class Identifier;
63
64
        void init (std::int32_t line, std::int32_t col, const char* text,
65
                        IScope* scopeRef, Type* typeRef, Expression* initRef,
66
                        bool isStatic, bool isControllable, bool isObservable)
67
        {
68
                ValueReferenceIdentifier::init(line,col,text,scopeRef,typeRef);
69
                m_initializer = initRef;
70
                m_isStatic = isStatic;
71
                m_isControllable = isControllable;
72
                m_isObservable = isObservable;
73
        }
74
75
        Expression* initializer() const { return m_initializer; };
76
        bool isStatic() const { return m_isStatic; };
77
        bool isObservable() const { return m_isObservable; };
78
        bool isControllable() const { return m_isControllable; };
79
80
        void accept(IAstVisitor& visitor) override { visitor.visit(this); };
81
        void setInitializer(Expression* newExpr) { m_initializer = newExpr; };
82
};
83
84
}