MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::Annex Struct Reference

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

#include <mim/plugin.h>

Public Member Functions

 Annex ()=delete
 

Static Public Member Functions

Annex Name

Anatomy of an Annex name:

%plugin.tag.sub
| 48 | 8 | 8 | <-- Number of bits per field.
  • 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)
 
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.
 

Static Public Attributes

Helpers for Matching

These are set via template specialization.

template<class Id >
static constexpr size_t Num = size_t(-1)
 
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 plugin)
 Mangles s into a dense 48-bit representation.
 
static Sym demangle (Driver &, plugin_t plugin)
 Reverts an Axiom::mangled string to a Sym.
 
static std::tuple< Sym, Sym, Sym > split (Driver &, Sym)
 

Detailed Description

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

Definition at line 52 of file plugin.h.

Constructor & Destructor Documentation

◆ Annex()

mim::Annex::Annex ( )
delete

Member Function Documentation

◆ demangle()

Sym mim::Annex::demangle ( Driver & driver,
plugin_t plugin )
static

Reverts an Axiom::mangled string to a Sym.

Ignores lower 16-bit of u.

Definition at line 37 of file plugin.cpp.

References Max_Plugin_Size.

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

◆ flags2base()

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

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

Definition at line 108 of file plugin.h.

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

◆ flags2plugin()

static plugin_t mim::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 99 of file plugin.h.

References Global_Plugin.

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

◆ flags2sub()

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

Yields the sub part of the name as integer.

Definition at line 105 of file plugin.h.

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

◆ flags2tag()

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

Yields the tag part of the name as integer.

Definition at line 102 of file plugin.h.

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

◆ mangle()

std::optional< plugin_t > mim::Annex::mangle ( Sym plugin)
static

Mangles s into a dense 48-bit representation.

The layout is as follows:

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

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 Max_Plugin_Size.

Referenced by mim::ast::AnnexInfo::AnnexInfo(), mim::ast::AST::bootstrap(), mim::ast::AST::name2annex(), and split().

◆ split()

std::tuple< Sym, Sym, Sym > mim::Annex::split ( Driver & driver,
Sym s )
static

Definition at line 58 of file plugin.cpp.

References mangle(), and mim::subview().

Referenced by mim_get_plugin(), and mim::ast::AST::name2annex().

Member Data Documentation

◆ Base

◆ Global_Plugin

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

Definition at line 58 of file plugin.h.

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

◆ Max_Plugin_Size

size_t mim::Annex::Max_Plugin_Size = 8
staticconstexpr

Definition at line 57 of file plugin.h.

Referenced by demangle(), and mangle().

◆ Num

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

Number of Axiom::subtags.

Definition at line 115 of file plugin.h.


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