Project

General

Profile

root / trunk / compiler / cppAst / ast / types / ListType.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 <ast/types/Type.hpp>
29
#include <cstdint>
30

    
31
namespace Ast {
32

    
33
class ListType final
34
        : public Type
35
{
36
protected:
37
        Type* m_innerType;
38
        std::uint32_t m_maxNumberOfElements;
39

    
40
        ListType():Type(TypeKind::ListType), m_innerType(nullptr), m_maxNumberOfElements(0){}
41
        ListType(const ListType& toCopy):
42
                Type(toCopy),
43
                m_innerType(toCopy.m_innerType),
44
                m_maxNumberOfElements (toCopy.m_maxNumberOfElements)
45
        {}
46

    
47
        static ListType* create() {return new ListType();}
48
        static ListType* createCopy(const ListType& toCopy) {return new ListType(toCopy);}
49
public:
50
        friend class Ast;
51
        friend class Type;
52

    
53
        void init(TypeIdentifier* identifierRef, bool anonymousType, Type* innerTypeRef,
54
                        std::uint32_t maxNumberOfElements)
55
        {
56
                Type::init(identifierRef,anonymousType);
57
                m_innerType = innerTypeRef;
58
                m_maxNumberOfElements = maxNumberOfElements;
59
        }
60

    
61
        Type* innerType() {return m_innerType;};
62
        std::uint32_t maxNumberOfElements() const {return m_maxNumberOfElements;};
63

    
64
        void setMaxNumberOfElements(std::uint32_t max) {m_maxNumberOfElements = max;};
65
        void accept(IAstVisitor& visitor) override {visitor.visit(this);};
66
        void setInnerType(Type* newType) {m_innerType = newType;};
67
};
68
}