immunio 0.15.4 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +0 -27
- data/ext/immunio/Rakefile +9 -0
- data/lib/immunio/plugins/active_record.rb +1 -1
- data/lib/immunio/plugins/active_record_relation.rb +1 -1
- data/lib/immunio/plugins/environment_reporter.rb +20 -0
- data/lib/immunio/rufus_lua_ext/ref.rb +1 -3
- data/lib/immunio/version.rb +1 -1
- data/lib/immunio/vm.rb +1 -2
- data/lua-hooks/Makefile +97 -0
- data/lua-hooks/ext/all.c +41 -52
- data/lua-hooks/ext/all.o +0 -0
- data/lua-hooks/ext/libinjection/libinjection_html5.o +0 -0
- data/lua-hooks/ext/libinjection/libinjection_sqli.o +0 -0
- data/lua-hooks/ext/libinjection/libinjection_xss.o +0 -0
- data/lua-hooks/ext/libinjection/lualib.c +2 -2
- data/lua-hooks/ext/lpeg/lpcap.c +2 -2
- data/lua-hooks/ext/lpeg/lpcap.o +0 -0
- data/lua-hooks/ext/lpeg/lpcode.c +2 -2
- data/lua-hooks/ext/lpeg/lpcode.h +1 -1
- data/lua-hooks/ext/lpeg/lpcode.o +0 -0
- data/lua-hooks/ext/lpeg/lpprint.o +0 -0
- data/lua-hooks/ext/lpeg/lptree.c +2 -2
- data/lua-hooks/ext/lpeg/lptypes.h +1 -1
- data/lua-hooks/ext/lpeg/lpvm.c +2 -2
- data/lua-hooks/ext/lpeg/lpvm.o +0 -0
- data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +16 -3
- data/lua-hooks/ext/lua-snapshot/snapshot.c +14 -7
- data/lua-hooks/ext/luajit/COPYRIGHT +56 -0
- data/lua-hooks/ext/luajit/Makefile +159 -0
- data/lua-hooks/ext/luajit/README +16 -0
- data/lua-hooks/ext/luajit/doc/bluequad-print.css +166 -0
- data/lua-hooks/ext/luajit/doc/bluequad.css +325 -0
- data/lua-hooks/ext/luajit/doc/changes.html +804 -0
- data/lua-hooks/ext/luajit/doc/contact.html +104 -0
- data/lua-hooks/ext/luajit/doc/ext_c_api.html +189 -0
- data/lua-hooks/ext/luajit/doc/ext_ffi.html +332 -0
- data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +570 -0
- data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +1261 -0
- data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +603 -0
- data/lua-hooks/ext/luajit/doc/ext_jit.html +201 -0
- data/lua-hooks/ext/luajit/doc/ext_profiler.html +365 -0
- data/lua-hooks/ext/luajit/doc/extensions.html +448 -0
- data/lua-hooks/ext/luajit/doc/faq.html +186 -0
- data/lua-hooks/ext/luajit/doc/img/contact.png +0 -0
- data/lua-hooks/ext/luajit/doc/install.html +659 -0
- data/lua-hooks/ext/luajit/doc/luajit.html +236 -0
- data/lua-hooks/ext/luajit/doc/running.html +309 -0
- data/lua-hooks/ext/luajit/doc/status.html +118 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +456 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +1125 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +518 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +1166 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +416 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +953 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +419 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +1919 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +83 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +12 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +471 -0
- data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +1945 -0
- data/lua-hooks/ext/luajit/dynasm/dynasm.lua +1094 -0
- data/lua-hooks/ext/luajit/etc/luajit.1 +88 -0
- data/lua-hooks/ext/luajit/etc/luajit.pc +25 -0
- data/lua-hooks/ext/luajit/src/Makefile +697 -0
- data/lua-hooks/ext/luajit/src/Makefile.dep +244 -0
- data/lua-hooks/ext/luajit/src/host/README +4 -0
- data/lua-hooks/ext/luajit/src/host/buildvm +0 -0
- data/lua-hooks/ext/luajit/src/host/buildvm.c +518 -0
- data/lua-hooks/ext/luajit/src/host/buildvm.h +105 -0
- data/lua-hooks/ext/luajit/src/host/buildvm.o +0 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_arch.h +7449 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +345 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_asm.o +0 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +229 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_fold.o +0 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +457 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_lib.o +0 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_libbc.h +45 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +368 -0
- data/lua-hooks/ext/luajit/src/host/buildvm_peobj.o +0 -0
- data/lua-hooks/ext/luajit/src/host/genlibbc.lua +197 -0
- data/lua-hooks/ext/luajit/src/host/genminilua.lua +428 -0
- data/lua-hooks/ext/luajit/src/host/minilua +0 -0
- data/lua-hooks/ext/luajit/src/host/minilua.c +7770 -0
- data/lua-hooks/ext/luajit/src/host/minilua.o +0 -0
- data/lua-hooks/ext/luajit/src/jit/bc.lua +190 -0
- data/lua-hooks/ext/luajit/src/jit/bcsave.lua +661 -0
- data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +689 -0
- data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +428 -0
- data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +17 -0
- data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +591 -0
- data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +17 -0
- data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +838 -0
- data/lua-hooks/ext/luajit/src/jit/dump.lua +706 -0
- data/lua-hooks/ext/luajit/src/jit/p.lua +310 -0
- data/lua-hooks/ext/luajit/src/jit/v.lua +170 -0
- data/lua-hooks/ext/luajit/src/jit/vmdef.lua +362 -0
- data/lua-hooks/ext/luajit/src/jit/zone.lua +45 -0
- data/lua-hooks/ext/{lua → luajit/src}/lauxlib.h +10 -17
- data/lua-hooks/ext/luajit/src/lib_aux.c +356 -0
- data/lua-hooks/ext/luajit/src/lib_aux.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_aux_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_base.c +664 -0
- data/lua-hooks/ext/luajit/src/lib_base.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_base_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_bit.c +180 -0
- data/lua-hooks/ext/luajit/src/lib_bit.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_bit_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_debug.c +405 -0
- data/lua-hooks/ext/luajit/src/lib_debug.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_debug_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_ffi.c +872 -0
- data/lua-hooks/ext/luajit/src/lib_ffi.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_ffi_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_init.c +55 -0
- data/lua-hooks/ext/luajit/src/lib_init.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_init_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_io.c +541 -0
- data/lua-hooks/ext/luajit/src/lib_io.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_io_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_jit.c +767 -0
- data/lua-hooks/ext/luajit/src/lib_jit.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_jit_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_math.c +230 -0
- data/lua-hooks/ext/luajit/src/lib_math.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_math_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_os.c +292 -0
- data/lua-hooks/ext/luajit/src/lib_os.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_os_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_package.c +610 -0
- data/lua-hooks/ext/luajit/src/lib_package.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_package_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_string.c +752 -0
- data/lua-hooks/ext/luajit/src/lib_string.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_string_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_table.c +307 -0
- data/lua-hooks/ext/luajit/src/lib_table.o +0 -0
- data/lua-hooks/ext/luajit/src/lib_table_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/libluajit.a +0 -0
- data/lua-hooks/ext/luajit/src/libluajit.so +0 -0
- data/lua-hooks/ext/luajit/src/lj.supp +26 -0
- data/lua-hooks/ext/luajit/src/lj_alloc.c +1398 -0
- data/lua-hooks/ext/luajit/src/lj_alloc.h +17 -0
- data/lua-hooks/ext/luajit/src/lj_alloc.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_alloc_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_api.c +1210 -0
- data/lua-hooks/ext/luajit/src/lj_api.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_api_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_arch.h +509 -0
- data/lua-hooks/ext/luajit/src/lj_asm.c +2278 -0
- data/lua-hooks/ext/luajit/src/lj_asm.h +17 -0
- data/lua-hooks/ext/luajit/src/lj_asm.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_asm_arm.h +2217 -0
- data/lua-hooks/ext/luajit/src/lj_asm_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_asm_mips.h +1833 -0
- data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +2015 -0
- data/lua-hooks/ext/luajit/src/lj_asm_x86.h +2634 -0
- data/lua-hooks/ext/luajit/src/lj_bc.c +14 -0
- data/lua-hooks/ext/luajit/src/lj_bc.h +265 -0
- data/lua-hooks/ext/luajit/src/lj_bc.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_bc_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_bcdef.h +220 -0
- data/lua-hooks/ext/luajit/src/lj_bcdump.h +68 -0
- data/lua-hooks/ext/luajit/src/lj_bcread.c +457 -0
- data/lua-hooks/ext/luajit/src/lj_bcread.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_bcread_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_bcwrite.c +361 -0
- data/lua-hooks/ext/luajit/src/lj_bcwrite.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_bcwrite_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_buf.c +234 -0
- data/lua-hooks/ext/luajit/src/lj_buf.h +105 -0
- data/lua-hooks/ext/luajit/src/lj_buf.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_buf_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_carith.c +429 -0
- data/lua-hooks/ext/luajit/src/lj_carith.h +37 -0
- data/lua-hooks/ext/luajit/src/lj_carith.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_carith_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ccall.c +984 -0
- data/lua-hooks/ext/luajit/src/lj_ccall.h +178 -0
- data/lua-hooks/ext/luajit/src/lj_ccall.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ccall_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ccallback.c +712 -0
- data/lua-hooks/ext/luajit/src/lj_ccallback.h +25 -0
- data/lua-hooks/ext/luajit/src/lj_ccallback.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ccallback_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cconv.c +752 -0
- data/lua-hooks/ext/luajit/src/lj_cconv.h +70 -0
- data/lua-hooks/ext/luajit/src/lj_cconv.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cconv_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cdata.c +288 -0
- data/lua-hooks/ext/luajit/src/lj_cdata.h +76 -0
- data/lua-hooks/ext/luajit/src/lj_cdata.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cdata_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_char.c +43 -0
- data/lua-hooks/ext/luajit/src/lj_char.h +42 -0
- data/lua-hooks/ext/luajit/src/lj_char.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_char_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_clib.c +418 -0
- data/lua-hooks/ext/luajit/src/lj_clib.h +29 -0
- data/lua-hooks/ext/luajit/src/lj_clib.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_clib_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cparse.c +1862 -0
- data/lua-hooks/ext/luajit/src/lj_cparse.h +65 -0
- data/lua-hooks/ext/luajit/src/lj_cparse.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_cparse_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_crecord.c +1834 -0
- data/lua-hooks/ext/luajit/src/lj_crecord.h +38 -0
- data/lua-hooks/ext/luajit/src/lj_crecord.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_crecord_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ctype.c +635 -0
- data/lua-hooks/ext/luajit/src/lj_ctype.h +461 -0
- data/lua-hooks/ext/luajit/src/lj_ctype.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ctype_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_debug.c +699 -0
- data/lua-hooks/ext/luajit/src/lj_debug.h +65 -0
- data/lua-hooks/ext/luajit/src/lj_debug.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_debug_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_def.h +365 -0
- data/lua-hooks/ext/luajit/src/lj_dispatch.c +557 -0
- data/lua-hooks/ext/luajit/src/lj_dispatch.h +138 -0
- data/lua-hooks/ext/luajit/src/lj_dispatch.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_dispatch_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_emit_arm.h +356 -0
- data/lua-hooks/ext/luajit/src/lj_emit_mips.h +211 -0
- data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +238 -0
- data/lua-hooks/ext/luajit/src/lj_emit_x86.h +462 -0
- data/lua-hooks/ext/luajit/src/lj_err.c +794 -0
- data/lua-hooks/ext/luajit/src/lj_err.h +41 -0
- data/lua-hooks/ext/luajit/src/lj_err.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_err_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_errmsg.h +190 -0
- data/lua-hooks/ext/luajit/src/lj_ff.h +18 -0
- data/lua-hooks/ext/luajit/src/lj_ffdef.h +209 -0
- data/lua-hooks/ext/luajit/src/lj_ffrecord.c +1247 -0
- data/lua-hooks/ext/luajit/src/lj_ffrecord.h +24 -0
- data/lua-hooks/ext/luajit/src/lj_ffrecord.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ffrecord_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_folddef.h +1138 -0
- data/lua-hooks/ext/luajit/src/lj_frame.h +259 -0
- data/lua-hooks/ext/luajit/src/lj_func.c +185 -0
- data/lua-hooks/ext/luajit/src/lj_func.h +24 -0
- data/lua-hooks/ext/luajit/src/lj_func.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_func_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_gc.c +845 -0
- data/lua-hooks/ext/luajit/src/lj_gc.h +134 -0
- data/lua-hooks/ext/luajit/src/lj_gc.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_gc_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_gdbjit.c +787 -0
- data/lua-hooks/ext/luajit/src/lj_gdbjit.h +22 -0
- data/lua-hooks/ext/luajit/src/lj_gdbjit.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_gdbjit_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ir.c +505 -0
- data/lua-hooks/ext/luajit/src/lj_ir.h +577 -0
- data/lua-hooks/ext/luajit/src/lj_ir.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ir_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_ircall.h +321 -0
- data/lua-hooks/ext/luajit/src/lj_iropt.h +161 -0
- data/lua-hooks/ext/luajit/src/lj_jit.h +440 -0
- data/lua-hooks/ext/luajit/src/lj_lex.c +482 -0
- data/lua-hooks/ext/luajit/src/lj_lex.h +86 -0
- data/lua-hooks/ext/luajit/src/lj_lex.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_lex_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_lib.c +303 -0
- data/lua-hooks/ext/luajit/src/lj_lib.h +115 -0
- data/lua-hooks/ext/luajit/src/lj_lib.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_lib_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_libdef.h +414 -0
- data/lua-hooks/ext/luajit/src/lj_load.c +168 -0
- data/lua-hooks/ext/luajit/src/lj_load.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_load_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_mcode.c +386 -0
- data/lua-hooks/ext/luajit/src/lj_mcode.h +30 -0
- data/lua-hooks/ext/luajit/src/lj_mcode.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_mcode_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_meta.c +477 -0
- data/lua-hooks/ext/luajit/src/lj_meta.h +38 -0
- data/lua-hooks/ext/luajit/src/lj_meta.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_meta_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_obj.c +50 -0
- data/lua-hooks/ext/luajit/src/lj_obj.h +976 -0
- data/lua-hooks/ext/luajit/src/lj_obj.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_obj_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_dce.c +78 -0
- data/lua-hooks/ext/luajit/src/lj_opt_dce.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_dce_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_fold.c +2488 -0
- data/lua-hooks/ext/luajit/src/lj_opt_fold.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_fold_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_loop.c +449 -0
- data/lua-hooks/ext/luajit/src/lj_opt_loop.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_loop_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_mem.c +935 -0
- data/lua-hooks/ext/luajit/src/lj_opt_mem.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_mem_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +652 -0
- data/lua-hooks/ext/luajit/src/lj_opt_narrow.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_narrow_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_sink.c +245 -0
- data/lua-hooks/ext/luajit/src/lj_opt_sink.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_sink_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_split.c +856 -0
- data/lua-hooks/ext/luajit/src/lj_opt_split.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_opt_split_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_parse.c +2725 -0
- data/lua-hooks/ext/luajit/src/lj_parse.h +18 -0
- data/lua-hooks/ext/luajit/src/lj_parse.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_parse_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_profile.c +368 -0
- data/lua-hooks/ext/luajit/src/lj_profile.h +21 -0
- data/lua-hooks/ext/luajit/src/lj_profile.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_profile_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_recdef.h +270 -0
- data/lua-hooks/ext/luajit/src/lj_record.c +2554 -0
- data/lua-hooks/ext/luajit/src/lj_record.h +45 -0
- data/lua-hooks/ext/luajit/src/lj_record.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_record_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_snap.c +870 -0
- data/lua-hooks/ext/luajit/src/lj_snap.h +34 -0
- data/lua-hooks/ext/luajit/src/lj_snap.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_snap_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_state.c +300 -0
- data/lua-hooks/ext/luajit/src/lj_state.h +35 -0
- data/lua-hooks/ext/luajit/src/lj_state.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_state_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_str.c +197 -0
- data/lua-hooks/ext/luajit/src/lj_str.h +27 -0
- data/lua-hooks/ext/luajit/src/lj_str.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_str_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_strfmt.c +554 -0
- data/lua-hooks/ext/luajit/src/lj_strfmt.h +125 -0
- data/lua-hooks/ext/luajit/src/lj_strfmt.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_strfmt_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_strscan.c +547 -0
- data/lua-hooks/ext/luajit/src/lj_strscan.h +39 -0
- data/lua-hooks/ext/luajit/src/lj_strscan.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_strscan_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_tab.c +666 -0
- data/lua-hooks/ext/luajit/src/lj_tab.h +73 -0
- data/lua-hooks/ext/luajit/src/lj_tab.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_tab_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_target.h +164 -0
- data/lua-hooks/ext/luajit/src/lj_target_arm.h +270 -0
- data/lua-hooks/ext/luajit/src/lj_target_arm64.h +97 -0
- data/lua-hooks/ext/luajit/src/lj_target_mips.h +260 -0
- data/lua-hooks/ext/luajit/src/lj_target_ppc.h +280 -0
- data/lua-hooks/ext/luajit/src/lj_target_x86.h +345 -0
- data/lua-hooks/ext/luajit/src/lj_trace.c +859 -0
- data/lua-hooks/ext/luajit/src/lj_trace.h +54 -0
- data/lua-hooks/ext/luajit/src/lj_trace.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_trace_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_traceerr.h +63 -0
- data/lua-hooks/ext/luajit/src/lj_udata.c +34 -0
- data/lua-hooks/ext/luajit/src/lj_udata.h +14 -0
- data/lua-hooks/ext/luajit/src/lj_udata.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_udata_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vm.S +2730 -0
- data/lua-hooks/ext/luajit/src/lj_vm.h +114 -0
- data/lua-hooks/ext/luajit/src/lj_vm.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vm_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vmevent.c +58 -0
- data/lua-hooks/ext/luajit/src/lj_vmevent.h +59 -0
- data/lua-hooks/ext/luajit/src/lj_vmevent.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vmevent_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vmmath.c +152 -0
- data/lua-hooks/ext/luajit/src/lj_vmmath.o +0 -0
- data/lua-hooks/ext/luajit/src/lj_vmmath_dyn.o +0 -0
- data/lua-hooks/ext/luajit/src/ljamalg.c +96 -0
- data/lua-hooks/ext/{lua → luajit/src}/lua.h +12 -7
- data/lua-hooks/ext/luajit/src/lua.hpp +9 -0
- data/lua-hooks/ext/luajit/src/luaconf.h +156 -0
- data/lua-hooks/ext/luajit/src/luajit +0 -0
- data/lua-hooks/ext/luajit/src/luajit.c +570 -0
- data/lua-hooks/ext/luajit/src/luajit.h +79 -0
- data/lua-hooks/ext/luajit/src/luajit.o +0 -0
- data/lua-hooks/ext/luajit/src/lualib.h +43 -0
- data/lua-hooks/ext/luajit/src/msvcbuild.bat +114 -0
- data/lua-hooks/ext/luajit/src/ps4build.bat +103 -0
- data/lua-hooks/ext/luajit/src/psvitabuild.bat +93 -0
- data/lua-hooks/ext/luajit/src/vm_arm.dasc +4585 -0
- data/lua-hooks/ext/luajit/src/vm_arm64.dasc +3764 -0
- data/lua-hooks/ext/luajit/src/vm_mips.dasc +4355 -0
- data/lua-hooks/ext/luajit/src/vm_ppc.dasc +5252 -0
- data/lua-hooks/ext/luajit/src/vm_x64.dasc +4902 -0
- data/lua-hooks/ext/luajit/src/vm_x86.dasc +5710 -0
- data/lua-hooks/ext/luajit/src/xb1build.bat +101 -0
- data/lua-hooks/ext/luajit/src/xedkbuild.bat +92 -0
- data/lua-hooks/ext/luautf8/lutf8lib.c +3 -3
- data/lua-hooks/lib/boot.lua +37 -2
- metadata +372 -69
- data/lua-hooks/ext/bitop/README +0 -22
- data/lua-hooks/ext/bitop/bit.c +0 -189
- data/lua-hooks/ext/extconf.rb +0 -38
- data/lua-hooks/ext/lua/COPYRIGHT +0 -34
- data/lua-hooks/ext/lua/lapi.c +0 -1087
- data/lua-hooks/ext/lua/lapi.h +0 -16
- data/lua-hooks/ext/lua/lauxlib.c +0 -652
- data/lua-hooks/ext/lua/lbaselib.c +0 -659
- data/lua-hooks/ext/lua/lcode.c +0 -831
- data/lua-hooks/ext/lua/lcode.h +0 -76
- data/lua-hooks/ext/lua/ldblib.c +0 -398
- data/lua-hooks/ext/lua/ldebug.c +0 -638
- data/lua-hooks/ext/lua/ldebug.h +0 -33
- data/lua-hooks/ext/lua/ldo.c +0 -519
- data/lua-hooks/ext/lua/ldo.h +0 -57
- data/lua-hooks/ext/lua/ldump.c +0 -164
- data/lua-hooks/ext/lua/lfunc.c +0 -174
- data/lua-hooks/ext/lua/lfunc.h +0 -34
- data/lua-hooks/ext/lua/lgc.c +0 -710
- data/lua-hooks/ext/lua/lgc.h +0 -110
- data/lua-hooks/ext/lua/linit.c +0 -38
- data/lua-hooks/ext/lua/liolib.c +0 -556
- data/lua-hooks/ext/lua/llex.c +0 -463
- data/lua-hooks/ext/lua/llex.h +0 -81
- data/lua-hooks/ext/lua/llimits.h +0 -128
- data/lua-hooks/ext/lua/lmathlib.c +0 -263
- data/lua-hooks/ext/lua/lmem.c +0 -86
- data/lua-hooks/ext/lua/lmem.h +0 -49
- data/lua-hooks/ext/lua/loadlib.c +0 -705
- data/lua-hooks/ext/lua/loadlib_rel.c +0 -760
- data/lua-hooks/ext/lua/lobject.c +0 -214
- data/lua-hooks/ext/lua/lobject.h +0 -381
- data/lua-hooks/ext/lua/lopcodes.c +0 -102
- data/lua-hooks/ext/lua/lopcodes.h +0 -268
- data/lua-hooks/ext/lua/loslib.c +0 -243
- data/lua-hooks/ext/lua/lparser.c +0 -1339
- data/lua-hooks/ext/lua/lparser.h +0 -82
- data/lua-hooks/ext/lua/lstate.c +0 -214
- data/lua-hooks/ext/lua/lstate.h +0 -169
- data/lua-hooks/ext/lua/lstring.c +0 -111
- data/lua-hooks/ext/lua/lstring.h +0 -31
- data/lua-hooks/ext/lua/lstrlib.c +0 -871
- data/lua-hooks/ext/lua/ltable.c +0 -588
- data/lua-hooks/ext/lua/ltable.h +0 -40
- data/lua-hooks/ext/lua/ltablib.c +0 -287
- data/lua-hooks/ext/lua/ltm.c +0 -75
- data/lua-hooks/ext/lua/ltm.h +0 -54
- data/lua-hooks/ext/lua/lua.c +0 -392
- data/lua-hooks/ext/lua/lua.def +0 -131
- data/lua-hooks/ext/lua/lua.rc +0 -28
- data/lua-hooks/ext/lua/lua_dll.rc +0 -26
- data/lua-hooks/ext/lua/luac.c +0 -200
- data/lua-hooks/ext/lua/luac.rc +0 -1
- data/lua-hooks/ext/lua/luaconf.h +0 -763
- data/lua-hooks/ext/lua/luaconf.h.in +0 -724
- data/lua-hooks/ext/lua/luaconf.h.orig +0 -763
- data/lua-hooks/ext/lua/lualib.h +0 -53
- data/lua-hooks/ext/lua/lundump.c +0 -227
- data/lua-hooks/ext/lua/lundump.h +0 -36
- data/lua-hooks/ext/lua/lvm.c +0 -767
- data/lua-hooks/ext/lua/lvm.h +0 -36
- data/lua-hooks/ext/lua/lzio.c +0 -82
- data/lua-hooks/ext/lua/lzio.h +0 -67
- data/lua-hooks/ext/lua/print.c +0 -227
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
** $Id: lua.h,v 1.218.1.
|
2
|
+
** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
|
3
3
|
** Lua - An Extensible Extension Language
|
4
4
|
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
5
5
|
** See Copyright Notice at the end of this file
|
@@ -17,10 +17,10 @@
|
|
17
17
|
|
18
18
|
|
19
19
|
#define LUA_VERSION "Lua 5.1"
|
20
|
-
#define LUA_RELEASE "Lua 5.1.
|
20
|
+
#define LUA_RELEASE "Lua 5.1.4"
|
21
21
|
#define LUA_VERSION_NUM 501
|
22
|
-
#define LUA_COPYRIGHT "Copyright (C) 1994-
|
23
|
-
#define LUA_AUTHORS
|
22
|
+
#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
|
23
|
+
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
|
24
24
|
|
25
25
|
|
26
26
|
/* mark for precompiled code (`<esc>Lua') */
|
@@ -245,7 +245,7 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
|
|
245
245
|
|
246
246
|
|
247
247
|
|
248
|
-
/*
|
248
|
+
/*
|
249
249
|
** ===============================================================
|
250
250
|
** some useful macros
|
251
251
|
** ===============================================================
|
@@ -336,12 +336,17 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
|
|
336
336
|
LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
|
337
337
|
LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
|
338
338
|
LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
|
339
|
-
|
340
339
|
LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
|
341
340
|
LUA_API lua_Hook lua_gethook (lua_State *L);
|
342
341
|
LUA_API int lua_gethookmask (lua_State *L);
|
343
342
|
LUA_API int lua_gethookcount (lua_State *L);
|
344
343
|
|
344
|
+
/* From Lua 5.2. */
|
345
|
+
LUA_API void *lua_upvalueid (lua_State *L, int idx, int n);
|
346
|
+
LUA_API void lua_upvaluejoin (lua_State *L, int idx1, int n1, int idx2, int n2);
|
347
|
+
LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt,
|
348
|
+
const char *chunkname, const char *mode);
|
349
|
+
|
345
350
|
|
346
351
|
struct lua_Debug {
|
347
352
|
int event;
|
@@ -362,7 +367,7 @@ struct lua_Debug {
|
|
362
367
|
|
363
368
|
|
364
369
|
/******************************************************************************
|
365
|
-
* Copyright (C) 1994-
|
370
|
+
* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
|
366
371
|
*
|
367
372
|
* Permission is hereby granted, free of charge, to any person obtaining
|
368
373
|
* a copy of this software and associated documentation files (the
|
@@ -0,0 +1,156 @@
|
|
1
|
+
/*
|
2
|
+
** Configuration header.
|
3
|
+
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
#ifndef luaconf_h
|
7
|
+
#define luaconf_h
|
8
|
+
|
9
|
+
#ifndef WINVER
|
10
|
+
#define WINVER 0x0501
|
11
|
+
#endif
|
12
|
+
#include <limits.h>
|
13
|
+
#include <stddef.h>
|
14
|
+
|
15
|
+
/* Default path for loading Lua and C modules with require(). */
|
16
|
+
#if defined(_WIN32)
|
17
|
+
/*
|
18
|
+
** In Windows, any exclamation mark ('!') in the path is replaced by the
|
19
|
+
** path of the directory of the executable file of the current process.
|
20
|
+
*/
|
21
|
+
#define LUA_LDIR "!\\lua\\"
|
22
|
+
#define LUA_CDIR "!\\"
|
23
|
+
#define LUA_PATH_DEFAULT \
|
24
|
+
".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;"
|
25
|
+
#define LUA_CPATH_DEFAULT \
|
26
|
+
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
|
27
|
+
#else
|
28
|
+
/*
|
29
|
+
** Note to distribution maintainers: do NOT patch the following lines!
|
30
|
+
** Please read ../doc/install.html#distro and pass PREFIX=/usr instead.
|
31
|
+
*/
|
32
|
+
#ifndef LUA_MULTILIB
|
33
|
+
#define LUA_MULTILIB "lib"
|
34
|
+
#endif
|
35
|
+
#ifndef LUA_LMULTILIB
|
36
|
+
#define LUA_LMULTILIB "lib"
|
37
|
+
#endif
|
38
|
+
#define LUA_LROOT "/usr/local"
|
39
|
+
#define LUA_LUADIR "/lua/5.1/"
|
40
|
+
#define LUA_LJDIR "/luajit-2.1.0-beta1/"
|
41
|
+
|
42
|
+
#ifdef LUA_ROOT
|
43
|
+
#define LUA_JROOT LUA_ROOT
|
44
|
+
#define LUA_RLDIR LUA_ROOT "/share" LUA_LUADIR
|
45
|
+
#define LUA_RCDIR LUA_ROOT "/" LUA_MULTILIB LUA_LUADIR
|
46
|
+
#define LUA_RLPATH ";" LUA_RLDIR "?.lua;" LUA_RLDIR "?/init.lua"
|
47
|
+
#define LUA_RCPATH ";" LUA_RCDIR "?.so"
|
48
|
+
#else
|
49
|
+
#define LUA_JROOT LUA_LROOT
|
50
|
+
#define LUA_RLPATH
|
51
|
+
#define LUA_RCPATH
|
52
|
+
#endif
|
53
|
+
|
54
|
+
#define LUA_JPATH ";" LUA_JROOT "/share" LUA_LJDIR "?.lua"
|
55
|
+
#define LUA_LLDIR LUA_LROOT "/share" LUA_LUADIR
|
56
|
+
#define LUA_LCDIR LUA_LROOT "/" LUA_LMULTILIB LUA_LUADIR
|
57
|
+
#define LUA_LLPATH ";" LUA_LLDIR "?.lua;" LUA_LLDIR "?/init.lua"
|
58
|
+
#define LUA_LCPATH1 ";" LUA_LCDIR "?.so"
|
59
|
+
#define LUA_LCPATH2 ";" LUA_LCDIR "loadall.so"
|
60
|
+
|
61
|
+
#define LUA_PATH_DEFAULT "./?.lua" LUA_JPATH LUA_LLPATH LUA_RLPATH
|
62
|
+
#define LUA_CPATH_DEFAULT "./?.so" LUA_LCPATH1 LUA_RCPATH LUA_LCPATH2
|
63
|
+
#endif
|
64
|
+
|
65
|
+
/* Environment variable names for path overrides and initialization code. */
|
66
|
+
#define LUA_PATH "LUA_PATH"
|
67
|
+
#define LUA_CPATH "LUA_CPATH"
|
68
|
+
#define LUA_INIT "LUA_INIT"
|
69
|
+
|
70
|
+
/* Special file system characters. */
|
71
|
+
#if defined(_WIN32)
|
72
|
+
#define LUA_DIRSEP "\\"
|
73
|
+
#else
|
74
|
+
#define LUA_DIRSEP "/"
|
75
|
+
#endif
|
76
|
+
#define LUA_PATHSEP ";"
|
77
|
+
#define LUA_PATH_MARK "?"
|
78
|
+
#define LUA_EXECDIR "!"
|
79
|
+
#define LUA_IGMARK "-"
|
80
|
+
#define LUA_PATH_CONFIG \
|
81
|
+
LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \
|
82
|
+
LUA_EXECDIR "\n" LUA_IGMARK
|
83
|
+
|
84
|
+
/* Quoting in error messages. */
|
85
|
+
#define LUA_QL(x) "'" x "'"
|
86
|
+
#define LUA_QS LUA_QL("%s")
|
87
|
+
|
88
|
+
/* Various tunables. */
|
89
|
+
#define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */
|
90
|
+
#define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */
|
91
|
+
#define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */
|
92
|
+
#define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */
|
93
|
+
#define LUA_MAXCAPTURES 32 /* Max. pattern captures. */
|
94
|
+
|
95
|
+
/* Compatibility with older library function names. */
|
96
|
+
#define LUA_COMPAT_MOD /* OLD: math.mod, NEW: math.fmod */
|
97
|
+
#define LUA_COMPAT_GFIND /* OLD: string.gfind, NEW: string.gmatch */
|
98
|
+
|
99
|
+
/* Configuration for the frontend (the luajit executable). */
|
100
|
+
#if defined(luajit_c)
|
101
|
+
#define LUA_PROGNAME "luajit" /* Fallback frontend name. */
|
102
|
+
#define LUA_PROMPT "> " /* Interactive prompt. */
|
103
|
+
#define LUA_PROMPT2 ">> " /* Continuation prompt. */
|
104
|
+
#define LUA_MAXINPUT 512 /* Max. input line length. */
|
105
|
+
#endif
|
106
|
+
|
107
|
+
/* Note: changing the following defines breaks the Lua 5.1 ABI. */
|
108
|
+
#define LUA_INTEGER ptrdiff_t
|
109
|
+
#define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */
|
110
|
+
/*
|
111
|
+
** Size of lauxlib and io.* on-stack buffers. Weird workaround to avoid using
|
112
|
+
** unreasonable amounts of stack space, but still retain ABI compatibility.
|
113
|
+
** Blame Lua for depending on BUFSIZ in the ABI, blame **** for wrecking it.
|
114
|
+
*/
|
115
|
+
#define LUAL_BUFFERSIZE (BUFSIZ > 16384 ? 8192 : BUFSIZ)
|
116
|
+
|
117
|
+
/* The following defines are here only for compatibility with luaconf.h
|
118
|
+
** from the standard Lua distribution. They must not be changed for LuaJIT.
|
119
|
+
*/
|
120
|
+
#define LUA_NUMBER_DOUBLE
|
121
|
+
#define LUA_NUMBER double
|
122
|
+
#define LUAI_UACNUMBER double
|
123
|
+
#define LUA_NUMBER_SCAN "%lf"
|
124
|
+
#define LUA_NUMBER_FMT "%.14g"
|
125
|
+
#define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n))
|
126
|
+
#define LUAI_MAXNUMBER2STR 32
|
127
|
+
#define LUA_INTFRMLEN "l"
|
128
|
+
#define LUA_INTFRM_T long
|
129
|
+
|
130
|
+
/* Linkage of public API functions. */
|
131
|
+
#if defined(LUA_BUILD_AS_DLL)
|
132
|
+
#if defined(LUA_CORE) || defined(LUA_LIB)
|
133
|
+
#define LUA_API __declspec(dllexport)
|
134
|
+
#else
|
135
|
+
#define LUA_API __declspec(dllimport)
|
136
|
+
#endif
|
137
|
+
#else
|
138
|
+
#define LUA_API extern
|
139
|
+
#endif
|
140
|
+
|
141
|
+
#define LUALIB_API LUA_API
|
142
|
+
|
143
|
+
/* Support for internal assertions. */
|
144
|
+
#if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK)
|
145
|
+
#include <assert.h>
|
146
|
+
#endif
|
147
|
+
#ifdef LUA_USE_ASSERT
|
148
|
+
#define lua_assert(x) assert(x)
|
149
|
+
#endif
|
150
|
+
#ifdef LUA_USE_APICHECK
|
151
|
+
#define luai_apicheck(L, o) { (void)L; assert(o); }
|
152
|
+
#else
|
153
|
+
#define luai_apicheck(L, o) { (void)L; }
|
154
|
+
#endif
|
155
|
+
|
156
|
+
#endif
|
Binary file
|
@@ -0,0 +1,570 @@
|
|
1
|
+
/*
|
2
|
+
** LuaJIT frontend. Runs commands, scripts, read-eval-print (REPL) etc.
|
3
|
+
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
|
4
|
+
**
|
5
|
+
** Major portions taken verbatim or adapted from the Lua interpreter.
|
6
|
+
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
7
|
+
*/
|
8
|
+
|
9
|
+
#include <stdio.h>
|
10
|
+
#include <stdlib.h>
|
11
|
+
#include <string.h>
|
12
|
+
|
13
|
+
#define luajit_c
|
14
|
+
|
15
|
+
#include "lua.h"
|
16
|
+
#include "lauxlib.h"
|
17
|
+
#include "lualib.h"
|
18
|
+
#include "luajit.h"
|
19
|
+
|
20
|
+
#include "lj_arch.h"
|
21
|
+
|
22
|
+
#if LJ_TARGET_POSIX
|
23
|
+
#include <unistd.h>
|
24
|
+
#define lua_stdin_is_tty() isatty(0)
|
25
|
+
#elif LJ_TARGET_WINDOWS
|
26
|
+
#include <io.h>
|
27
|
+
#ifdef __BORLANDC__
|
28
|
+
#define lua_stdin_is_tty() isatty(_fileno(stdin))
|
29
|
+
#else
|
30
|
+
#define lua_stdin_is_tty() _isatty(_fileno(stdin))
|
31
|
+
#endif
|
32
|
+
#else
|
33
|
+
#define lua_stdin_is_tty() 1
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#if !LJ_TARGET_CONSOLE
|
37
|
+
#include <signal.h>
|
38
|
+
#endif
|
39
|
+
|
40
|
+
static lua_State *globalL = NULL;
|
41
|
+
static const char *progname = LUA_PROGNAME;
|
42
|
+
|
43
|
+
#if !LJ_TARGET_CONSOLE
|
44
|
+
static void lstop(lua_State *L, lua_Debug *ar)
|
45
|
+
{
|
46
|
+
(void)ar; /* unused arg. */
|
47
|
+
lua_sethook(L, NULL, 0, 0);
|
48
|
+
/* Avoid luaL_error -- a C hook doesn't add an extra frame. */
|
49
|
+
luaL_where(L, 0);
|
50
|
+
lua_pushfstring(L, "%sinterrupted!", lua_tostring(L, -1));
|
51
|
+
lua_error(L);
|
52
|
+
}
|
53
|
+
|
54
|
+
static void laction(int i)
|
55
|
+
{
|
56
|
+
signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
|
57
|
+
terminate process (default action) */
|
58
|
+
lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
|
59
|
+
}
|
60
|
+
#endif
|
61
|
+
|
62
|
+
static void print_usage(void)
|
63
|
+
{
|
64
|
+
fputs("usage: ", stderr);
|
65
|
+
fputs(progname, stderr);
|
66
|
+
fputs(" [options]... [script [args]...].\n"
|
67
|
+
"Available options are:\n"
|
68
|
+
" -e chunk Execute string " LUA_QL("chunk") ".\n"
|
69
|
+
" -l name Require library " LUA_QL("name") ".\n"
|
70
|
+
" -b ... Save or list bytecode.\n"
|
71
|
+
" -j cmd Perform LuaJIT control command.\n"
|
72
|
+
" -O[opt] Control LuaJIT optimizations.\n"
|
73
|
+
" -i Enter interactive mode after executing " LUA_QL("script") ".\n"
|
74
|
+
" -v Show version information.\n"
|
75
|
+
" -E Ignore environment variables.\n"
|
76
|
+
" -- Stop handling options.\n"
|
77
|
+
" - Execute stdin and stop handling options.\n", stderr);
|
78
|
+
fflush(stderr);
|
79
|
+
}
|
80
|
+
|
81
|
+
static void l_message(const char *pname, const char *msg)
|
82
|
+
{
|
83
|
+
if (pname) { fputs(pname, stderr); fputc(':', stderr); fputc(' ', stderr); }
|
84
|
+
fputs(msg, stderr); fputc('\n', stderr);
|
85
|
+
fflush(stderr);
|
86
|
+
}
|
87
|
+
|
88
|
+
static int report(lua_State *L, int status)
|
89
|
+
{
|
90
|
+
if (status && !lua_isnil(L, -1)) {
|
91
|
+
const char *msg = lua_tostring(L, -1);
|
92
|
+
if (msg == NULL) msg = "(error object is not a string)";
|
93
|
+
l_message(progname, msg);
|
94
|
+
lua_pop(L, 1);
|
95
|
+
}
|
96
|
+
return status;
|
97
|
+
}
|
98
|
+
|
99
|
+
static int traceback(lua_State *L)
|
100
|
+
{
|
101
|
+
if (!lua_isstring(L, 1)) { /* Non-string error object? Try metamethod. */
|
102
|
+
if (lua_isnoneornil(L, 1) ||
|
103
|
+
!luaL_callmeta(L, 1, "__tostring") ||
|
104
|
+
!lua_isstring(L, -1))
|
105
|
+
return 1; /* Return non-string error object. */
|
106
|
+
lua_remove(L, 1); /* Replace object by result of __tostring metamethod. */
|
107
|
+
}
|
108
|
+
luaL_traceback(L, L, lua_tostring(L, 1), 1);
|
109
|
+
return 1;
|
110
|
+
}
|
111
|
+
|
112
|
+
static int docall(lua_State *L, int narg, int clear)
|
113
|
+
{
|
114
|
+
int status;
|
115
|
+
int base = lua_gettop(L) - narg; /* function index */
|
116
|
+
lua_pushcfunction(L, traceback); /* push traceback function */
|
117
|
+
lua_insert(L, base); /* put it under chunk and args */
|
118
|
+
#if !LJ_TARGET_CONSOLE
|
119
|
+
signal(SIGINT, laction);
|
120
|
+
#endif
|
121
|
+
status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
|
122
|
+
#if !LJ_TARGET_CONSOLE
|
123
|
+
signal(SIGINT, SIG_DFL);
|
124
|
+
#endif
|
125
|
+
lua_remove(L, base); /* remove traceback function */
|
126
|
+
/* force a complete garbage collection in case of errors */
|
127
|
+
if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0);
|
128
|
+
return status;
|
129
|
+
}
|
130
|
+
|
131
|
+
static void print_version(void)
|
132
|
+
{
|
133
|
+
fputs(LUAJIT_VERSION " -- " LUAJIT_COPYRIGHT ". " LUAJIT_URL "\n", stdout);
|
134
|
+
}
|
135
|
+
|
136
|
+
static void print_jit_status(lua_State *L)
|
137
|
+
{
|
138
|
+
int n;
|
139
|
+
const char *s;
|
140
|
+
lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
|
141
|
+
lua_getfield(L, -1, "jit"); /* Get jit.* module table. */
|
142
|
+
lua_remove(L, -2);
|
143
|
+
lua_getfield(L, -1, "status");
|
144
|
+
lua_remove(L, -2);
|
145
|
+
n = lua_gettop(L);
|
146
|
+
lua_call(L, 0, LUA_MULTRET);
|
147
|
+
fputs(lua_toboolean(L, n) ? "JIT: ON" : "JIT: OFF", stdout);
|
148
|
+
for (n++; (s = lua_tostring(L, n)); n++) {
|
149
|
+
putc(' ', stdout);
|
150
|
+
fputs(s, stdout);
|
151
|
+
}
|
152
|
+
putc('\n', stdout);
|
153
|
+
}
|
154
|
+
|
155
|
+
static int getargs(lua_State *L, char **argv, int n)
|
156
|
+
{
|
157
|
+
int narg;
|
158
|
+
int i;
|
159
|
+
int argc = 0;
|
160
|
+
while (argv[argc]) argc++; /* count total number of arguments */
|
161
|
+
narg = argc - (n + 1); /* number of arguments to the script */
|
162
|
+
luaL_checkstack(L, narg + 3, "too many arguments to script");
|
163
|
+
for (i = n+1; i < argc; i++)
|
164
|
+
lua_pushstring(L, argv[i]);
|
165
|
+
lua_createtable(L, narg, n + 1);
|
166
|
+
for (i = 0; i < argc; i++) {
|
167
|
+
lua_pushstring(L, argv[i]);
|
168
|
+
lua_rawseti(L, -2, i - n);
|
169
|
+
}
|
170
|
+
return narg;
|
171
|
+
}
|
172
|
+
|
173
|
+
static int dofile(lua_State *L, const char *name)
|
174
|
+
{
|
175
|
+
int status = luaL_loadfile(L, name) || docall(L, 0, 1);
|
176
|
+
return report(L, status);
|
177
|
+
}
|
178
|
+
|
179
|
+
static int dostring(lua_State *L, const char *s, const char *name)
|
180
|
+
{
|
181
|
+
int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1);
|
182
|
+
return report(L, status);
|
183
|
+
}
|
184
|
+
|
185
|
+
static int dolibrary(lua_State *L, const char *name)
|
186
|
+
{
|
187
|
+
lua_getglobal(L, "require");
|
188
|
+
lua_pushstring(L, name);
|
189
|
+
return report(L, docall(L, 1, 1));
|
190
|
+
}
|
191
|
+
|
192
|
+
static void write_prompt(lua_State *L, int firstline)
|
193
|
+
{
|
194
|
+
const char *p;
|
195
|
+
lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2");
|
196
|
+
p = lua_tostring(L, -1);
|
197
|
+
if (p == NULL) p = firstline ? LUA_PROMPT : LUA_PROMPT2;
|
198
|
+
fputs(p, stdout);
|
199
|
+
fflush(stdout);
|
200
|
+
lua_pop(L, 1); /* remove global */
|
201
|
+
}
|
202
|
+
|
203
|
+
static int incomplete(lua_State *L, int status)
|
204
|
+
{
|
205
|
+
if (status == LUA_ERRSYNTAX) {
|
206
|
+
size_t lmsg;
|
207
|
+
const char *msg = lua_tolstring(L, -1, &lmsg);
|
208
|
+
const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1);
|
209
|
+
if (strstr(msg, LUA_QL("<eof>")) == tp) {
|
210
|
+
lua_pop(L, 1);
|
211
|
+
return 1;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
return 0; /* else... */
|
215
|
+
}
|
216
|
+
|
217
|
+
static int pushline(lua_State *L, int firstline)
|
218
|
+
{
|
219
|
+
char buf[LUA_MAXINPUT];
|
220
|
+
write_prompt(L, firstline);
|
221
|
+
if (fgets(buf, LUA_MAXINPUT, stdin)) {
|
222
|
+
size_t len = strlen(buf);
|
223
|
+
if (len > 0 && buf[len-1] == '\n')
|
224
|
+
buf[len-1] = '\0';
|
225
|
+
if (firstline && buf[0] == '=')
|
226
|
+
lua_pushfstring(L, "return %s", buf+1);
|
227
|
+
else
|
228
|
+
lua_pushstring(L, buf);
|
229
|
+
return 1;
|
230
|
+
}
|
231
|
+
return 0;
|
232
|
+
}
|
233
|
+
|
234
|
+
static int loadline(lua_State *L)
|
235
|
+
{
|
236
|
+
int status;
|
237
|
+
lua_settop(L, 0);
|
238
|
+
if (!pushline(L, 1))
|
239
|
+
return -1; /* no input */
|
240
|
+
for (;;) { /* repeat until gets a complete line */
|
241
|
+
status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin");
|
242
|
+
if (!incomplete(L, status)) break; /* cannot try to add lines? */
|
243
|
+
if (!pushline(L, 0)) /* no more input? */
|
244
|
+
return -1;
|
245
|
+
lua_pushliteral(L, "\n"); /* add a new line... */
|
246
|
+
lua_insert(L, -2); /* ...between the two lines */
|
247
|
+
lua_concat(L, 3); /* join them */
|
248
|
+
}
|
249
|
+
lua_remove(L, 1); /* remove line */
|
250
|
+
return status;
|
251
|
+
}
|
252
|
+
|
253
|
+
static void dotty(lua_State *L)
|
254
|
+
{
|
255
|
+
int status;
|
256
|
+
const char *oldprogname = progname;
|
257
|
+
progname = NULL;
|
258
|
+
while ((status = loadline(L)) != -1) {
|
259
|
+
if (status == 0) status = docall(L, 0, 0);
|
260
|
+
report(L, status);
|
261
|
+
if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */
|
262
|
+
lua_getglobal(L, "print");
|
263
|
+
lua_insert(L, 1);
|
264
|
+
if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
|
265
|
+
l_message(progname,
|
266
|
+
lua_pushfstring(L, "error calling " LUA_QL("print") " (%s)",
|
267
|
+
lua_tostring(L, -1)));
|
268
|
+
}
|
269
|
+
}
|
270
|
+
lua_settop(L, 0); /* clear stack */
|
271
|
+
fputs("\n", stdout);
|
272
|
+
fflush(stdout);
|
273
|
+
progname = oldprogname;
|
274
|
+
}
|
275
|
+
|
276
|
+
static int handle_script(lua_State *L, char **argv, int n)
|
277
|
+
{
|
278
|
+
int status;
|
279
|
+
const char *fname;
|
280
|
+
int narg = getargs(L, argv, n); /* collect arguments */
|
281
|
+
lua_setglobal(L, "arg");
|
282
|
+
fname = argv[n];
|
283
|
+
if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0)
|
284
|
+
fname = NULL; /* stdin */
|
285
|
+
status = luaL_loadfile(L, fname);
|
286
|
+
lua_insert(L, -(narg+1));
|
287
|
+
if (status == 0)
|
288
|
+
status = docall(L, narg, 0);
|
289
|
+
else
|
290
|
+
lua_pop(L, narg);
|
291
|
+
return report(L, status);
|
292
|
+
}
|
293
|
+
|
294
|
+
/* Load add-on module. */
|
295
|
+
static int loadjitmodule(lua_State *L)
|
296
|
+
{
|
297
|
+
lua_getglobal(L, "require");
|
298
|
+
lua_pushliteral(L, "jit.");
|
299
|
+
lua_pushvalue(L, -3);
|
300
|
+
lua_concat(L, 2);
|
301
|
+
if (lua_pcall(L, 1, 1, 0)) {
|
302
|
+
const char *msg = lua_tostring(L, -1);
|
303
|
+
if (msg && !strncmp(msg, "module ", 7))
|
304
|
+
goto nomodule;
|
305
|
+
return report(L, 1);
|
306
|
+
}
|
307
|
+
lua_getfield(L, -1, "start");
|
308
|
+
if (lua_isnil(L, -1)) {
|
309
|
+
nomodule:
|
310
|
+
l_message(progname,
|
311
|
+
"unknown luaJIT command or jit.* modules not installed");
|
312
|
+
return 1;
|
313
|
+
}
|
314
|
+
lua_remove(L, -2); /* Drop module table. */
|
315
|
+
return 0;
|
316
|
+
}
|
317
|
+
|
318
|
+
/* Run command with options. */
|
319
|
+
static int runcmdopt(lua_State *L, const char *opt)
|
320
|
+
{
|
321
|
+
int narg = 0;
|
322
|
+
if (opt && *opt) {
|
323
|
+
for (;;) { /* Split arguments. */
|
324
|
+
const char *p = strchr(opt, ',');
|
325
|
+
narg++;
|
326
|
+
if (!p) break;
|
327
|
+
if (p == opt)
|
328
|
+
lua_pushnil(L);
|
329
|
+
else
|
330
|
+
lua_pushlstring(L, opt, (size_t)(p - opt));
|
331
|
+
opt = p + 1;
|
332
|
+
}
|
333
|
+
if (*opt)
|
334
|
+
lua_pushstring(L, opt);
|
335
|
+
else
|
336
|
+
lua_pushnil(L);
|
337
|
+
}
|
338
|
+
return report(L, lua_pcall(L, narg, 0, 0));
|
339
|
+
}
|
340
|
+
|
341
|
+
/* JIT engine control command: try jit library first or load add-on module. */
|
342
|
+
static int dojitcmd(lua_State *L, const char *cmd)
|
343
|
+
{
|
344
|
+
const char *opt = strchr(cmd, '=');
|
345
|
+
lua_pushlstring(L, cmd, opt ? (size_t)(opt - cmd) : strlen(cmd));
|
346
|
+
lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
|
347
|
+
lua_getfield(L, -1, "jit"); /* Get jit.* module table. */
|
348
|
+
lua_remove(L, -2);
|
349
|
+
lua_pushvalue(L, -2);
|
350
|
+
lua_gettable(L, -2); /* Lookup library function. */
|
351
|
+
if (!lua_isfunction(L, -1)) {
|
352
|
+
lua_pop(L, 2); /* Drop non-function and jit.* table, keep module name. */
|
353
|
+
if (loadjitmodule(L))
|
354
|
+
return 1;
|
355
|
+
} else {
|
356
|
+
lua_remove(L, -2); /* Drop jit.* table. */
|
357
|
+
}
|
358
|
+
lua_remove(L, -2); /* Drop module name. */
|
359
|
+
return runcmdopt(L, opt ? opt+1 : opt);
|
360
|
+
}
|
361
|
+
|
362
|
+
/* Optimization flags. */
|
363
|
+
static int dojitopt(lua_State *L, const char *opt)
|
364
|
+
{
|
365
|
+
lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
|
366
|
+
lua_getfield(L, -1, "jit.opt"); /* Get jit.opt.* module table. */
|
367
|
+
lua_remove(L, -2);
|
368
|
+
lua_getfield(L, -1, "start");
|
369
|
+
lua_remove(L, -2);
|
370
|
+
return runcmdopt(L, opt);
|
371
|
+
}
|
372
|
+
|
373
|
+
/* Save or list bytecode. */
|
374
|
+
static int dobytecode(lua_State *L, char **argv)
|
375
|
+
{
|
376
|
+
int narg = 0;
|
377
|
+
lua_pushliteral(L, "bcsave");
|
378
|
+
if (loadjitmodule(L))
|
379
|
+
return 1;
|
380
|
+
if (argv[0][2]) {
|
381
|
+
narg++;
|
382
|
+
argv[0][1] = '-';
|
383
|
+
lua_pushstring(L, argv[0]+1);
|
384
|
+
}
|
385
|
+
for (argv++; *argv != NULL; narg++, argv++)
|
386
|
+
lua_pushstring(L, *argv);
|
387
|
+
return report(L, lua_pcall(L, narg, 0, 0));
|
388
|
+
}
|
389
|
+
|
390
|
+
/* check that argument has no extra characters at the end */
|
391
|
+
#define notail(x) {if ((x)[2] != '\0') return -1;}
|
392
|
+
|
393
|
+
#define FLAGS_INTERACTIVE 1
|
394
|
+
#define FLAGS_VERSION 2
|
395
|
+
#define FLAGS_EXEC 4
|
396
|
+
#define FLAGS_OPTION 8
|
397
|
+
#define FLAGS_NOENV 16
|
398
|
+
|
399
|
+
static int collectargs(char **argv, int *flags)
|
400
|
+
{
|
401
|
+
int i;
|
402
|
+
for (i = 1; argv[i] != NULL; i++) {
|
403
|
+
if (argv[i][0] != '-') /* Not an option? */
|
404
|
+
return i;
|
405
|
+
switch (argv[i][1]) { /* Check option. */
|
406
|
+
case '-':
|
407
|
+
notail(argv[i]);
|
408
|
+
return (argv[i+1] != NULL ? i+1 : 0);
|
409
|
+
case '\0':
|
410
|
+
return i;
|
411
|
+
case 'i':
|
412
|
+
notail(argv[i]);
|
413
|
+
*flags |= FLAGS_INTERACTIVE;
|
414
|
+
/* fallthrough */
|
415
|
+
case 'v':
|
416
|
+
notail(argv[i]);
|
417
|
+
*flags |= FLAGS_VERSION;
|
418
|
+
break;
|
419
|
+
case 'e':
|
420
|
+
*flags |= FLAGS_EXEC;
|
421
|
+
case 'j': /* LuaJIT extension */
|
422
|
+
case 'l':
|
423
|
+
*flags |= FLAGS_OPTION;
|
424
|
+
if (argv[i][2] == '\0') {
|
425
|
+
i++;
|
426
|
+
if (argv[i] == NULL) return -1;
|
427
|
+
}
|
428
|
+
break;
|
429
|
+
case 'O': break; /* LuaJIT extension */
|
430
|
+
case 'b': /* LuaJIT extension */
|
431
|
+
if (*flags) return -1;
|
432
|
+
*flags |= FLAGS_EXEC;
|
433
|
+
return 0;
|
434
|
+
case 'E':
|
435
|
+
*flags |= FLAGS_NOENV;
|
436
|
+
break;
|
437
|
+
default: return -1; /* invalid option */
|
438
|
+
}
|
439
|
+
}
|
440
|
+
return 0;
|
441
|
+
}
|
442
|
+
|
443
|
+
static int runargs(lua_State *L, char **argv, int n)
|
444
|
+
{
|
445
|
+
int i;
|
446
|
+
for (i = 1; i < n; i++) {
|
447
|
+
if (argv[i] == NULL) continue;
|
448
|
+
lua_assert(argv[i][0] == '-');
|
449
|
+
switch (argv[i][1]) { /* option */
|
450
|
+
case 'e': {
|
451
|
+
const char *chunk = argv[i] + 2;
|
452
|
+
if (*chunk == '\0') chunk = argv[++i];
|
453
|
+
lua_assert(chunk != NULL);
|
454
|
+
if (dostring(L, chunk, "=(command line)") != 0)
|
455
|
+
return 1;
|
456
|
+
break;
|
457
|
+
}
|
458
|
+
case 'l': {
|
459
|
+
const char *filename = argv[i] + 2;
|
460
|
+
if (*filename == '\0') filename = argv[++i];
|
461
|
+
lua_assert(filename != NULL);
|
462
|
+
if (dolibrary(L, filename))
|
463
|
+
return 1; /* stop if file fails */
|
464
|
+
break;
|
465
|
+
}
|
466
|
+
case 'j': { /* LuaJIT extension */
|
467
|
+
const char *cmd = argv[i] + 2;
|
468
|
+
if (*cmd == '\0') cmd = argv[++i];
|
469
|
+
lua_assert(cmd != NULL);
|
470
|
+
if (dojitcmd(L, cmd))
|
471
|
+
return 1;
|
472
|
+
break;
|
473
|
+
}
|
474
|
+
case 'O': /* LuaJIT extension */
|
475
|
+
if (dojitopt(L, argv[i] + 2))
|
476
|
+
return 1;
|
477
|
+
break;
|
478
|
+
case 'b': /* LuaJIT extension */
|
479
|
+
return dobytecode(L, argv+i);
|
480
|
+
default: break;
|
481
|
+
}
|
482
|
+
}
|
483
|
+
return 0;
|
484
|
+
}
|
485
|
+
|
486
|
+
static int handle_luainit(lua_State *L)
|
487
|
+
{
|
488
|
+
#if LJ_TARGET_CONSOLE
|
489
|
+
const char *init = NULL;
|
490
|
+
#else
|
491
|
+
const char *init = getenv(LUA_INIT);
|
492
|
+
#endif
|
493
|
+
if (init == NULL)
|
494
|
+
return 0; /* status OK */
|
495
|
+
else if (init[0] == '@')
|
496
|
+
return dofile(L, init+1);
|
497
|
+
else
|
498
|
+
return dostring(L, init, "=" LUA_INIT);
|
499
|
+
}
|
500
|
+
|
501
|
+
static struct Smain {
|
502
|
+
char **argv;
|
503
|
+
int argc;
|
504
|
+
int status;
|
505
|
+
} smain;
|
506
|
+
|
507
|
+
static int pmain(lua_State *L)
|
508
|
+
{
|
509
|
+
struct Smain *s = &smain;
|
510
|
+
char **argv = s->argv;
|
511
|
+
int script;
|
512
|
+
int flags = 0;
|
513
|
+
globalL = L;
|
514
|
+
if (argv[0] && argv[0][0]) progname = argv[0];
|
515
|
+
LUAJIT_VERSION_SYM(); /* linker-enforced version check */
|
516
|
+
script = collectargs(argv, &flags);
|
517
|
+
if (script < 0) { /* invalid args? */
|
518
|
+
print_usage();
|
519
|
+
s->status = 1;
|
520
|
+
return 0;
|
521
|
+
}
|
522
|
+
if ((flags & FLAGS_NOENV)) {
|
523
|
+
lua_pushboolean(L, 1);
|
524
|
+
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
|
525
|
+
}
|
526
|
+
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
|
527
|
+
luaL_openlibs(L); /* open libraries */
|
528
|
+
lua_gc(L, LUA_GCRESTART, -1);
|
529
|
+
if (!(flags & FLAGS_NOENV)) {
|
530
|
+
s->status = handle_luainit(L);
|
531
|
+
if (s->status != 0) return 0;
|
532
|
+
}
|
533
|
+
if ((flags & FLAGS_VERSION)) print_version();
|
534
|
+
s->status = runargs(L, argv, (script > 0) ? script : s->argc);
|
535
|
+
if (s->status != 0) return 0;
|
536
|
+
if (script) {
|
537
|
+
s->status = handle_script(L, argv, script);
|
538
|
+
if (s->status != 0) return 0;
|
539
|
+
}
|
540
|
+
if ((flags & FLAGS_INTERACTIVE)) {
|
541
|
+
print_jit_status(L);
|
542
|
+
dotty(L);
|
543
|
+
} else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) {
|
544
|
+
if (lua_stdin_is_tty()) {
|
545
|
+
print_version();
|
546
|
+
print_jit_status(L);
|
547
|
+
dotty(L);
|
548
|
+
} else {
|
549
|
+
dofile(L, NULL); /* executes stdin as a file */
|
550
|
+
}
|
551
|
+
}
|
552
|
+
return 0;
|
553
|
+
}
|
554
|
+
|
555
|
+
int main(int argc, char **argv)
|
556
|
+
{
|
557
|
+
int status;
|
558
|
+
lua_State *L = lua_open(); /* create state */
|
559
|
+
if (L == NULL) {
|
560
|
+
l_message(argv[0], "cannot create state: not enough memory");
|
561
|
+
return EXIT_FAILURE;
|
562
|
+
}
|
563
|
+
smain.argc = argc;
|
564
|
+
smain.argv = argv;
|
565
|
+
status = lua_cpcall(L, pmain, NULL);
|
566
|
+
report(L, status);
|
567
|
+
lua_close(L);
|
568
|
+
return (status || smain.status) ? EXIT_FAILURE : EXIT_SUCCESS;
|
569
|
+
}
|
570
|
+
|