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
@@ -1,5 +1,5 @@
1
1
  /*
2
- ** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $
2
+ ** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
3
3
  ** Lua - An Extensible Extension Language
4
4
  ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
5
5
  ** See Copyright Notice at the end of this file
@@ -17,10 +17,10 @@
17
17
 
18
18
 
19
19
  #define LUA_VERSION "Lua 5.1"
20
- #define LUA_RELEASE "Lua 5.1.5"
20
+ #define LUA_RELEASE "Lua 5.1.4"
21
21
  #define LUA_VERSION_NUM 501
22
- #define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
23
- #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
22
+ #define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
23
+ #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
24
24
 
25
25
 
26
26
  /* mark for precompiled code (`<esc>Lua') */
@@ -245,7 +245,7 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
245
245
 
246
246
 
247
247
 
248
- /*
248
+ /*
249
249
  ** ===============================================================
250
250
  ** some useful macros
251
251
  ** ===============================================================
@@ -336,12 +336,17 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
336
336
  LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
337
337
  LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
338
338
  LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
339
-
340
339
  LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
341
340
  LUA_API lua_Hook lua_gethook (lua_State *L);
342
341
  LUA_API int lua_gethookmask (lua_State *L);
343
342
  LUA_API int lua_gethookcount (lua_State *L);
344
343
 
344
+ /* From Lua 5.2. */
345
+ LUA_API void *lua_upvalueid (lua_State *L, int idx, int n);
346
+ LUA_API void lua_upvaluejoin (lua_State *L, int idx1, int n1, int idx2, int n2);
347
+ LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt,
348
+ const char *chunkname, const char *mode);
349
+
345
350
 
