immunio 0.15.4 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (454) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +0 -27
  3. data/ext/immunio/Rakefile +9 -0
  4. data/lib/immunio/plugins/active_record.rb +1 -1
  5. data/lib/immunio/plugins/active_record_relation.rb +1 -1
  6. data/lib/immunio/plugins/environment_reporter.rb +20 -0
  7. data/lib/immunio/rufus_lua_ext/ref.rb +1 -3
  8. data/lib/immunio/version.rb +1 -1
  9. data/lib/immunio/vm.rb +1 -2
  10. data/lua-hooks/Makefile +97 -0
  11. data/lua-hooks/ext/all.c +41 -52
  12. data/lua-hooks/ext/all.o +0 -0
  13. data/lua-hooks/ext/libinjection/libinjection_html5.o +0 -0
  14. data/lua-hooks/ext/libinjection/libinjection_sqli.o +0 -0
  15. data/lua-hooks/ext/libinjection/libinjection_xss.o +0 -0
  16. data/lua-hooks/ext/libinjection/lualib.c +2 -2
  17. data/lua-hooks/ext/lpeg/lpcap.c +2 -2
  18. data/lua-hooks/ext/lpeg/lpcap.o +0 -0
  19. data/lua-hooks/ext/lpeg/lpcode.c +2 -2
  20. data/lua-hooks/ext/lpeg/lpcode.h +1 -1
  21. data/lua-hooks/ext/lpeg/lpcode.o +0 -0
  22. data/lua-hooks/ext/lpeg/lpprint.o +0 -0
  23. data/lua-hooks/ext/lpeg/lptree.c +2 -2
  24. data/lua-hooks/ext/lpeg/lptypes.h +1 -1
  25. data/lua-hooks/ext/lpeg/lpvm.c +2 -2
  26. data/lua-hooks/ext/lpeg/lpvm.o +0 -0
  27. data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +16 -3
  28. data/lua-hooks/ext/lua-snapshot/snapshot.c +14 -7
  29. data/lua-hooks/ext/luajit/COPYRIGHT +56 -0
  30. data/lua-hooks/ext/luajit/Makefile +159 -0
  31. data/lua-hooks/ext/luajit/README +16 -0
  32. data/lua-hooks/ext/luajit/doc/bluequad-print.css +166 -0
  33. data/lua-hooks/ext/luajit/doc/bluequad.css +325 -0
  34. data/lua-hooks/ext/luajit/doc/changes.html +804 -0
  35. data/lua-hooks/ext/luajit/doc/contact.html +104 -0
  36. data/lua-hooks/ext/luajit/doc/ext_c_api.html +189 -0
  37. data/lua-hooks/ext/luajit/doc/ext_ffi.html +332 -0
  38. data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +570 -0
  39. data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +1261 -0
  40. data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +603 -0
  41. data/lua-hooks/ext/luajit/doc/ext_jit.html +201 -0
  42. data/lua-hooks/ext/luajit/doc/ext_profiler.html +365 -0
  43. data/lua-hooks/ext/luajit/doc/extensions.html +448 -0
  44. data/lua-hooks/ext/luajit/doc/faq.html +186 -0
  45. data/lua-hooks/ext/luajit/doc/img/contact.png +0 -0
  46. data/lua-hooks/ext/luajit/doc/install.html +659 -0
  47. data/lua-hooks/ext/luajit/doc/luajit.html +236 -0
  48. data/lua-hooks/ext/luajit/doc/running.html +309 -0
  49. data/lua-hooks/ext/luajit/doc/status.html +118 -0
  50. data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +456 -0
  51. data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +1125 -0
  52. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +518 -0
  53. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +1166 -0
  54. data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +416 -0
  55. data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +953 -0
  56. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +419 -0
  57. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +1919 -0
  58. data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +83 -0
  59. data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +12 -0
  60. data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +471 -0
  61. data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +1945 -0
  62. data/lua-hooks/ext/luajit/dynasm/dynasm.lua +1094 -0
  63. data/lua-hooks/ext/luajit/etc/luajit.1 +88 -0
  64. data/lua-hooks/ext/luajit/etc/luajit.pc +25 -0
  65. data/lua-hooks/ext/luajit/src/Makefile +697 -0
  66. data/lua-hooks/ext/luajit/src/Makefile.dep +244 -0
  67. data/lua-hooks/ext/luajit/src/host/README +4 -0
  68. data/lua-hooks/ext/luajit/src/host/buildvm +0 -0
  69. data/lua-hooks/ext/luajit/src/host/buildvm.c +518 -0
  70. data/lua-hooks/ext/luajit/src/host/buildvm.h +105 -0
  71. data/lua-hooks/ext/luajit/src/host/buildvm.o +0 -0
  72. data/lua-hooks/ext/luajit/src/host/buildvm_arch.h +7449 -0
  73. data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +345 -0
  74. data/lua-hooks/ext/luajit/src/host/buildvm_asm.o +0 -0
  75. data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +229 -0
  76. data/lua-hooks/ext/luajit/src/host/buildvm_fold.o +0 -0
  77. data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +457 -0
  78. data/lua-hooks/ext/luajit/src/host/buildvm_lib.o +0 -0
  79. data/lua-hooks/ext/luajit/src/host/buildvm_libbc.h +45 -0
  80. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +368 -0
  81. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.o +0 -0
  82. data/lua-hooks/ext/luajit/src/host/genlibbc.lua +197 -0
  83. data/lua-hooks/ext/luajit/src/host/genminilua.lua +428 -0
  84. data/lua-hooks/ext/luajit/src/host/minilua +0 -0
  85. data/lua-hooks/ext/luajit/src/host/minilua.c +7770 -0
  86. data/lua-hooks/ext/luajit/src/host/minilua.o +0 -0
  87. data/lua-hooks/ext/luajit/src/jit/bc.lua +190 -0
  88. data/lua-hooks/ext/luajit/src/jit/bcsave.lua +661 -0
  89. data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +689 -0
  90. data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +428 -0
  91. data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +17 -0
  92. data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +591 -0
  93. data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +17 -0
  94. data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +838 -0
  95. data/lua-hooks/ext/luajit/src/jit/dump.lua +706 -0
  96. data/lua-hooks/ext/luajit/src/jit/p.lua +310 -0
  97. data/lua-hooks/ext/luajit/src/jit/v.lua +170 -0
  98. data/lua-hooks/ext/luajit/src/jit/vmdef.lua +362 -0
  99. data/lua-hooks/ext/luajit/src/jit/zone.lua +45 -0
  100. data/lua-hooks/ext/{lua → luajit/src}/lauxlib.h +10 -17
  101. data/lua-hooks/ext/luajit/src/lib_aux.c +356 -0
  102. data/lua-hooks/ext/luajit/src/lib_aux.o +0 -0
  103. data/lua-hooks/ext/luajit/src/lib_aux_dyn.o +0 -0
  104. data/lua-hooks/ext/luajit/src/lib_base.c +664 -0
  105. data/lua-hooks/ext/luajit/src/lib_base.o +0 -0
  106. data/lua-hooks/ext/luajit/src/lib_base_dyn.o +0 -0
  107. data/lua-hooks/ext/luajit/src/lib_bit.c +180 -0
  108. data/lua-hooks/ext/luajit/src/lib_bit.o +0 -0
  109. data/lua-hooks/ext/luajit/src/lib_bit_dyn.o +0 -0
  110. data/lua-hooks/ext/luajit/src/lib_debug.c +405 -0
  111. data/lua-hooks/ext/luajit/src/lib_debug.o +0 -0
  112. data/lua-hooks/ext/luajit/src/lib_debug_dyn.o +0 -0
  113. data/lua-hooks/ext/luajit/src/lib_ffi.c +872 -0
  114. data/lua-hooks/ext/luajit/src/lib_ffi.o +0 -0
  115. data/lua-hooks/ext/luajit/src/lib_ffi_dyn.o +0 -0
  116. data/lua-hooks/ext/luajit/src/lib_init.c +55 -0
  117. data/lua-hooks/ext/luajit/src/lib_init.o +0 -0
  118. data/lua-hooks/ext/luajit/src/lib_init_dyn.o +0 -0
  119. data/lua-hooks/ext/luajit/src/lib_io.c +541 -0
  120. data/lua-hooks/ext/luajit/src/lib_io.o +0 -0
  121. data/lua-hooks/ext/luajit/src/lib_io_dyn.o +0 -0
  122. data/lua-hooks/ext/luajit/src/lib_jit.c +767 -0
  123. data/lua-hooks/ext/luajit/src/lib_jit.o +0 -0
  124. data/lua-hooks/ext/luajit/src/lib_jit_dyn.o +0 -0
  125. data/lua-hooks/ext/luajit/src/lib_math.c +230 -0
  126. data/lua-hooks/ext/luajit/src/lib_math.o +0 -0
  127. data/lua-hooks/ext/luajit/src/lib_math_dyn.o +0 -0
  128. data/lua-hooks/ext/luajit/src/lib_os.c +292 -0
  129. data/lua-hooks/ext/luajit/src/lib_os.o +0 -0
  130. data/lua-hooks/ext/luajit/src/lib_os_dyn.o +0 -0
  131. data/lua-hooks/ext/luajit/src/lib_package.c +610 -0
  132. data/lua-hooks/ext/luajit/src/lib_package.o +0 -0
  133. data/lua-hooks/ext/luajit/src/lib_package_dyn.o +0 -0
  134. data/lua-hooks/ext/luajit/src/lib_string.c +752 -0
  135. data/lua-hooks/ext/luajit/src/lib_string.o +0 -0
  136. data/lua-hooks/ext/luajit/src/lib_string_dyn.o +0 -0
  137. data/lua-hooks/ext/luajit/src/lib_table.c +307 -0
  138. data/lua-hooks/ext/luajit/src/lib_table.o +0 -0
  139. data/lua-hooks/ext/luajit/src/lib_table_dyn.o +0 -0
  140. data/lua-hooks/ext/luajit/src/libluajit.a +0 -0
  141. data/lua-hooks/ext/luajit/src/libluajit.so +0 -0
  142. data/lua-hooks/ext/luajit/src/lj.supp +26 -0
  143. data/lua-hooks/ext/luajit/src/lj_alloc.c +1398 -0
  144. data/lua-hooks/ext/luajit/src/lj_alloc.h +17 -0
  145. data/lua-hooks/ext/luajit/src/lj_alloc.o +0 -0
  146. data/lua-hooks/ext/luajit/src/lj_alloc_dyn.o +0 -0
  147. data/lua-hooks/ext/luajit/src/lj_api.c +1210 -0
  148. data/lua-hooks/ext/luajit/src/lj_api.o +0 -0
  149. data/lua-hooks/ext/luajit/src/lj_api_dyn.o +0 -0
  150. data/lua-hooks/ext/luajit/src/lj_arch.h +509 -0
  151. data/lua-hooks/ext/luajit/src/lj_asm.c +2278 -0
  152. data/lua-hooks/ext/luajit/src/lj_asm.h +17 -0
  153. data/lua-hooks/ext/luajit/src/lj_asm.o +0 -0
  154. data/lua-hooks/ext/luajit/src/lj_asm_arm.h +2217 -0
  155. data/lua-hooks/ext/luajit/src/lj_asm_dyn.o +0 -0
  156. data/lua-hooks/ext/luajit/src/lj_asm_mips.h +1833 -0
  157. data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +2015 -0
  158. data/lua-hooks/ext/luajit/src/lj_asm_x86.h +2634 -0
  159. data/lua-hooks/ext/luajit/src/lj_bc.c +14 -0
  160. data/lua-hooks/ext/luajit/src/lj_bc.h +265 -0
  161. data/lua-hooks/ext/luajit/src/lj_bc.o +0 -0
  162. data/lua-hooks/ext/luajit/src/lj_bc_dyn.o +0 -0
  163. data/lua-hooks/ext/luajit/src/lj_bcdef.h +220 -0
  164. data/lua-hooks/ext/luajit/src/lj_bcdump.h +68 -0
  165. data/lua-hooks/ext/luajit/src/lj_bcread.c +457 -0
  166. data/lua-hooks/ext/luajit/src/lj_bcread.o +0 -0
  167. data/lua-hooks/ext/luajit/src/lj_bcread_dyn.o +0 -0
  168. data/lua-hooks/ext/luajit/src/lj_bcwrite.c +361 -0
  169. data/lua-hooks/ext/luajit/src/lj_bcwrite.o +0 -0
  170. data/lua-hooks/ext/luajit/src/lj_bcwrite_dyn.o +0 -0
  171. data/lua-hooks/ext/luajit/src/lj_buf.c +234 -0
  172. data/lua-hooks/ext/luajit/src/lj_buf.h +105 -0
  173. data/lua-hooks/ext/luajit/src/lj_buf.o +0 -0
  174. data/lua-hooks/ext/luajit/src/lj_buf_dyn.o +0 -0
  175. data/lua-hooks/ext/luajit/src/lj_carith.c +429 -0
  176. data/lua-hooks/ext/luajit/src/lj_carith.h +37 -0
  177. data/lua-hooks/ext/luajit/src/lj_carith.o +0 -0
  178. data/lua-hooks/ext/luajit/src/lj_carith_dyn.o +0 -0
  179. data/lua-hooks/ext/luajit/src/lj_ccall.c +984 -0
  180. data/lua-hooks/ext/luajit/src/lj_ccall.h +178 -0
  181. data/lua-hooks/ext/luajit/src/lj_ccall.o +0 -0
  182. data/lua-hooks/ext/luajit/src/lj_ccall_dyn.o +0 -0
  183. data/lua-hooks/ext/luajit/src/lj_ccallback.c +712 -0
  184. data/lua-hooks/ext/luajit/src/lj_ccallback.h +25 -0
  185. data/lua-hooks/ext/luajit/src/lj_ccallback.o +0 -0
  186. data/lua-hooks/ext/luajit/src/lj_ccallback_dyn.o +0 -0
  187. data/lua-hooks/ext/luajit/src/lj_cconv.c +752 -0
  188. data/lua-hooks/ext/luajit/src/lj_cconv.h +70 -0
  189. data/lua-hooks/ext/luajit/src/lj_cconv.o +0 -0
  190. data/lua-hooks/ext/luajit/src/lj_cconv_dyn.o +0 -0
  191. data/lua-hooks/ext/luajit/src/lj_cdata.c +288 -0
  192. data/lua-hooks/ext/luajit/src/lj_cdata.h +76 -0
  193. data/lua-hooks/ext/luajit/src/lj_cdata.o +0 -0
  194. data/lua-hooks/ext/luajit/src/lj_cdata_dyn.o +0 -0
  195. data/lua-hooks/ext/luajit/src/lj_char.c +43 -0
  196. data/lua-hooks/ext/luajit/src/lj_char.h +42 -0
  197. data/lua-hooks/ext/luajit/src/lj_char.o +0 -0
  198. data/lua-hooks/ext/luajit/src/lj_char_dyn.o +0 -0
  199. data/lua-hooks/ext/luajit/src/lj_clib.c +418 -0
  200. data/lua-hooks/ext/luajit/src/lj_clib.h +29 -0
  201. data/lua-hooks/ext/luajit/src/lj_clib.o +0 -0
  202. data/lua-hooks/ext/luajit/src/lj_clib_dyn.o +0 -0
  203. data/lua-hooks/ext/luajit/src/lj_cparse.c +1862 -0
  204. data/lua-hooks/ext/luajit/src/lj_cparse.h +65 -0
  205. data/lua-hooks/ext/luajit/src/lj_cparse.o +0 -0
  206. data/lua-hooks/ext/luajit/src/lj_cparse_dyn.o +0 -0
  207. data/lua-hooks/ext/luajit/src/lj_crecord.c +1834 -0
  208. data/lua-hooks/ext/luajit/src/lj_crecord.h +38 -0
  209. data/lua-hooks/ext/luajit/src/lj_crecord.o +0 -0
  210. data/lua-hooks/ext/luajit/src/lj_crecord_dyn.o +0 -0
  211. data/lua-hooks/ext/luajit/src/lj_ctype.c +635 -0
  212. data/lua-hooks/ext/luajit/src/lj_ctype.h +461 -0
  213. data/lua-hooks/ext/luajit/src/lj_ctype.o +0 -0
  214. data/lua-hooks/ext/luajit/src/lj_ctype_dyn.o +0 -0
  215. data/lua-hooks/ext/luajit/src/lj_debug.c +699 -0
  216. data/lua-hooks/ext/luajit/src/lj_debug.h +65 -0
  217. data/lua-hooks/ext/luajit/src/lj_debug.o +0 -0
  218. data/lua-hooks/ext/luajit/src/lj_debug_dyn.o +0 -0
  219. data/lua-hooks/ext/luajit/src/lj_def.h +365 -0
  220. data/lua-hooks/ext/luajit/src/lj_dispatch.c +557 -0
  221. data/lua-hooks/ext/luajit/src/lj_dispatch.h +138 -0
  222. data/lua-hooks/ext/luajit/src/lj_dispatch.o +0 -0
  223. data/lua-hooks/ext/luajit/src/lj_dispatch_dyn.o +0 -0
  224. data/lua-hooks/ext/luajit/src/lj_emit_arm.h +356 -0
  225. data/lua-hooks/ext/luajit/src/lj_emit_mips.h +211 -0
  226. data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +238 -0
  227. data/lua-hooks/ext/luajit/src/lj_emit_x86.h +462 -0
  228. data/lua-hooks/ext/luajit/src/lj_err.c +794 -0
  229. data/lua-hooks/ext/luajit/src/lj_err.h +41 -0
  230. data/lua-hooks/ext/luajit/src/lj_err.o +0 -0
  231. data/lua-hooks/ext/luajit/src/lj_err_dyn.o +0 -0
  232. data/lua-hooks/ext/luajit/src/lj_errmsg.h +190 -0
  233. data/lua-hooks/ext/luajit/src/lj_ff.h +18 -0
  234. data/lua-hooks/ext/luajit/src/lj_ffdef.h +209 -0
  235. data/lua-hooks/ext/luajit/src/lj_ffrecord.c +1247 -0
  236. data/lua-hooks/ext/luajit/src/lj_ffrecord.h +24 -0
  237. data/lua-hooks/ext/luajit/src/lj_ffrecord.o +0 -0
  238. data/lua-hooks/ext/luajit/src/lj_ffrecord_dyn.o +0 -0
  239. data/lua-hooks/ext/luajit/src/lj_folddef.h +1138 -0
  240. data/lua-hooks/ext/luajit/src/lj_frame.h +259 -0
  241. data/lua-hooks/ext/luajit/src/lj_func.c +185 -0
  242. data/lua-hooks/ext/luajit/src/lj_func.h +24 -0
  243. data/lua-hooks/ext/luajit/src/lj_func.o +0 -0
  244. data/lua-hooks/ext/luajit/src/lj_func_dyn.o +0 -0
  245. data/lua-hooks/ext/luajit/src/lj_gc.c +845 -0
  246. data/lua-hooks/ext/luajit/src/lj_gc.h +134 -0
  247. data/lua-hooks/ext/luajit/src/lj_gc.o +0 -0
  248. data/lua-hooks/ext/luajit/src/lj_gc_dyn.o +0 -0
  249. data/lua-hooks/ext/luajit/src/lj_gdbjit.c +787 -0
  250. data/lua-hooks/ext/luajit/src/lj_gdbjit.h +22 -0
  251. data/lua-hooks/ext/luajit/src/lj_gdbjit.o +0 -0
  252. data/lua-hooks/ext/luajit/src/lj_gdbjit_dyn.o +0 -0
  253. data/lua-hooks/ext/luajit/src/lj_ir.c +505 -0
  254. data/lua-hooks/ext/luajit/src/lj_ir.h +577 -0
  255. data/lua-hooks/ext/luajit/src/lj_ir.o +0 -0
  256. data/lua-hooks/ext/luajit/src/lj_ir_dyn.o +0 -0
  257. data/lua-hooks/ext/luajit/src/lj_ircall.h +321 -0
  258. data/lua-hooks/ext/luajit/src/lj_iropt.h +161 -0
  259. data/lua-hooks/ext/luajit/src/lj_jit.h +440 -0
  260. data/lua-hooks/ext/luajit/src/lj_lex.c +482 -0
  261. data/lua-hooks/ext/luajit/src/lj_lex.h +86 -0
  262. data/lua-hooks/ext/luajit/src/lj_lex.o +0 -0
  263. data/lua-hooks/ext/luajit/src/lj_lex_dyn.o +0 -0
  264. data/lua-hooks/ext/luajit/src/lj_lib.c +303 -0
  265. data/lua-hooks/ext/luajit/src/lj_lib.h +115 -0
  266. data/lua-hooks/ext/luajit/src/lj_lib.o +0 -0
  267. data/lua-hooks/ext/luajit/src/lj_lib_dyn.o +0 -0
  268. data/lua-hooks/ext/luajit/src/lj_libdef.h +414 -0
  269. data/lua-hooks/ext/luajit/src/lj_load.c +168 -0
  270. data/lua-hooks/ext/luajit/src/lj_load.o +0 -0
  271. data/lua-hooks/ext/luajit/src/lj_load_dyn.o +0 -0
  272. data/lua-hooks/ext/luajit/src/lj_mcode.c +386 -0
  273. data/lua-hooks/ext/luajit/src/lj_mcode.h +30 -0
  274. data/lua-hooks/ext/luajit/src/lj_mcode.o +0 -0
  275. data/lua-hooks/ext/luajit/src/lj_mcode_dyn.o +0 -0
  276. data/lua-hooks/ext/luajit/src/lj_meta.c +477 -0
  277. data/lua-hooks/ext/luajit/src/lj_meta.h +38 -0
  278. data/lua-hooks/ext/luajit/src/lj_meta.o +0 -0
  279. data/lua-hooks/ext/luajit/src/lj_meta_dyn.o +0 -0
  280. data/lua-hooks/ext/luajit/src/lj_obj.c +50 -0
  281. data/lua-hooks/ext/luajit/src/lj_obj.h +976 -0
  282. data/lua-hooks/ext/luajit/src/lj_obj.o +0 -0
  283. data/lua-hooks/ext/luajit/src/lj_obj_dyn.o +0 -0
  284. data/lua-hooks/ext/luajit/src/lj_opt_dce.c +78 -0
  285. data/lua-hooks/ext/luajit/src/lj_opt_dce.o +0 -0
  286. data/lua-hooks/ext/luajit/src/lj_opt_dce_dyn.o +0 -0
  287. data/lua-hooks/ext/luajit/src/lj_opt_fold.c +2488 -0
  288. data/lua-hooks/ext/luajit/src/lj_opt_fold.o +0 -0
  289. data/lua-hooks/ext/luajit/src/lj_opt_fold_dyn.o +0 -0
  290. data/lua-hooks/ext/luajit/src/lj_opt_loop.c +449 -0
  291. data/lua-hooks/ext/luajit/src/lj_opt_loop.o +0 -0
  292. data/lua-hooks/ext/luajit/src/lj_opt_loop_dyn.o +0 -0
  293. data/lua-hooks/ext/luajit/src/lj_opt_mem.c +935 -0
  294. data/lua-hooks/ext/luajit/src/lj_opt_mem.o +0 -0
  295. data/lua-hooks/ext/luajit/src/lj_opt_mem_dyn.o +0 -0
  296. data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +652 -0
  297. data/lua-hooks/ext/luajit/src/lj_opt_narrow.o +0 -0
  298. data/lua-hooks/ext/luajit/src/lj_opt_narrow_dyn.o +0 -0
  299. data/lua-hooks/ext/luajit/src/lj_opt_sink.c +245 -0
  300. data/lua-hooks/ext/luajit/src/lj_opt_sink.o +0 -0
  301. data/lua-hooks/ext/luajit/src/lj_opt_sink_dyn.o +0 -0
  302. data/lua-hooks/ext/luajit/src/lj_opt_split.c +856 -0
  303. data/lua-hooks/ext/luajit/src/lj_opt_split.o +0 -0
  304. data/lua-hooks/ext/luajit/src/lj_opt_split_dyn.o +0 -0
  305. data/lua-hooks/ext/luajit/src/lj_parse.c +2725 -0
  306. data/lua-hooks/ext/luajit/src/lj_parse.h +18 -0
  307. data/lua-hooks/ext/luajit/src/lj_parse.o +0 -0
  308. data/lua-hooks/ext/luajit/src/lj_parse_dyn.o +0 -0
  309. data/lua-hooks/ext/luajit/src/lj_profile.c +368 -0
  310. data/lua-hooks/ext/luajit/src/lj_profile.h +21 -0
  311. data/lua-hooks/ext/luajit/src/lj_profile.o +0 -0
  312. data/lua-hooks/ext/luajit/src/lj_profile_dyn.o +0 -0
  313. data/lua-hooks/ext/luajit/src/lj_recdef.h +270 -0
  314. data/lua-hooks/ext/luajit/src/lj_record.c +2554 -0
  315. data/lua-hooks/ext/luajit/src/lj_record.h +45 -0
  316. data/lua-hooks/ext/luajit/src/lj_record.o +0 -0
  317. data/lua-hooks/ext/luajit/src/lj_record_dyn.o +0 -0
  318. data/lua-hooks/ext/luajit/src/lj_snap.c +870 -0
  319. data/lua-hooks/ext/luajit/src/lj_snap.h +34 -0
  320. data/lua-hooks/ext/luajit/src/lj_snap.o +0 -0
  321. data/lua-hooks/ext/luajit/src/lj_snap_dyn.o +0 -0
  322. data/lua-hooks/ext/luajit/src/lj_state.c +300 -0
  323. data/lua-hooks/ext/luajit/src/lj_state.h +35 -0
  324. data/lua-hooks/ext/luajit/src/lj_state.o +0 -0
  325. data/lua-hooks/ext/luajit/src/lj_state_dyn.o +0 -0
  326. data/lua-hooks/ext/luajit/src/lj_str.c +197 -0
  327. data/lua-hooks/ext/luajit/src/lj_str.h +27 -0
  328. data/lua-hooks/ext/luajit/src/lj_str.o +0 -0
  329. data/lua-hooks/ext/luajit/src/lj_str_dyn.o +0 -0
  330. data/lua-hooks/ext/luajit/src/lj_strfmt.c +554 -0
  331. data/lua-hooks/ext/luajit/src/lj_strfmt.h +125 -0
  332. data/lua-hooks/ext/luajit/src/lj_strfmt.o +0 -0
  333. data/lua-hooks/ext/luajit/src/lj_strfmt_dyn.o +0 -0
  334. data/lua-hooks/ext/luajit/src/lj_strscan.c +547 -0
  335. data/lua-hooks/ext/luajit/src/lj_strscan.h +39 -0
  336. data/lua-hooks/ext/luajit/src/lj_strscan.o +0 -0
  337. data/lua-hooks/ext/luajit/src/lj_strscan_dyn.o +0 -0
  338. data/lua-hooks/ext/luajit/src/lj_tab.c +666 -0
  339. data/lua-hooks/ext/luajit/src/lj_tab.h +73 -0
  340. data/lua-hooks/ext/luajit/src/lj_tab.o +0 -0
  341. data/lua-hooks/ext/luajit/src/lj_tab_dyn.o +0 -0
  342. data/lua-hooks/ext/luajit/src/lj_target.h +164 -0
  343. data/lua-hooks/ext/luajit/src/lj_target_arm.h +270 -0
  344. data/lua-hooks/ext/luajit/src/lj_target_arm64.h +97 -0
  345. data/lua-hooks/ext/luajit/src/lj_target_mips.h +260 -0
  346. data/lua-hooks/ext/luajit/src/lj_target_ppc.h +280 -0
  347. data/lua-hooks/ext/luajit/src/lj_target_x86.h +345 -0
  348. data/lua-hooks/ext/luajit/src/lj_trace.c +859 -0
  349. data/lua-hooks/ext/luajit/src/lj_trace.h +54 -0
  350. data/lua-hooks/ext/luajit/src/lj_trace.o +0 -0
  351. data/lua-hooks/ext/luajit/src/lj_trace_dyn.o +0 -0
  352. data/lua-hooks/ext/luajit/src/lj_traceerr.h +63 -0
  353. data/lua-hooks/ext/luajit/src/lj_udata.c +34 -0
  354. data/lua-hooks/ext/luajit/src/lj_udata.h +14 -0
  355. data/lua-hooks/ext/luajit/src/lj_udata.o +0 -0
  356. data/lua-hooks/ext/luajit/src/lj_udata_dyn.o +0 -0
  357. data/lua-hooks/ext/luajit/src/lj_vm.S +2730 -0
  358. data/lua-hooks/ext/luajit/src/lj_vm.h +114 -0
  359. data/lua-hooks/ext/luajit/src/lj_vm.o +0 -0
  360. data/lua-hooks/ext/luajit/src/lj_vm_dyn.o +0 -0
  361. data/lua-hooks/ext/luajit/src/lj_vmevent.c +58 -0
  362. data/lua-hooks/ext/luajit/src/lj_vmevent.h +59 -0
  363. data/lua-hooks/ext/luajit/src/lj_vmevent.o +0 -0
  364. data/lua-hooks/ext/luajit/src/lj_vmevent_dyn.o +0 -0
  365. data/lua-hooks/ext/luajit/src/lj_vmmath.c +152 -0
  366. data/lua-hooks/ext/luajit/src/lj_vmmath.o +0 -0
  367. data/lua-hooks/ext/luajit/src/lj_vmmath_dyn.o +0 -0
  368. data/lua-hooks/ext/luajit/src/ljamalg.c +96 -0
  369. data/lua-hooks/ext/{lua → luajit/src}/lua.h +12 -7
  370. data/lua-hooks/ext/luajit/src/lua.hpp +9 -0
  371. data/lua-hooks/ext/luajit/src/luaconf.h +156 -0
  372. data/lua-hooks/ext/luajit/src/luajit +0 -0
  373. data/lua-hooks/ext/luajit/src/luajit.c +570 -0
  374. data/lua-hooks/ext/luajit/src/luajit.h +79 -0
  375. data/lua-hooks/ext/luajit/src/luajit.o +0 -0
  376. data/lua-hooks/ext/luajit/src/lualib.h +43 -0
  377. data/lua-hooks/ext/luajit/src/msvcbuild.bat +114 -0
  378. data/lua-hooks/ext/luajit/src/ps4build.bat +103 -0
  379. data/lua-hooks/ext/luajit/src/psvitabuild.bat +93 -0
  380. data/lua-hooks/ext/luajit/src/vm_arm.dasc +4585 -0
  381. data/lua-hooks/ext/luajit/src/vm_arm64.dasc +3764 -0
  382. data/lua-hooks/ext/luajit/src/vm_mips.dasc +4355 -0
  383. data/lua-hooks/ext/luajit/src/vm_ppc.dasc +5252 -0
  384. data/lua-hooks/ext/luajit/src/vm_x64.dasc +4902 -0
  385. data/lua-hooks/ext/luajit/src/vm_x86.dasc +5710 -0
  386. data/lua-hooks/ext/luajit/src/xb1build.bat +101 -0
  387. data/lua-hooks/ext/luajit/src/xedkbuild.bat +92 -0
  388. data/lua-hooks/ext/luautf8/lutf8lib.c +3 -3
  389. data/lua-hooks/lib/boot.lua +37 -2
  390. metadata +372 -69
  391. data/lua-hooks/ext/bitop/README +0 -22
  392. data/lua-hooks/ext/bitop/bit.c +0 -189
  393. data/lua-hooks/ext/extconf.rb +0 -38
  394. data/lua-hooks/ext/lua/COPYRIGHT +0 -34
  395. data/lua-hooks/ext/lua/lapi.c +0 -1087
  396. data/lua-hooks/ext/lua/lapi.h +0 -16
  397. data/lua-hooks/ext/lua/lauxlib.c +0 -652
  398. data/lua-hooks/ext/lua/lbaselib.c +0 -659
  399. data/lua-hooks/ext/lua/lcode.c +0 -831
  400. data/lua-hooks/ext/lua/lcode.h +0 -76
  401. data/lua-hooks/ext/lua/ldblib.c +0 -398
  402. data/lua-hooks/ext/lua/ldebug.c +0 -638
  403. data/lua-hooks/ext/lua/ldebug.h +0 -33
  404. data/lua-hooks/ext/lua/ldo.c +0 -519
  405. data/lua-hooks/ext/lua/ldo.h +0 -57
  406. data/lua-hooks/ext/lua/ldump.c +0 -164
  407. data/lua-hooks/ext/lua/lfunc.c +0 -174
  408. data/lua-hooks/ext/lua/lfunc.h +0 -34
  409. data/lua-hooks/ext/lua/lgc.c +0 -710
  410. data/lua-hooks/ext/lua/lgc.h +0 -110
  411. data/lua-hooks/ext/lua/linit.c +0 -38
  412. data/lua-hooks/ext/lua/liolib.c +0 -556
  413. data/lua-hooks/ext/lua/llex.c +0 -463
  414. data/lua-hooks/ext/lua/llex.h +0 -81
  415. data/lua-hooks/ext/lua/llimits.h +0 -128
  416. data/lua-hooks/ext/lua/lmathlib.c +0 -263
  417. data/lua-hooks/ext/lua/lmem.c +0 -86
  418. data/lua-hooks/ext/lua/lmem.h +0 -49
  419. data/lua-hooks/ext/lua/loadlib.c +0 -705
  420. data/lua-hooks/ext/lua/loadlib_rel.c +0 -760
  421. data/lua-hooks/ext/lua/lobject.c +0 -214
  422. data/lua-hooks/ext/lua/lobject.h +0 -381
  423. data/lua-hooks/ext/lua/lopcodes.c +0 -102
  424. data/lua-hooks/ext/lua/lopcodes.h +0 -268
  425. data/lua-hooks/ext/lua/loslib.c +0 -243
  426. data/lua-hooks/ext/lua/lparser.c +0 -1339
  427. data/lua-hooks/ext/lua/lparser.h +0 -82
  428. data/lua-hooks/ext/lua/lstate.c +0 -214
  429. data/lua-hooks/ext/lua/lstate.h +0 -169
  430. data/lua-hooks/ext/lua/lstring.c +0 -111
  431. data/lua-hooks/ext/lua/lstring.h +0 -31
  432. data/lua-hooks/ext/lua/lstrlib.c +0 -871
  433. data/lua-hooks/ext/lua/ltable.c +0 -588
  434. data/lua-hooks/ext/lua/ltable.h +0 -40
  435. data/lua-hooks/ext/lua/ltablib.c +0 -287
  436. data/lua-hooks/ext/lua/ltm.c +0 -75
  437. data/lua-hooks/ext/lua/ltm.h +0 -54
  438. data/lua-hooks/ext/lua/lua.c +0 -392
  439. data/lua-hooks/ext/lua/lua.def +0 -131
  440. data/lua-hooks/ext/lua/lua.rc +0 -28
  441. data/lua-hooks/ext/lua/lua_dll.rc +0 -26
  442. data/lua-hooks/ext/lua/luac.c +0 -200
  443. data/lua-hooks/ext/lua/luac.rc +0 -1
  444. data/lua-hooks/ext/lua/luaconf.h +0 -763
  445. data/lua-hooks/ext/lua/luaconf.h.in +0 -724
  446. data/lua-hooks/ext/lua/luaconf.h.orig +0 -763
  447. data/lua-hooks/ext/lua/lualib.h +0 -53
  448. data/lua-hooks/ext/lua/lundump.c +0 -227
  449. data/lua-hooks/ext/lua/lundump.h +0 -36
  450. data/lua-hooks/ext/lua/lvm.c +0 -767
  451. data/lua-hooks/ext/lua/lvm.h +0 -36
  452. data/lua-hooks/ext/lua/lzio.c +0 -82
  453. data/lua-hooks/ext/lua/lzio.h +0 -67
  454. data/lua-hooks/ext/lua/print.c +0 -227
