MimIR
0.5-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
single.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <span>
4
5
#include "
mim/def.h
"
6
7
namespace
mim
{
8
9
/// Single%ton type formation.
10
class
Single :
public
Def,
public
Setters
<Single> {
11
private
:
12
Single(
const
Def*
type
,
const
Def*
op
)
13
: Def(
Node
,
type
, {
op
}, 0) {}
14
15
public
:
16
using
Setters
<Single>
::set
;
17
18
/// @name ops
19
///@{
20
const
Def*
op
()
const
{
return
Def::op
(0); }
21
///@}
22
23
static
constexpr
auto
Node
=
mim::Node::Single
;
24
static
constexpr
size_t
Num_Ops
= 1;
25
26
private
:
27
friend
class
World
;
28
};
29
30
/// Single%ton term introduction.
31
/// @note We never build a singleton term elimination as World::unwrap immediately normalizes to Single::op.
32
class
Wrap :
public
Def,
public
Setters
<Wrap> {
33
private
:
34
Wrap(
const
Def*
type
,
const
Def*
op
)
35
: Def(
Node
,
type
, {
op
}, 0) {}
36
37
public
:
38
using
Setters
<Wrap>
::set
;
39
40
/// @name ops
41
///@{
42
const
Def*
op
()
const
{
return
Def::op
(0); }
43
///@}
44
45
static
constexpr
auto
Node
=
mim::Node::Wrap
;
46
static
constexpr
size_t
Num_Ops
= 1;
47
48
private
:
49
friend
class
World
;
50
};
51
52
}
// namespace mim
mim::Def::set
Def * set(size_t i, const Def *)
Successively set from left to right.
Definition
def.cpp:188
mim::Def::op
const Def * op(size_t i) const noexcept
Definition
def.h:377
mim::Def::type
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
Definition
def.h:1119
mim::Setters
CRTP-based mixin to declare setters for Def::loc & Def::name using a covariant return type.
Definition
def.h:220
mim::Single::op
const Def * op() const
Definition
single.h:20
mim::Single::Node
static constexpr auto Node
Definition
single.h:23
mim::Single::World
friend class World
Definition
single.h:27
mim::Single::Num_Ops
static constexpr size_t Num_Ops
Definition
single.h:24
mim::Wrap::op
const Def * op() const
Definition
single.h:42
mim::Wrap::Num_Ops
static constexpr size_t Num_Ops
Definition
single.h:46
mim::Wrap::World
friend class World
Definition
single.h:49
mim::Wrap::Node
static constexpr auto Node
Definition
single.h:45
def.h
mim
Definition
ast.h:16
mim::Node::Single
@ Single
Definition
def.h:125
mim::Node::Wrap
@ Wrap
Definition
def.h:125
include
mim
single.h
Generated by
1.18.0