IDL compiler front-end library
Loading...
Searching...
No Matches
Constant.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_CONSTANT_H_
28#define IDLFE_AST_CONSTANT_H_
29#pragma once
30
31#include "NamedItem.h"
32#include "Type.h"
33#include "Variant.h"
34
35namespace AST {
36
41class Constant :
42 public NamedItem,
43 public Type,
44 public Variant
45{
46private:
47 template <class T> friend class Ptr;
48
49 Constant (Builder& builder, Type&& type, const SimpleDeclarator& name, Variant&& val) :
51 Type (std::move (type)),
52 Variant (val.vtype () == Variant::VT::FIXED ? Variant (Fixed::normalize (val.as_Fixed ())) : std::move (val))
53 {}
54
55 Constant (Builder& builder, Type&& type, const SimpleDeclarator& name) :
57 Type (std::move (type))
58 {}
59
60};
61
62}
63
64#endif
The AST builder.
Definition Builder.h:60
const definition.
Definition Constant.h:45
@ CONSTANT
class Constant
A named AST item.
Definition NamedItem.h:45
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
An IDL type.
Definition Type.h:47
Type()
Default constructor.
Definition Type.h:145
Stores the constant value.
Definition Variant.h:42
@ FIXED
Variant::as_Fixed ();.
Variant()
VT::EMPTY.
Definition Variant.h:252
Abstract Syntax Tree namespace.
Definition Array.h:34