1 //===-- ScriptInterpreterLua.h ----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_Lua_h_
10 #define liblldb_Lua_h_
11 
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/Support/Error.h"
14 
15 #include "lua.hpp"
16 
17 namespace lldb_private {
18 
19 extern "C" {
20 int luaopen_lldb(lua_State *L);
21 }
22 
23 class Lua {
24 public:
25   Lua() : m_lua_state(luaL_newstate()) {
26     assert(m_lua_state);
27     luaL_openlibs(m_lua_state);
28     luaopen_lldb(m_lua_state);
29   }
30 
31   ~Lua() {
32     assert(m_lua_state);
33     luaL_openlibs(m_lua_state);
34   }
35 
36   llvm::Error Run(llvm::StringRef buffer);
37 
38 private:
39   lua_State *m_lua_state;
40 };
41 
42 } // namespace lldb_private
43 
44 #endif // liblldb_Lua_h_
45