Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
thorin::Annex Struct Reference

Holds info about an entity defined within a Plugin (called Annex). More...

#include <thorin/plugin.h>

Public Member Functions

 Annex (Sym plugin, Sym tag, flags_t tag_id)
 

Static Public Member Functions

Annex Name

Anatomy of an Annex name:

%plugin.tag.sub
| 48 | 8 | 8 | <-- Number of bits per field.
static constexpr flags_t Base
Definition plugin.h:131
  • Def::name() retrieves the full name as Sym.
  • Def::flags() retrieves the full name as Axiom::mangled 64-bit integer.
static plugin_t flags2plugin (flags_t f)
 Yields the plugin part of the name as integer.
 
static tag_t flags2tag (flags_t f)
 Yields the tag part of the name as integer.
 
static sub_t flags2sub (flags_t f)
 Yields the sub part of the name as integer.
 
static flags_t flags2base (flags_t f)
 Includes Axiom::plugin() and Axiom::tag() but not Axiom::sub.
 

Public Attributes

Sym plugin
 
Sym tag
 
flags_t tag_id
 
std::deque< std::deque< Sym > > subs
 List of subs which is a list of aliases.
 
Sym normalizer
 
bool pi = false
 

Static Public Attributes

Helpers for Matching

These are set via template specialization.

template<class Id >
static constexpr size_t Num = size_t(-1)
 Number of Axiom::subtags.
 
template<class Id >
static constexpr flags_t Base = flags_t(-1)
 

Mangling Plugin Name

static constexpr size_t Max_Plugin_Size = 8
 
static constexpr plugin_t Global_Plugin = 0xffff'ffff'ffff'0000_u64
 
static std::optional< plugin_tmangle (Sym s)
 Mangles s into a dense 48-bit representation.
 
static Sym demangle (World &, plugin_t u)
 Reverts an Axiom::mangled string to a Sym.
 
static std::array< Sym, 3 > split (World &, Sym)
 

Detailed Description

Holds info about an entity defined within a Plugin (called Annex).

Definition at line 53 of file plugin.h.

Constructor & Destructor Documentation

◆ Annex()

thorin::Annex::Annex ( Sym  plugin,
Sym  tag,
flags_t  tag_id 
)
inline

Definition at line 54 of file plugin.h.

Member Function Documentation

◆ demangle()

Sym thorin::Annex::demangle ( World world,
plugin_t  u 
)
static

Reverts an Axiom::mangled string to a Sym.

Ignores lower 16-bit of u.

Definition at line 37 of file plugin.cpp.

References Base, Max_Plugin_Size, and thorin::World::sym().

Referenced by thorin::World::annex(), and thorin::World::register_annex().

◆ flags2base()

static flags_t thorin::Annex::flags2base ( flags_t  f)
inlinestatic

Includes Axiom::plugin() and Axiom::tag() but not Axiom::sub.

Definition at line 120 of file plugin.h.

References Base.

Referenced by thorin::Axiom::base().

◆ flags2plugin()

static plugin_t thorin::Annex::flags2plugin ( flags_t  f)
inlinestatic

Yields the plugin part of the name as integer.

It consists of 48 relevant bits that are returned in the highest 6 bytes of a 64-bit integer.

Definition at line 111 of file plugin.h.

References Global_Plugin.

Referenced by thorin::Axiom::plugin().

◆ flags2sub()

static sub_t thorin::Annex::flags2sub ( flags_t  f)
inlinestatic

Yields the sub part of the name as integer.

Definition at line 117 of file plugin.h.

References Base.

Referenced by thorin::Axiom::sub().

◆ flags2tag()

static tag_t thorin::Annex::flags2tag ( flags_t  f)
inlinestatic

Yields the tag part of the name as integer.

Definition at line 114 of file plugin.h.

References Base.

Referenced by thorin::Axiom::tag().

◆ mangle()

std::optional< plugin_t > thorin::Annex::mangle ( Sym  s)
static

Mangles s into a dense 48-bit representation.

The layout is as follows:

|---7--||---6--||---5--||---4--||---3--||---2--||---1--||---0--|
7654321076543210765432107654321076543210765432107654321076543210

The reserved part is used for the Axiom::tag and the Axiom::sub. Each Char6x is 6-bit wide and hence a plugin name has at most Axiom::Max_Plugin_Size = 8 chars. It uses this encoding:

Char6 ASCII
1: _
2-27: a-z
28-53: A-Z
54-63: 0-9

The 0 is special and marks the end of the name if the name has less than 8 chars.

Returns
std::nullopt if encoding is not possible.

Definition at line 9 of file plugin.cpp.

References Base, and Max_Plugin_Size.

Referenced by thorin::bootstrap(), and split().

◆ split()

std::array< Sym, 3 > thorin::Annex::split ( World world,
Sym  s 
)
static

Definition at line 58 of file plugin.cpp.

References Base, mangle(), plugin, thorin::subview(), thorin::World::sym(), and tag.

Referenced by thorin_get_plugin().

Member Data Documentation

◆ Base

◆ Global_Plugin

constexpr plugin_t thorin::Annex::Global_Plugin = 0xffff'ffff'ffff'0000_u64
staticconstexpr

Definition at line 69 of file plugin.h.

Referenced by thorin::World::axiom(), and flags2plugin().

◆ Max_Plugin_Size

constexpr size_t thorin::Annex::Max_Plugin_Size = 8
staticconstexpr

Definition at line 68 of file plugin.h.

Referenced by demangle(), and mangle().

◆ normalizer

Sym thorin::Annex::normalizer

Definition at line 63 of file plugin.h.

◆ Num

template<class Id >
constexpr size_t thorin::Annex::Num = size_t(-1)
staticconstexpr

Number of Axiom::subtags.

Definition at line 128 of file plugin.h.

◆ pi

bool thorin::Annex::pi = false

Definition at line 64 of file plugin.h.

◆ plugin

Sym thorin::Annex::plugin

Definition at line 59 of file plugin.h.

Referenced by split().

◆ subs

std::deque<std::deque<Sym> > thorin::Annex::subs

List of subs which is a list of aliases.

Definition at line 62 of file plugin.h.

◆ tag

Sym thorin::Annex::tag

Definition at line 60 of file plugin.h.

Referenced by split().

◆ tag_id

flags_t thorin::Annex::tag_id

Definition at line 61 of file plugin.h.


The documentation for this struct was generated from the following files: