Browse Source

Merge gcc-lua

Peter Colberg 7 months ago
parent
commit
29a39f65ae
3 changed files with 12 additions and 4 deletions
  1. 1
    1
      gcc-lua/doc/index.html
  2. 1
    1
      gcc-lua/doc/index.mdwn
  3. 10
    2
      gcc-lua/gcc/gcclua.c

+ 1
- 1
gcc-lua/doc/index.html View File

@@ -22,7 +22,7 @@
22 22
 </div>
23 23
 <div class="body">
24 24
 <h1>About the Lua plugin for the GNU Compiler Collection</h1>
25
-<p><a href="http://colberg.org/gcc-lua/"><img src="gcc-lua.png" title="Lua plugin for GCC" /></a> The <a href="http://colberg.org/gcc-lua/">Lua plugin for GCC</a> extends the <a href="http://gcc.gnu.org/">GNU Compiler Collection</a> with the ability to run Lua scripts. The plugin provides an interface to register callback functions for plugin events, and inspect the abstract syntax tree of a translation unit. The plugin is useful for static C code analysis. The Lua plugin for GCC supports GCC 4.5 to 7 and <a href="http://www.lua.org/">Lua</a> 5.1 or 5.2 or 5.3 or <a href="http://luajit.org/">LuaJIT</a>.</p>
25
+<p><a href="http://colberg.org/gcc-lua/"><img src="gcc-lua.png" title="Lua plugin for GCC" /></a> The <a href="http://colberg.org/gcc-lua/">Lua plugin for GCC</a> extends the <a href="http://gcc.gnu.org/">GNU Compiler Collection</a> with the ability to run Lua scripts. The plugin provides an interface to register callback functions for plugin events, and inspect the abstract syntax tree of a translation unit. The plugin is useful for static C code analysis. The Lua plugin for GCC supports GCC 4.5 to 8 and <a href="http://www.lua.org/">Lua</a> 5.1 or 5.2 or 5.3 or <a href="http://luajit.org/">LuaJIT</a>.</p>
26 26
 <h2 id="acknowledgements">Acknowledgements</h2>
27 27
 <p>I would like to thank David Malcolm, author of the <a href="http://gcc-python-plugin.readthedocs.org">GCC Python plugin</a>, whose code and documentation was of invaluable aid in comprehending the GCC internal API.</p>
28 28
 </div>

+ 1
- 1
gcc-lua/doc/index.mdwn View File

@@ -7,7 +7,7 @@ The [Lua plugin for GCC] extends the [GNU Compiler Collection] with the ability
7 7
 to run Lua scripts. The plugin provides an interface to register callback
8 8
 functions for plugin events, and inspect the abstract syntax tree of a
9 9
 translation unit. The plugin is useful for static C code analysis. The Lua
10
-plugin for GCC supports GCC 4.5 to 7 and [Lua] 5.1 or 5.2 or 5.3 or [LuaJIT].
10
+plugin for GCC supports GCC 4.5 to 8 and [Lua] 5.1 or 5.2 or 5.3 or [LuaJIT].
11 11
 
12 12
 [Lua plugin for GCC]: http://colberg.org/gcc-lua/
13 13
 [GNU Compiler Collection]: http://gcc.gnu.org/

+ 10
- 2
gcc-lua/gcc/gcclua.c View File

@@ -59,11 +59,15 @@ extern "C" {
59 59
 #define TYPE_UNNAMED_P TYPE_ANONYMOUS_P
60 60
 #endif
61 61
 
62
+#if GCCPLUGIN_VERSION < 8000
63
+#define get_namespace_binding namespace_binding
64
+#endif
65
+
62 66
 /* http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses */
63 67
 int plugin_is_GPL_compatible;
64 68
 
65 69
 /* weak symbol is non-NULL for C++ frontend */
66
-__typeof__(namespace_binding) namespace_binding __attribute__((weak));
70
+__typeof__(get_namespace_binding) get_namespace_binding __attribute__((weak));
67 71
 
68 72
 /* registry key for tree userdata cache */
69 73
 static char gcclua_tree_cache;
@@ -638,7 +642,7 @@ static int gcclua_tree_get_type_anonymous(lua_State *L)
638 642
   const tree *t;
639 643
   luaL_checktype(L, 1, LUA_TUSERDATA);
640 644
   t = (const tree *)lua_touserdata(L, 1);
641
-  if (!namespace_binding) {
645
+  if (!get_namespace_binding) {
642 646
     return 0;
643 647
   }
644 648
   lua_pushboolean(L, TYPE_UNNAMED_P(*t));
@@ -888,7 +892,11 @@ static int gcclua_tree_get_type_vector_subparts(lua_State *L)
888 892
   const tree *t;
889 893
   luaL_checktype(L, 1, LUA_TUSERDATA);
890 894
   t = (const tree *)lua_touserdata(L, 1);
895
+#if GCCPLUGIN_VERSION < 8000
891 896
   lua_pushinteger(L, TYPE_VECTOR_SUBPARTS(*t));
897
+#else
898
+  lua_pushinteger(L, TYPE_VECTOR_SUBPARTS(*t).to_constant());
899
+#endif
892 900
   return 1;
893 901
 }
894 902
 

Loading…
Cancel
Save