immunio 0.15.4 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (454) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +0 -27
  3. data/ext/immunio/Rakefile +9 -0
  4. data/lib/immunio/plugins/active_record.rb +1 -1
  5. data/lib/immunio/plugins/active_record_relation.rb +1 -1
  6. data/lib/immunio/plugins/environment_reporter.rb +20 -0
  7. data/lib/immunio/rufus_lua_ext/ref.rb +1 -3
  8. data/lib/immunio/version.rb +1 -1
  9. data/lib/immunio/vm.rb +1 -2
  10. data/lua-hooks/Makefile +97 -0
  11. data/lua-hooks/ext/all.c +41 -52
  12. data/lua-hooks/ext/all.o +0 -0
  13. data/lua-hooks/ext/libinjection/libinjection_html5.o +0 -0
  14. data/lua-hooks/ext/libinjection/libinjection_sqli.o +0 -0
  15. data/lua-hooks/ext/libinjection/libinjection_xss.o +0 -0
  16. data/lua-hooks/ext/libinjection/lualib.c +2 -2
  17. data/lua-hooks/ext/lpeg/lpcap.c +2 -2
  18. data/lua-hooks/ext/lpeg/lpcap.o +0 -0
  19. data/lua-hooks/ext/lpeg/lpcode.c +2 -2
  20. data/lua-hooks/ext/lpeg/lpcode.h +1 -1
  21. data/lua-hooks/ext/lpeg/lpcode.o +0 -0
  22. data/lua-hooks/ext/lpeg/lpprint.o +0 -0
  23. data/lua-hooks/ext/lpeg/lptree.c +2 -2
  24. data/lua-hooks/ext/lpeg/lptypes.h +1 -1
  25. data/lua-hooks/ext/lpeg/lpvm.c +2 -2
  26. data/lua-hooks/ext/lpeg/lpvm.o +0 -0
  27. data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +16 -3
  28. data/lua-hooks/ext/lua-snapshot/snapshot.c +14 -7
  29. data/lua-hooks/ext/luajit/COPYRIGHT +56 -0
  30. data/lua-hooks/ext/luajit/Makefile +159 -0
  31. data/lua-hooks/ext/luajit/README +16 -0
  32. data/lua-hooks/ext/luajit/doc/bluequad-print.css +166 -0
  33. data/lua-hooks/ext/luajit/doc/bluequad.css +325 -0
  34. data/lua-hooks/ext/luajit/doc/changes.html +804 -0
  35. data/lua-hooks/ext/luajit/doc/contact.html +104 -0
  36. data/lua-hooks/ext/luajit/doc/ext_c_api.html +189 -0
  37. data/lua-hooks/ext/luajit/doc/ext_ffi.html +332 -0
  38. data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +570 -0
  39. data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +1261 -0
  40. data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +603 -0
  41. data/lua-hooks/ext/luajit/doc/ext_jit.html +201 -0
  42. data/lua-hooks/ext/luajit/doc/ext_profiler.html +365 -0
  43. data/lua-hooks/ext/luajit/doc/extensions.html +448 -0
  44. data/lua-hooks/ext/luajit/doc/faq.html +186 -0
  45. data/lua-hooks/ext/luajit/doc/img/contact.png +0 -0
  46. data/lua-hooks/ext/luajit/doc/install.html +659 -0
  47. data/lua-hooks/ext/luajit/doc/luajit.html +236 -0
  48. data/lua-hooks/ext/luajit/doc/running.html +309 -0
  49. data/lua-hooks/ext/luajit/doc/status.html +118 -0
  50. data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +456 -0
  51. data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +1125 -0
  52. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +518 -0
  53. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +1166 -0
  54. data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +416 -0
  55. data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +953 -0
  56. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +419 -0
  57. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +1919 -0
  58. data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +83 -0
  59. data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +12 -0
  60. data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +471 -0
  61. data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +1945 -0
  62. data/lua-hooks/ext/luajit/dynasm/dynasm.lua +1094 -0
  63. data/lua-hooks/ext/luajit/etc/luajit.1 +88 -0
  64. data/lua-hooks/ext/luajit/etc/luajit.pc +25 -0
  65. data/lua-hooks/ext/luajit/src/Makefile +697 -0
  66. data/lua-hooks/ext/luajit/src/Makefile.dep +244 -0
  67. data/lua-hooks/ext/luajit/src/host/README +4 -0
  68. data/lua-hooks/ext/luajit/src/host/buildvm +0 -0
  69. data/lua-hooks/ext/luajit/src/host/buildvm.c +518 -0
  70. data/lua-hooks/ext/luajit/src/host/buildvm.h +105 -0
  71. data/lua-hooks/ext/luajit/src/host/buildvm.o +0 -0
  72. data/lua-hooks/ext/luajit/src/host/buildvm_arch.h +7449 -0
  73. data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +345 -0
  74. data/lua-hooks/ext/luajit/src/host/buildvm_asm.o +0 -0
  75. data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +229 -0
  76. data/lua-hooks/ext/luajit/src/host/buildvm_fold.o +0 -0
  77. data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +457 -0
  78. data/lua-hooks/ext/luajit/src/host/buildvm_lib.o +0 -0
  79. data/lua-hooks/ext/luajit/src/host/buildvm_libbc.h +45 -0
  80. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +368 -0
  81. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.o +0 -0
  82. data/lua-hooks/ext/luajit/src/host/genlibbc.lua +197 -0
  83. data/lua-hooks/ext/luajit/src/host/genminilua.lua +428 -0
  84. data/lua-hooks/ext/luajit/src/host/minilua +0 -0
  85. data/lua-hooks/ext/luajit/src/host/minilua.c +7770 -0
  86. data/lua-hooks/ext/luajit/src/host/minilua.o +0 -0
  87. data/lua-hooks/ext/luajit/src/jit/bc.lua +190 -0
  88. data/lua-hooks/ext/luajit/src/jit/bcsave.lua +661 -0
  89. data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +689 -0
  90. data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +428 -0
  91. data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +17 -0
  92. data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +591 -0
  93. data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +17 -0
  94. data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +838 -0
  95. data/lua-hooks/ext/luajit/src/jit/dump.lua +706 -0
  96. data/lua-hooks/ext/luajit/src/jit/p.lua +310 -0
  97. data/lua-hooks/ext/luajit/src/jit/v.lua +170 -0
  98. data/lua-hooks/ext/luajit/src/jit/vmdef.lua +362 -0
  99. data/lua-hooks/ext/luajit/src/jit/zone.lua +45 -0
  100. data/lua-hooks/ext/{lua → luajit/src}/lauxlib.h +10 -17
  101. data/lua-hooks/ext/luajit/src/lib_aux.c +356 -0
  102. data/lua-hooks/ext/luajit/src/lib_aux.o +0 -0
  103. data/lua-hooks/ext/luajit/src/lib_aux_dyn.o +0 -0
  104. data/lua-hooks/ext/luajit/src/lib_base.c +664 -0
  105. data/lua-hooks/ext/luajit/src/lib_base.o +0 -0
  106. data/lua-hooks/ext/luajit/src/lib_base_dyn.o +0 -0
  107. data/lua-hooks/ext/luajit/src/lib_bit.c +180 -0
  108. data/lua-hooks/ext/luajit/src/lib_bit.o +0 -0
  109. data/lua-hooks/ext/luajit/src/lib_bit_dyn.o +0 -0
  110. data/lua-hooks/ext/luajit/src/lib_debug.c +405 -0
  111. data/lua-hooks/ext/luajit/src/lib_debug.o +0 -0
  112. data/lua-hooks/ext/luajit/src/lib_debug_dyn.o +0 -0
  113. data/lua-hooks/ext/luajit/src/lib_ffi.c +872 -0
  114. data/lua-hooks/ext/luajit/src/lib_ffi.o +0 -0
  115. data/lua-hooks/ext/luajit/src/lib_ffi_dyn.o +0 -0
  116. data/lua-hooks/ext/luajit/src/lib_init.c +55 -0
  117. data/lua-hooks/ext/luajit/src/lib_init.o +0 -0
  118. data/lua-hooks/ext/luajit/src/lib_init_dyn.o +0 -0
  119. data/lua-hooks/ext/luajit/src/lib_io.c +541 -0
  120. data/lua-hooks/ext/luajit/src/lib_io.o +0 -0
  121. data/lua-hooks/ext/luajit/src/lib_io_dyn.o +0 -0
  122. data/lua-hooks/ext/luajit/src/lib_jit.c +767 -0
  123. data/lua-hooks/ext/luajit/src/lib_jit.o +0 -0
  124. data/lua-hooks/ext/luajit/src/lib_jit_dyn.o +0 -0
  125. data/lua-hooks/ext/luajit/src/lib_math.c +230 -0
  126. data/lua-hooks/ext/luajit/src/lib_math.o +0 -0
  127. data/lua-hooks/ext/luajit/src/lib_math_dyn.o +0 -0
  128. data/lua-hooks/ext/luajit/src/lib_os.c +292 -0
  129. data/lua-hooks/ext/luajit/src/lib_os.o +0 -0
  130. data/lua-hooks/ext/luajit/src/lib_os_dyn.o +0 -0
  131. data/lua-hooks/ext/luajit/src/lib_package.c +610 -0
  132. data/lua-hooks/ext/luajit/src/lib_package.o +0 -0
  133. data/lua-hooks/ext/luajit/src/lib_package_dyn.o +0 -0
  134. data/lua-hooks/ext/luajit/src/lib_string.c +752 -0
  135. data/lua-hooks/ext/luajit/src/lib_string.o +0 -0
  136. data/lua-hooks/ext/luajit/src/lib_string_dyn.o +0 -0
  137. data/lua-hooks/ext/luajit/src/lib_table.c +307 -0
  138. data/lua-hooks/ext/luajit/src/lib_table.o +0 -0
  139. data/lua-hooks/ext/luajit/src/lib_table_dyn.o +0 -0
  140. data/lua-hooks/ext/luajit/src/libluajit.a +0 -0
  141. data/lua-hooks/ext/luajit/src/libluajit.so +0 -0
  142. data/lua-hooks/ext/luajit/src/lj.supp +26 -0
  143. data/lua-hooks/ext/luajit/src/lj_alloc.c +1398 -0
  144. data/lua-hooks/ext/luajit/src/lj_alloc.h +17 -0
  145. data/lua-hooks/ext/luajit/src/lj_alloc.o +0 -0
  146. data/lua-hooks/ext/luajit/src/lj_alloc_dyn.o +0 -0
  147. data/lua-hooks/ext/luajit/src/lj_api.c +1210 -0
  148. data/lua-hooks/ext/luajit/src/lj_api.o +0 -0
  149. data/lua-hooks/ext/luajit/src/lj_api_dyn.o +0 -0
  150. data/lua-hooks/ext/luajit/src/lj_arch.h +509 -0
  151. data/lua-hooks/ext/luajit/src/lj_asm.c +2278 -0
  152. data/lua-hooks/ext/luajit/src/lj_asm.h +17 -0
  153. data/lua-hooks/ext/luajit/src/lj_asm.o +0 -0
  154. data/lua-hooks/ext/luajit/src/lj_asm_arm.h +2217 -0
  155. data/lua-hooks/ext/luajit/src/lj_asm_dyn.o +0 -0
  156. data/lua-hooks/ext/luajit/src/lj_asm_mips.h +1833 -0
  157. data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +2015 -0
  158. data/lua-hooks/ext/luajit/src/lj_asm_x86.h +2634 -0
  159. data/lua-hooks/ext/luajit/src/lj_bc.c +14 -0
  160. data/lua-hooks/ext/luajit/src/lj_bc.h +265 -0
  161. data/lua-hooks/ext/luajit/src/lj_bc.o +0 -0
  162. data/lua-hooks/ext/luajit/src/lj_bc_dyn.o +0 -0
  163. data/lua-hooks/ext/luajit/src/lj_bcdef.h +220 -0
  164. data/lua-hooks/ext/luajit/src/lj_bcdump.h +68 -0
  165. data/lua-hooks/ext/luajit/src/lj_bcread.c +457 -0
  166. data/lua-hooks/ext/luajit/src/lj_bcread.o +0 -0
  167. data/lua-hooks/ext/luajit/src/lj_bcread_dyn.o +0 -0
  168. data/lua-hooks/ext/luajit/src/lj_bcwrite.c +361 -0
  169. data/lua-hooks/ext/luajit/src/lj_bcwrite.o +0 -0
  170. data/lua-hooks/ext/luajit/src/lj_bcwrite_dyn.o +0 -0
  171. data/lua-hooks/ext/luajit/src/lj_buf.c +234 -0
  172. data/lua-hooks/ext/luajit/src/lj_buf.h +105 -0
  173. data/lua-hooks/ext/luajit/src/lj_buf.o +0 -0
  174. data/lua-hooks/ext/luajit/src/lj_buf_dyn.o +0 -0
  175. data/lua-hooks/ext/luajit/src/lj_carith.c +429 -0
  176. data/lua-hooks/ext/luajit/src/lj_carith.h +37 -0
  177. data/lua-hooks/ext/luajit/src/lj_carith.o +0 -0
  178. data/lua-hooks/ext/luajit/src/lj_carith_dyn.o +0 -0
  179. data/lua-hooks/ext/luajit/src/lj_ccall.c +984 -0
  180. data/lua-hooks/ext/luajit/src/lj_ccall.h +178 -0
  181. data/lua-hooks/ext/luajit/src/lj_ccall.o +0 -0
  182. data/lua-hooks/ext/luajit/src/lj_ccall_dyn.o +0 -0
  183. data/lua-hooks/ext/luajit/src/lj_ccallback.c +712 -0
  184. data/lua-hooks/ext/luajit/src/lj_ccallback.h +25 -0
  185. data/lua-hooks/ext/luajit/src/lj_ccallback.o +0 -0
  186. data/lua-hooks/ext/luajit/src/lj_ccallback_dyn.o +0 -0
  187. data/lua-hooks/ext/luajit/src/lj_cconv.c +752 -0
  188. data/lua-hooks/ext/luajit/src/lj_cconv.h +70 -0
  189. data/lua-hooks/ext/luajit/src/lj_cconv.o +0 -0
  190. data/lua-hooks/ext/luajit/src/lj_cconv_dyn.o +0 -0
  191. data/lua-hooks/ext/luajit/src/lj_cdata.c +288 -0
  192. data/lua-hooks/ext/luajit/src/lj_cdata.h +76 -0
  193. data/lua-hooks/ext/luajit/src/lj_cdata.o +0 -0
  194. data/lua-hooks/ext/luajit/src/lj_cdata_dyn.o +0 -0
  195. data/lua-hooks/ext/luajit/src/lj_char.c +43 -0
  196. data/lua-hooks/ext/luajit/src/lj_char.h +42 -0
  197. data/lua-hooks/ext/luajit/src/lj_char.o +0 -0
  198. data/lua-hooks/ext/luajit/src/lj_char_dyn.o +0 -0
  199. data/lua-hooks/ext/luajit/src/lj_clib.c +418 -0
  200. data/lua-hooks/ext/luajit/src/lj_clib.h +29 -0
  201. data/lua-hooks/ext/luajit/src/lj_clib.o +0 -0
  202. data/lua-hooks/ext/luajit/src/lj_clib_dyn.o +0 -0
  203. data/lua-hooks/ext/luajit/src/lj_cparse.c +1862 -0
  204. data/lua-hooks/ext/luajit/src/lj_cparse.h +65 -0
  205. data/lua-hooks/ext/luajit/src/lj_cparse.o +0 -0
  206. data/lua-hooks/ext/luajit/src/lj_cparse_dyn.o +0 -0
  207. data/lua-hooks/ext/luajit/src/lj_crecord.c +1834 -0
  208. data/lua-hooks/ext/luajit/src/lj_crecord.h +38 -0
  209. data/lua-hooks/ext/luajit/src/lj_crecord.o +0 -0
  210. data/lua-hooks/ext/luajit/src/lj_crecord_dyn.o +0 -0
  211. data/lua-hooks/ext/luajit/src/lj_ctype.c +635 -0
  212. data/lua-hooks/ext/luajit/src/lj_ctype.h +461 -0
  213. data/lua-hooks/ext/luajit/src/lj_ctype.o +0 -0
  214. data/lua-hooks/ext/luajit/src/lj_ctype_dyn.o +0 -0
  215. data/lua-hooks/ext/luajit/src/lj_debug.c +699 -0
  216. data/lua-hooks/ext/luajit/src/lj_debug.h +65 -0
  217. data/lua-hooks/ext/luajit/src/lj_debug.o +0 -0
  218. data/lua-hooks/ext/luajit/src/lj_debug_dyn.o +0 -0
  219. data/lua-hooks/ext/luajit/src/lj_def.h +365 -0
  220. data/lua-hooks/ext/luajit/src/lj_dispatch.c +557 -0
  221. data/lua-hooks/ext/luajit/src/lj_dispatch.h +138 -0
  222. data/lua-hooks/ext/luajit/src/lj_dispatch.o +0 -0
  223. data/lua-hooks/ext/luajit/src/lj_dispatch_dyn.o +0 -0
  224. data/lua-hooks/ext/luajit/src/lj_emit_arm.h +356 -0
  225. data/lua-hooks/ext/luajit/src/lj_emit_mips.h +211 -0
  226. data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +238 -0
  227. data/lua-hooks/ext/luajit/src/lj_emit_x86.h +462 -0
  228. data/lua-hooks/ext/luajit/src/lj_err.c +794 -0
  229. data/lua-hooks/ext/luajit/src/lj_err.h +41 -0
  230. data/lua-hooks/ext/luajit/src/lj_err.o +0 -0
  231. data/lua-hooks/ext/luajit/src/lj_err_dyn.o +0 -0
  232. data/lua-hooks/ext/luajit/src/lj_errmsg.h +190 -0
  233. data/lua-hooks/ext/luajit/src/lj_ff.h +18 -0
  234. data/lua-hooks/ext/luajit/src/lj_ffdef.h +209 -0
  235. data/lua-hooks/ext/luajit/src/lj_ffrecord.c +1247 -0
  236. data/lua-hooks/ext/luajit/src/lj_ffrecord.h +24 -0
  237. data/lua-hooks/ext/luajit/src/lj_ffrecord.o +0 -0
  238. data/lua-hooks/ext/luajit/src/lj_ffrecord_dyn.o +0 -0
  239. data/lua-hooks/ext/luajit/src/lj_folddef.h +1138 -0
  240. data/lua-hooks/ext/luajit/src/lj_frame.h +259 -0
  241. data/lua-hooks/ext/luajit/src/lj_func.c +185 -0
  242. data/lua-hooks/ext/luajit/src/lj_func.h +24 -0
  243. data/lua-hooks/ext/luajit/src/lj_func.o +0 -0
  244. data/lua-hooks/ext/luajit/src/lj_func_dyn.o +0 -0
  245. data/lua-hooks/ext/luajit/src/lj_gc.c +845 -0
  246. data/lua-hooks/ext/luajit/src/lj_gc.h +134 -0
  247. data/lua-hooks/ext/luajit/src/lj_gc.o +0 -0
  248. data/lua-hooks/ext/luajit/src/lj_gc_dyn.o +0 -0
  249. data/lua-hooks/ext/luajit/src/lj_gdbjit.c +787 -0
  250. data/lua-hooks/ext/luajit/src/lj_gdbjit.h +22 -0
  251. data/lua-hooks/ext/luajit/src/lj_gdbjit.o +0 -0
  252. data/lua-hooks/ext/luajit/src/lj_gdbjit_dyn.o +0 -0
  253. data/lua-hooks/ext/luajit/src/lj_ir.c +505 -0
  254. data/lua-hooks/ext/luajit/src/lj_ir.h +577 -0
  255. data/lua-hooks/ext/luajit/src/lj_ir.o +0 -0
  256. data/lua-hooks/ext/luajit/src/lj_ir_dyn.o +0 -0
  257. data/lua-hooks/ext/luajit/src/lj_ircall.h +321 -0
  258. data/lua-hooks/ext/luajit/src/lj_iropt.h +161 -0
  259. data/lua-hooks/ext/luajit/src/lj_jit.h +440 -0
  260. data/lua-hooks/ext/luajit/src/lj_lex.c +482 -0
  261. data/lua-hooks/ext/luajit/src/lj_lex.h +86 -0
  262. data/lua-hooks/ext/luajit/src/lj_lex.o +0 -0
  263. data/lua-hooks/ext/luajit/src/lj_lex_dyn.o +0 -0
  264. data/lua-hooks/ext/luajit/src/lj_lib.c +303 -0
  265. data/lua-hooks/ext/luajit/src/lj_lib.h +115 -0
  266. data/lua-hooks/ext/luajit/src/lj_lib.o +0 -0
  267. data/lua-hooks/ext/luajit/src/lj_lib_dyn.o +0 -0
  268. data/lua-hooks/ext/luajit/src/lj_libdef.h +414 -0
  269. data/lua-hooks/ext/luajit/src/lj_load.c +168 -0
  270. data/lua-hooks/ext/luajit/src/lj_load.o +0 -0
  271. data/lua-hooks/ext/luajit/src/lj_load_dyn.o +0 -0
  272. data/lua-hooks/ext/luajit/src/lj_mcode.c +386 -0
  273. data/lua-hooks/ext/luajit/src/lj_mcode.h +30 -0
  274. data/lua-hooks/ext/luajit/src/lj_mcode.o +0 -0
  275. data/lua-hooks/ext/luajit/src/lj_mcode_dyn.o +0 -0
  276. data/lua-hooks/ext/luajit/src/lj_meta.c +477 -0
  277. data/lua-hooks/ext/luajit/src/lj_meta.h +38 -0
  278. data/lua-hooks/ext/luajit/src/lj_meta.o +0 -0
  279. data/lua-hooks/ext/luajit/src/lj_meta_dyn.o +0 -0
  280. data/lua-hooks/ext/luajit/src/lj_obj.c +50 -0
  281. data/lua-hooks/ext/luajit/src/lj_obj.h +976 -0
  282. data/lua-hooks/ext/luajit/src/lj_obj.o +0 -0
  283. data/lua-hooks/ext/luajit/src/lj_obj_dyn.o +0 -0
  284. data/lua-hooks/ext/luajit/src/lj_opt_dce.c +78 -0
  285. data/lua-hooks/ext/luajit/src/lj_opt_dce.o +0 -0
  286. data/lua-hooks/ext/luajit/src/lj_opt_dce_dyn.o +0 -0
  287. data/lua-hooks/ext/luajit/src/lj_opt_fold.c +2488 -0
  288. data/lua-hooks/ext/luajit/src/lj_opt_fold.o +0 -0
  289. data/lua-hooks/ext/luajit/src/lj_opt_fold_dyn.o +0 -0
  290. data/lua-hooks/ext/luajit/src/lj_opt_loop.c +449 -0
  291. data/lua-hooks/ext/luajit/src/lj_opt_loop.o +0 -0
  292. data/lua-hooks/ext/luajit/src/lj_opt_loop_dyn.o +0 -0
  293. data/lua-hooks/ext/luajit/src/lj_opt_mem.c +935 -0
  294. data/lua-hooks/ext/luajit/src/lj_opt_mem.o +0 -0
  295. data/lua-hooks/ext/luajit/src/lj_opt_mem_dyn.o +0 -0
  296. data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +652 -0
  297. data/lua-hooks/ext/luajit/src/lj_opt_narrow.o +0 -0
  298. data/lua-hooks/ext/luajit/src/lj_opt_narrow_dyn.o +0 -0
  299. data/lua-hooks/ext/luajit/src/lj_opt_sink.c +245 -0
  300. data/lua-hooks/ext/luajit/src/lj_opt_sink.o +0 -0
  301. data/lua-hooks/ext/luajit/src/lj_opt_sink_dyn.o +0 -0
  302. data/lua-hooks/ext/luajit/src/lj_opt_split.c +856 -0
  303. data/lua-hooks/ext/luajit/src/lj_opt_split.o +0 -0
  304. data/lua-hooks/ext/luajit/src/lj_opt_split_dyn.o +0 -0
  305. data/lua-hooks/ext/luajit/src/lj_parse.c +2725 -0
  306. data/lua-hooks/ext/luajit/src/lj_parse.h +18 -0
  307. data/lua-hooks/ext/luajit/src/lj_parse.o +0 -0
  308. data/lua-hooks/ext/luajit/src/lj_parse_dyn.o +0 -0
  309. data/lua-hooks/ext/luajit/src/lj_profile.c +368 -0
  310. data/lua-hooks/ext/luajit/src/lj_profile.h +21 -0
  311. data/lua-hooks/ext/luajit/src/lj_profile.o +0 -0
  312. data/lua-hooks/ext/luajit/src/lj_profile_dyn.o +0 -0
  313. data/lua-hooks/ext/luajit/src/lj_recdef.h +270 -0
  314. data/lua-hooks/ext/luajit/src/lj_record.c +2554 -0
  315. data/lua-hooks/ext/luajit/src/lj_record.h +45 -0
  316. data/lua-hooks/ext/luajit/src/lj_record.o +0 -0
  317. data/lua-hooks/ext/luajit/src/lj_record_dyn.o +0 -0
  318. data/lua-hooks/ext/luajit/src/lj_snap.c +870 -0
  319. data/lua-hooks/ext/luajit/src/lj_snap.h +34 -0
  320. data/lua-hooks/ext/luajit/src/lj_snap.o +0 -0
  321. data/lua-hooks/ext/luajit/src/lj_snap_dyn.o +0 -0
  322. data/lua-hooks/ext/luajit/src/lj_state.c +300 -0
  323. data/lua-hooks/ext/luajit/src/lj_state.h +35 -0
  324. data/lua-hooks/ext/luajit/src/lj_state.o +0 -0
  325. data/lua-hooks/ext/luajit/src/lj_state_dyn.o +0 -0
  326. data/lua-hooks/ext/luajit/src/lj_str.c +197 -0
  327. data/lua-hooks/ext/luajit/src/lj_str.h +27 -0
  328. data/lua-hooks/ext/luajit/src/lj_str.o +0 -0
  329. data/lua-hooks/ext/luajit/src/lj_str_dyn.o +0 -0
  330. data/lua-hooks/ext/luajit/src/lj_strfmt.c +554 -0
  331. data/lua-hooks/ext/luajit/src/lj_strfmt.h +125 -0
  332. data/lua-hooks/ext/luajit/src/lj_strfmt.o +0 -0
  333. data/lua-hooks/ext/luajit/src/lj_strfmt_dyn.o +0 -0
  334. data/lua-hooks/ext/luajit/src/lj_strscan.c +547 -0
  335. data/lua-hooks/ext/luajit/src/lj_strscan.h +39 -0
  336. data/lua-hooks/ext/luajit/src/lj_strscan.o +0 -0
  337. data/lua-hooks/ext/luajit/src/lj_strscan_dyn.o +0 -0
  338. data/lua-hooks/ext/luajit/src/lj_tab.c +666 -0
  339. data/lua-hooks/ext/luajit/src/lj_tab.h +73 -0
  340. data/lua-hooks/ext/luajit/src/lj_tab.o +0 -0
  341. data/lua-hooks/ext/luajit/src/lj_tab_dyn.o +0 -0
  342. data/lua-hooks/ext/luajit/src/lj_target.h +164 -0
  343. data/lua-hooks/ext/luajit/src/lj_target_arm.h +270 -0
  344. data/lua-hooks/ext/luajit/src/lj_target_arm64.h +97 -0
  345. data/lua-hooks/ext/luajit/src/lj_target_mips.h +260 -0
  346. data/lua-hooks/ext/luajit/src/lj_target_ppc.h +280 -0
  347. data/lua-hooks/ext/luajit/src/lj_target_x86.h +345 -0
  348. data/lua-hooks/ext/luajit/src/lj_trace.c +859 -0
  349. data/lua-hooks/ext/luajit/src/lj_trace.h +54 -0
  350. data/lua-hooks/ext/luajit/src/lj_trace.o +0 -0
  351. data/lua-hooks/ext/luajit/src/lj_trace_dyn.o +0 -0
  352. data/lua-hooks/ext/luajit/src/lj_traceerr.h +63 -0
  353. data/lua-hooks/ext/luajit/src/lj_udata.c +34 -0
  354. data/lua-hooks/ext/luajit/src/lj_udata.h +14 -0
  355. data/lua-hooks/ext/luajit/src/lj_udata.o +0 -0
  356. data/lua-hooks/ext/luajit/src/lj_udata_dyn.o +0 -0
  357. data/lua-hooks/ext/luajit/src/lj_vm.S +2730 -0
  358. data/lua-hooks/ext/luajit/src/lj_vm.h +114 -0
  359. data/lua-hooks/ext/luajit/src/lj_vm.o +0 -0
  360. data/lua-hooks/ext/luajit/src/lj_vm_dyn.o +0 -0
  361. data/lua-hooks/ext/luajit/src/lj_vmevent.c +58 -0
  362. data/lua-hooks/ext/luajit/src/lj_vmevent.h +59 -0
  363. data/lua-hooks/ext/luajit/src/lj_vmevent.o +0 -0
  364. data/lua-hooks/ext/luajit/src/lj_vmevent_dyn.o +0 -0
  365. data/lua-hooks/ext/luajit/src/lj_vmmath.c +152 -0
  366. data/lua-hooks/ext/luajit/src/lj_vmmath.o +0 -0
  367. data/lua-hooks/ext/luajit/src/lj_vmmath_dyn.o +0 -0
  368. data/lua-hooks/ext/luajit/src/ljamalg.c +96 -0
  369. data/lua-hooks/ext/{lua → luajit/src}/lua.h +12 -7
  370. data/lua-hooks/ext/luajit/src/lua.hpp +9 -0
  371. data/lua-hooks/ext/luajit/src/luaconf.h +156 -0
  372. data/lua-hooks/ext/luajit/src/luajit +0 -0
  373. data/lua-hooks/ext/luajit/src/luajit.c +570 -0
  374. data/lua-hooks/ext/luajit/src/luajit.h +79 -0
  375. data/lua-hooks/ext/luajit/src/luajit.o +0 -0
  376. data/lua-hooks/ext/luajit/src/lualib.h +43 -0
  377. data/lua-hooks/ext/luajit/src/msvcbuild.bat +114 -0
  378. data/lua-hooks/ext/luajit/src/ps4build.bat +103 -0
  379. data/lua-hooks/ext/luajit/src/psvitabuild.bat +93 -0
  380. data/lua-hooks/ext/luajit/src/vm_arm.dasc +4585 -0
  381. data/lua-hooks/ext/luajit/src/vm_arm64.dasc +3764 -0
  382. data/lua-hooks/ext/luajit/src/vm_mips.dasc +4355 -0
  383. data/lua-hooks/ext/luajit/src/vm_ppc.dasc +5252 -0
  384. data/lua-hooks/ext/luajit/src/vm_x64.dasc +4902 -0
  385. data/lua-hooks/ext/luajit/src/vm_x86.dasc +5710 -0
  386. data/lua-hooks/ext/luajit/src/xb1build.bat +101 -0
  387. data/lua-hooks/ext/luajit/src/xedkbuild.bat +92 -0
  388. data/lua-hooks/ext/luautf8/lutf8lib.c +3 -3
  389. data/lua-hooks/lib/boot.lua +37 -2
  390. metadata +372 -69
  391. data/lua-hooks/ext/bitop/README +0 -22
  392. data/lua-hooks/ext/bitop/bit.c +0 -189
  393. data/lua-hooks/ext/extconf.rb +0 -38
  394. data/lua-hooks/ext/lua/COPYRIGHT +0 -34
  395. data/lua-hooks/ext/lua/lapi.c +0 -1087
  396. data/lua-hooks/ext/lua/lapi.h +0 -16
  397. data/lua-hooks/ext/lua/lauxlib.c +0 -652
  398. data/lua-hooks/ext/lua/lbaselib.c +0 -659
  399. data/lua-hooks/ext/lua/lcode.c +0 -831
  400. data/lua-hooks/ext/lua/lcode.h +0 -76
  401. data/lua-hooks/ext/lua/ldblib.c +0 -398
  402. data/lua-hooks/ext/lua/ldebug.c +0 -638
  403. data/lua-hooks/ext/lua/ldebug.h +0 -33
  404. data/lua-hooks/ext/lua/ldo.c +0 -519
  405. data/lua-hooks/ext/lua/ldo.h +0 -57
  406. data/lua-hooks/ext/lua/ldump.c +0 -164
  407. data/lua-hooks/ext/lua/lfunc.c +0 -174
  408. data/lua-hooks/ext/lua/lfunc.h +0 -34
  409. data/lua-hooks/ext/lua/lgc.c +0 -710
  410. data/lua-hooks/ext/lua/lgc.h +0 -110
  411. data/lua-hooks/ext/lua/linit.c +0 -38
  412. data/lua-hooks/ext/lua/liolib.c +0 -556
  413. data/lua-hooks/ext/lua/llex.c +0 -463
  414. data/lua-hooks/ext/lua/llex.h +0 -81
  415. data/lua-hooks/ext/lua/llimits.h +0 -128
  416. data/lua-hooks/ext/lua/lmathlib.c +0 -263
  417. data/lua-hooks/ext/lua/lmem.c +0 -86
  418. data/lua-hooks/ext/lua/lmem.h +0 -49
  419. data/lua-hooks/ext/lua/loadlib.c +0 -705
  420. data/lua-hooks/ext/lua/loadlib_rel.c +0 -760
  421. data/lua-hooks/ext/lua/lobject.c +0 -214
  422. data/lua-hooks/ext/lua/lobject.h +0 -381
  423. data/lua-hooks/ext/lua/lopcodes.c +0 -102
  424. data/lua-hooks/ext/lua/lopcodes.h +0 -268
  425. data/lua-hooks/ext/lua/loslib.c +0 -243
  426. data/lua-hooks/ext/lua/lparser.c +0 -1339
  427. data/lua-hooks/ext/lua/lparser.h +0 -82
  428. data/lua-hooks/ext/lua/lstate.c +0 -214
  429. data/lua-hooks/ext/lua/lstate.h +0 -169
  430. data/lua-hooks/ext/lua/lstring.c +0 -111
  431. data/lua-hooks/ext/lua/lstring.h +0 -31
  432. data/lua-hooks/ext/lua/lstrlib.c +0 -871
  433. data/lua-hooks/ext/lua/ltable.c +0 -588
  434. data/lua-hooks/ext/lua/ltable.h +0 -40
  435. data/lua-hooks/ext/lua/ltablib.c +0 -287
  436. data/lua-hooks/ext/lua/ltm.c +0 -75
  437. data/lua-hooks/ext/lua/ltm.h +0 -54
  438. data/lua-hooks/ext/lua/lua.c +0 -392
  439. data/lua-hooks/ext/lua/lua.def +0 -131
  440. data/lua-hooks/ext/lua/lua.rc +0 -28
  441. data/lua-hooks/ext/lua/lua_dll.rc +0 -26
  442. data/lua-hooks/ext/lua/luac.c +0 -200
  443. data/lua-hooks/ext/lua/luac.rc +0 -1
  444. data/lua-hooks/ext/lua/luaconf.h +0 -763
  445. data/lua-hooks/ext/lua/luaconf.h.in +0 -724
  446. data/lua-hooks/ext/lua/luaconf.h.orig +0 -763
  447. data/lua-hooks/ext/lua/lualib.h +0 -53
  448. data/lua-hooks/ext/lua/lundump.c +0 -227
  449. data/lua-hooks/ext/lua/lundump.h +0 -36
  450. data/lua-hooks/ext/lua/lvm.c +0 -767
  451. data/lua-hooks/ext/lua/lvm.h +0 -36
  452. data/lua-hooks/ext/lua/lzio.c +0 -82
  453. data/lua-hooks/ext/lua/lzio.h +0 -67
  454. data/lua-hooks/ext/lua/print.c +0 -227
@@ -0,0 +1,38 @@
1
+ /*
2
+ ** Trace recorder for C data operations.
3
+ ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
4
+ */
5
+
6
+ #ifndef _LJ_CRECORD_H
7
+ #define _LJ_CRECORD_H
8
+
9
+ #include "lj_obj.h"
10
+ #include "lj_jit.h"
11
+ #include "lj_ffrecord.h"
12
+
13
+ #if LJ_HASJIT && LJ_HASFFI
14
+ LJ_FUNC void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd);
15
+ LJ_FUNC void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd);
16
+ LJ_FUNC void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd);
17
+ LJ_FUNC void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd);
18
+ LJ_FUNC void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd);
19
+ LJ_FUNC void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd);
20
+ LJ_FUNC void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd);
21
+ LJ_FUNC void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd);
22
+ LJ_FUNC void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd);
23
+ LJ_FUNC void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd);
24
+ LJ_FUNC void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd);
25
+ LJ_FUNC void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd);
26
+ LJ_FUNC void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd);
27
+ LJ_FUNC void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd);
28
+
29
+ LJ_FUNC void LJ_FASTCALL recff_bit64_tobit(jit_State *J, RecordFFData *rd);
30
+ LJ_FUNC int LJ_FASTCALL recff_bit64_unary(jit_State *J, RecordFFData *rd);
31
+ LJ_FUNC int LJ_FASTCALL recff_bit64_nary(jit_State *J, RecordFFData *rd);
32
+ LJ_FUNC int LJ_FASTCALL recff_bit64_shift(jit_State *J, RecordFFData *rd);
33
+ LJ_FUNC TRef recff_bit64_tohex(jit_State *J, RecordFFData *rd, TRef hdr);
34
+
35
+ LJ_FUNC void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd);
36
+ #endif
37
+
38
+ #endif
@@ -0,0 +1,635 @@
1
+ /*
2
+ ** C type management.
3
+ ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
4
+ */
5
+
6
+ #include "lj_obj.h"
7
+
8
+ #if LJ_HASFFI
9
+
10
+ #include "lj_gc.h"
11
+ #include "lj_err.h"
12
+ #include "lj_str.h"
13
+ #include "lj_tab.h"
14
+ #include "lj_strfmt.h"
15
+ #include "lj_ctype.h"
16
+ #include "lj_ccallback.h"
17
+
18
+ /* -- C type definitions -------------------------------------------------- */
19
+
20
+ /* Predefined typedefs. */
21
+ #define CTTDDEF(_) \
22
+ /* Vararg handling. */ \
23
+ _("va_list", P_VOID) \
24
+ _("__builtin_va_list", P_VOID) \
25
+ _("__gnuc_va_list", P_VOID) \
26
+ /* From stddef.h. */ \
27
+ _("ptrdiff_t", INT_PSZ) \
28
+ _("size_t", UINT_PSZ) \
29
+ _("wchar_t", WCHAR) \
30
+ /* Subset of stdint.h. */ \
31
+ _("int8_t", INT8) \
32
+ _("int16_t", INT16) \
33
+ _("int32_t", INT32) \
34
+ _("int64_t", INT64) \
35
+ _("uint8_t", UINT8) \
36
+ _("uint16_t", UINT16) \
37
+ _("uint32_t", UINT32) \
38
+ _("uint64_t", UINT64) \
39
+ _("intptr_t", INT_PSZ) \
40
+ _("uintptr_t", UINT_PSZ) \
41
+ /* End of typedef list. */
42
+
43
+ /* Keywords (only the ones we actually care for). */
44
+ #define CTKWDEF(_) \
45
+ /* Type specifiers. */ \
46
+ _("void", -1, CTOK_VOID) \
47
+ _("_Bool", 0, CTOK_BOOL) \
48
+ _("bool", 1, CTOK_BOOL) \
49
+ _("char", 1, CTOK_CHAR) \
50
+ _("int", 4, CTOK_INT) \
51
+ _("__int8", 1, CTOK_INT) \
52
+ _("__int16", 2, CTOK_INT) \
53
+ _("__int32", 4, CTOK_INT) \
54
+ _("__int64", 8, CTOK_INT) \
55
+ _("float", 4, CTOK_FP) \
56
+ _("double", 8, CTOK_FP) \
57
+ _("long", 0, CTOK_LONG) \
58
+ _("short", 0, CTOK_SHORT) \
59
+ _("_Complex", 0, CTOK_COMPLEX) \
60
+ _("complex", 0, CTOK_COMPLEX) \
61
+ _("__complex", 0, CTOK_COMPLEX) \
62
+ _("__complex__", 0, CTOK_COMPLEX) \
63
+ _("signed", 0, CTOK_SIGNED) \
64
+ _("__signed", 0, CTOK_SIGNED) \
65
+ _("__signed__", 0, CTOK_SIGNED) \
66
+ _("unsigned", 0, CTOK_UNSIGNED) \
67
+ /* Type qualifiers. */ \
68
+ _("const", 0, CTOK_CONST) \
69
+ _("__const", 0, CTOK_CONST) \
70
+ _("__const__", 0, CTOK_CONST) \
71
+ _("volatile", 0, CTOK_VOLATILE) \
72
+ _("__volatile", 0, CTOK_VOLATILE) \
73
+ _("__volatile__", 0, CTOK_VOLATILE) \
74
+ _("restrict", 0, CTOK_RESTRICT) \
75
+ _("__restrict", 0, CTOK_RESTRICT) \
76
+ _("__restrict__", 0, CTOK_RESTRICT) \
77
+ _("inline", 0, CTOK_INLINE) \
78
+ _("__inline", 0, CTOK_INLINE) \
79
+ _("__inline__", 0, CTOK_INLINE) \
80
+ /* Storage class specifiers. */ \
81
+ _("typedef", 0, CTOK_TYPEDEF) \
82
+ _("extern", 0, CTOK_EXTERN) \
83
+ _("static", 0, CTOK_STATIC) \
84
+ _("auto", 0, CTOK_AUTO) \
85
+ _("register", 0, CTOK_REGISTER) \
86
+ /* GCC Attributes. */ \
87
+ _("__extension__", 0, CTOK_EXTENSION) \
88
+ _("__attribute", 0, CTOK_ATTRIBUTE) \
89
+ _("__attribute__", 0, CTOK_ATTRIBUTE) \
90
+ _("asm", 0, CTOK_ASM) \
91
+ _("__asm", 0, CTOK_ASM) \
92
+ _("__asm__", 0, CTOK_ASM) \
93
+ /* MSVC Attributes. */ \
94
+ _("__declspec", 0, CTOK_DECLSPEC) \
95
+ _("__cdecl", CTCC_CDECL, CTOK_CCDECL) \
96
+ _("__thiscall", CTCC_THISCALL, CTOK_CCDECL) \
97
+ _("__fastcall", CTCC_FASTCALL, CTOK_CCDECL) \
98
+ _("__stdcall", CTCC_STDCALL, CTOK_CCDECL) \
99
+ _("__ptr32", 4, CTOK_PTRSZ) \
100
+ _("__ptr64", 8, CTOK_PTRSZ) \
101
+ /* Other type specifiers. */ \
102
+ _("struct", 0, CTOK_STRUCT) \
103
+ _("union", 0, CTOK_UNION) \
104
+ _("enum", 0, CTOK_ENUM) \
105
+ /* Operators. */ \
106
+ _("sizeof", 0, CTOK_SIZEOF) \
107
+ _("__alignof", 0, CTOK_ALIGNOF) \
108
+ _("__alignof__", 0, CTOK_ALIGNOF) \
109
+ /* End of keyword list. */
110
+
111
+ /* Type info for predefined types. Size merged in. */
112
+ static CTInfo lj_ctype_typeinfo[] = {
113
+ #define CTTYINFODEF(id, sz, ct, info) CTINFO((ct),(((sz)&0x3fu)<<10)+(info)),
114
+ #define CTTDINFODEF(name, id) CTINFO(CT_TYPEDEF, CTID_##id),
115
+ #define CTKWINFODEF(name, sz, kw) CTINFO(CT_KW,(((sz)&0x3fu)<<10)+(kw)),
116
+ CTTYDEF(CTTYINFODEF)
117
+ CTTDDEF(CTTDINFODEF)
118
+ CTKWDEF(CTKWINFODEF)
119
+ #undef CTTYINFODEF
120
+ #undef CTTDINFODEF
121
+ #undef CTKWINFODEF
122
+ 0
123
+ };
124
+
125
+ /* Predefined type names collected in a single string. */
126
+ static const char * const lj_ctype_typenames =
127
+ #define CTTDNAMEDEF(name, id) name "\0"
128
+ #define CTKWNAMEDEF(name, sz, cds) name "\0"
129
+ CTTDDEF(CTTDNAMEDEF)
130
+ CTKWDEF(CTKWNAMEDEF)
131
+ #undef CTTDNAMEDEF
132
+ #undef CTKWNAMEDEF
133
+ ;
134
+
135
+ #define CTTYPEINFO_NUM (sizeof(lj_ctype_typeinfo)/sizeof(CTInfo)-1)
136
+ #ifdef LUAJIT_CTYPE_CHECK_ANCHOR
137
+ #define CTTYPETAB_MIN CTTYPEINFO_NUM
138
+ #else
139
+ #define CTTYPETAB_MIN 128
140
+ #endif
141
+
142
+ /* -- C type interning ---------------------------------------------------- */
143
+
144
+ #define ct_hashtype(info, size) (hashrot(info, size) & CTHASH_MASK)
145
+ #define ct_hashname(name) \
146
+ (hashrot(u32ptr(name), u32ptr(name) + HASH_BIAS) & CTHASH_MASK)
147
+
148
+ /* Create new type element. */
149
+ CTypeID lj_ctype_new(CTState *cts, CType **ctp)
150
+ {
151
+ CTypeID id = cts->top;
152
+ CType *ct;
153
+ lua_assert(cts->L);
154
+ if (LJ_UNLIKELY(id >= cts->sizetab)) {
155
+ if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV);
156
+ #ifdef LUAJIT_CTYPE_CHECK_ANCHOR
157
+ ct = lj_mem_newvec(cts->L, id+1, CType);
158
+ memcpy(ct, cts->tab, id*sizeof(CType));
159
+ memset(cts->tab, 0, id*sizeof(CType));
160
+ lj_mem_freevec(cts->g, cts->tab, cts->sizetab, CType);
161
+ cts->tab = ct;
162
+ cts->sizetab = id+1;
163
+ #else
164
+ lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType);
165
+ #endif
166
+ }
167
+ cts->top = id+1;
168
+ *ctp = ct = &cts->tab[id];
169
+ ct->info = 0;
170
+ ct->size = 0;
171
+ ct->sib = 0;
172
+ ct->next = 0;
173
+ setgcrefnull(ct->name);
174
+ return id;
175
+ }
176
+
177
+ /* Intern a type element. */
178
+ CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size)
179
+ {
180
+ uint32_t h = ct_hashtype(info, size);
181
+ CTypeID id = cts->hash[h];
182
+ lua_assert(cts->L);
183
+ while (id) {
184
+ CType *ct = ctype_get(cts, id);
185
+ if (ct->info == info && ct->size == size)
186
+ return id;
187
+ id = ct->next;
188
+ }
189
+ id = cts->top;
190
+ if (LJ_UNLIKELY(id >= cts->sizetab)) {
191
+ if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV);
192
+ lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType);
193
+ }
194
+ cts->top = id+1;
195
+ cts->tab[id].info = info;
196
+ cts->tab[id].size = size;
197
+ cts->tab[id].sib = 0;
198
+ cts->tab[id].next = cts->hash[h];
199
+ setgcrefnull(cts->tab[id].name);
200
+ cts->hash[h] = (CTypeID1)id;
201
+ return id;
202
+ }
203
+
204
+ /* Add type element to hash table. */
205
+ static void ctype_addtype(CTState *cts, CType *ct, CTypeID id)
206
+ {
207
+ uint32_t h = ct_hashtype(ct->info, ct->size);
208
+ ct->next = cts->hash[h];
209
+ cts->hash[h] = (CTypeID1)id;
210
+ }
211
+
212
+ /* Add named element to hash table. */
213
+ void lj_ctype_addname(CTState *cts, CType *ct, CTypeID id)
214
+ {
215
+ uint32_t h = ct_hashname(gcref(ct->name));
216
+ ct->next = cts->hash[h];
217
+ cts->hash[h] = (CTypeID1)id;
218
+ }
219
+
220
+ /* Get a C type by name, matching the type mask. */
221
+ CTypeID lj_ctype_getname(CTState *cts, CType **ctp, GCstr *name, uint32_t tmask)
222
+ {
223
+ CTypeID id = cts->hash[ct_hashname(name)];
224
+ while (id) {
225
+ CType *ct = ctype_get(cts, id);
226
+ if (gcref(ct->name) == obj2gco(name) &&
227
+ ((tmask >> ctype_type(ct->info)) & 1)) {
228
+ *ctp = ct;
229
+ return id;
230
+ }
231
+ id = ct->next;
232
+ }
233
+ *ctp = &cts->tab[0]; /* Simplify caller logic. ctype_get() would assert. */
234
+ return 0;
235
+ }
236
+
237
+ /* Get a struct/union/enum/function field by name. */
238
+ CType *lj_ctype_getfieldq(CTState *cts, CType *ct, GCstr *name, CTSize *ofs,
239
+ CTInfo *qual)
240
+ {
241
+ while (ct->sib) {
242
+ ct = ctype_get(cts, ct->sib);
243
+ if (gcref(ct->name) == obj2gco(name)) {
244
+ *ofs = ct->size;
245
+ return ct;
246
+ }
247
+ if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) {
248
+ CType *fct, *cct = ctype_child(cts, ct);
249
+ CTInfo q = 0;
250
+ while (ctype_isattrib(cct->info)) {
251
+ if (ctype_attrib(cct->info) == CTA_QUAL) q |= cct->size;
252
+ cct = ctype_child(cts, cct);
253
+ }
254
+ fct = lj_ctype_getfieldq(cts, cct, name, ofs, qual);
255
+ if (fct) {
256
+ if (qual) *qual |= q;
257
+ *ofs += ct->size;
258
+ return fct;
259
+ }
260
+ }
261
+ }
262
+ return NULL; /* Not found. */
263
+ }
264
+
265
+ /* -- C type information -------------------------------------------------- */
266
+
267
+ /* Follow references and get raw type for a C type ID. */
268
+ CType *lj_ctype_rawref(CTState *cts, CTypeID id)
269
+ {
270
+ CType *ct = ctype_get(cts, id);
271
+ while (ctype_isattrib(ct->info) || ctype_isref(ct->info))
272
+ ct = ctype_child(cts, ct);
273
+ return ct;
274
+ }
275
+
276
+ /* Get size for a C type ID. Does NOT support VLA/VLS. */
277
+ CTSize lj_ctype_size(CTState *cts, CTypeID id)
278
+ {
279
+ CType *ct = ctype_raw(cts, id);
280
+ return ctype_hassize(ct->info) ? ct->size : CTSIZE_INVALID;
281
+ }
282
+
283
+ /* Get size for a variable-length C type. Does NOT support other C types. */
284
+ CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem)
285
+ {
286
+ uint64_t xsz = 0;
287
+ if (ctype_isstruct(ct->info)) {
288
+ CTypeID arrid = 0, fid = ct->sib;
289
+ xsz = ct->size; /* Add the struct size. */
290
+ while (fid) {
291
+ CType *ctf = ctype_get(cts, fid);
292
+ if (ctype_type(ctf->info) == CT_FIELD)
293
+ arrid = ctype_cid(ctf->info); /* Remember last field of VLS. */
294
+ fid = ctf->sib;
295
+ }
296
+ ct = ctype_raw(cts, arrid);
297
+ }
298
+ lua_assert(ctype_isvlarray(ct->info)); /* Must be a VLA. */
299
+ ct = ctype_rawchild(cts, ct); /* Get array element. */
300
+ lua_assert(ctype_hassize(ct->info));
301
+ /* Calculate actual size of VLA and check for overflow. */
302
+ xsz += (uint64_t)ct->size * nelem;
303
+ return xsz < 0x80000000u ? (CTSize)xsz : CTSIZE_INVALID;
304
+ }
305
+
306
+ /* Get type, qualifiers, size and alignment for a C type ID. */
307
+ CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp)
308
+ {
309
+ CTInfo qual = 0;
310
+ CType *ct = ctype_get(cts, id);
311
+ for (;;) {
312
+ CTInfo info = ct->info;
313
+ if (ctype_isenum(info)) {
314
+ /* Follow child. Need to look at its attributes, too. */
315
+ } else if (ctype_isattrib(info)) {
316
+ if (ctype_isxattrib(info, CTA_QUAL))
317
+ qual |= ct->size;
318
+ else if (ctype_isxattrib(info, CTA_ALIGN) && !(qual & CTFP_ALIGNED))
319
+ qual |= CTFP_ALIGNED + CTALIGN(ct->size);
320
+ } else {
321
+ if (!(qual & CTFP_ALIGNED)) qual |= (info & CTF_ALIGN);
322
+ qual |= (info & ~(CTF_ALIGN|CTMASK_CID));
323
+ lua_assert(ctype_hassize(info) || ctype_isfunc(info));
324
+ *szp = ctype_isfunc(info) ? CTSIZE_INVALID : ct->size;
325
+ break;
326
+ }
327
+ ct = ctype_get(cts, ctype_cid(info));
328
+ }
329
+ return qual;
330
+ }
331
+
332
+ /* Get ctype metamethod. */
333
+ cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm)
334
+ {
335
+ CType *ct = ctype_get(cts, id);
336
+ cTValue *tv;
337
+ while (ctype_isattrib(ct->info) || ctype_isref(ct->info)) {
338
+ id = ctype_cid(ct->info);
339
+ ct = ctype_get(cts, id);
340
+ }
341
+ if (ctype_isptr(ct->info) &&
342
+ ctype_isfunc(ctype_get(cts, ctype_cid(ct->info))->info))
343
+ tv = lj_tab_getstr(cts->miscmap, &cts->g->strempty);
344
+ else
345
+ tv = lj_tab_getinth(cts->miscmap, -(int32_t)id);
346
+ if (tv && tvistab(tv) &&
347
+ (tv = lj_tab_getstr(tabV(tv), mmname_str(cts->g, mm))) && !tvisnil(tv))
348
+ return tv;
349
+ return NULL;
350
+ }
351
+
352
+ /* -- C type representation ----------------------------------------------- */
353
+
354
+ /* Fixed max. length of a C type representation. */
355
+ #define CTREPR_MAX 512
356
+
357
+ typedef struct CTRepr {
358
+ char *pb, *pe;
359
+ CTState *cts;
360
+ lua_State *L;
361
+ int needsp;
362
+ int ok;
363
+ char buf[CTREPR_MAX];
364
+ } CTRepr;
365
+
366
+ /* Prepend string. */
367
+ static void ctype_prepstr(CTRepr *ctr, const char *str, MSize len)
368
+ {
369
+ char *p = ctr->pb;
370
+ if (ctr->buf + len+1 > p) { ctr->ok = 0; return; }
371
+ if (ctr->needsp) *--p = ' ';
372
+ ctr->needsp = 1;
373
+ p -= len;
374
+ while (len-- > 0) p[len] = str[len];
375
+ ctr->pb = p;
376
+ }
377
+
378
+ #define ctype_preplit(ctr, str) ctype_prepstr((ctr), "" str, sizeof(str)-1)
379
+
380
+ /* Prepend char. */
381
+ static void ctype_prepc(CTRepr *ctr, int c)
382
+ {
383
+ if (ctr->buf >= ctr->pb) { ctr->ok = 0; return; }
384
+ *--ctr->pb = c;
385
+ }
386
+
387
+ /* Prepend number. */
388
+ static void ctype_prepnum(CTRepr *ctr, uint32_t n)
389
+ {
390
+ char *p = ctr->pb;
391
+ if (ctr->buf + 10+1 > p) { ctr->ok = 0; return; }
392
+ do { *--p = (char)('0' + n % 10); } while (n /= 10);
393
+ ctr->pb = p;
394
+ ctr->needsp = 0;
395
+ }
396
+
397
+ /* Append char. */
398
+ static void ctype_appc(CTRepr *ctr, int c)
399
+ {
400
+ if (ctr->pe >= ctr->buf + CTREPR_MAX) { ctr->ok = 0; return; }
401
+ *ctr->pe++ = c;
402
+ }
403
+
404
+ /* Append number. */
405
+ static void ctype_appnum(CTRepr *ctr, uint32_t n)
406
+ {
407
+ char buf[10];
408
+ char *p = buf+sizeof(buf);
409
+ char *q = ctr->pe;
410
+ if (q > ctr->buf + CTREPR_MAX - 10) { ctr->ok = 0; return; }
411
+ do { *--p = (char)('0' + n % 10); } while (n /= 10);
412
+ do { *q++ = *p++; } while (p < buf+sizeof(buf));
413
+ ctr->pe = q;
414
+ }
415
+
416
+ /* Prepend qualifiers. */
417
+ static void ctype_prepqual(CTRepr *ctr, CTInfo info)
418
+ {
419
+ if ((info & CTF_VOLATILE)) ctype_preplit(ctr, "volatile");
420
+ if ((info & CTF_CONST)) ctype_preplit(ctr, "const");
421
+ }
422
+
423
+ /* Prepend named type. */
424
+ static void ctype_preptype(CTRepr *ctr, CType *ct, CTInfo qual, const char *t)
425
+ {
426
+ if (gcref(ct->name)) {
427
+ GCstr *str = gco2str(gcref(ct->name));
428
+ ctype_prepstr(ctr, strdata(str), str->len);
429
+ } else {
430
+ if (ctr->needsp) ctype_prepc(ctr, ' ');
431
+ ctype_prepnum(ctr, ctype_typeid(ctr->cts, ct));
432
+ ctr->needsp = 1;
433
+ }
434
+ ctype_prepstr(ctr, t, (MSize)strlen(t));
435
+ ctype_prepqual(ctr, qual);
436
+ }
437
+
438
+ static void ctype_repr(CTRepr *ctr, CTypeID id)
439
+ {
440
+ CType *ct = ctype_get(ctr->cts, id);
441
+ CTInfo qual = 0;
442
+ int ptrto = 0;
443
+ for (;;) {
444
+ CTInfo info = ct->info;
445
+ CTSize size = ct->size;
446
+ switch (ctype_type(info)) {
447
+ case CT_NUM:
448
+ if ((info & CTF_BOOL)) {
449
+ ctype_preplit(ctr, "bool");
450
+ } else if ((info & CTF_FP)) {
451
+ if (size == sizeof(double)) ctype_preplit(ctr, "double");
452
+ else if (size == sizeof(float)) ctype_preplit(ctr, "float");
453
+ else ctype_preplit(ctr, "long double");
454
+ } else if (size == 1) {
455
+ if (!((info ^ CTF_UCHAR) & CTF_UNSIGNED)) ctype_preplit(ctr, "char");
456
+ else if (CTF_UCHAR) ctype_preplit(ctr, "signed char");
457
+ else ctype_preplit(ctr, "unsigned char");
458
+ } else if (size < 8) {
459
+ if (size == 4) ctype_preplit(ctr, "int");
460
+ else ctype_preplit(ctr, "short");
461
+ if ((info & CTF_UNSIGNED)) ctype_preplit(ctr, "unsigned");
462
+ } else {
463
+ ctype_preplit(ctr, "_t");
464
+ ctype_prepnum(ctr, size*8);
465
+ ctype_preplit(ctr, "int");
466
+ if ((info & CTF_UNSIGNED)) ctype_prepc(ctr, 'u');
467
+ }
468
+ ctype_prepqual(ctr, (qual|info));
469
+ return;
470
+ case CT_VOID:
471
+ ctype_preplit(ctr, "void");
472
+ ctype_prepqual(ctr, (qual|info));
473
+ return;
474
+ case CT_STRUCT:
475
+ ctype_preptype(ctr, ct, qual, (info & CTF_UNION) ? "union" : "struct");
476
+ return;
477
+ case CT_ENUM:
478
+ if (id == CTID_CTYPEID) {
479
+ ctype_preplit(ctr, "ctype");
480
+ return;
481
+ }
482
+ ctype_preptype(ctr, ct, qual, "enum");
483
+ return;
484
+ case CT_ATTRIB:
485
+ if (ctype_attrib(info) == CTA_QUAL) qual |= size;
486
+ break;
487
+ case CT_PTR:
488
+ if ((info & CTF_REF)) {
489
+ ctype_prepc(ctr, '&');
490
+ } else {
491
+ ctype_prepqual(ctr, (qual|info));
492
+ if (LJ_64 && size == 4) ctype_preplit(ctr, "__ptr32");
493
+ ctype_prepc(ctr, '*');
494
+ }
495
+ qual = 0;
496
+ ptrto = 1;
497
+ ctr->needsp = 1;
498
+ break;
499
+ case CT_ARRAY:
500
+ if (ctype_isrefarray(info)) {
501
+ ctr->needsp = 1;
502
+ if (ptrto) { ptrto = 0; ctype_prepc(ctr, '('); ctype_appc(ctr, ')'); }
503
+ ctype_appc(ctr, '[');
504
+ if (size != CTSIZE_INVALID) {
505
+ CTSize csize = ctype_child(ctr->cts, ct)->size;
506
+ ctype_appnum(ctr, csize ? size/csize : 0);
507
+ } else if ((info & CTF_VLA)) {
508
+ ctype_appc(ctr, '?');
509
+ }
510
+ ctype_appc(ctr, ']');
511
+ } else if ((info & CTF_COMPLEX)) {
512
+ if (size == 2*sizeof(float)) ctype_preplit(ctr, "float");
513
+ ctype_preplit(ctr, "complex");
514
+ return;
515
+ } else {
516
+ ctype_preplit(ctr, ")))");
517
+ ctype_prepnum(ctr, size);
518
+ ctype_preplit(ctr, "__attribute__((vector_size(");
519
+ }
520
+ break;
521
+ case CT_FUNC:
522
+ ctr->needsp = 1;
523
+ if (ptrto) { ptrto = 0; ctype_prepc(ctr, '('); ctype_appc(ctr, ')'); }
524
+ ctype_appc(ctr, '(');
525
+ ctype_appc(ctr, ')');
526
+ break;
527
+ default:
528
+ lua_assert(0);
529
+ break;
530
+ }
531
+ ct = ctype_get(ctr->cts, ctype_cid(info));
532
+ }
533
+ }
534
+
535
+ /* Return a printable representation of a C type. */
536
+ GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name)
537
+ {
538
+ global_State *g = G(L);
539
+ CTRepr ctr;
540
+ ctr.pb = ctr.pe = &ctr.buf[CTREPR_MAX/2];
541
+ ctr.cts = ctype_ctsG(g);
542
+ ctr.L = L;
543
+ ctr.ok = 1;
544
+ ctr.needsp = 0;
545
+ if (name) ctype_prepstr(&ctr, strdata(name), name->len);
546
+ ctype_repr(&ctr, id);
547
+ if (LJ_UNLIKELY(!ctr.ok)) return lj_str_newlit(L, "?");
548
+ return lj_str_new(L, ctr.pb, ctr.pe - ctr.pb);
549
+ }
550
+
551
+ /* Convert int64_t/uint64_t to string with 'LL' or 'ULL' suffix. */
552
+ GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned)
553
+ {
554
+ char buf[1+20+3];
555
+ char *p = buf+sizeof(buf);
556
+ int sign = 0;
557
+ *--p = 'L'; *--p = 'L';
558
+ if (isunsigned) {
559
+ *--p = 'U';
560
+ } else if ((int64_t)n < 0) {
561
+ n = (uint64_t)-(int64_t)n;
562
+ sign = 1;
563
+ }
564
+ do { *--p = (char)('0' + n % 10); } while (n /= 10);
565
+ if (sign) *--p = '-';
566
+ return lj_str_new(L, p, (size_t)(buf+sizeof(buf)-p));
567
+ }
568
+
569
+ /* Convert complex to string with 'i' or 'I' suffix. */
570
+ GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size)
571
+ {
572
+ char buf[2*STRFMT_MAXBUF_NUM+2+1], *p = buf;
573
+ TValue re, im;
574
+ if (size == 2*sizeof(double)) {
575
+ re.n = *(double *)sp; im.n = ((double *)sp)[1];
576
+ } else {
577
+ re.n = (double)*(float *)sp; im.n = (double)((float *)sp)[1];
578
+ }
579
+ p = lj_strfmt_wnum(p, &re);
580
+ if (!(im.u32.hi & 0x80000000u) || im.n != im.n) *p++ = '+';
581
+ p = lj_strfmt_wnum(p, &im);
582
+ *p = *(p-1) >= 'a' ? 'I' : 'i';
583
+ p++;
584
+ return lj_str_new(L, buf, p-buf);
585
+ }
586
+
587
+ /* -- C type state -------------------------------------------------------- */
588
+
589
+ /* Initialize C type table and state. */
590
+ CTState *lj_ctype_init(lua_State *L)
591
+ {
592
+ CTState *cts = lj_mem_newt(L, sizeof(CTState), CTState);
593
+ CType *ct = lj_mem_newvec(L, CTTYPETAB_MIN, CType);
594
+ const char *name = lj_ctype_typenames;
595
+ CTypeID id;
596
+ memset(cts, 0, sizeof(CTState));
597
+ cts->tab = ct;
598
+ cts->sizetab = CTTYPETAB_MIN;
599
+ cts->top = CTTYPEINFO_NUM;
600
+ cts->L = NULL;
601
+ cts->g = G(L);
602
+ for (id = 0; id < CTTYPEINFO_NUM; id++, ct++) {
603
+ CTInfo info = lj_ctype_typeinfo[id];
604
+ ct->size = (CTSize)((int32_t)(info << 16) >> 26);
605
+ ct->info = info & 0xffff03ffu;
606
+ ct->sib = 0;
607
+ if (ctype_type(info) == CT_KW || ctype_istypedef(info)) {
608
+ size_t len = strlen(name);
609
+ GCstr *str = lj_str_new(L, name, len);
610
+ ctype_setname(ct, str);
611
+ name += len+1;
612
+ lj_ctype_addname(cts, ct, id);
613
+ } else {
614
+ setgcrefnull(ct->name);
615
+ ct->next = 0;
616
+ if (!ctype_isenum(info)) ctype_addtype(cts, ct, id);
617
+ }
618
+ }
619
+ setmref(G(L)->ctype_state, cts);
620
+ return cts;
621
+ }
622
+
623
+ /* Free C type table and state. */
624
+ void lj_ctype_freestate(global_State *g)
625
+ {
626
+ CTState *cts = ctype_ctsG(g);
627
+ if (cts) {
628
+ lj_ccallback_mcode_free(cts);
629
+ lj_mem_freevec(g, cts->tab, cts->sizetab, CType);
630
+ lj_mem_freevec(g, cts->cb.cbid, cts->cb.sizeid, CTypeID1);
631
+ lj_mem_freet(g, cts);
632
+ }
633
+ }
634
+
635
+ #endif