/////////////////////////////////////////////////////////////////////////////
//
// LUASNAP
//
// A lua interpreter that can be checkpointed (snapshotted). This makes it
// possible to roll the entire interpreter back to a previously-snapshotted
// state.
//
// To accomplish this, we use eris serialization.  This is messy and not
// very modular, but it does work.
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "streambuffer.hpp"
#include "luastack.hpp"

class LuaSnap : public eng::nevernew {
private:
    lua_State *state_;
    
public:
    LuaSnap();
    ~LuaSnap();

    // Get the lua intepreter.
    //
    lua_State *state() const { return state_; }

    // Serialize the state of the lua interpreter.
    //
    void serialize(StreamBuffer *sb);
    
    // Restore the the lua interpreter given a serialized state.
    //
    void deserialize(StreamBuffer *sb);
};
