blob: 755a0c62d24914a6841d147ce4a4b09de9369ed9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#pragma once
#include "deep.h"
#include "macros_and_utils.h"
// forwards
class Universe;
// #################################################################################################
void push_registry_subtable_mode(lua_State* L, RegistryUniqueKey key_, const char* mode_);
void push_registry_subtable(lua_State* L, RegistryUniqueKey key_);
enum class VT
{
NORMAL, // keep this one first so that it's the value we get when we default-construct
KEY,
METATABLE
};
enum class InterCopyResult
{
Success,
NotEnoughValues,
Error
};
// #################################################################################################
using CacheIndex = Unique<int>;
using SourceIndex = Unique<int>;
class InterCopyContext
{
public:
Universe* const U;
DestState const L2;
SourceState const L1;
CacheIndex const L2_cache_i;
SourceIndex L1_i; // that one can change when we reuse the context
VT vt; // that one can change when we reuse the context
LookupMode const mode;
char const* name; // that one can change when we reuse the context
private:
// for use in copy_cached_func
void copy_func() const;
void lookup_native_func() const;
// for use in inter_copy_function
void copy_cached_func() const;
[[nodiscard]] bool lookup_table() const;
// for use in inter_copy_table
void inter_copy_keyvaluepair() const;
[[nodiscard]] bool push_cached_metatable() const;
// for use in inter_copy_userdata
[[nodiscard]] bool copyclone() const;
[[nodiscard]] bool copydeep() const;
// copying a single Lua stack item
[[nodiscard]] bool inter_copy_boolean() const;
[[nodiscard]] bool inter_copy_function() const;
[[nodiscard]] bool inter_copy_lightuserdata() const;
[[nodiscard]] bool inter_copy_nil() const;
[[nodiscard]] bool inter_copy_number() const;
[[nodiscard]] bool inter_copy_string() const;
[[nodiscard]] bool inter_copy_table() const;
[[nodiscard]] bool inter_copy_userdata() const;
public:
[[nodiscard]] bool inter_copy_one() const;
[[nodiscard]] InterCopyResult inter_copy_package() const;
[[nodiscard]] InterCopyResult inter_copy(int n_) const;
[[nodiscard]] InterCopyResult inter_move(int n_) const;
};
// #################################################################################################
[[nodiscard]] int luaG_nameof(lua_State* L);
void populate_func_lookup_table(lua_State* L, int _i, char const* _name);
void initialize_allocator_function(Universe* U, lua_State* L);
// #################################################################################################
// crc64/we of string "CONFIG_REGKEY" generated at http://www.nitrxgen.net/hashgen/
static constexpr RegistryUniqueKey CONFIG_REGKEY{ 0x31CD24894EAE8624ull }; // registry key to access the configuration
// crc64/we of string "LOOKUP_REGKEY" generated at http://www.nitrxgen.net/hashgen/
static constexpr RegistryUniqueKey LOOKUP_REGKEY{ 0x5051ED67EE7B51A1ull }; // registry key to access the lookup database
|