MimIR
MimIR is my Intermediate Representation
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
7namespace mim {
8
9/// Single%ton type formation.
10class Single : public Def, public Setters<Single> {
11private:
12 Single(const Def* type, const Def* op)
13 : Def(Node, type, {op}, 0) {}
14
15public:
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
26private:
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.
32class Wrap : public Def, public Setters<Wrap> {
33private:
34 Wrap(const Def* type, const Def* op)
35 : Def(Node, type, {op}, 0) {}
36
37public:
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
48private:
49 friend class World;
50};
51
52} // namespace mim
Def * set(size_t i, const Def *)
Successively set from left to right.
Definition def.cpp:188
const Def * op(size_t i) const noexcept
Definition def.h:377
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
Definition def.h:1119
CRTP-based mixin to declare setters for Def::loc & Def::name using a covariant return type.
Definition def.h:220
const Def * op() const
Definition single.h:20
static constexpr auto Node
Definition single.h:23
friend class World
Definition single.h:27
static constexpr size_t Num_Ops
Definition single.h:24
const Def * op() const
Definition single.h:42
static constexpr size_t Num_Ops
Definition single.h:46
friend class World
Definition single.h:49
static constexpr auto Node
Definition single.h:45
Definition ast.h:16
@ Single
Definition def.h:125
@ Wrap
Definition def.h:125