IDL compiler front-end library
Loading...
Searching...
No Matches
ValueType.h
Go to the documentation of this file.
1
2/*
3* Nirvana IDL front-end library.
4*
5* This is a part of the Nirvana project.
6*
7* Author: Igor Popov
8*
9* Copyright (c) 2021 Igor Popov.
10*
11* This program is free software; you can redistribute it and/or modify
12* it under the terms of the GNU Lesser General Public License as published by
13* the Free Software Foundation; either version 3 of the License, or
14* (at your option) any later version.
15*
16* This program is distributed in the hope that it will be useful,
17* but WITHOUT ANY WARRANTY; without even the implied warranty of
18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19* GNU General Public License for more details.
20*
21* You should have received a copy of the GNU Lesser General Public
22* License along with this library. If not, see <http://www.gnu.org/licenses/>.
23*
24* Send comments and/or bug reports to:
25* popov.nirvana@gmail.com
26*/
27#ifndef IDLFE_AST_VALUETYPE_H_
28#define IDLFE_AST_VALUETYPE_H_
29#pragma once
30
31#include "Interface.h"
32#include "Type.h"
33
34namespace AST {
35
36class ValueType;
37
39typedef std::vector <const ValueType*> ValueTypes;
40
59class ValueType :
60 public IV_Base
61{
62public:
64 enum class Modifier
65 {
66 NONE,
67 CUSTOM,
68 ABSTRACT,
70 };
71
73 Modifier modifier () const noexcept
74 {
75 return modifier_;
76 }
77
79 const ValueTypes& bases () const noexcept
80 {
81 return bases_;
82 }
83
85 const Interfaces& supports () const noexcept
86 {
87 return supports_;
88 }
89
90private:
91 template <class T> friend class Ptr;
92
94 IV_Base (Item::Kind::VALUE_TYPE, builder, name),
95 modifier_ (modifier)
96 {}
97
98 friend class Builder;
99
100 const char* modifier_name () const noexcept;
101
102 void set_truncatable ()
103 {
104 assert (modifier_ == Modifier::NONE);
105 modifier_ = Modifier::TRUNCATABLE;
106 }
107
108 void add_base (const ValueType& vt)
109 {
110 bases_.push_back (&vt);
111 }
112
113 void add_supports (const Interface& itf)
114 {
115 supports_.push_back (&itf);
116 }
117
118 void get_all_interfaces (IV_Bases& all) const;
119
120private:
121 Modifier modifier_;
122 ValueTypes bases_;
123 Interfaces supports_;
124};
125
131 public ItemWithId
132{
133public:
135 bool is_abstract () const noexcept
136 {
137 return is_abstract_;
138 }
139
140private:
141 template <class T> friend class Ptr;
142
143 ValueTypeDecl (Builder& builder, const SimpleDeclarator& name, bool abstr) :
145 is_abstract_ (abstr)
146 {}
147
148private:
149 bool is_abstract_;
150};
151
152}
153
154#endif
The AST builder.
Definition Builder.h:60
The common base for Interface and ValueType.
Definition IV_Base.h:42
An AST item.
Definition Item.h:41
Kind
The kind of item.
Definition Item.h:45
@ VALUE_TYPE
class ValueType
@ VALUE_TYPE_DECL
class ValueTypeDecl
Items which have repository identifiers derive from this class.
Definition ItemWithId.h:42
const Identifier & name() const noexcept
Definition NamedItem.h:48
AST item smart pointer.
Definition Item.h:134
The IDL simple declarator.
Definition Declarators.h:41
Value type forward declaration.
Definition ValueType.h:132
bool is_abstract() const noexcept
Definition ValueType.h:135
Value type definition.
Definition ValueType.h:61
const ValueTypes & bases() const noexcept
Definition ValueType.h:79
Modifier modifier() const noexcept
Definition ValueType.h:73
Modifier
Value type modifier.
Definition ValueType.h:65
const Interfaces & supports() const noexcept
Definition ValueType.h:85
Abstract Syntax Tree namespace.
Definition Array.h:34
std::vector< const Interface * > Interfaces
The sequence of interfaces.
Definition Interface.h:73
std::vector< const ValueType * > ValueTypes
The sequence of value types.
Definition ValueType.h:39