Project

General

Profile

root / trunk / compiler / cppAst / ast / identifiers / TypeIdentifier.hpp @ 7

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 <string>
29
#include <ast/identifiers/Identifier.hpp>
30
#include <ast/types/Type.hpp>
31
#include <ast/IScope.hpp>
32

    
33
namespace Ast {
34

    
35
class TypeIdentifier
36
        : public Identifier
37
{
38
protected:
39
        string m_prefix;
40

    
41
        TypeIdentifier(IdentifierKind id):
42
                Identifier(id),
43
                m_prefix("")
44
        {}
45

    
46
        TypeIdentifier():
47
                Identifier(IdentifierKind::TypeIdentifier),
48
                m_prefix ("")
49
        {};
50

    
51
        TypeIdentifier(std::string /*name*/, Type* someType, IScope* aDefiningScope):
52
                TypeIdentifier()
53
        {
54
                m_type = someType;
55
                m_definingScope = aDefiningScope;
56
        };
57
        TypeIdentifier(const TypeIdentifier& toCopy) :
58
                Identifier(toCopy),
59
                m_prefix (toCopy.m_prefix)
60
        {};
61

    
62
        static TypeIdentifier* create() {return new TypeIdentifier();}
63
        static TypeIdentifier* createCopy(const TypeIdentifier& toCopy) {return new TypeIdentifier(toCopy);}
64
public:
65
        friend class Ast;
66
        friend class Identifier;
67

    
68
        void init(std::int32_t line, std::int32_t col, const char* text,
69
                        IScope* scopeRef, Type* typeRef, const char* prefix)
70
        {
71
                Identifier::init(line,col,text,scopeRef,typeRef);
72
                m_prefix = prefix;
73
        }
74

    
75
        void accept(IAstVisitor& visitor) override
76
        {
77
                visitor.visit(this);
78
        }
79
};
80
}