346
351
  struct lua_Debug {
347
352
  int event;
@@ -362,7 +367,7 @@ struct lua_Debug {
362
367
 
363
368
 
364
369
  /******************************************************************************
365
- * Copyright (C) 1994-2012 Lua.org, PUC-Rio. All rights reserved.
370
+ * Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
366
371
  *
367
372
  * Permission is hereby granted, free of charge, to any person obtaining
368
373
  * a copy of this software and associated documentation files (the
@@ -0,0 +1,9 @@
1
+ // C++ wrapper for LuaJIT header files.
2
+
3
+ extern "C" {
4
+ #include "lua.h"
5
+ #include "lauxlib.h"
6
+ #include "lualib.h"
7
+ #include "luajit.h"
8
+ }
9
+
@@ -0,0 +1,156 @@
1
+ /*
2
+ ** Configuration header.
3
+ ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
4
+ */
5
+
6
+ #ifndef luaconf_h
7
+ #define luaconf_h
8
+
9
+ #ifndef WINVER
10
+ #define WINVER 0x0501
11
+ #endif
12
+ #include <limits.h>
13
+ #include <stddef.h>
14
+
15
+ /* Default path for loading Lua and C modules with require(). */
16
+ #if defined(_WIN32)
17
+ /*
18
+ ** In Windows, any exclamation mark ('!') in the path is replaced by the
19
+ ** path of the directory of the executable file of the current process.
20
+ */
21
+ #define LUA_LDIR "!\\lua\\"
22
+ #define LUA_CDIR "!\\"
23
+ #define LUA_PATH_DEFAULT \
24
+ ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;"
25
+ #define LUA_CPATH_DEFAULT \
26
+ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
27
+ #else
28
+ /*
29
+ ** Note to distribution maintainers: do NOT patch the following lines!
30
+ ** Please read ../doc/install.html#distro and pass PREFIX=/usr instead.
31
+ */
32
+ #ifndef LUA_MULTILIB
33
+ #define LUA_MULTILIB "lib"
34
+ #endif
35
+ #ifndef LUA_LMULTILIB
36
+ #define LUA_LMULTILIB "lib"
37
+ #endif
38
+ #define LUA_LROOT "/usr/local"
39
+ #define LUA_LUADIR "/lua/5.1/"
40
+ #define LUA_LJDIR "/luajit-2.1.0-beta1/"
41
+
42
+ #ifdef LUA_ROOT
43
+ #define LUA_JROOT LUA_ROOT
44
+ #define LUA_RLDIR LUA_ROOT "/share" LUA_LUADIR
45
+ #define LUA_RCDIR LUA_ROOT "/" LUA_MULTILIB LUA_LUADIR
46
+ #define LUA_RLPATH ";" LUA_RLDIR "?.lua;" LUA_RLDIR "?/init.lua"
47
+ #define LUA_RCPATH ";" LUA_RCDIR "?.so"
48
+ #else
49
+ #define LUA_JROOT LUA_LROOT
50
+ #define LUA_RLPATH
51
+ #define LUA_RCPATH
52
+ #endif
53
+
54
+ #define LUA_JPATH ";" LUA_JROOT "/share" LUA_LJDIR "?.lua"
55
+ #define LUA_LLDIR LUA_LROOT "/share" LUA_LUADIR
56
+ #define LUA_LCDIR LUA_LROOT "/" LUA_LMULTILIB LUA_LUADIR
57
+ #define LUA_LLPATH ";" LUA_LLDIR "?.lua;" LUA_LLDIR "?/init.lua"
58
+ #define LUA_LCPATH1 ";" LUA_LCDIR "?.so"
59
+ #define LUA_LCPATH2 ";" LUA_LCDIR "loadall.so"
60
+
61
+ #define LUA_PATH_DEFAULT "./?.lua" LUA_JPATH LUA_LLPATH LUA_RLPATH
62
+ #define LUA_CPATH_DEFAULT "./?.so" LUA_LCPATH1 LUA_RCPATH LUA_LCPATH2
63
+ #endif
64
+
65
+ /* Environment variable names for path overrides and initialization code. */
66
+ #define LUA_PATH "LUA_PATH"
67
+ #define LUA_CPATH "LUA_CPATH"
68
+ #define LUA_INIT "LUA_INIT"
69
+
70
+ /* Special file system characters. */
71
+ #if defined(_WIN32)
72
+ #define LUA_DIRSEP "\\"
73
+ #else
74
+ #define LUA_DIRSEP "/"
75
+ #endif
76
+ #define LUA_PATHSEP ";"
77
+ #define LUA_PATH_MARK "?"
78
+ #define LUA_EXECDIR "!"
79
+ #define LUA_IGMARK "-"
80
+ #define LUA_PATH_CONFIG \
81
+ LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \
82
+ LUA_EXECDIR "\n" LUA_IGMARK
83
+
84
+ /* Quoting in error messages. */
85
+ #define LUA_QL(x) "'" x "'"
86
+ #define LUA_QS LUA_QL("%s")
87
+
88
+ /* Various tunables. */
89
+ #define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */
90
+ #define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */
91
+ #define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */
92
+ #define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */
93
+ #define LUA_MAXCAPTURES 32 /* Max. pattern captures. */
94
+
95
+ /* Compatibility with older library function names. */
96
+ #define LUA_COMPAT_MOD /* OLD: math.mod, NEW: math.fmod */
97
+ #define LUA_COMPAT_GFIND /* OLD: string.gfind, NEW: string.gmatch */
98
+
99
+ /* Configuration for the frontend (the luajit executable). */
100
+ #if defined(luajit_c)
101
+ #define LUA_PROGNAME "luajit" /* Fallback frontend name. */
102
+ #define LUA_PROMPT "> " /* Interactive prompt. */
103
+ #define LUA_PROMPT2 ">> " /* Continuation prompt. */
104
+ #define LUA_MAXINPUT 512 /* Max. input line length. */
105
+ #endif
106
+
107
+ /* Note: changing the following defines breaks the Lua 5.1 ABI. */
108
+ #define LUA_INTEGER ptrdiff_t
109
+ #define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */
110
+ /*
111
+ ** Size of lauxlib and io.* on-stack buffers. Weird workaround to avoid using
112
+ ** unreasonable amounts of stack space, but still retain ABI compatibility.
113
+ ** Blame Lua for depending on BUFSIZ in the ABI, blame **** for wrecking it.
114
+ */
115
+ #define LUAL_BUFFERSIZE (BUFSIZ > 16384 ? 8192 : BUFSIZ)
116
+
117
+ /* The following defines are here only for compatibility with luaconf.h
118
+ ** from the standard Lua distribution. They must not be changed for LuaJIT.
119
+ */
120
+ #define LUA_NUMBER_DOUBLE
121
+ #define LUA_NUMBER double
122
+ #define LUAI_UACNUMBER double
123
+ #define LUA_NUMBER_SCAN "%lf"
124
+ #define LUA_NUMBER_FMT "%.14g"
125
+ #define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n))
126
+ #define LUAI_MAXNUMBER2STR 32
127
+ #define LUA_INTFRMLEN "l"
128
+ #define LUA_INTFRM_T long
129
+
130
+ /* Linkage of public API functions. */
131
+ #if defined(LUA_BUILD_AS_DLL)
132
+ #if defined(LUA_CORE) || defined(LUA_LIB)
133
+ #define LUA_API __declspec(dllexport)
134
+ #else
135
+ #define LUA_API __declspec(dllimport)
136
+ #endif
137
+ #else
138
+ #define LUA_API extern
139
+ #endif
140
+
141
+ #define LUALIB_API LUA_API
142
+
143
+ /* Support for internal assertions. */
144
+ #if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK)
145
+ #include <assert.h>
146
+ #endif
147
+ #ifdef LUA_USE_ASSERT
148
+ #define lua_assert(x) assert(x)
149
+ #endif
150
+ #ifdef LUA_USE_APICHECK
151
+ #define luai_apicheck(L, o) { (void)L; assert(o); }
152
+ #else
153
+ #define luai_apicheck(L, o) { (void)L; }
154
+ #endif
155
+
156
+ #endif
@@ -0,0 +1,570 @@
1
+ /*
2
+ ** LuaJIT frontend. Runs commands, scripts, read-eval-print (REPL) etc.
3
+ ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
4
+ **
5
+ ** Major portions taken verbatim or adapted from the Lua interpreter.
6
+ ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
7
+ */
8
+
9
+ #include <stdio.h>
10
+ #include <stdlib.h>
11
+ #include <string.h>
12
+
13
+ #define luajit_c
14
+
15
+ #include "lua.h"
16
+ #include "lauxlib.h"
17
+ #include "lualib.h"
18
+ #include "luajit.h"
19
+
20
+ #include "lj_arch.h"
21
+
22
+ #if LJ_TARGET_POSIX
23
+ #include <unistd.h>
24
+ #define lua_stdin_is_tty() isatty(0)
25
+ #elif LJ_TARGET_WINDOWS
26
+ #include <io.h>
27
+ #ifdef __BORLANDC__
28
+ #define lua_stdin_is_tty() isatty(_fileno(stdin))
29
+ #else
30
+ #define lua_stdin_is_tty() _isatty(_fileno(stdin))
31
+ #endif
32
+ #else
33
+ #define lua_stdin_is_tty() 1
34
+ #endif
35
+
36
+ #if !LJ_TARGET_CONSOLE
37
+ #include <signal.h>
38
+ #endif
39
+
40
+ static lua_State *globalL = NULL;
41
+ static const char *progname = LUA_PROGNAME;
42
+
43
+ #if !LJ_TARGET_CONSOLE
44
+ static void lstop(lua_State *L, lua_Debug *ar)
45
+ {
46
+ (void)ar; /* unused arg. */
47
+ lua_sethook(L, NULL, 0, 0);
48
+ /* Avoid luaL_error -- a C hook doesn't add an extra frame. */
49
+ luaL_where(L, 0);
50
+ lua_pushfstring(L, "%sinterrupted!", lua_tostring(L, -1));
51
+ lua_error(L);
52
+ }
53
+
54
+ static void laction(int i)
55
+ {
56
+ signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
57
+ terminate process (default action) */
58
+ lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
59
+ }
60
+ #endif
61
+
62
+ static void print_usage(void)
63
+ {
64
+ fputs("usage: ", stderr);
65
+ fputs(progname, stderr);
66
+ fputs(" [options]... [script [args]...].\n"
67
+ "Available options are:\n"
68
+ " -e chunk Execute string " LUA_QL("chunk") ".\n"
69
+ " -l name Require library " LUA_QL("name") ".\n"
70
+ " -b ... Save or list bytecode.\n"
71
+ " -j cmd Perform LuaJIT control command.\n"
72
+ " -O[opt] Control LuaJIT optimizations.\n"
73
+ " -i Enter interactive mode after executing " LUA_QL("script") ".\n"
74
+ " -v Show version information.\n"
75
+ " -E Ignore environment variables.\n"
76
+ " -- Stop handling options.\n"
77
+ " - Execute stdin and stop handling options.\n", stderr);
78
+ fflush(stderr);
79
+ }
80
+
81
+ static void l_message(const char *pname, const char *msg)
82
+ {
83
+ if (pname) { fputs(pname, stderr); fputc(':', stderr); fputc(' ', stderr); }
84
+ fputs(msg, stderr); fputc('\n', stderr);
85
+ fflush(stderr);
86
+ }
87
+
88
+ static int report(lua_State *L, int status)
89
+ {
90
+ if (status && !lua_isnil(L, -1)) {
91
+ const char *msg = lua_tostring(L, -1);
92
+ if (msg == NULL) msg = "(error object is not a string)";
93
+ l_message(progname, msg);
94
+ lua_pop(L, 1);
95
+ }
96
+ return status;
97
+ }
98
+
99
+ static int traceback(lua_State *L)
100
+ {
101
+ if (!lua_isstring(L, 1)) { /* Non-string error object? Try metamethod. */
102
+ if (lua_isnoneornil(L, 1) ||
103
+ !luaL_callmeta(L, 1, "__tostring") ||
104
+ !lua_isstring(L, -1))
105
+ return 1; /* Return non-string error object. */
106
+ lua_remove(L, 1); /* Replace object by result of __tostring metamethod. */
107
+ }
108
+ luaL_traceback(L, L, lua_tostring(L, 1), 1);
109
+ return 1;
110
+ }
111
+
112
+ static int docall(lua_State *L, int narg, int clear)
113
+ {
114
+ int status;
115
+ int base = lua_gettop(L) - narg; /* function index */
116
+ lua_pushcfunction(L, traceback); /* push traceback function */
117
+ lua_insert(L, base); /* put it under chunk and args */
118
+ #if !LJ_TARGET_CONSOLE
119
+ signal(SIGINT, laction);
120
+ #endif
121
+ status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
122
+ #if !LJ_TARGET_CONSOLE
123
+ signal(SIGINT, SIG_DFL);
124
+ #endif
125
+ lua_remove(L, base); /* remove traceback function */
126
+ /* force a complete garbage collection in case of errors */
127
+ if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0);
128
+ return status;
129
+ }
130
+
131
+ static void print_version(void)
132
+ {
133
+ fputs(LUAJIT_VERSION " -- " LUAJIT_COPYRIGHT ". " LUAJIT_URL "\n", stdout);
134
+ }
135
+
136
+ static void print_jit_status(lua_State *L)
137
+ {
138
+ int n;
139
+ const char *s;
140
+ lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
141
+ lua_getfield(L, -1, "jit"); /* Get jit.* module table. */
142
+ lua_remove(L, -2);
143
+ lua_getfield(L, -1, "status");
144
+ lua_remove(L, -2);
145
+ n = lua_gettop(L);
146
+ lua_call(L, 0, LUA_MULTRET);
147
+ fputs(lua_toboolean(L, n) ? "JIT: ON" : "JIT: OFF", stdout);
148
+ for (n++; (s = lua_tostring(L, n)); n++) {
149
+ putc(' ', stdout);
150
+ fputs(s, stdout);
151
+ }
152
+ putc('\n', stdout);
153
+ }
154
+
155
+ static int getargs(lua_State *L, char **argv, int n)
156
+ {
157
+ int narg;
158
+ int i;
159
+ int argc = 0;
160
+ while (argv[argc]) argc++; /* count total number of arguments */
161
+ narg = argc - (n + 1); /* number of arguments to the script */
162
+ luaL_checkstack(L, narg + 3, "too many arguments to script");
163
+ for (i = n+1; i < argc; i++)
164
+ lua_pushstring(L, argv[i]);
165
+ lua_createtable(L, narg, n + 1);
166
+ for (i = 0; i < argc; i++) {
167
+ lua_pushstring(L, argv[i]);
168
+ lua_rawseti(L, -2, i - n);
169
+ }
170
+ return narg;
171
+ }
172
+
173
+ static int dofile(lua_State *L, const char *name)
174
+ {
175
+ int status = luaL_loadfile(L, name) || docall(L, 0, 1);
176
+ return report(L, status);
177
+ }
178
+
179
+ static int dostring(lua_State *L, const char *s, const char *name)
180
+ {
181
+ int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1);
182
+ return report(L, status);
183
+ }
184
+
185
+ static int dolibrary(lua_State *L, const char *name)
186
+ {
187
+ lua_getglobal(L, "require");
188
+ lua_pushstring(L, name);
189
+ return report(L, docall(L, 1, 1));
190
+ }
191
+
192
+ static void write_prompt(lua_State *L, int firstline)
193
+ {
194
+ const char *p;
195
+ lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2");
196
+ p = lua_tostring(L, -1);
197
+ if (p == NULL) p = firstline ? LUA_PROMPT : LUA_PROMPT2;
198
+ fputs(p, stdout);
199
+ fflush(stdout);
200
+ lua_pop(L, 1); /* remove global */
201
+ }
202
+
203
+ static int incomplete(lua_State *L, int status)
204
+ {
205
+ if (status == LUA_ERRSYNTAX) {
206
+ size_t lmsg;
207
+ const char *msg = lua_tolstring(L, -1, &lmsg);
208
+ const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1);
209
+ if (strstr(msg, LUA_QL("<eof>")) == tp) {
210
+ lua_pop(L, 1);
211
+ return 1;
212
+ }
213
+ }
214
+ return 0; /* else... */
215
+ }
216
+
217
+ static int pushline(lua_State *L, int firstline)
218
+ {
219
+ char buf[LUA_MAXINPUT];
220
+ write_prompt(L, firstline);
221
+ if (fgets(buf, LUA_MAXINPUT, stdin)) {
222
+ size_t len = strlen(buf);
223
+ if (len > 0 && buf[len-1] == '\n')
224
+ buf[len-1] = '\0';
225
+ if (firstline && buf[0] == '=')
226
+ lua_pushfstring(L, "return %s", buf+1);
227
+ else
228
+ lua_pushstring(L, buf);
229
+ return 1;
230
+ }
231
+ return 0;
232
+ }
233
+
234
+ static int loadline(lua_State *L)
235
+ {
236
+ int status;
237
+ lua_settop(L, 0);
238
+ if (!pushline(L, 1))
239
+ return -1; /* no input */
240
+ for (;;) { /* repeat until gets a complete line */
241
+ status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin");
242
+ if (!incomplete(L, status)) break; /* cannot try to add lines? */
243
+ if (!pushline(L, 0)) /* no more input? */
244
+ return -1;
245
+ lua_pushliteral(L, "\n"); /* add a new line... */
246
+ lua_insert(L, -2); /* ...between the two lines */
247
+ lua_concat(L, 3); /* join them */
248
+ }
249
+ lua_remove(L, 1); /* remove line */
250
+ return status;
251
+ }
252
+
253
+ static void dotty(lua_State *L)
254
+ {
255
+ int status;
256
+ const char *oldprogname = progname;
257
+ progname = NULL;
258
+ while ((status = loadline(L)) != -1) {
259
+ if (status == 0) status = docall(L, 0, 0);
260
+ report(L, status);
261
+ if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */
262
+ lua_getglobal(L, "print");
263
+ lua_insert(L, 1);
264
+ if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
265
+ l_message(progname,
266
+ lua_pushfstring(L, "error calling " LUA_QL("print") " (%s)",
267
+ lua_tostring(L, -1)));
268
+ }
269
+ }
270
+ lua_settop(L, 0); /* clear stack */
271
+ fputs("\n", stdout);
272
+ fflush(stdout);
273
+ progname = oldprogname;
274
+ }
275
+
276
+ static int handle_script(lua_State *L, char **argv, int n)
277
+ {
278
+ int status;
279
+ const char *fname;
280
+ int narg = getargs(L, argv, n); /* collect arguments */
281
+ lua_setglobal(L, "arg");
282
+ fname = argv[n];
283
+ if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0)
284
+ fname = NULL; /* stdin */
285
+ status = luaL_loadfile(L, fname);
286
+ lua_insert(L, -(narg+1));
287
+ if (status == 0)
288
+ status = docall(L, narg, 0);
289
+ else
290
+ lua_pop(L, narg);
291
+ return report(L, status);
292
+ }
293
+
294
+ /* Load add-on module. */
295
+ static int loadjitmodule(lua_State *L)
296
+ {
297
+ lua_getglobal(L, "require");
298
+ lua_pushliteral(L, "jit.");
299
+ lua_pushvalue(L, -3);
300
+ lua_concat(L, 2);
301
+ if (lua_pcall(L, 1, 1, 0)) {
302
+ const char *msg = lua_tostring(L, -1);
303
+ if (msg && !strncmp(msg, "module ", 7))
304
+ goto nomodule;
305
+ return report(L, 1);
306
+ }
307
+ lua_getfield(L, -1, "start");
308
+ if (lua_isnil(L, -1)) {
309
+ nomodule:
310
+ l_message(progname,
311
+ "unknown luaJIT command or jit.* modules not installed");
312
+ return 1;
313
+ }
314
+ lua_remove(L, -2); /* Drop module table. */
315
+ return 0;
316
+ }
317
+
318
+ /* Run command with options. */
319
+ static int runcmdopt(lua_State *L, const char *opt)
320
+ {
321
+ int narg = 0;
322
+ if (opt && *opt) {
323
+ for (;;) { /* Split arguments. */
324
+ const char *p = strchr(opt, ',');
325
+ narg++;
326
+ if (!p) break;
327
+ if (p == opt)
328
+ lua_pushnil(L);
329
+ else
330
+ lua_pushlstring(L, opt, (size_t)(p - opt));
331
+ opt = p + 1;
332
+ }
333
+ if (*opt)
334
+ lua_pushstring(L, opt);
335
+ else
336
+ lua_pushnil(L);
337
+ }
338
+ return report(L, lua_pcall(L, narg, 0, 0));
339
+ }
340
+
341
+ /* JIT engine control command: try jit library first or load add-on module. */
342
+ static int dojitcmd(lua_State *L, const char *cmd)
343
+ {
344
+ const char *opt = strchr(cmd, '=');
345
+ lua_pushlstring(L, cmd, opt ? (size_t)(opt - cmd) : strlen(cmd));
346
+ lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
347
+ lua_getfield(L, -1, "jit"); /* Get jit.* module table. */
348
+ lua_remove(L, -2);
349
+ lua_pushvalue(L, -2);
350
+ lua_gettable(L, -2); /* Lookup library function. */
351
+ if (!lua_isfunction(L, -1)) {
352
+ lua_pop(L, 2); /* Drop non-function and jit.* table, keep module name. */
353
+ if (loadjitmodule(L))
354
+ return 1;
355
+ } else {
356
+ lua_remove(L, -2); /* Drop jit.* table. */
357
+ }
358
+ lua_remove(L, -2); /* Drop module name. */
359
+ return runcmdopt(L, opt ? opt+1 : opt);
360
+ }
361
+
362
+ /* Optimization flags. */
363
+ static int dojitopt(lua_State *L, const char *opt)
364
+ {
365
+ lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
366
+ lua_getfield(L, -1, "jit.opt"); /* Get jit.opt.* module table. */
367
+ lua_remove(L, -2);
368
+ lua_getfield(L, -1, "start");
369
+ lua_remove(L, -2);
370
+ return runcmdopt(L, opt);
371
+ }
372
+
373
+ /* Save or list bytecode. */
374
+ static int dobytecode(lua_State *L, char **argv)
375
+ {
376
+ int narg = 0;
377
+ lua_pushliteral(L, "bcsave");
378
+ if (loadjitmodule(L))
379
+ return 1;
380
+ if (argv[0][2]) {
381
+ narg++;
382
+ argv[0][1] = '-';
383
+ lua_pushstring(L, argv[0]+1);
384
+ }
385
+ for (argv++; *argv != NULL; narg++, argv++)
386
+ lua_pushstring(L, *argv);
387
+ return report(L, lua_pcall(L, narg, 0, 0));
388
+ }
389
+
390
+ /* check that argument has no extra characters at the end */
391
+ #define notail(x) {if ((x)[2] != '\0') return -1;}
392
+
393
+ #define FLAGS_INTERACTIVE 1
394
+ #define FLAGS_VERSION 2
395
+ #define FLAGS_EXEC 4
396
+ #define FLAGS_OPTION 8
397
+ #define FLAGS_NOENV 16
398
+
399
+ static int collectargs(char **argv, int *flags)
400
+ {
401
+ int i;
402
+ for (i = 1; argv[i] != NULL; i++) {
403
+ if (argv[i][0] != '-') /* Not an option? */
404
+ return i;
405
+ switch (argv[i][1]) { /* Check option. */
406
+ case '-':
407
+ notail(argv[i]);
408
+ return (argv[i+1] != NULL ? i+1 : 0);
409
+ case '\0':
410
+ return i;
411
+ case 'i':
412
+ notail(argv[i]);
413
+ *flags |= FLAGS_INTERACTIVE;
414
+ /* fallthrough */
415
+ case 'v':
416
+ notail(argv[i]);
417
+ *flags |= FLAGS_VERSION;
418
+ break;
419
+ case 'e':
420
+ *flags |= FLAGS_EXEC;
421
+ case 'j': /* LuaJIT extension */
422
+ case 'l':
423
+ *flags |= FLAGS_OPTION;
424
+ if (argv[i][2] == '\0') {
425
+ i++;
426
+ if (argv[i] == NULL) return -1;
427
+ }
428
+ break;
429
+ case 'O': break; /* LuaJIT extension */
430
+ case 'b': /* LuaJIT extension */
431
+ if (*flags) return -1;
432
+ *flags |= FLAGS_EXEC;
433
+ return 0;
434
+ case 'E':
435
+ *flags |= FLAGS_NOENV;
436
+ break;
437
+ default: return -1; /* invalid option */
438
+ }
439
+ }
440
+ return 0;
441
+ }
442
+
443
+ static int runargs(lua_State *L, char **argv, int n)
444
+ {
445
+ int i;
446
+ for (i = 1; i < n; i++) {
447
+ if (argv[i] == NULL) continue;
448
+ lua_assert(argv[i][0] == '-');
449
+ switch (argv[i][1]) { /* option */
450
+ case 'e': {
451
+ const char *chunk = argv[i] + 2;
452
+ if (*chunk == '\0') chunk = argv[++i];
453
+ lua_assert(chunk != NULL);
454
+ if (dostring(L, chunk, "=(command line)") != 0)
455
+ return 1;
456
+ break;
457
+ }
458
+ case 'l': {
459
+ const char *filename = argv[i] + 2;
460
+ if (*filename == '\0') filename = argv[++i];
461
+ lua_assert(filename != NULL);
462
+ if (dolibrary(L, filename))
463
+ return 1; /* stop if file fails */
464
+ break;
465
+ }
466
+ case 'j': { /* LuaJIT extension */
467
+ const char *cmd = argv[i] + 2;
468
+ if (*cmd == '\0') cmd = argv[++i];
469
+ lua_assert(cmd != NULL);
470
+ if (dojitcmd(L, cmd))
471
+ return 1;
472
+ break;
473
+ }
474
+ case 'O': /* LuaJIT extension */
475
+ if (dojitopt(L, argv[i] + 2))
476
+ return 1;
477
+ break;
478
+ case 'b': /* LuaJIT extension */
479
+ return dobytecode(L, argv+i);
480
+ default: break;
481
+ }
482
+ }
483
+ return 0;
484
+ }
485
+
486
+ static int handle_luainit(lua_State *L)
487
+ {
488
+ #if LJ_TARGET_CONSOLE
489
+ const char *init = NULL;
490
+ #else
491
+ const char *init = getenv(LUA_INIT);
492
+ #endif
493
+ if (init == NULL)
494
+ return 0; /* status OK */
495
+ else if (init[0] == '@')
496
+ return dofile(L, init+1);
497
+ else
498
+ return dostring(L, init, "=" LUA_INIT);
499
+ }
500
+
501
+ static struct Smain {
502
+ char **argv;
503
+ int argc;
504
+ int status;
505
+ } smain;
506
+
507
+ static int pmain(lua_State *L)
508
+ {
509
+ struct Smain *s = &smain;
510
+ char **argv = s->argv;
511
+ int script;
512
+ int flags = 0;
513
+ globalL = L;
514
+ if (argv[0] && argv[0][0]) progname = argv[0];
515
+ LUAJIT_VERSION_SYM(); /* linker-enforced version check */
516
+ script = collectargs(argv, &flags);
517
+ if (script < 0) { /* invalid args? */
518
+ print_usage();
519
+ s->status = 1;
520
+ return 0;
521
+ }
522
+ if ((flags & FLAGS_NOENV)) {
523
+ lua_pushboolean(L, 1);
524
+ lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
525
+ }
526
+ lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
527
+ luaL_openlibs(L); /* open libraries */
528
+ lua_gc(L, LUA_GCRESTART, -1);
529
+ if (!(flags & FLAGS_NOENV)) {
530
+ s->status = handle_luainit(L);
531
+ if (s->status != 0) return 0;
532
+ }
533
+ if ((flags & FLAGS_VERSION)) print_version();
534
+ s->status = runargs(L, argv, (script > 0) ? script : s->argc);
535
+ if (s->status != 0) return 0;
536
+ if (script) {
537
+ s->status = handle_script(L, argv, script);
538
+ if (s->status != 0) return 0;
539
+ }
540
+ if ((flags & FLAGS_INTERACTIVE)) {
541
+ print_jit_status(L);
542
+ dotty(L);
543
+ } else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) {
544
+ if (lua_stdin_is_tty()) {
545
+ print_version();
546
+ print_jit_status(L);
547
+ dotty(L);
548
+ } else {
549
+ dofile(L, NULL); /* executes stdin as a file */
550
+ }
551
+ }
552
+ return 0;
553
+ }
554
+
555
+ int main(int argc, char **argv)
556
+ {
557
+ int status;
558
+ lua_State *L = lua_open(); /* create state */
559
+ if (L == NULL) {
560
+ l_message(argv[0], "cannot create state: not enough memory");
561
+ return EXIT_FAILURE;
562
+ }
563
+ smain.argc = argc;
564
+ smain.argv = argv;
565
+ status = lua_cpcall(L, pmain, NULL);
566
+ report(L, status);
567
+ lua_close(L);
568
+ return (status || smain.status) ? EXIT_FAILURE : EXIT_SUCCESS;
569
+ }
570
+