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,831 +0,0 @@
1
- /*
2
- ** $Id: lcode.c,v 2.25.1.5 2011/01/31 14:53:16 roberto Exp $
3
- ** Code generator for Lua
4
- ** See Copyright Notice in lua.h
5
- */
6
-
7
-
8
- #include <stdlib.h>
9
-
10
- #define lcode_c
11
- #define LUA_CORE
12
-
13
- #include "lua.h"
14
-
15
- #include "lcode.h"
16
- #include "ldebug.h"
17
- #include "ldo.h"
18
- #include "lgc.h"
19
- #include "llex.h"
20
- #include "lmem.h"
21
- #include "lobject.h"
22
- #include "lopcodes.h"
23
- #include "lparser.h"
24
- #include "ltable.h"
25
-
26
-
27
- #define hasjumps(e) ((e)->t != (e)->f)
28
-
29
-
30
- static int isnumeral(expdesc *e) {
31
- return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
32
- }
33
-
34
-
35
- void luaK_nil (FuncState *fs, int from, int n) {
36
- Instruction *previous;
37
- if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
38
- if (fs->pc == 0) { /* function start? */
39
- if (from >= fs->nactvar)
40
- return; /* positions are already clean */
41
- }
42
- else {
43
- previous = &fs->f->code[fs->pc-1];
44
- if (GET_OPCODE(*previous) == OP_LOADNIL) {
45
- int pfrom = GETARG_A(*previous);
46
- int pto = GETARG_B(*previous);
47
- if (pfrom <= from && from <= pto+1) { /* can connect both? */
48
- if (from+n-1 > pto)
49
- SETARG_B(*previous, from+n-1);
50
- return;
51
- }
52
- }
53
- }
54
- }
55
- luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */
56
- }
57
-
58
-
59
- int luaK_jump (FuncState *fs) {
60
- int jpc = fs->jpc; /* save list of jumps to here */
61
- int j;
62
- fs->jpc = NO_JUMP;
63
- j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
64
- luaK_concat(fs, &j, jpc); /* keep them on hold */
65
- return j;
66
- }
67
-
68
-
69
- void luaK_ret (FuncState *fs, int first, int nret) {
70
- luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
71
- }
72
-
73
-
74
- static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
75
- luaK_codeABC(fs, op, A, B, C);
76
- return luaK_jump(fs);
77
- }
78
-
79
-
80
- static void fixjump (FuncState *fs, int pc, int dest) {
81
- Instruction *jmp = &fs->f->code[pc];
82
- int offset = dest-(pc+1);
83
- lua_assert(dest != NO_JUMP);
84
- if (abs(offset) > MAXARG_sBx)
85
- luaX_syntaxerror(fs->ls, "control structure too long");
86
- SETARG_sBx(*jmp, offset);
87
- }
88
-
89
-
90
- /*
91
- ** returns current `pc' and marks it as a jump target (to avoid wrong
92
- ** optimizations with consecutive instructions not in the same basic block).
93
- */
94
- int luaK_getlabel (FuncState *fs) {
95
- fs->lasttarget = fs->pc;
96
- return fs->pc;
97
- }
98
-
99
-
100
- static int getjump (FuncState *fs, int pc) {
101
- int offset = GETARG_sBx(fs->f->code[pc]);
102
- if (offset == NO_JUMP) /* point to itself represents end of list */
103
- return NO_JUMP; /* end of list */
104
- else
105
- return (pc+1)+offset; /* turn offset into absolute position */
106
- }
107
-
108
-
109
- static Instruction *getjumpcontrol (FuncState *fs, int pc) {
110
- Instruction *pi = &fs->f->code[pc];
111
- if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
112
- return pi-1;
113
- else
114
- return pi;
115
- }
116
-
117
-
118
- /*
119
- ** check whether list has any jump that do not produce a value
120
- ** (or produce an inverted value)
121
- */
122
- static int need_value (FuncState *fs, int list) {
123
- for (; list != NO_JUMP; list = getjump(fs, list)) {
124
- Instruction i = *getjumpcontrol(fs, list);
125
- if (GET_OPCODE(i) != OP_TESTSET) return 1;
126
- }
127
- return 0; /* not found */
128
- }
129
-
130
-
131
- static int patchtestreg (FuncState *fs, int node, int reg) {
132
- Instruction *i = getjumpcontrol(fs, node);
133
- if (GET_OPCODE(*i) != OP_TESTSET)
134
- return 0; /* cannot patch other instructions */
135
- if (reg != NO_REG && reg != GETARG_B(*i))
136
- SETARG_A(*i, reg);
137
- else /* no register to put value or register already has the value */
138
- *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
139
-
140
- return 1;
141
- }
142
-
143
-
144
- static void removevalues (FuncState *fs, int list) {
145
- for (; list != NO_JUMP; list = getjump(fs, list))
146
- patchtestreg(fs, list, NO_REG);
147
- }
148
-
149
-
150
- static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
151
- int dtarget) {
152
- while (list != NO_JUMP) {
153
- int next = getjump(fs, list);
154
- if (patchtestreg(fs, list, reg))
155
- fixjump(fs, list, vtarget);
156
- else
157
- fixjump(fs, list, dtarget); /* jump to default target */
158
- list = next;
159
- }
160
- }
161
-
162
-
163
- static void dischargejpc (FuncState *fs) {
164
- patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
165
- fs->jpc = NO_JUMP;
166
- }
167
-
168
-
169
- void luaK_patchlist (FuncState *fs, int list, int target) {
170
- if (target == fs->pc)
171
- luaK_patchtohere(fs, list);
172
- else {
173
- lua_assert(target < fs->pc);
174
- patchlistaux(fs, list, target, NO_REG, target);
175
- }
176
- }
177
-
178
-
179
- void luaK_patchtohere (FuncState *fs, int list) {
180
- luaK_getlabel(fs);
181
- luaK_concat(fs, &fs->jpc, list);
182
- }
183
-
184
-
185
- void luaK_concat (FuncState *fs, int *l1, int l2) {
186
- if (l2 == NO_JUMP) return;
187
- else if (*l1 == NO_JUMP)
188
- *l1 = l2;
189
- else {
190
- int list = *l1;
191
- int next;
192
- while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */
193
- list = next;
194
- fixjump(fs, list, l2);
195
- }
196
- }
197
-
198
-
199
- void luaK_checkstack (FuncState *fs, int n) {
200
- int newstack = fs->freereg + n;
201
- if (newstack > fs->f->maxstacksize) {
202
- if (newstack >= MAXSTACK)
203
- luaX_syntaxerror(fs->ls, "function or expression too complex");
204
- fs->f->maxstacksize = cast_byte(newstack);
205
- }
206
- }
207
-
208
-
209
- void luaK_reserveregs (FuncState *fs, int n) {
210
- luaK_checkstack(fs, n);
211
- fs->freereg += n;
212
- }
213
-
214
-
215
- static void freereg (FuncState *fs, int reg) {
216
- if (!ISK(reg) && reg >= fs->nactvar) {
217
- fs->freereg--;
218
- lua_assert(reg == fs->freereg);
219
- }
220
- }
221
-
222
-
223
- static void freeexp (FuncState *fs, expdesc *e) {
224
- if (e->k == VNONRELOC)
225
- freereg(fs, e->u.s.info);
226
- }
227
-
228
-
229
- static int addk (FuncState *fs, TValue *k, TValue *v) {
230
- lua_State *L = fs->L;
231
- TValue *idx = luaH_set(L, fs->h, k);
232
- Proto *f = fs->f;
233
- int oldsize = f->sizek;
234
- if (ttisnumber(idx)) {
235
- lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
236
- return cast_int(nvalue(idx));
237
- }
238
- else { /* constant not found; create a new entry */
239
- setnvalue(idx, cast_num(fs->nk));
240
- luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
241
- MAXARG_Bx, "constant table overflow");
242
- while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
243
- setobj(L, &f->k[fs->nk], v);
244
- luaC_barrier(L, f, v);
245
- return fs->nk++;
246
- }
247
- }
248
-
249
-
250
- int luaK_stringK (FuncState *fs, TString *s) {
251
- TValue o;
252
- setsvalue(fs->L, &o, s);
253
- return addk(fs, &o, &o);
254
- }
255
-
256
-
257
- int luaK_numberK (FuncState *fs, lua_Number r) {
258
- TValue o;
259
- setnvalue(&o, r);
260
- return addk(fs, &o, &o);
261
- }
262
-
263
-
264
- static int boolK (FuncState *fs, int b) {
265
- TValue o;
266
- setbvalue(&o, b);
267
- return addk(fs, &o, &o);
268
- }
269
-
270
-
271
- static int nilK (FuncState *fs) {
272
- TValue k, v;
273
- setnilvalue(&v);
274
- /* cannot use nil as key; instead use table itself to represent nil */
275
- sethvalue(fs->L, &k, fs->h);
276
- return addk(fs, &k, &v);
277
- }
278
-
279
-
280
- void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
281
- if (e->k == VCALL) { /* expression is an open function call? */
282
- SETARG_C(getcode(fs, e), nresults+1);
283
- }
284
- else if (e->k == VVARARG) {
285
- SETARG_B(getcode(fs, e), nresults+1);
286
- SETARG_A(getcode(fs, e), fs->freereg);
287
- luaK_reserveregs(fs, 1);
288
- }
289
- }
290
-
291
-
292
- void luaK_setoneret (FuncState *fs, expdesc *e) {
293
- if (e->k == VCALL) { /* expression is an open function call? */
294
- e->k = VNONRELOC;
295
- e->u.s.info = GETARG_A(getcode(fs, e));
296
- }
297
- else if (e->k == VVARARG) {
298
- SETARG_B(getcode(fs, e), 2);
299
- e->k = VRELOCABLE; /* can relocate its simple result */
300
- }
301
- }
302
-
303
-
304
- void luaK_dischargevars (FuncState *fs, expdesc *e) {
305
- switch (e->k) {
306
- case VLOCAL: {
307
- e->k = VNONRELOC;
308
- break;
309
- }
310
- case VUPVAL: {
311
- e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0);
312
- e->k = VRELOCABLE;
313
- break;
314
- }
315
- case VGLOBAL: {
316
- e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info);
317
- e->k = VRELOCABLE;
318
- break;
319
- }
320
- case VINDEXED: {
321
- freereg(fs, e->u.s.aux);
322
- freereg(fs, e->u.s.info);
323
- e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux);
324
- e->k = VRELOCABLE;
325
- break;
326
- }
327
- case VVARARG:
328
- case VCALL: {
329
- luaK_setoneret(fs, e);
330
- break;
331
- }
332
- default: break; /* there is one value available (somewhere) */
333
- }
334
- }
335
-
336
-
337
- static int code_label (FuncState *fs, int A, int b, int jump) {
338
- luaK_getlabel(fs); /* those instructions may be jump targets */
339
- return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
340
- }
341
-
342
-
343
- static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
344
- luaK_dischargevars(fs, e);
345
- switch (e->k) {
346
- case VNIL: {
347
- luaK_nil(fs, reg, 1);
348
- break;
349
- }
350
- case VFALSE: case VTRUE: {
351
- luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0);
352
- break;
353
- }
354
- case VK: {
355
- luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info);
356
- break;
357
- }
358
- case VKNUM: {
359
- luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
360
- break;
361
- }
362
- case VRELOCABLE: {
363
- Instruction *pc = &getcode(fs, e);
364
- SETARG_A(*pc, reg);
365
- break;
366
- }
367
- case VNONRELOC: {
368
- if (reg != e->u.s.info)
369
- luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0);
370
- break;
371
- }
372
- default: {
373
- lua_assert(e->k == VVOID || e->k == VJMP);
374
- return; /* nothing to do... */
375
- }
376
- }
377
- e->u.s.info = reg;
378
- e->k = VNONRELOC;
379
- }
380
-
381
-
382
- static void discharge2anyreg (FuncState *fs, expdesc *e) {
383
- if (e->k != VNONRELOC) {
384
- luaK_reserveregs(fs, 1);
385
- discharge2reg(fs, e, fs->freereg-1);
386
- }
387
- }
388
-
389
-
390
- static void exp2reg (FuncState *fs, expdesc *e, int reg) {
391
- discharge2reg(fs, e, reg);
392
- if (e->k == VJMP)
393
- luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */
394
- if (hasjumps(e)) {
395
- int final; /* position after whole expression */
396
- int p_f = NO_JUMP; /* position of an eventual LOAD false */
397
- int p_t = NO_JUMP; /* position of an eventual LOAD true */
398
- if (need_value(fs, e->t) || need_value(fs, e->f)) {
399
- int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
400
- p_f = code_label(fs, reg, 0, 1);
401
- p_t = code_label(fs, reg, 1, 0);
402
- luaK_patchtohere(fs, fj);
403
- }
404
- final = luaK_getlabel(fs);
405
- patchlistaux(fs, e->f, final, reg, p_f);
406
- patchlistaux(fs, e->t, final, reg, p_t);
407
- }
408
- e->f = e->t = NO_JUMP;
409
- e->u.s.info = reg;
410
- e->k = VNONRELOC;
411
- }
412
-
413
-
414
- void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
415
- luaK_dischargevars(fs, e);
416
- freeexp(fs, e);
417
- luaK_reserveregs(fs, 1);
418
- exp2reg(fs, e, fs->freereg - 1);
419
- }
420
-
421
-
422
- int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
423
- luaK_dischargevars(fs, e);
424
- if (e->k == VNONRELOC) {
425
- if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */
426
- if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */
427
- exp2reg(fs, e, e->u.s.info); /* put value on it */
428
- return e->u.s.info;
429
- }
430
- }
431
- luaK_exp2nextreg(fs, e); /* default */
432
- return e->u.s.info;
433
- }
434
-
435
-
436
- void luaK_exp2val (FuncState *fs, expdesc *e) {
437
- if (hasjumps(e))
438
- luaK_exp2anyreg(fs, e);
439
- else
440
- luaK_dischargevars(fs, e);
441
- }
442
-
443
-
444
- int luaK_exp2RK (FuncState *fs, expdesc *e) {
445
- luaK_exp2val(fs, e);
446
- switch (e->k) {
447
- case VKNUM:
448
- case VTRUE:
449
- case VFALSE:
450
- case VNIL: {
451
- if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */
452
- e->u.s.info = (e->k == VNIL) ? nilK(fs) :
453
- (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
454
- boolK(fs, (e->k == VTRUE));
455
- e->k = VK;
456
- return RKASK(e->u.s.info);
457
- }
458
- else break;
459
- }
460
- case VK: {
461
- if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */
462
- return RKASK(e->u.s.info);
463
- else break;
464
- }
465
- default: break;
466
- }
467
- /* not a constant in the right range: put it in a register */
468
- return luaK_exp2anyreg(fs, e);
469
- }
470
-
471
-
472
- void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
473
- switch (var->k) {
474
- case VLOCAL: {
475
- freeexp(fs, ex);
476
- exp2reg(fs, ex, var->u.s.info);
477
- return;
478
- }
479
- case VUPVAL: {
480
- int e = luaK_exp2anyreg(fs, ex);
481
- luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0);
482
- break;
483
- }
484
- case VGLOBAL: {
485
- int e = luaK_exp2anyreg(fs, ex);
486
- luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info);
487
- break;
488
- }
489
- case VINDEXED: {
490
- int e = luaK_exp2RK(fs, ex);
491
- luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e);
492
- break;
493
- }
494
- default: {
495
- lua_assert(0); /* invalid var kind to store */
496
- break;
497
- }
498
- }
499
- freeexp(fs, ex);
500
- }
501
-
502
-
503
- void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
504
- int func;
505
- luaK_exp2anyreg(fs, e);
506
- freeexp(fs, e);
507
- func = fs->freereg;
508
- luaK_reserveregs(fs, 2);
509
- luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key));
510
- freeexp(fs, key);
511
- e->u.s.info = func;
512
- e->k = VNONRELOC;
513
- }
514
-
515
-
516
- static void invertjump (FuncState *fs, expdesc *e) {
517
- Instruction *pc = getjumpcontrol(fs, e->u.s.info);
518
- lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
519
- GET_OPCODE(*pc) != OP_TEST);
520
- SETARG_A(*pc, !(GETARG_A(*pc)));
521
- }
522
-
523
-
524
- static int jumponcond (FuncState *fs, expdesc *e, int cond) {
525
- if (e->k == VRELOCABLE) {
526
- Instruction ie = getcode(fs, e);
527
- if (GET_OPCODE(ie) == OP_NOT) {
528
- fs->pc--; /* remove previous OP_NOT */
529
- return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond);
530
- }
531
- /* else go through */
532
- }
533
- discharge2anyreg(fs, e);
534
- freeexp(fs, e);
535
- return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond);
536
- }
537
-
538
-
539
- void luaK_goiftrue (FuncState *fs, expdesc *e) {
540
- int pc; /* pc of last jump */
541
- luaK_dischargevars(fs, e);
542
- switch (e->k) {
543
- case VK: case VKNUM: case VTRUE: {
544
- pc = NO_JUMP; /* always true; do nothing */
545
- break;
546
- }
547
- case VJMP: {
548
- invertjump(fs, e);
549
- pc = e->u.s.info;
550
- break;
551
- }
552
- default: {
553
- pc = jumponcond(fs, e, 0);
554
- break;
555
- }
556
- }
557
- luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */
558
- luaK_patchtohere(fs, e->t);
559
- e->t = NO_JUMP;
560
- }
561
-
562
-
563
- static void luaK_goiffalse (FuncState *fs, expdesc *e) {
564
- int pc; /* pc of last jump */
565
- luaK_dischargevars(fs, e);
566
- switch (e->k) {
567
- case VNIL: case VFALSE: {
568
- pc = NO_JUMP; /* always false; do nothing */
569
- break;
570
- }
571
- case VJMP: {
572
- pc = e->u.s.info;
573
- break;
574
- }
575
- default: {
576
- pc = jumponcond(fs, e, 1);
577
- break;
578
- }
579
- }
580
- luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */
581
- luaK_patchtohere(fs, e->f);
582
- e->f = NO_JUMP;
583
- }
584
-
585
-
586
- static void codenot (FuncState *fs, expdesc *e) {
587
- luaK_dischargevars(fs, e);
588
- switch (e->k) {
589
- case VNIL: case VFALSE: {
590
- e->k = VTRUE;
591
- break;
592
- }
593
- case VK: case VKNUM: case VTRUE: {
594
- e->k = VFALSE;
595
- break;
596
- }
597
- case VJMP: {
598
- invertjump(fs, e);
599
- break;
600
- }
601
- case VRELOCABLE:
602
- case VNONRELOC: {
603
- discharge2anyreg(fs, e);
604
- freeexp(fs, e);
605
- e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0);
606
- e->k = VRELOCABLE;
607
- break;
608
- }
609
- default: {
610
- lua_assert(0); /* cannot happen */
611
- break;
612
- }
613
- }
614
- /* interchange true and false lists */
615
- { int temp = e->f; e->f = e->t; e->t = temp; }
616
- removevalues(fs, e->f);
617
- removevalues(fs, e->t);
618
- }
619
-
620
-
621
- void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
622
- t->u.s.aux = luaK_exp2RK(fs, k);
623
- t->k = VINDEXED;
624
- }
625
-
626
-
627
- static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
628
- lua_Number v1, v2, r;
629
- if (!isnumeral(e1) || !isnumeral(e2)) return 0;
630
- v1 = e1->u.nval;
631
- v2 = e2->u.nval;
632
- switch (op) {
633
- case OP_ADD: r = luai_numadd(v1, v2); break;
634
- case OP_SUB: r = luai_numsub(v1, v2); break;
635
- case OP_MUL: r = luai_nummul(v1, v2); break;
636
- case OP_DIV:
637
- if (v2 == 0) return 0; /* do not attempt to divide by 0 */
638
- r = luai_numdiv(v1, v2); break;
639
- case OP_MOD:
640
- if (v2 == 0) return 0; /* do not attempt to divide by 0 */
641
- r = luai_nummod(v1, v2); break;
642
- case OP_POW: r = luai_numpow(v1, v2); break;
643
- case OP_UNM: r = luai_numunm(v1); break;
644
- case OP_LEN: return 0; /* no constant folding for 'len' */
645
- default: lua_assert(0); r = 0; break;
646
- }
647
- if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */
648
- e1->u.nval = r;
649
- return 1;
650
- }
651
-
652
-
653
- static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
654
- if (constfolding(op, e1, e2))
655
- return;
656
- else {
657
- int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
658
- int o1 = luaK_exp2RK(fs, e1);
659
- if (o1 > o2) {
660
- freeexp(fs, e1);
661
- freeexp(fs, e2);
662
- }
663
- else {
664
- freeexp(fs, e2);
665
- freeexp(fs, e1);
666
- }
667
- e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2);
668
- e1->k = VRELOCABLE;
669
- }
670
- }
671
-
672
-
673
- static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
674
- expdesc *e2) {
675
- int o1 = luaK_exp2RK(fs, e1);
676
- int o2 = luaK_exp2RK(fs, e2);
677
- freeexp(fs, e2);
678
- freeexp(fs, e1);
679
- if (cond == 0 && op != OP_EQ) {
680
- int temp; /* exchange args to replace by `<' or `<=' */
681
- temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */
682
- cond = 1;
683
- }
684
- e1->u.s.info = condjump(fs, op, cond, o1, o2);
685
- e1->k = VJMP;
686
- }
687
-
688
-
689
- void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
690
- expdesc e2;
691
- e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
692
- switch (op) {
693
- case OPR_MINUS: {
694
- if (!isnumeral(e))
695
- luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
696
- codearith(fs, OP_UNM, e, &e2);
697
- break;
698
- }
699
- case OPR_NOT: codenot(fs, e); break;
700
- case OPR_LEN: {
701
- luaK_exp2anyreg(fs, e); /* cannot operate on constants */
702
- codearith(fs, OP_LEN, e, &e2);
703
- break;
704
- }
705
- default: lua_assert(0);
706
- }
707
- }
708
-
709
-
710
- void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
711
- switch (op) {
712
- case OPR_AND: {
713
- luaK_goiftrue(fs, v);
714
- break;
715
- }
716
- case OPR_OR: {
717
- luaK_goiffalse(fs, v);
718
- break;
719
- }
720
- case OPR_CONCAT: {
721
- luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */
722
- break;
723
- }
724
- case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
725
- case OPR_MOD: case OPR_POW: {
726
- if (!isnumeral(v)) luaK_exp2RK(fs, v);
727
- break;
728
- }
729
- default: {
730
- luaK_exp2RK(fs, v);
731
- break;
732
- }
733
- }
734
- }
735
-
736
-
737
- void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
738
- switch (op) {
739
- case OPR_AND: {
740
- lua_assert(e1->t == NO_JUMP); /* list must be closed */
741
- luaK_dischargevars(fs, e2);
742
- luaK_concat(fs, &e2->f, e1->f);
743
- *e1 = *e2;
744
- break;
745
- }
746
- case OPR_OR: {
747
- lua_assert(e1->f == NO_JUMP); /* list must be closed */
748
- luaK_dischargevars(fs, e2);
749
- luaK_concat(fs, &e2->t, e1->t);
750
- *e1 = *e2;
751
- break;
752
- }
753
- case OPR_CONCAT: {
754
- luaK_exp2val(fs, e2);
755
- if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) {
756
- lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1);
757
- freeexp(fs, e1);
758
- SETARG_B(getcode(fs, e2), e1->u.s.info);
759
- e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info;
760
- }
761
- else {
762
- luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */
763
- codearith(fs, OP_CONCAT, e1, e2);
764
- }
765
- break;
766
- }
767
- case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break;
768
- case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break;
769
- case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break;
770
- case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break;
771
- case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break;
772
- case OPR_POW: codearith(fs, OP_POW, e1, e2); break;
773
- case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break;
774
- case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break;
775
- case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break;
776
- case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break;
777
- case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break;
778
- case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break;
779
- default: lua_assert(0);
780
- }
781
- }
782
-
783
-
784
- void luaK_fixline (FuncState *fs, int line) {
785
- fs->f->lineinfo[fs->pc - 1] = line;
786
- }
787
-
788
-
789
- static int luaK_code (FuncState *fs, Instruction i, int line) {
790
- Proto *f = fs->f;
791
- dischargejpc(fs); /* `pc' will change */
792
- /* put new instruction in code array */
793
- luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction,
794
- MAX_INT, "code size overflow");
795
- f->code[fs->pc] = i;
796
- /* save corresponding line information */
797
- luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int,
798
- MAX_INT, "code size overflow");
799
- f->lineinfo[fs->pc] = line;
800
- return fs->pc++;
801
- }
802
-
803
-
804
- int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
805
- lua_assert(getOpMode(o) == iABC);
806
- lua_assert(getBMode(o) != OpArgN || b == 0);
807
- lua_assert(getCMode(o) != OpArgN || c == 0);
808
- return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline);
809
- }
810
-
811
-
812
- int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
813
- lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
814
- lua_assert(getCMode(o) == OpArgN);
815
- return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
816
- }
817
-
818
-
819
- void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
820
- int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
821
- int b = (tostore == LUA_MULTRET) ? 0 : tostore;
822
- lua_assert(tostore != 0);
823
- if (c <= MAXARG_C)
824
- luaK_codeABC(fs, OP_SETLIST, base, b, c);
825
- else {
826
- luaK_codeABC(fs, OP_SETLIST, base, b, 0);
827
- luaK_code(fs, cast(Instruction, c), fs->ls->lastline);
828
- }
829
- fs->freereg = base + 1; /* free registers with list values */
830
- }
831
-