@@ -0,0 +1,416 @@
1
+ /*
2
+ ** DynASM MIPS encoding engine.
3
+ ** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
4
+ ** Released under the MIT license. See dynasm.lua for full copyright notice.
5
+ */
6
+
7
+ #include <stddef.h>
8
+ #include <stdarg.h>
9
+ #include <string.h>
10
+ #include <stdlib.h>
11
+
12
+ #define DASM_ARCH "mips"
13
+
14
+ #ifndef DASM_EXTERN
15
+ #define DASM_EXTERN(a,b,c,d) 0
16
+ #endif
17
+
18
+ /* Action definitions. */
19
+ enum {
20
+ DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT,
21
+ /* The following actions need a buffer position. */
22
+ DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG,
23
+ /* The following actions also have an argument. */
24
+ DASM_REL_PC, DASM_LABEL_PC, DASM_IMM,
25
+ DASM__MAX
26
+ };
27
+
28
+ /* Maximum number of section buffer positions for a single dasm_put() call. */
29
+ #define DASM_MAXSECPOS 25
30
+
31
+ /* DynASM encoder status codes. Action list offset or number are or'ed in. */
32
+ #define DASM_S_OK 0x00000000
33
+ #define DASM_S_NOMEM 0x01000000
34
+ #define DASM_S_PHASE 0x02000000
35
+ #define DASM_S_MATCH_SEC 0x03000000
36
+ #define DASM_S_RANGE_I 0x11000000
37
+ #define DASM_S_RANGE_SEC 0x12000000
38
+ #define DASM_S_RANGE_LG 0x13000000
39
+ #define DASM_S_RANGE_PC 0x14000000
40
+ #define DASM_S_RANGE_REL 0x15000000
41
+ #define DASM_S_UNDEF_LG 0x21000000
42
+ #define DASM_S_UNDEF_PC 0x22000000
43
+
44
+ /* Macros to convert positions (8 bit section + 24 bit index). */
45
+ #define DASM_POS2IDX(pos) ((pos)&0x00ffffff)
46
+ #define DASM_POS2BIAS(pos) ((pos)&0xff000000)
47
+ #define DASM_SEC2POS(sec) ((sec)<<24)
48
+ #define DASM_POS2SEC(pos) ((pos)>>24)
49
+ #define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos))
50
+
51
+ /* Action list type. */
52
+ typedef const unsigned int *dasm_ActList;
53
+
54
+ /* Per-section structure. */
55
+ typedef struct dasm_Section {
56
+ int *rbuf; /* Biased buffer pointer (negative section bias). */
57
+ int *buf; /* True buffer pointer. */
58
+ size_t bsize; /* Buffer size in bytes. */
59
+ int pos; /* Biased buffer position. */
60
+ int epos; /* End of biased buffer position - max single put. */
61
+ int ofs; /* Byte offset into section. */
62
+ } dasm_Section;
63
+
64
+ /* Core structure holding the DynASM encoding state. */
65
+ struct dasm_State {
66
+ size_t psize; /* Allocated size of this structure. */
67
+ dasm_ActList actionlist; /* Current actionlist pointer. */
68
+ int *lglabels; /* Local/global chain/pos ptrs. */
69
+ size_t lgsize;
70
+ int *pclabels; /* PC label chains/pos ptrs. */
71
+ size_t pcsize;
72
+ void **globals; /* Array of globals (bias -10). */
73
+ dasm_Section *section; /* Pointer to active section. */
74
+ size_t codesize; /* Total size of all code sections. */
75
+ int maxsection; /* 0 <= sectionidx < maxsection. */
76
+ int status; /* Status code. */
77
+ dasm_Section sections[1]; /* All sections. Alloc-extended. */
78
+ };
79
+
80
+ /* The size of the core structure depends on the max. number of sections. */
81
+ #define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section))
82
+
83
+
84
+ /* Initialize DynASM state. */
85
+ void dasm_init(Dst_DECL, int maxsection)
86
+ {
87
+ dasm_State *D;
88
+ size_t psz = 0;
89
+ int i;
90
+ Dst_REF = NULL;
91
+ DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection));
92
+ D = Dst_REF;
93
+ D->psize = psz;
94
+ D->lglabels = NULL;
95
+ D->lgsize = 0;
96
+ D->pclabels = NULL;
97
+ D->pcsize = 0;
98
+ D->globals = NULL;
99
+ D->maxsection = maxsection;
100
+ for (i = 0; i < maxsection; i++) {
101
+ D->sections[i].buf = NULL; /* Need this for pass3. */
102
+ D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i);
103
+ D->sections[i].bsize = 0;
104
+ D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */
105
+ }
106
+ }
107
+
108
+ /* Free DynASM state. */
109
+ void dasm_free(Dst_DECL)
110
+ {
111
+ dasm_State *D = Dst_REF;
112
+ int i;
113
+ for (i = 0; i < D->maxsection; i++)
114
+ if (D->sections[i].buf)
115
+ DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize);
116
+ if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize);
117
+ if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize);
118
+ DASM_M_FREE(Dst, D, D->psize);
119
+ }
120
+
121
+ /* Setup global label array. Must be called before dasm_setup(). */
122
+ void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl)
123
+ {
124
+ dasm_State *D = Dst_REF;
125
+ D->globals = gl - 10; /* Negative bias to compensate for locals. */
126
+ DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int));
127
+ }
128
+
129
+ /* Grow PC label array. Can be called after dasm_setup(), too. */
130
+ void dasm_growpc(Dst_DECL, unsigned int maxpc)
131
+ {
132
+ dasm_State *D = Dst_REF;
133
+ size_t osz = D->pcsize;
134
+ DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int));
135
+ memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz);
136
+ }
137
+
138
+ /* Setup encoder. */
139
+ void dasm_setup(Dst_DECL, const void *actionlist)
140
+ {
141
+ dasm_State *D = Dst_REF;
142
+ int i;
143
+ D->actionlist = (dasm_ActList)actionlist;
144
+ D->status = DASM_S_OK;
145
+ D->section = &D->sections[0];
146
+ memset((void *)D->lglabels, 0, D->lgsize);
147
+ if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
148
+ for (i = 0; i < D->maxsection; i++) {
149
+ D->sections[i].pos = DASM_SEC2POS(i);
150
+ D->sections[i].ofs = 0;
151
+ }
152
+ }
153
+
154
+
155
+ #ifdef DASM_CHECKS
156
+ #define CK(x, st) \
157
+ do { if (!(x)) { \
158
+ D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0)
159
+ #define CKPL(kind, st) \
160
+ do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
161
+ D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0)
162
+ #else
163
+ #define CK(x, st) ((void)0)
164
+ #define CKPL(kind, st) ((void)0)
165
+ #endif
166
+
167
+ /* Pass 1: Store actions and args, link branches/labels, estimate offsets. */
168
+ void dasm_put(Dst_DECL, int start, ...)
169
+ {
170
+ va_list ap;
171
+ dasm_State *D = Dst_REF;
172
+ dasm_ActList p = D->actionlist + start;
173
+ dasm_Section *sec = D->section;
174
+ int pos = sec->pos, ofs = sec->ofs;
175
+ int *b;
176
+
177
+ if (pos >= sec->epos) {
178
+ DASM_M_GROW(Dst, int, sec->buf, sec->bsize,
179
+ sec->bsize + 2*DASM_MAXSECPOS*sizeof(int));
180
+ sec->rbuf = sec->buf - DASM_POS2BIAS(pos);
181
+ sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos);
182
+ }
183
+
184
+ b = sec->rbuf;
185
+ b[pos++] = start;
186
+
187
+ va_start(ap, start);
188
+ while (1) {
189
+ unsigned int ins = *p++;
190
+ unsigned int action = (ins >> 16) - 0xff00;
191
+ if (action >= DASM__MAX) {
192
+ ofs += 4;
193
+ } else {
194
+ int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0;
195
+ switch (action) {
196
+ case DASM_STOP: goto stop;
197
+ case DASM_SECTION:
198
+ n = (ins & 255); CK(n < D->maxsection, RANGE_SEC);
199
+ D->section = &D->sections[n]; goto stop;
200
+ case DASM_ESC: p++; ofs += 4; break;
201
+ case DASM_REL_EXT: break;
202
+ case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break;
203
+ case DASM_REL_LG:
204
+ n = (ins & 2047) - 10; pl = D->lglabels + n;
205
+ /* Bkwd rel or global. */
206
+ if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; }
207
+ pl += 10; n = *pl;
208
+ if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */
209
+ goto linkrel;
210
+ case DASM_REL_PC:
211
+ pl = D->pclabels + n; CKPL(pc, PC);
212
+ putrel:
213
+ n = *pl;
214
+ if (n < 0) { /* Label exists. Get label pos and store it. */
215
+ b[pos] = -n;
216
+ } else {
217
+ linkrel:
218
+ b[pos] = n; /* Else link to rel chain, anchored at label. */
219
+ *pl = pos;
220
+ }
221
+ pos++;
222
+ break;
223
+ case DASM_LABEL_LG:
224
+ pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel;
225
+ case DASM_LABEL_PC:
226
+ pl = D->pclabels + n; CKPL(pc, PC);
227
+ putlabel:
228
+ n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */
229
+ while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos;
230
+ }
231
+ *pl = -pos; /* Label exists now. */
232
+ b[pos++] = ofs; /* Store pass1 offset estimate. */
233
+ break;
234
+ case DASM_IMM:
235
+ #ifdef DASM_CHECKS
236
+ CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I);
237
+ #endif
238
+ n >>= ((ins>>10)&31);
239
+ #ifdef DASM_CHECKS
240
+ if (ins & 0x8000)
241
+ CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I);
242
+ else
243
+ CK((n>>((ins>>5)&31)) == 0, RANGE_I);
244
+ #endif
245
+ b[pos++] = n;
246
+ break;
247
+ }
248
+ }
249
+ }
250
+ stop:
251
+ va_end(ap);
252
+ sec->pos = pos;
253
+ sec->ofs = ofs;
254
+ }
255
+ #undef CK
256
+
257
+ /* Pass 2: Link sections, shrink aligns, fix label offsets. */
258
+ int dasm_link(Dst_DECL, size_t *szp)
259
+ {
260
+ dasm_State *D = Dst_REF;
261
+ int secnum;
262
+ int ofs = 0;
263
+
264
+ #ifdef DASM_CHECKS
265
+ *szp = 0;
266
+ if (D->status != DASM_S_OK) return D->status;
267
+ {
268
+ int pc;
269
+ for (pc = 0; pc*sizeof(int) < D->pcsize; pc++)
270
+ if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc;
271
+ }
272
+ #endif
273
+
274
+ { /* Handle globals not defined in this translation unit. */
275
+ int idx;
276
+ for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) {
277
+ int n = D->lglabels[idx];
278
+ /* Undefined label: Collapse rel chain and replace with marker (< 0). */
279
+ while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; }
280
+ }
281
+ }
282
+
283
+ /* Combine all code sections. No support for data sections (yet). */
284
+ for (secnum = 0; secnum < D->maxsection; secnum++) {
285
+ dasm_Section *sec = D->sections + secnum;
286
+ int *b = sec->rbuf;
287
+ int pos = DASM_SEC2POS(secnum);
288
+ int lastpos = sec->pos;
289
+
290
+ while (pos != lastpos) {
291
+ dasm_ActList p = D->actionlist + b[pos++];
292
+ while (1) {
293
+ unsigned int ins = *p++;
294
+ unsigned int action = (ins >> 16) - 0xff00;
295
+ switch (action) {
296
+ case DASM_STOP: case DASM_SECTION: goto stop;
297
+ case DASM_ESC: p++; break;
298
+ case DASM_REL_EXT: break;
299
+ case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break;
300
+ case DASM_REL_LG: case DASM_REL_PC: pos++; break;
301
+ case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break;
302
+ case DASM_IMM: pos++; break;
303
+ }
304
+ }
305
+ stop: (void)0;
306
+ }
307
+ ofs += sec->ofs; /* Next section starts right after current section. */
308
+ }
309
+
310
+ D->codesize = ofs; /* Total size of all code sections */
311
+ *szp = ofs;
312
+ return DASM_S_OK;
313
+ }
314
+
315
+ #ifdef DASM_CHECKS
316
+ #define CK(x, st) \
317
+ do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0)
318
+ #else
319
+ #define CK(x, st) ((void)0)
320
+ #endif
321
+
322
+ /* Pass 3: Encode sections. */
323
+ int dasm_encode(Dst_DECL, void *buffer)
324
+ {
325
+ dasm_State *D = Dst_REF;
326
+ char *base = (char *)buffer;
327
+ unsigned int *cp = (unsigned int *)buffer;
328
+ int secnum;
329
+
330
+ /* Encode all code sections. No support for data sections (yet). */
331
+ for (secnum = 0; secnum < D->maxsection; secnum++) {
332
+ dasm_Section *sec = D->sections + secnum;
333
+ int *b = sec->buf;
334
+ int *endb = sec->rbuf + sec->pos;
335
+
336
+ while (b != endb) {
337
+ dasm_ActList p = D->actionlist + *b++;
338
+ while (1) {
339
+ unsigned int ins = *p++;
340
+ unsigned int action = (ins >> 16) - 0xff00;
341
+ int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0;
342
+ switch (action) {
343
+ case DASM_STOP: case DASM_SECTION: goto stop;
344
+ case DASM_ESC: *cp++ = *p++; break;
345
+ case DASM_REL_EXT:
346
+ n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1);
347
+ goto patchrel;
348
+ case DASM_ALIGN:
349
+ ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000;
350
+ break;
351
+ case DASM_REL_LG:
352
+ CK(n >= 0, UNDEF_LG);
353
+ case DASM_REL_PC:
354
+ CK(n >= 0, UNDEF_PC);
355
+ n = *DASM_POS2PTR(D, n);
356
+ if (ins & 2048)
357
+ n = n - (int)((char *)cp - base);
358
+ else
359
+ n = (n + (int)base) & 0x0fffffff;
360
+ patchrel:
361
+ CK((n & 3) == 0 &&
362
+ ((n + ((ins & 2048) ? 0x00020000 : 0)) >>
363
+ ((ins & 2048) ? 18 : 28)) == 0, RANGE_REL);
364
+ cp[-1] |= ((n>>2) & ((ins & 2048) ? 0x0000ffff: 0x03ffffff));
365
+ break;
366
+ case DASM_LABEL_LG:
367
+ ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n);
368
+ break;
369
+ case DASM_LABEL_PC: break;
370
+ case DASM_IMM:
371
+ cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31);
372
+ break;
373
+ default: *cp++ = ins; break;
374
+ }
375
+ }
376
+ stop: (void)0;
377
+ }
378
+ }
379
+
380
+ if (base + D->codesize != (char *)cp) /* Check for phase errors. */
381
+ return DASM_S_PHASE;
382
+ return DASM_S_OK;
383
+ }
384
+ #undef CK
385
+
386
+ /* Get PC label offset. */
387
+ int dasm_getpclabel(Dst_DECL, unsigned int pc)
388
+ {
389
+ dasm_State *D = Dst_REF;
390
+ if (pc*sizeof(int) < D->pcsize) {
391
+ int pos = D->pclabels[pc];
392
+ if (pos < 0) return *DASM_POS2PTR(D, -pos);
393
+ if (pos > 0) return -1; /* Undefined. */
394
+ }
395
+ return -2; /* Unused or out of range. */
396
+ }
397
+
398
+ #ifdef DASM_CHECKS
399
+ /* Optional sanity checker to call between isolated encoding steps. */
400
+ int dasm_checkstep(Dst_DECL, int secmatch)
401
+ {
402
+ dasm_State *D = Dst_REF;
403
+ if (D->status == DASM_S_OK) {
404
+ int i;
405
+ for (i = 1; i <= 9; i++) {
406
+ if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; }
407
+ D->lglabels[i] = 0;
408
+ }
409
+ }
410
+ if (D->status == DASM_S_OK && secmatch >= 0 &&
411
+ D->section != &D->sections[secmatch])
412
+ D->status = DASM_S_MATCH_SEC|(D->section-D->sections);
413
+ return D->status;
414
+ }
415
+ #endif
416
+
@@ -0,0 +1,953 @@
1
+ ------------------------------------------------------------------------------
2
+ -- DynASM MIPS module.
3
+ --
4
+ -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
5
+ -- See dynasm.lua for full copyright notice.
6
+ ------------------------------------------------------------------------------
7
+
8
+ -- Module information:
9
+ local _info = {
10
+ arch = "mips",
11
+ description = "DynASM MIPS module",
12
+ version = "1.3.0",
13
+ vernum = 10300,
14
+ release = "2012-01-23",
15
+ author = "Mike Pall",
16
+ license = "MIT",
17
+ }
18
+
19
+ -- Exported glue functions for the arch-specific module.
20
+ local _M = { _info = _info }
21
+
22
+ -- Cache library functions.
23
+ local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs
24
+ local assert, setmetatable = assert, setmetatable
25
+ local _s = string
26
+ local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char
27
+ local match, gmatch = _s.match, _s.gmatch
28
+ local concat, sort = table.concat, table.sort
29
+ local bit = bit or require("bit")
30
+ local band, shl, sar, tohex = bit.band, bit.lshift, bit.arshift, bit.tohex
31
+
32
+ -- Inherited tables and callbacks.
33
+ local g_opt, g_arch
34
+ local wline, werror, wfatal, wwarn
35
+
36
+ -- Action name list.
37
+ -- CHECK: Keep this in sync with the C code!
38
+ local action_names = {
39
+ "STOP", "SECTION", "ESC", "REL_EXT",
40
+ "ALIGN", "REL_LG", "LABEL_LG",
41
+ "REL_PC", "LABEL_PC", "IMM",
42
+ }
43
+
44
+ -- Maximum number of section buffer positions for dasm_put().
45
+ -- CHECK: Keep this in sync with the C code!
46
+ local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines.
47
+
48
+ -- Action name -> action number.
49
+ local map_action = {}
50
+ for n,name in ipairs(action_names) do
51
+ map_action[name] = n-1
52
+ end
53
+
54
+ -- Action list buffer.
55
+ local actlist = {}
56
+
57
+ -- Argument list for next dasm_put(). Start with offset 0 into action list.
58
+ local actargs = { 0 }
59
+
60
+ -- Current number of section buffer positions for dasm_put().
61
+ local secpos = 1
62
+
63
+ ------------------------------------------------------------------------------
64
+
65
+ -- Dump action names and numbers.
66
+ local function dumpactions(out)
67
+ out:write("DynASM encoding engine action codes:\n")
68
+ for n,name in ipairs(action_names) do
69
+ local num = map_action[name]
70
+ out:write(format(" %-10s %02X %d\n", name, num, num))
71
+ end
72
+ out:write("\n")
73
+ end
74
+
75
+ -- Write action list buffer as a huge static C array.
76
+ local function writeactions(out, name)
77
+ local nn = #actlist
78
+ if nn == 0 then nn = 1; actlist[0] = map_action.STOP end
79
+ out:write("static const unsigned int ", name, "[", nn, "] = {\n")
80
+ for i = 1,nn-1 do
81
+ assert(out:write("0x", tohex(actlist[i]), ",\n"))
82
+ end
83
+ assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n"))
84
+ end
85
+
86
+ ------------------------------------------------------------------------------
87
+
88
+ -- Add word to action list.
89
+ local function wputxw(n)
90
+ assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range")
91
+ actlist[#actlist+1] = n
92
+ end
93
+
94
+ -- Add action to list with optional arg. Advance buffer pos, too.
95
+ local function waction(action, val, a, num)
96
+ local w = assert(map_action[action], "bad action name `"..action.."'")
97
+ wputxw(0xff000000 + w * 0x10000 + (val or 0))
98
+ if a then actargs[#actargs+1] = a end
99
+ if a or num then secpos = secpos + (num or 1) end
100
+ end
101
+
102
+ -- Flush action list (intervening C code or buffer pos overflow).
103
+ local function wflush(term)
104
+ if #actlist == actargs[1] then return end -- Nothing to flush.
105
+ if not term then waction("STOP") end -- Terminate action list.
106
+ wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true)
107
+ actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put().
108
+ secpos = 1 -- The actionlist offset occupies a buffer position, too.
109
+ end
110
+
111
+ -- Put escaped word.
112
+ local function wputw(n)
113
+ if n >= 0xff000000 then waction("ESC") end
114
+ wputxw(n)
115
+ end
116
+
117
+ -- Reserve position for word.
118
+ local function wpos()
119
+ local pos = #actlist+1
120
+ actlist[pos] = ""
121
+ return pos
122
+ end
123
+
124
+ -- Store word to reserved position.
125
+ local function wputpos(pos, n)
126
+ assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range")
127
+ actlist[pos] = n
128
+ end
129
+
130
+ ------------------------------------------------------------------------------
131
+
132
+ -- Global label name -> global label number. With auto assignment on 1st use.
133
+ local next_global = 20
134
+ local map_global = setmetatable({}, { __index = function(t, name)
135
+ if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end
136
+ local n = next_global
137
+ if n > 2047 then werror("too many global labels") end
138
+ next_global = n + 1
139
+ t[name] = n
140
+ return n
141
+ end})
142
+
143
+ -- Dump global labels.
144
+ local function dumpglobals(out, lvl)
145
+ local t = {}
146
+ for name, n in pairs(map_global) do t[n] = name end
147
+ out:write("Global labels:\n")
148
+ for i=20,next_global-1 do
149
+ out:write(format(" %s\n", t[i]))
150
+ end
151
+ out:write("\n")
152
+ end
153
+
154
+ -- Write global label enum.
155
+ local function writeglobals(out, prefix)
156
+ local t = {}
157
+ for name, n in pairs(map_global) do t[n] = name end
158
+ out:write("enum {\n")
159
+ for i=20,next_global-1 do
160
+ out:write(" ", prefix, t[i], ",\n")
161
+ end
162
+ out:write(" ", prefix, "_MAX\n};\n")
163
+ end
164
+
165
+ -- Write global label names.
166
+ local function writeglobalnames(out, name)
167
+ local t = {}
168
+ for name, n in pairs(map_global) do t[n] = name end
169
+ out:write("static const char *const ", name, "[] = {\n")
170
+ for i=20,next_global-1 do
171
+ out:write(" \"", t[i], "\",\n")
172
+ end
173
+ out:write(" (const char *)0\n};\n")
174
+ end
175
+
176
+ ------------------------------------------------------------------------------
177
+
178
+ -- Extern label name -> extern label number. With auto assignment on 1st use.
179
+ local next_extern = 0
180
+ local map_extern_ = {}
181
+ local map_extern = setmetatable({}, { __index = function(t, name)
182
+ -- No restrictions on the name for now.
183
+ local n = next_extern
184
+ if n > 2047 then werror("too many extern labels") end
185
+ next_extern = n + 1
186
+ t[name] = n
187
+ map_extern_[n] = name
188
+ return n
189
+ end})
190
+
191
+ -- Dump extern labels.
192
+ local function dumpexterns(out, lvl)
193
+ out:write("Extern labels:\n")
194
+ for i=0,next_extern-1 do
195
+ out:write(format(" %s\n", map_extern_[i]))
196
+ end
197
+ out:write("\n")
198
+ end
199
+
200
+ -- Write extern label names.
201
+ local function writeexternnames(out, name)
202
+ out:write("static const char *const ", name, "[] = {\n")
203
+ for i=0,next_extern-1 do
204
+ out:write(" \"", map_extern_[i], "\",\n")
205
+ end
206
+ out:write(" (const char *)0\n};\n")
207
+ end
208
+
209
+ ------------------------------------------------------------------------------
210
+
211
+ -- Arch-specific maps.
212
+ local map_archdef = { sp="r29", ra="r31" } -- Ext. register name -> int. name.
213
+
214
+ local map_type = {} -- Type name -> { ctype, reg }
215
+ local ctypenum = 0 -- Type number (for Dt... macros).
216
+
217
+ -- Reverse defines for registers.
218
+ function _M.revdef(s)
219
+ if s == "r29" then return "sp"
220
+ elseif s == "r31" then return "ra" end
221
+ return s
222
+ end
223
+
224
+ ------------------------------------------------------------------------------
225
+
226
+ -- Template strings for MIPS instructions.
227
+ local map_op = {
228
+ -- First-level opcodes.
229
+ j_1 = "08000000J",
230
+ jal_1 = "0c000000J",
231
+ b_1 = "10000000B",
232
+ beqz_2 = "10000000SB",
233
+ beq_3 = "10000000STB",
234
+ bnez_2 = "14000000SB",
235
+ bne_3 = "14000000STB",
236
+ blez_2 = "18000000SB",
237
+ bgtz_2 = "1c000000SB",
238
+ addi_3 = "20000000TSI",
239
+ li_2 = "24000000TI",
240
+ addiu_3 = "24000000TSI",
241
+ slti_3 = "28000000TSI",
242
+ sltiu_3 = "2c000000TSI",
243
+ andi_3 = "30000000TSU",
244
+ lu_2 = "34000000TU",
245
+ ori_3 = "34000000TSU",
246
+ xori_3 = "38000000TSU",
247
+ lui_2 = "3c000000TU",
248
+ beqzl_2 = "50000000SB",
249
+ beql_3 = "50000000STB",
250
+ bnezl_2 = "54000000SB",
251
+ bnel_3 = "54000000STB",
252
+ blezl_2 = "58000000SB",
253
+ bgtzl_2 = "5c000000SB",
254
+ lb_2 = "80000000TO",
255
+ lh_2 = "84000000TO",
256
+ lwl_2 = "88000000TO",
257
+ lw_2 = "8c000000TO",
258
+ lbu_2 = "90000000TO",
259
+ lhu_2 = "94000000TO",
260
+ lwr_2 = "98000000TO",
261
+ sb_2 = "a0000000TO",
262
+ sh_2 = "a4000000TO",
263
+ swl_2 = "a8000000TO",
264
+ sw_2 = "ac000000TO",
265
+ swr_2 = "b8000000TO",
266
+ cache_2 = "bc000000NO",
267
+ ll_2 = "c0000000TO",
268
+ lwc1_2 = "c4000000HO",
269
+ pref_2 = "cc000000NO",
270
+ ldc1_2 = "d4000000HO",
271
+ sc_2 = "e0000000TO",
272
+ swc1_2 = "e4000000HO",
273
+ sdc1_2 = "f4000000HO",
274
+
275
+ -- Opcode SPECIAL.
276
+ nop_0 = "00000000",
277
+ sll_3 = "00000000DTA",
278
+ movf_2 = "00000001DS",
279
+ movf_3 = "00000001DSC",
280
+ movt_2 = "00010001DS",
281
+ movt_3 = "00010001DSC",
282
+ srl_3 = "00000002DTA",
283
+ rotr_3 = "00200002DTA",
284
+ sra_3 = "00000003DTA",
285
+ sllv_3 = "00000004DTS",
286
+ srlv_3 = "00000006DTS",
287
+ rotrv_3 = "00000046DTS",
288
+ srav_3 = "00000007DTS",
289
+ jr_1 = "00000008S",
290
+ jalr_1 = "0000f809S",
291
+ jalr_2 = "00000009DS",
292
+ movz_3 = "0000000aDST",
293
+ movn_3 = "0000000bDST",
294
+ syscall_0 = "0000000c",
295
+ syscall_1 = "0000000cY",
296
+ break_0 = "0000000d",
297
+ break_1 = "0000000dY",
298
+ sync_0 = "0000000f",
299
+ mfhi_1 = "00000010D",
300
+ mthi_1 = "00000011S",
301
+ mflo_1 = "00000012D",
302
+ mtlo_1 = "00000013S",
303
+ mult_2 = "00000018ST",
304
+ multu_2 = "00000019ST",
305
+ div_2 = "0000001aST",
306
+ divu_2 = "0000001bST",
307
+ add_3 = "00000020DST",
308
+ move_2 = "00000021DS",
309
+ addu_3 = "00000021DST",
310
+ sub_3 = "00000022DST",
311
+ negu_2 = "00000023DT",
312
+ subu_3 = "00000023DST",
313
+ and_3 = "00000024DST",
314
+ or_3 = "00000025DST",
315
+ xor_3 = "00000026DST",
316
+ not_2 = "00000027DS",
317
+ nor_3 = "00000027DST",
318
+ slt_3 = "0000002aDST",
319
+ sltu_3 = "0000002bDST",
320
+ tge_2 = "00000030ST",
321
+ tge_3 = "00000030STZ",
322
+ tgeu_2 = "00000031ST",
323
+ tgeu_3 = "00000031STZ",
324
+ tlt_2 = "00000032ST",
325
+ tlt_3 = "00000032STZ",
326
+ tltu_2 = "00000033ST",
327
+ tltu_3 = "00000033STZ",
328
+ teq_2 = "00000034ST",
329
+ teq_3 = "00000034STZ",
330
+ tne_2 = "00000036ST",
331
+ tne_3 = "00000036STZ",
332
+
333
+ -- Opcode REGIMM.
334
+ bltz_2 = "04000000SB",
335
+ bgez_2 = "04010000SB",
336
+ bltzl_2 = "04020000SB",
337
+ bgezl_2 = "04030000SB",
338
+ tgei_2 = "04080000SI",
339
+ tgeiu_2 = "04090000SI",
340
+ tlti_2 = "040a0000SI",
341
+ tltiu_2 = "040b0000SI",
342
+ teqi_2 = "040c0000SI",
343
+ tnei_2 = "040e0000SI",
344
+ bltzal_2 = "04100000SB",
345
+ bal_1 = "04110000B",
346
+ bgezal_2 = "04110000SB",
347
+ bltzall_2 = "04120000SB",
348
+ bgezall_2 = "04130000SB",
349
+ synci_1 = "041f0000O",
350
+
351
+ -- Opcode SPECIAL2.
352
+ madd_2 = "70000000ST",
353
+ maddu_2 = "70000001ST",
354
+ mul_3 = "70000002DST",
355
+ msub_2 = "70000004ST",
356
+ msubu_2 = "70000005ST",
357
+ clz_2 = "70000020DS=",
358
+ clo_2 = "70000021DS=",
359
+ sdbbp_0 = "7000003f",
360
+ sdbbp_1 = "7000003fY",
361
+
362
+ -- Opcode SPECIAL3.
363
+ ext_4 = "7c000000TSAM", -- Note: last arg is msbd = size-1
364
+ ins_4 = "7c000004TSAM", -- Note: last arg is msb = pos+size-1
365
+ wsbh_2 = "7c0000a0DT",
366
+ seb_2 = "7c000420DT",
367
+ seh_2 = "7c000620DT",
368
+ rdhwr_2 = "7c00003bTD",
369
+
370
+ -- Opcode COP0.
371
+ mfc0_2 = "40000000TD",
372
+ mfc0_3 = "40000000TDW",
373
+ mtc0_2 = "40800000TD",
374
+ mtc0_3 = "40800000TDW",
375
+ rdpgpr_2 = "41400000DT",
376
+ di_0 = "41606000",
377
+ di_1 = "41606000T",
378
+ ei_0 = "41606020",
379
+ ei_1 = "41606020T",
380
+ wrpgpr_2 = "41c00000DT",
381
+ tlbr_0 = "42000001",
382
+ tlbwi_0 = "42000002",
383
+ tlbwr_0 = "42000006",
384
+ tlbp_0 = "42000008",
385
+ eret_0 = "42000018",
386
+ deret_0 = "4200001f",
387
+ wait_0 = "42000020",
388
+
389
+ -- Opcode COP1.
390
+ mfc1_2 = "44000000TG",
391
+ cfc1_2 = "44400000TG",
392
+ mfhc1_2 = "44600000TG",
393
+ mtc1_2 = "44800000TG",
394
+ ctc1_2 = "44c00000TG",
395
+ mthc1_2 = "44e00000TG",
396
+
397
+ bc1f_1 = "45000000B",
398
+ bc1f_2 = "45000000CB",
399
+ bc1t_1 = "45010000B",
400
+ bc1t_2 = "45010000CB",
401
+ bc1fl_1 = "45020000B",
402
+ bc1fl_2 = "45020000CB",
403
+ bc1tl_1 = "45030000B",
404
+ bc1tl_2 = "45030000CB",
405
+
406
+ ["add.s_3"] = "46000000FGH",
407
+ ["sub.s_3"] = "46000001FGH",
408
+ ["mul.s_3"] = "46000002FGH",
409
+ ["div.s_3"] = "46000003FGH",
410
+ ["sqrt.s_2"] = "46000004FG",
411
+ ["abs.s_2"] = "46000005FG",
412
+ ["mov.s_2"] = "46000006FG",
413
+ ["neg.s_2"] = "46000007FG",
414
+ ["round.l.s_2"] = "46000008FG",
415
+ ["trunc.l.s_2"] = "46000009FG",
416
+ ["ceil.l.s_2"] = "4600000aFG",
417
+ ["floor.l.s_2"] = "4600000bFG",
418
+ ["round.w.s_2"] = "4600000cFG",
419
+ ["trunc.w.s_2"] = "4600000dFG",
420
+ ["ceil.w.s_2"] = "4600000eFG",
421
+ ["floor.w.s_2"] = "4600000fFG",
422
+ ["movf.s_2"] = "46000011FG",
423
+ ["movf.s_3"] = "46000011FGC",
424
+ ["movt.s_2"] = "46010011FG",
425
+ ["movt.s_3"] = "46010011FGC",
426
+ ["movz.s_3"] = "46000012FGT",
427
+ ["movn.s_3"] = "46000013FGT",
428
+ ["recip.s_2"] = "46000015FG",
429
+ ["rsqrt.s_2"] = "46000016FG",
430
+ ["cvt.d.s_2"] = "46000021FG",
431
+ ["cvt.w.s_2"] = "46000024FG",
432
+ ["cvt.l.s_2"] = "46000025FG",
433
+ ["cvt.ps.s_3"] = "46000026FGH",
434
+ ["c.f.s_2"] = "46000030GH",
435
+ ["c.f.s_3"] = "46000030VGH",
436
+ ["c.un.s_2"] = "46000031GH",
437
+ ["c.un.s_3"] = "46000031VGH",
438
+ ["c.eq.s_2"] = "46000032GH",
439
+ ["c.eq.s_3"] = "46000032VGH",
440
+ ["c.ueq.s_2"] = "46000033GH",
441
+ ["c.ueq.s_3"] = "46000033VGH",
442
+ ["c.olt.s_2"] = "46000034GH",
443
+ ["c.olt.s_3"] = "46000034VGH",
444
+ ["c.ult.s_2"] = "46000035GH",
445
+ ["c.ult.s_3"] = "46000035VGH",
446
+ ["c.ole.s_2"] = "46000036GH",
447
+ ["c.ole.s_3"] = "46000036VGH",
448
+ ["c.ule.s_2"] = "46000037GH",
449
+ ["c.ule.s_3"] = "46000037VGH",
450
+ ["c.sf.s_2"] = "46000038GH",
451
+ ["c.sf.s_3"] = "46000038VGH",
452
+ ["c.ngle.s_2"] = "46000039GH",
453
+ ["c.ngle.s_3"] = "46000039VGH",
454
+ ["c.seq.s_2"] = "4600003aGH",
455
+ ["c.seq.s_3"] = "4600003aVGH",
456
+ ["c.ngl.s_2"] = "4600003bGH",
457
+ ["c.ngl.s_3"] = "4600003bVGH",
458
+ ["c.lt.s_2"] = "4600003cGH",
459
+ ["c.lt.s_3"] = "4600003cVGH",
460
+ ["c.nge.s_2"] = "4600003dGH",
461
+ ["c.nge.s_3"] = "4600003dVGH",
462
+ ["c.le.s_2"] = "4600003eGH",
463
+ ["c.le.s_3"] = "4600003eVGH",
464
+ ["c.ngt.s_2"] = "4600003fGH",
465
+ ["c.ngt.s_3"] = "4600003fVGH",
466
+
467
+ ["add.d_3"] = "46200000FGH",
468
+ ["sub.d_3"] = "46200001FGH",
469
+ ["mul.d_3"] = "46200002FGH",
470
+ ["div.d_3"] = "46200003FGH",
471
+ ["sqrt.d_2"] = "46200004FG",
472
+ ["abs.d_2"] = "46200005FG",
473
+ ["mov.d_2"] = "46200006FG",
474
+ ["neg.d_2"] = "46200007FG",
475
+ ["round.l.d_2"] = "46200008FG",
476
+ ["trunc.l.d_2"] = "46200009FG",
477
+ ["ceil.l.d_2"] = "4620000aFG",
478
+ ["floor.l.d_2"] = "4620000bFG",
479
+ ["round.w.d_2"] = "4620000cFG",
480
+ ["trunc.w.d_2"] = "4620000dFG",
481
+ ["ceil.w.d_2"] = "4620000eFG",
482
+ ["floor.w.d_2"] = "4620000fFG",
483
+ ["movf.d_2"] = "46200011FG",
484
+ ["movf.d_3"] = "46200011FGC",
485
+ ["movt.d_2"] = "46210011FG",
486
+ ["movt.d_3"] = "46210011FGC",
487
+ ["movz.d_3"] = "46200012FGT",
488
+ ["movn.d_3"] = "46200013FGT",
489
+ ["recip.d_2"] = "46200015FG",
490
+ ["rsqrt.d_2"] = "46200016FG",
491
+ ["cvt.s.d_2"] = "46200020FG",
492
+ ["cvt.w.d_2"] = "46200024FG",
493
+ ["cvt.l.d_2"] = "46200025FG",
494
+ ["c.f.d_2"] = "46200030GH",
495
+ ["c.f.d_3"] = "46200030VGH",
496
+ ["c.un.d_2"] = "46200031GH",
497
+ ["c.un.d_3"] = "46200031VGH",
498
+ ["c.eq.d_2"] = "46200032GH",
499
+ ["c.eq.d_3"] = "46200032VGH",
500
+ ["c.ueq.d_2"] = "46200033GH",
501
+ ["c.ueq.d_3"] = "46200033VGH",
502
+ ["c.olt.d_2"] = "46200034GH",
503
+ ["c.olt.d_3"] = "46200034VGH",
504
+ ["c.ult.d_2"] = "46200035GH",
505
+ ["c.ult.d_3"] = "46200035VGH",
506
+ ["c.ole.d_2"] = "46200036GH",
507
+ ["c.ole.d_3"] = "46200036VGH",
508
+ ["c.ule.d_2"] = "46200037GH",
509
+ ["c.ule.d_3"] = "46200037VGH",
510
+ ["c.sf.d_2"] = "46200038GH",
511
+ ["c.sf.d_3"] = "46200038VGH",
512
+ ["c.ngle.d_2"] = "46200039GH",
513
+ ["c.ngle.d_3"] = "46200039VGH",
514
+ ["c.seq.d_2"] = "4620003aGH",
515
+ ["c.seq.d_3"] = "4620003aVGH",
516
+ ["c.ngl.d_2"] = "4620003bGH",
517
+ ["c.ngl.d_3"] = "4620003bVGH",
518
+ ["c.lt.d_2"] = "4620003cGH",
519
+ ["c.lt.d_3"] = "4620003cVGH",
520
+ ["c.nge.d_2"] = "4620003dGH",
521
+ ["c.nge.d_3"] = "4620003dVGH",
522
+ ["c.le.d_2"] = "4620003eGH",
523
+ ["c.le.d_3"] = "4620003eVGH",
524
+ ["c.ngt.d_2"] = "4620003fGH",
525
+ ["c.ngt.d_3"] = "4620003fVGH",
526
+
527
+ ["add.ps_3"] = "46c00000FGH",
528
+ ["sub.ps_3"] = "46c00001FGH",
529
+ ["mul.ps_3"] = "46c00002FGH",
530
+ ["abs.ps_2"] = "46c00005FG",
531
+ ["mov.ps_2"] = "46c00006FG",
532
+ ["neg.ps_2"] = "46c00007FG",
533
+ ["movf.ps_2"] = "46c00011FG",
534
+ ["movf.ps_3"] = "46c00011FGC",
535
+ ["movt.ps_2"] = "46c10011FG",
536
+ ["movt.ps_3"] = "46c10011FGC",
537
+ ["movz.ps_3"] = "46c00012FGT",
538
+ ["movn.ps_3"] = "46c00013FGT",
539
+ ["cvt.s.pu_2"] = "46c00020FG",
540
+ ["cvt.s.pl_2"] = "46c00028FG",
541
+ ["pll.ps_3"] = "46c0002cFGH",
542
+ ["plu.ps_3"] = "46c0002dFGH",
543
+ ["pul.ps_3"] = "46c0002eFGH",
544
+ ["puu.ps_3"] = "46c0002fFGH",
545
+ ["c.f.ps_2"] = "46c00030GH",
546
+ ["c.f.ps_3"] = "46c00030VGH",
547
+ ["c.un.ps_2"] = "46c00031GH",
548
+ ["c.un.ps_3"] = "46c00031VGH",
549
+ ["c.eq.ps_2"] = "46c00032GH",
550
+ ["c.eq.ps_3"] = "46c00032VGH",
551
+ ["c.ueq.ps_2"] = "46c00033GH",
552
+ ["c.ueq.ps_3"] = "46c00033VGH",
553
+ ["c.olt.ps_2"] = "46c00034GH",
554
+ ["c.olt.ps_3"] = "46c00034VGH",
555
+ ["c.ult.ps_2"] = "46c00035GH",
556
+ ["c.ult.ps_3"] = "46c00035VGH",
557
+ ["c.ole.ps_2"] = "46c00036GH",
558
+ ["c.ole.ps_3"] = "46c00036VGH",
559
+ ["c.ule.ps_2"] = "46c00037GH",
560
+ ["c.ule.ps_3"] = "46c00037VGH",
561
+ ["c.sf.ps_2"] = "46c00038GH",
562
+ ["c.sf.ps_3"] = "46c00038VGH",
563
+ ["c.ngle.ps_2"] = "46c00039GH",
564
+ ["c.ngle.ps_3"] = "46c00039VGH",
565
+ ["c.seq.ps_2"] = "46c0003aGH",
566
+ ["c.seq.ps_3"] = "46c0003aVGH",
567
+ ["c.ngl.ps_2"] = "46c0003bGH",
568
+ ["c.ngl.ps_3"] = "46c0003bVGH",
569
+ ["c.lt.ps_2"] = "46c0003cGH",
570
+ ["c.lt.ps_3"] = "46c0003cVGH",
571
+ ["c.nge.ps_2"] = "46c0003dGH",
572
+ ["c.nge.ps_3"] = "46c0003dVGH",
573
+ ["c.le.ps_2"] = "46c0003eGH",
574
+ ["c.le.ps_3"] = "46c0003eVGH",
575
+ ["c.ngt.ps_2"] = "46c0003fGH",
576
+ ["c.ngt.ps_3"] = "46c0003fVGH",
577
+
578
+ ["cvt.s.w_2"] = "46800020FG",
579
+ ["cvt.d.w_2"] = "46800021FG",
580
+
581
+ ["cvt.s.l_2"] = "46a00020FG",
582
+ ["cvt.d.l_2"] = "46a00021FG",
583
+
584
+ -- Opcode COP1X.
585
+ lwxc1_2 = "4c000000FX",
586
+ ldxc1_2 = "4c000001FX",
587
+ luxc1_2 = "4c000005FX",
588
+ swxc1_2 = "4c000008FX",
589
+ sdxc1_2 = "4c000009FX",
590
+ suxc1_2 = "4c00000dFX",
591
+ prefx_2 = "4c00000fMX",
592
+ ["alnv.ps_4"] = "4c00001eFGHS",
593
+ ["madd.s_4"] = "4c000020FRGH",
594
+ ["madd.d_4"] = "4c000021FRGH",
595
+ ["madd.ps_4"] = "4c000026FRGH",
596
+ ["msub.s_4"] = "4c000028FRGH",
597
+ ["msub.d_4"] = "4c000029FRGH",
598
+ ["msub.ps_4"] = "4c00002eFRGH",
599
+ ["nmadd.s_4"] = "4c000030FRGH",
600
+ ["nmadd.d_4"] = "4c000031FRGH",
601
+ ["nmadd.ps_4"] = "4c000036FRGH",
602
+ ["nmsub.s_4"] = "4c000038FRGH",
603
+ ["nmsub.d_4"] = "4c000039FRGH",
604
+ ["nmsub.ps_4"] = "4c00003eFRGH",
605
+ }
606
+
607
+ ------------------------------------------------------------------------------
608
+
609
+ local function parse_gpr(expr)
610
+ local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$")
611
+ local tp = map_type[tname or expr]
612
+ if tp then
613
+ local reg = ovreg or tp.reg
614
+ if not reg then
615
+ werror("type `"..(tname or expr).."' needs a register override")
616
+ end
617
+ expr = reg
618
+ end
619
+ local r = match(expr, "^r([1-3]?[0-9])$")
620
+ if r then
621
+ r = tonumber(r)
622
+ if r <= 31 then return r, tp end
623
+ end
624
+ werror("bad register name `"..expr.."'")
625
+ end
626
+
627
+ local function parse_fpr(expr)
628
+ local r = match(expr, "^f([1-3]?[0-9])$")
629
+ if r then
630
+ r = tonumber(r)
631
+ if r <= 31 then return r end
632
+ end
633
+ werror("bad register name `"..expr.."'")
634
+ end
635
+
636
+ local function parse_imm(imm, bits, shift, scale, signed)
637
+ local n = tonumber(imm)
638
+ if n then
639
+ local m = sar(n, scale)
640
+ if shl(m, scale) == n then
641
+ if signed then
642
+ local s = sar(m, bits-1)
643
+ if s == 0 then return shl(m, shift)
644
+ elseif s == -1 then return shl(m + shl(1, bits), shift) end
645
+ else
646
+ if sar(m, bits) == 0 then return shl(m, shift) end
647
+ end
648
+ end
649
+ werror("out of range immediate `"..imm.."'")
650
+ elseif match(imm, "^[rf]([1-3]?[0-9])$") or
651
+ match(imm, "^([%w_]+):([rf][1-3]?[0-9])$") then
652
+ werror("expected immediate operand, got register")
653
+ else
654
+ waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm)
655
+ return 0
656
+ end
657
+ end
658
+
659
+ local function parse_disp(disp)
660
+ local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$")
661
+ if imm then
662
+ local r = shl(parse_gpr(reg), 21)
663
+ local extname = match(imm, "^extern%s+(%S+)$")
664
+ if extname then
665
+ waction("REL_EXT", map_extern[extname], nil, 1)
666
+ return r
667
+ else
668
+ return r + parse_imm(imm, 16, 0, 0, true)
669
+ end
670
+ end
671
+ local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$")
672
+ if reg and tailr ~= "" then
673
+ local r, tp = parse_gpr(reg)
674
+ if tp then
675
+ waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr))
676
+ return shl(r, 21)
677
+ end
678
+ end
679
+ werror("bad displacement `"..disp.."'")
680
+ end
681
+
682
+ local function parse_index(idx)
683
+ local rt, rs = match(idx, "^(.*)%(([%w_:]+)%)$")
684
+ if rt then
685
+ rt = parse_gpr(rt)
686
+ rs = parse_gpr(rs)
687
+ return shl(rt, 16) + shl(rs, 21)
688
+ end
689
+ werror("bad index `"..idx.."'")
690
+ end
691
+
692
+ local function parse_label(label, def)
693
+ local prefix = sub(label, 1, 2)
694
+ -- =>label (pc label reference)
695
+ if prefix == "=>" then
696
+ return "PC", 0, sub(label, 3)
697
+ end
698
+ -- ->name (global label reference)
699
+ if prefix == "->" then
700
+ return "LG", map_global[sub(label, 3)]
701
+ end
702
+ if def then
703
+ -- [1-9] (local label definition)
704
+ if match(label, "^[1-9]$") then
705
+ return "LG", 10+tonumber(label)
706
+ end
707
+ else
708
+ -- [<>][1-9] (local label reference)
709
+ local dir, lnum = match(label, "^([<>])([1-9])$")
710
+ if dir then -- Fwd: 1-9, Bkwd: 11-19.
711
+ return "LG", lnum + (dir == ">" and 0 or 10)
712
+ end
713
+ -- extern label (extern label reference)
714
+ local extname = match(label, "^extern%s+(%S+)$")
715
+ if extname then
716
+ return "EXT", map_extern[extname]
717
+ end
718
+ end
719
+ werror("bad label `"..label.."'")
720
+ end
721
+
722
+ ------------------------------------------------------------------------------
723
+
724
+ -- Handle opcodes defined with template strings.
725
+ map_op[".template__"] = function(params, template, nparams)
726
+ if not params then return sub(template, 9) end
727
+ local op = tonumber(sub(template, 1, 8), 16)
728
+ local n = 1
729
+
730
+ -- Limit number of section buffer positions used by a single dasm_put().
731
+ -- A single opcode needs a maximum of 2 positions (ins/ext).
732
+ if secpos+2 > maxsecpos then wflush() end
733
+ local pos = wpos()
734
+
735
+ -- Process each character.
736
+ for p in gmatch(sub(template, 9), ".") do
737
+ if p == "D" then
738
+ op = op + shl(parse_gpr(params[n]), 11); n = n + 1
739
+ elseif p == "T" then
740
+ op = op + shl(parse_gpr(params[n]), 16); n = n + 1
741
+ elseif p == "S" then
742
+ op = op + shl(parse_gpr(params[n]), 21); n = n + 1
743
+ elseif p == "F" then
744
+ op = op + shl(parse_fpr(params[n]), 6); n = n + 1
745
+ elseif p == "G" then
746
+ op = op + shl(parse_fpr(params[n]), 11); n = n + 1
747
+ elseif p == "H" then
748
+ op = op + shl(parse_fpr(params[n]), 16); n = n + 1
749
+ elseif p == "R" then
750
+ op = op + shl(parse_fpr(params[n]), 21); n = n + 1
751
+ elseif p == "I" then
752
+ op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1
753
+ elseif p == "U" then
754
+ op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1
755
+ elseif p == "O" then
756
+ op = op + parse_disp(params[n]); n = n + 1
757
+ elseif p == "X" then
758
+ op = op + parse_index(params[n]); n = n + 1
759
+ elseif p == "B" or p == "J" then
760
+ local mode, n, s = parse_label(params[n], false)
761
+ if p == "B" then n = n + 2048 end
762
+ waction("REL_"..mode, n, s, 1)
763
+ n = n + 1
764
+ elseif p == "A" then
765
+ op = op + parse_imm(params[n], 5, 6, 0, false); n = n + 1
766
+ elseif p == "M" then
767
+ op = op + parse_imm(params[n], 5, 11, 0, false); n = n + 1
768
+ elseif p == "N" then
769
+ op = op + parse_imm(params[n], 5, 16, 0, false); n = n + 1
770
+ elseif p == "C" then
771
+ op = op + parse_imm(params[n], 3, 18, 0, false); n = n + 1
772
+ elseif p == "V" then
773
+ op = op + parse_imm(params[n], 3, 8, 0, false); n = n + 1
774
+ elseif p == "W" then
775
+ op = op + parse_imm(params[n], 3, 0, 0, false); n = n + 1
776
+ elseif p == "Y" then
777
+ op = op + parse_imm(params[n], 20, 6, 0, false); n = n + 1
778
+ elseif p == "Z" then
779
+ op = op + parse_imm(params[n], 10, 6, 0, false); n = n + 1
780
+ elseif p == "=" then
781
+ op = op + shl(band(op, 0xf800), 5) -- Copy D to T for clz, clo.
782
+ else
783
+ assert(false)
784
+ end
785
+ end
786
+ wputpos(pos, op)
787
+ end
788
+
789
+ ------------------------------------------------------------------------------
790
+
791
+ -- Pseudo-opcode to mark the position where the action list is to be emitted.
792
+ map_op[".actionlist_1"] = function(params)
793
+ if not params then return "cvar" end
794
+ local name = params[1] -- No syntax check. You get to keep the pieces.
795
+ wline(function(out) writeactions(out, name) end)
796
+ end
797
+
798
+ -- Pseudo-opcode to mark the position where the global enum is to be emitted.
799
+ map_op[".globals_1"] = function(params)
800
+ if not params then return "prefix" end
801
+ local prefix = params[1] -- No syntax check. You get to keep the pieces.
802
+ wline(function(out) writeglobals(out, prefix) end)
803
+ end
804
+
805
+ -- Pseudo-opcode to mark the position where the global names are to be emitted.
806
+ map_op[".globalnames_1"] = function(params)
807
+ if not params then return "cvar" end
808
+ local name = params[1] -- No syntax check. You get to keep the pieces.
809
+ wline(function(out) writeglobalnames(out, name) end)
810
+ end
811
+
812
+ -- Pseudo-opcode to mark the position where the extern names are to be emitted.
813
+ map_op[".externnames_1"] = function(params)
814
+ if not params then return "cvar" end
815
+ local name = params[1] -- No syntax check. You get to keep the pieces.
816
+ wline(function(out) writeexternnames(out, name) end)
817
+ end
818
+
819
+ ------------------------------------------------------------------------------
820
+
821
+ -- Label pseudo-opcode (converted from trailing colon form).
822
+ map_op[".label_1"] = function(params)
823
+ if not params then return "[1-9] | ->global | =>pcexpr" end
824
+ if secpos+1 > maxsecpos then wflush() end
825
+ local mode, n, s = parse_label(params[1], true)
826
+ if mode == "EXT" then werror("bad label definition") end
827
+ waction("LABEL_"..mode, n, s, 1)
828
+ end
829
+
830
+ ------------------------------------------------------------------------------
831
+
832
+ -- Pseudo-opcodes for data storage.
833
+ map_op[".long_*"] = function(params)
834
+ if not params then return "imm..." end
835
+ for _,p in ipairs(params) do
836
+ local n = tonumber(p)
837
+ if not n then werror("bad immediate `"..p.."'") end
838
+ if n < 0 then n = n + 2^32 end
839
+ wputw(n)
840
+ if secpos+2 > maxsecpos then wflush() end
841
+ end
842
+ end
843
+
844
+ -- Alignment pseudo-opcode.
845
+ map_op[".align_1"] = function(params)
846
+ if not params then return "numpow2" end
847
+ if secpos+1 > maxsecpos then wflush() end
848
+ local align = tonumber(params[1])
849
+ if align then
850
+ local x = align
851
+ -- Must be a power of 2 in the range (2 ... 256).
852
+ for i=1,8 do
853
+ x = x / 2
854
+ if x == 1 then
855
+ waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1.
856
+ return
857
+ end
858
+ end
859
+ end
860
+ werror("bad alignment")
861
+ end
862
+
863
+ ------------------------------------------------------------------------------
864
+
865
+ -- Pseudo-opcode for (primitive) type definitions (map to C types).
866
+ map_op[".type_3"] = function(params, nparams)
867
+ if not params then
868
+ return nparams == 2 and "name, ctype" or "name, ctype, reg"
869
+ end
870
+ local name, ctype, reg = params[1], params[2], params[3]
871
+ if not match(name, "^[%a_][%w_]*$") then
872
+ werror("bad type name `"..name.."'")
873
+ end
874
+ local tp = map_type[name]
875
+ if tp then
876
+ werror("duplicate type `"..name.."'")
877
+ end
878
+ -- Add #type to defines. A bit unclean to put it in map_archdef.
879
+ map_archdef["#"..name] = "sizeof("..ctype..")"
880
+ -- Add new type and emit shortcut define.
881
+ local num = ctypenum + 1
882
+ map_type[name] = {
883
+ ctype = ctype,
884
+ ctypefmt = format("Dt%X(%%s)", num),
885
+ reg = reg,
886
+ }
887
+ wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype))
888
+ ctypenum = num
889
+ end
890
+ map_op[".type_2"] = map_op[".type_3"]
891
+
892
+ -- Dump type definitions.
893
+ local function dumptypes(out, lvl)
894
+ local t = {}
895
+ for name in pairs(map_type) do t[#t+1] = name end
896
+ sort(t)
897
+ out:write("Type definitions:\n")
898
+ for _,name in ipairs(t) do
899
+ local tp = map_type[name]
900
+ local reg = tp.reg or ""
901
+ out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg))
902
+ end
903
+ out:write("\n")
904
+ end
905
+
906
+ ------------------------------------------------------------------------------
907
+
908
+ -- Set the current section.
909
+ function _M.section(num)
910
+ waction("SECTION", num)
911
+ wflush(true) -- SECTION is a terminal action.
912
+ end
913
+
914
+ ------------------------------------------------------------------------------
915
+
916
+ -- Dump architecture description.
917
+ function _M.dumparch(out)
918
+ out:write(format("DynASM %s version %s, released %s\n\n",
919
+ _info.arch, _info.version, _info.release))
920
+ dumpactions(out)
921
+ end
922
+
923
+ -- Dump all user defined elements.
924
+ function _M.dumpdef(out, lvl)
925
+ dumptypes(out, lvl)
926
+ dumpglobals(out, lvl)
927
+ dumpexterns(out, lvl)
928
+ end
929
+
930
+ ------------------------------------------------------------------------------
931
+
932
+ -- Pass callbacks from/to the DynASM core.
933
+ function _M.passcb(wl, we, wf, ww)
934
+ wline, werror, wfatal, wwarn = wl, we, wf, ww
935
+ return wflush
936
+ end
937
+
938
+ -- Setup the arch-specific module.
939
+ function _M.setup(arch, opt)
940
+ g_arch, g_opt = arch, opt
941
+ end
942
+
943
+ -- Merge the core maps and the arch-specific maps.
944
+ function _M.mergemaps(map_coreop, map_def)
945
+ setmetatable(map_op, { __index = map_coreop })
946
+ setmetatable(map_def, { __index = map_archdef })
947
+ return map_op, map_def
948
+ end
949
+
950
+ return _M
951
+
952
+ ------------------------------------------------------------------------------
953
+