diff --git a/src/luerl.erl b/src/luerl.erl index a90dfc1..ee04c49 100644 --- a/src/luerl.erl +++ b/src/luerl.erl @@ -46,6 +46,9 @@ %% Helping with storing VM state -export([externalize/1,internalize/1]). +%% Storing and retrieving private data +-export([put_private/3,get_private/2]). + %% init() -> State. init() -> @@ -506,3 +509,10 @@ externalize(S) -> internalize(S) -> luerl_lib_math:internalize(S). + +put_private(Key, Value, S) -> + Private = maps:put(Key, Value, S#luerl.private), + S#luerl{private=Private}. + +get_private(Key, S) -> + maps:get(Key, S#luerl.private). diff --git a/src/luerl.hrl b/src/luerl.hrl index 21ce276..824dcac 100644 --- a/src/luerl.hrl +++ b/src/luerl.hrl @@ -34,7 +34,8 @@ rand, %Random state tag, %Unique tag trace_func=none, %Trace function - trace_data %Trace data + trace_data, %Trace data + private=#{} }). %% Table structure.