Leonardus
Loading...
Searching...
No Matches
registry.h
Go to the documentation of this file.
1
17#pragma once
18
19// Inc Library
20#include <vector>
21#include <string>
22#include <string_view>
23#include <utility>
24#include <unordered_map>
25#include <cstdint>
26
27// Inc Pure
28#include "dbc.h"
29#include "helper.h"
30
31
36class Registry {
37
38public:
39
41 enum class CCIntention : std::uint8_t {
43 LeoDict,
44 Loop,
45 Odo,
47 };
48
49private:
50
53 std::string_view name_;
55 size_t stackusage_;
56 };
57
58
60 static const std::unordered_map< core_t *, CoreCodeMetadata > coreCodeTable_;
61
62public:
63
64#ifndef DBC_IS_VOID
69 [[gnu::const]] static bool lookUp( core_t * p_core ) {
70 return coreCodeTable_.find( p_core ) != coreCodeTable_.end();
71 }
72#endif
73
74
81 static std::string_view lookUpName( core_t * p_core );
82
83
90 static size_t lookUpStackusage( core_t * p_core );
91
92
98 static core_t * lookUpCoreCode( std::string_view p_name );
99
100
105 static std::vector<std::pair<std::string_view, core_t *>> getPopulate( CCIntention p_int );
106
107};
Central registry for all core code entries.
Definition registry.h:36
static const std::unordered_map< core_t *, CoreCodeMetadata > coreCodeTable_
Table of all core code entries.
Definition registry.h:69
static std::vector< std::pair< std::string_view, core_t * > > getPopulate(CCIntention p_int)
Assembles a vector with all core code entries of a specific intention.
Definition registry.cpp:34
static std::string_view lookUpName(core_t *p_core)
Finds the name of a core code.
Definition registry.cpp:46
CCIntention
Intention of a core code entry.
Definition registry.h:41
@ LeoDict
Registered in leodict.
@ Loop
Unregistered auxiliary loop operators (e.g., __for_up_continue).
@ Odo
Unregistered optimization operators (for bind).
@ SystemDict
Registered in systemdict.
@ Compatibility
Unregistered operators for PostScript/Forth compatibility.
static core_t * lookUpCoreCode(std::string_view p_name)
Finds the core code for a name.
Definition registry.cpp:61
static size_t lookUpStackusage(core_t *p_core)
Finds the stackusage of a core code.
Definition registry.cpp:53
static bool lookUp(core_t *p_core)
Checks if core code is in the static table.
Definition registry.h:69
Helpers for design by contract idioms.
Miscellaneous definitions and functions.
void(Context &) core_t
A shortcut for the core code function type.
Definition helper.h:82
Internal representation of a core code entry.
Definition registry.h:52
size_t stackusage_
Number of arguments needed on the exec stack.
Definition registry.h:55
std::string_view name_
Name of the core code.
Definition registry.h:53
CCIntention intention_
Intention of the core code.
Definition registry.h:54