├── .gitignore ├── .gitmodules ├── .travis.yml ├── ChunkSpy ├── ChunkSpy51.lua ├── ChunkSpy52.lua └── ChunkSpy53.lua ├── LuaAssemblyTools ├── .gitignore ├── Changelog.txt ├── Decompiler51.lua ├── Decompiler52.lua ├── LASM.docx ├── LAT.lua ├── LICENSE ├── LasmCompiler51.lua ├── LasmCompiler52.lua ├── LasmInterpreter51.lua ├── LasmInterpreter52.lua ├── Readme.txt ├── etc │ ├── ChunkBake.lua │ ├── ChunkSpy.lua │ ├── LASM Compiler Suite │ │ ├── LASM_Assembler.lua │ │ ├── LASM_Dumper.lua │ │ ├── LASM_Lexer.lua │ │ ├── bit_lib.lua │ │ └── example script.lua │ ├── LuaDbg.lua │ ├── MODS.lua │ ├── StackSteal.luac │ └── docs │ │ └── ANoFrillsIntroToLua51VMInstructions.pdf ├── samples │ ├── consteval.bat │ ├── consteval.lua │ ├── consteval_test.lasm │ └── consteval_test.luac ├── src │ ├── Lua51 │ │ ├── Chunk.lua │ │ ├── Decompiler │ │ │ └── LASM.lua │ │ ├── Disassembler.lua │ │ ├── Dumper.lua │ │ ├── Instruction.lua │ │ ├── LasmParser │ │ │ ├── LasmParser.lua.old │ │ │ ├── Lexer.lua │ │ │ └── Parser.lua │ │ ├── LuaFile.lua │ │ ├── PlatformConfig.lua │ │ ├── Verifier.lua │ │ └── bin.lua │ ├── Lua52 │ │ ├── Chunk.lua │ │ ├── Decompiler │ │ │ └── LASM.lua │ │ ├── Disassembler.lua │ │ ├── Dumper.lua │ │ ├── Instruction.lua │ │ ├── LasmParser │ │ │ ├── Lexer.lua │ │ │ └── Parser.lua │ │ ├── LuaFile.lua │ │ ├── PlatformConfig.lua │ │ ├── TODO.txt │ │ ├── Verifier.lua │ │ ├── bin.lua │ │ └── tests │ │ │ ├── a.luac │ │ │ └── b.luac │ ├── init.lua │ └── lua50 │ │ └── ANoFrillsIntroToLua5VMInstructions.odt └── tests │ ├── 51 │ ├── LASM_JumpWithLabel.lasm │ ├── LASM_JumpWithLabel.luac │ ├── LasmTests.bat │ ├── RoundTripBinTest.lua │ ├── RoundTripDecompilerAndLasmParserTest.lua │ ├── RoundTrip_LasmCompiler.bat │ ├── RoundTrip_LasmCompiler_SharpLua.bat │ └── RunTests.bat │ ├── 52 │ ├── BuildAndRun.bat │ ├── HelloWorld.lasm │ └── HelloWorld.luac │ └── Any │ ├── add.lasm │ ├── add.luac │ ├── l.out │ ├── lasm.luac │ ├── lasm.out │ └── test.lasm ├── README.md ├── bin ├── ChunkSpy-Test.bat ├── ChunkSpy51.bat ├── ChunkSpy52.bat ├── ChunkSpy53.bat ├── allopcodes-5.1.lua ├── allopcodes-5.2.lua ├── allopcodes-5.3.lua ├── bin2c.lua ├── fun_check_count.lua ├── ilua.bat ├── issue41_gen_large_table.lua ├── lasmc.bat ├── lasmd.bat └── test-long.bat ├── compare ├── compare.rb └── luadecguess.rb ├── ilua ├── LICENSE.txt ├── README.txt ├── TODO.txt ├── ilua.lua └── readline.c ├── lua-5.1 ├── .gitignore ├── COPYRIGHT ├── HISTORY ├── INSTALL ├── Makefile ├── README ├── doc │ ├── contents.html │ ├── cover.png │ ├── logo.gif │ ├── lua.1 │ ├── lua.css │ ├── lua.html │ ├── luac.1 │ ├── luac.html │ ├── manual.css │ ├── manual.html │ └── readme.html ├── etc │ ├── Makefile │ ├── README │ ├── all.c │ ├── lua.hpp │ ├── lua.ico │ ├── lua.pc │ ├── luavs.bat │ ├── min.c │ ├── noparser.c │ └── strict.lua ├── src │ ├── Makefile │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lcode.c │ ├── lcode.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── liolib.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ ├── lzio.h │ └── print.c └── test │ ├── README │ ├── bisect.lua │ ├── cf.lua │ ├── echo.lua │ ├── env.lua │ ├── factorial.lua │ ├── fib.lua │ ├── fibfor.lua │ ├── globals.lua │ ├── hello.lua │ ├── life.lua │ ├── luac.lua │ ├── printf.lua │ ├── readonly.lua │ ├── sieve.lua │ ├── sort.lua │ ├── table.lua │ ├── trace-calls.lua │ ├── trace-globals.lua │ └── xd.lua ├── lua-5.2 ├── .gitignore ├── Makefile ├── README ├── doc │ ├── contents.html │ ├── logo.gif │ ├── lua.1 │ ├── lua.css │ ├── luac.1 │ ├── manual.css │ ├── manual.html │ ├── osi-certified-72x60.png │ └── readme.html └── src │ ├── Makefile │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lbitlib.c │ ├── lcode.c │ ├── lcode.h │ ├── lcorolib.c │ ├── lctype.c │ ├── lctype.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── liolib.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── lua.hpp │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ └── lzio.h ├── lua-5.3 ├── Makefile ├── README ├── doc │ ├── contents.html │ ├── index.css │ ├── logo.gif │ ├── lua.1 │ ├── lua.css │ ├── luac.1 │ ├── manual.css │ ├── manual.html │ ├── osi-certified-72x60.png │ └── readme.html └── src │ ├── Makefile │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lbitlib.c │ ├── lcode.c │ ├── lcode.h │ ├── lcorolib.c │ ├── lctype.c │ ├── lctype.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── liolib.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lprefix.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── lua.hpp │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lutf8lib.c │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ └── lzio.h ├── luadec ├── Makefile ├── StringBuffer.c ├── StringBuffer.h ├── allopcodes.lua ├── allopcodes.luac ├── allopcodes_lua.h ├── allopcodes_luac.h ├── common.h ├── decompile.c ├── decompile.h ├── disassemble.c ├── disassemble.h ├── expression.c ├── expression.h ├── gen-allopcodes-h.cmd ├── gen-git-srcversion.cmd ├── gen-svn-srcversion.cmd ├── guess.c ├── lua-compat.h ├── luadec.c ├── luaopswap.c ├── luareplace.c ├── lundump-5.1.c ├── macro-array.c ├── macro-array.h ├── proto.c ├── proto.h ├── srcversion.h ├── srcversion.h.template ├── statement.c ├── statement.h ├── structs.c └── structs.h ├── memwatch ├── FAQ ├── Makefile ├── README ├── USING ├── gpl.txt ├── memwatch.c ├── memwatch.h ├── memwatch.lsm └── test.c ├── test-compiled └── lua-5.1 │ ├── JX3_BF_Base_BigFoot.lua │ ├── JX3_BF_ChannelsSimulator.lua │ ├── JX3_BF_InfoBox.lua │ ├── JX3_BF_QuestPlus.lua │ ├── JX3_BF_Quest_Data.lua │ ├── JX3_Xu_MacroFHX_Main.lua │ ├── defense_witches │ ├── c01_daisy01.lua │ ├── config.lua │ ├── cont.lua │ ├── cont_game.lua │ ├── crystal.lua │ ├── game.lua │ ├── help_reload.lua │ ├── invite.lua │ ├── kpi.lua │ ├── main.lua │ ├── modstatus.lua │ ├── modstatus1.lua │ ├── powerup.lua │ ├── stage.lua │ ├── status.lua │ ├── status4.lua │ └── title.lua │ ├── dialer_md5_encrypt_data.lua │ ├── gcode1_db_m.lua │ ├── gcode7_cave.lua │ ├── gcode9_WeightStation.lua │ ├── pangu_formula_action_formula_c.lua │ ├── pangu_formula_gossip_lingshou.lua │ ├── popup_hint.lua │ └── xunlei │ ├── Button.xml.lua │ ├── CheckBox.xml.lua │ ├── DownloaderAssistantWnd.xml.lua │ ├── DownloaderHelper.lua │ ├── DownloaderMainWnd.xml.lua │ ├── DownloaderMainWnd727.xml.lua │ ├── DownloaderMessageBox.xml.lua │ ├── ImageButton.xml.lua │ ├── Progress.xml.lua │ ├── Root.lua │ ├── TextLink.xml.lua │ ├── checkEnv.lua │ └── onload.lua ├── test ├── 20130707 │ ├── _logic_leaks.lua │ ├── _nestif.lua │ ├── _repeat_repeat.lua │ ├── _while.lua │ └── _while_if.lua ├── 0512 │ ├── if.lua │ ├── repeat-for.lua │ ├── repeat-repeat.lua │ ├── repeat-until.lua │ ├── repeat.lua │ ├── repeat4.lua │ ├── upvalue-list.lua │ ├── while-error.lua │ ├── while-error2.lua │ ├── while.lua │ ├── while1-while1-error.lua │ ├── while1-while1.lua │ ├── while2-error.lua │ ├── while2.lua │ ├── while3.lua │ ├── while4.lua │ ├── while5.lua │ └── while6.lua ├── error_nested_if │ ├── doreturnend.lua │ ├── doreturnend2.lua │ ├── doreturnend3.lua │ ├── if1.lua │ ├── if2.lua │ └── logic │ │ ├── if.lua │ │ ├── if2.lua │ │ ├── if_all.lua │ │ ├── if_error.lua │ │ └── logic.lua ├── issues │ ├── issue13_direct_call.lua │ ├── issue15_fn_upvalue.lua │ ├── issue17_self_call.lua │ ├── issue22_exp_settable.lua │ ├── issue23_cannot_jmp_out_else.lua │ ├── issue24_while_if.lua │ ├── issue27_and_or_or.lua │ ├── issue28_lt_le_const.lua │ ├── issue29_vararg.lua │ ├── issue30_local_reuse.lua │ ├── issue32_global_or_to_if.lua │ ├── issue33_if_if.lua │ ├── issue41_most_const_51.lua │ ├── issue42_function_local_scope.lua │ ├── issue42_local_scope.lua │ ├── issue43_local_func_as_upval.lua │ ├── issue4_jmp_loadbool.lua │ └── issue4_jmp_loadbool_all.lua ├── loop_structure │ ├── 4while1.lua │ ├── complex_while.lua │ ├── complex_while2.lua │ ├── for.lua │ ├── repeat-for.lua │ ├── repeat-while.lua │ ├── repeat.lua │ ├── tfor.lua │ ├── until1.lua │ ├── while-while.lua │ ├── while.lua │ ├── while1-if.lua │ ├── while1-until.lua │ ├── while1-while1.lua │ └── while1.lua ├── lua-5.1-test │ ├── README │ ├── bisect.lua │ ├── cf.lua │ ├── echo.lua │ ├── env.lua │ ├── factorial.lua │ ├── fib.lua │ ├── fibfor.lua │ ├── globals.lua │ ├── hello.lua │ ├── life.lua │ ├── luac.lua │ ├── printf.lua │ ├── readonly.lua │ ├── sieve.lua │ ├── sort.lua │ ├── table.lua │ ├── trace-calls.lua │ ├── trace-globals.lua │ └── xd.lua ├── lua-5.1-tests │ ├── README │ ├── all.lua │ ├── api.lua │ ├── attrib.lua │ ├── big.lua │ ├── calls.lua │ ├── checktable.lua │ ├── closure.lua │ ├── code.lua │ ├── constructs.lua │ ├── db.lua │ ├── errors.lua │ ├── etc │ │ ├── ltests.c │ │ └── ltests.h │ ├── events.lua │ ├── files.lua │ ├── gc.lua │ ├── libs │ │ └── P1 │ │ │ └── .gitignore │ ├── literals.lua │ ├── locals.lua │ ├── main.lua │ ├── math.lua │ ├── nextvar.lua │ ├── pm.lua │ ├── sort.lua │ ├── strings.lua │ ├── vararg.lua │ └── verybig.lua ├── lua-5.2-tests │ ├── all.lua │ ├── api.lua │ ├── attrib.lua │ ├── big.lua │ ├── bitwise.lua │ ├── calls.lua │ ├── checktable.lua │ ├── closure.lua │ ├── code.lua │ ├── constructs.lua │ ├── coroutine.lua │ ├── db.lua │ ├── errors.lua │ ├── events.lua │ ├── files.lua │ ├── gc.lua │ ├── goto.lua │ ├── libs │ │ ├── P1 │ │ │ └── .gitignore │ │ ├── lib1.c │ │ ├── lib11.c │ │ ├── lib2.c │ │ ├── lib21.c │ │ └── makefile │ ├── literals.lua │ ├── locals.lua │ ├── ltests │ │ ├── ltests.c │ │ └── ltests.h │ ├── main.lua │ ├── math.lua │ ├── nextvar.lua │ ├── pm.lua │ ├── sort.lua │ ├── strings.lua │ ├── vararg.lua │ └── verybig.lua ├── lua-5.3-tests │ ├── all.lua │ ├── api.lua │ ├── attrib.lua │ ├── big.lua │ ├── bitwise.lua │ ├── calls.lua │ ├── closure.lua │ ├── code.lua │ ├── constructs.lua │ ├── coroutine.lua │ ├── db.lua │ ├── errors.lua │ ├── events.lua │ ├── files.lua │ ├── gc.lua │ ├── goto.lua │ ├── libs │ │ ├── P1 │ │ │ └── .gitignore │ │ ├── lib1.c │ │ ├── lib11.c │ │ ├── lib2.c │ │ ├── lib21.c │ │ └── makefile │ ├── literals.lua │ ├── locals.lua │ ├── ltests │ │ ├── ltests.c │ │ └── ltests.h │ ├── main.lua │ ├── math.lua │ ├── nextvar.lua │ ├── pm.lua │ ├── sort.lua │ ├── strings.lua │ ├── tpack.lua │ ├── utf8.lua │ ├── vararg.lua │ └── verybig.lua ├── ok_declare │ ├── a_er.lua │ ├── a_ok.lua │ └── a_ok2.lua ├── other │ ├── _60000funs_simple.lua │ ├── _simple_logic.lua │ ├── constructs.lua │ ├── fortest.lua │ ├── fun.lua │ ├── function_compare.lua │ ├── getmop.lua │ ├── if_else.lua │ ├── if_else_if.lua │ ├── if_not_else.lua │ ├── local_and_set.lua │ ├── logic.lua │ ├── producelua.lua │ ├── readchunk.lua │ ├── serialize.lua │ ├── table.lua │ ├── test.lua │ ├── testall.lua │ ├── testindex.lua │ ├── testup.lua │ ├── txt.lua │ └── vararg.lua ├── tested │ ├── assign.lua │ ├── assign2.lua │ ├── for.lua │ ├── for_if.lua │ ├── if_for.lua │ ├── index.lua │ ├── setlist.lua │ ├── setlist2.lua │ ├── table_constructor.lua │ ├── table_formated.lua │ ├── varg_call.lua │ └── varg_func.lua ├── todo │ ├── ch4.lua │ ├── f.lua │ ├── funret.lua │ ├── ifelse.lua │ ├── ifelseif2.lua │ ├── more.lua │ └── vararg.lua ├── unluac-test │ ├── adjust01.lua │ ├── adjust02.lua │ ├── adjust03.lua │ ├── adjust04.lua │ ├── adjust05.lua │ ├── assign.lua │ ├── booleanassign01.lua │ ├── booleanassign02.lua │ ├── booleanassign03.lua │ ├── booleanassign04.lua │ ├── booleanassign05.lua │ ├── booleanassign06.lua │ ├── booleanassign07.lua │ ├── booleanassign08.lua │ ├── booleanassign09.lua │ ├── booleanassign10.lua │ ├── booleanexpression01.lua │ ├── booleanexpression02.lua │ ├── booleanexpression03.lua │ ├── booleanexpression04.lua │ ├── booleanexpression05.lua │ ├── booleanmultiassign01.lua │ ├── booleanselfassign01.lua │ ├── closure.lua │ ├── combinebexpression01.lua │ ├── combinebexpression02.lua │ ├── combinebexpression03.lua │ ├── combinebexpression04.lua │ ├── compareassign01.lua │ ├── compareexpression.lua │ ├── compareorder01.lua │ ├── compareorder02.lua │ ├── compareorder03.lua │ ├── compareorder04.lua │ ├── compareorder05.lua │ ├── complexassign01.lua │ ├── complexassign02.lua │ ├── complexassign03.lua │ ├── condition.lua │ ├── control01.lua │ ├── control02.lua │ ├── control03.lua │ ├── control04.lua │ ├── control05.lua │ ├── control06.lua │ ├── control07.lua │ ├── declare.lua │ ├── declare02.lua │ ├── declare03.lua │ ├── doend01.lua │ ├── doend02.lua │ ├── doend03.lua │ ├── doend04.lua │ ├── doend05.lua │ ├── ellipsis.lua │ ├── expression.lua │ ├── final01.lua │ ├── final02.lua │ ├── functioncall.lua │ ├── ifthen.lua │ ├── ifthenelse.lua │ ├── literal.lua │ ├── literallist.lua │ ├── localbooleanassign.lua │ ├── localfunction01.lua │ ├── localfunction02.lua │ ├── localfunction03.lua │ ├── localfunction04.lua │ ├── method01.lua │ ├── multiassign.lua │ ├── multiliteraltarget.lua │ ├── nestedif.lua │ ├── nestedif02.lua │ ├── repeat.lua │ ├── table01.lua │ ├── table02.lua │ └── while.lua └── while │ ├── if_while_break.lua │ ├── until.lua │ ├── while-if.lua │ ├── while.lua │ ├── while1-if-else-break.lua │ ├── while1-if-else.lua │ ├── while1-if.lua │ ├── while1-while.lua │ └── while1.lua ├── vcproj-5.1 ├── lua.vcproj ├── lua51.sln ├── luac.vcproj ├── luadec.vcproj ├── luadll.vcproj ├── lualib.vcproj ├── luaopswap.vcproj └── luareplace.vcproj ├── vcproj-5.2 ├── lua.vcproj ├── lua52.sln ├── luac.vcproj ├── luadec.vcproj ├── luadll.vcproj ├── lualib.vcproj ├── luaopswap.vcproj └── luareplace.vcproj └── vcproj-5.3 ├── Backup └── lua53.sln ├── UpgradeLog.htm ├── lua.vcproj ├── lua.vcxproj ├── lua.vcxproj.filters ├── lua.vcxproj.user ├── lua53.sln ├── luac.vcproj ├── luac.vcxproj ├── luac.vcxproj.filters ├── luac.vcxproj.user ├── luadec.vcproj ├── luadec.vcxproj ├── luadec.vcxproj.filters ├── luadec.vcxproj.user ├── luadll.vcproj ├── luadll.vcxproj ├── luadll.vcxproj.filters ├── luadll.vcxproj.user ├── lualib.vcproj ├── lualib.vcxproj ├── lualib.vcxproj.filters ├── lualib.vcxproj.user ├── luaopswap.vcproj ├── luaopswap.vcxproj ├── luaopswap.vcxproj.filters ├── luaopswap.vcxproj.user ├── luareplace.vcproj ├── luareplace.vcxproj ├── luareplace.vcxproj.filters └── luareplace.vcxproj.user /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "LuaAssemblyTools"] 2 | path = LuaAssemblyTools 3 | url = https://github.com/mlnlover11/LuaAssemblyTools 4 | [submodule "ilua"] 5 | path = ilua 6 | url = https://github.com/ilua/ilua 7 | [submodule "memwatch"] 8 | path = memwatch 9 | url = https://github.com/viruscamp/memwatch 10 | [submodule "lua-5.1"] 11 | path = lua-5.1 12 | url = https://github.com/viruscamp/lua5 13 | branch = 5.1 14 | [submodule "lua-5.2"] 15 | path = lua-5.2 16 | url = https://github.com/viruscamp/lua5 17 | branch = 5.2 18 | [submodule "lua-5.3"] 19 | path = lua-5.3 20 | url = https://github.com/viruscamp/lua5 21 | branch = 5.3 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | compiler: 4 | - clang 5 | - gcc 6 | 7 | env: 8 | - LUAVER=5.1 9 | - LUAVER=5.2 10 | - LUAVER=5.3 11 | 12 | before_script: 13 | - cd lua-$LUAVER/src && make linux CC=$CC && cd ../../luadec 14 | 15 | script: 16 | - make CC=$CC LUAVER=$LUAVER 17 | -------------------------------------------------------------------------------- /LuaAssemblyTools/.gitignore: -------------------------------------------------------------------------------- 1 | samples\*.luac 2 | tests\*.luac 3 | src\*.luac 4 | Lua52bin*/ 5 | t[e]mp/ -------------------------------------------------------------------------------- /LuaAssemblyTools/Changelog.txt: -------------------------------------------------------------------------------- 1 | CHANGELOG/TODO for Lua Assembly Toolkit 2 | 3 | - = done 4 | + = planned 5 | B = bug 6 | 7 | + add .params, .args, .arg, .arguments, .argcount, ... to set the argument count 8 | + stop writing line info when a LineNumber is 0 9 | + Find unused constants and remove them 10 | + Resize MaxStackSize based upon used/unused registers 11 | 12 | 13 | 12/4/12 to 12/6/12 - v1.2 14 | - Add some more samples (make a samples dir?) 15 | - Complete re-write of the LASM parser, using tokenizer and parser 16 | - Empty strings now compile 17 | 18 | 19 | 8/23/12 - v1.1.1 20 | - LASM Compiler and Decompiler mini apps 21 | - Added external files 22 | - Platform conversion 23 | - Fixed a decompiler bug, code now can round trip and then run. 24 | 25 | 8/22/12 - v1.1 26 | - LASM Decompiler 27 | - LASM Compiler 28 | - ROUND TRIP LASM DECOMPILER/COMPILER WORKS!!! :D HECK YES 29 | 30 | 8/21/12 - v 1.0 31 | - Initial Commit -------------------------------------------------------------------------------- /LuaAssemblyTools/Decompiler51.lua: -------------------------------------------------------------------------------- 1 | require'LAT' 2 | 3 | if #arg == 0 then 4 | error("No input file specified!") 5 | end 6 | file = LAT.Lua51.Disassemble(io.open(arg[1], "rb"):read"*a") 7 | print("; Decompiled to lasm by LASM Decompiler v1.0") 8 | print("; Decompiler Copyright (C) 2012 LoDC") 9 | print"" 10 | print(LAT.Lua51.Decompile.LASM(file)) 11 | -------------------------------------------------------------------------------- /LuaAssemblyTools/Decompiler52.lua: -------------------------------------------------------------------------------- 1 | require'LAT' 2 | 3 | if #arg == 0 then 4 | error("No input file specified!") 5 | end 6 | file = LAT.Lua52.Disassemble(io.open(arg[1], "rb"):read"*a") 7 | print("; Decompiled to lasm by LASM Decompiler v1.0") 8 | print("; Decompiler Copyright (C) 2012 LoDC") 9 | print"" 10 | print(LAT.Lua52.Decompile.LASM(file)) 11 | -------------------------------------------------------------------------------- /LuaAssemblyTools/LASM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/LASM.docx -------------------------------------------------------------------------------- /LuaAssemblyTools/LAT.lua: -------------------------------------------------------------------------------- 1 | -- LAT = Lua Assembly Tools 2 | package.path = "./?/init.lua;./src/?.lua;" .. package.path 3 | require'src' 4 | -------------------------------------------------------------------------------- /LuaAssemblyTools/LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 3 | 4 | 0. You just DO WHAT THE FUCK YOU WANT TO. 5 | 1. I claim absolutely no responsibility for anything that happens as a result of viewing, downloading, running, editing, WHATEVER -------------------------------------------------------------------------------- /LuaAssemblyTools/LasmInterpreter51.lua: -------------------------------------------------------------------------------- 1 | require'LAT' 2 | 3 | -- 1.0 - Original 4 | -- 1.1 - makes it not continue attempting to execute chunk if one step fails 5 | 6 | print"LASM Interpreter version 1.1" 7 | print"Copyright (C) 2012 LODC" 8 | print"Press twice (empty line) to run LASM chunk" 9 | 10 | while true do 11 | io.write">> " 12 | local line = "" 13 | while true do 14 | local line2 = io.read"*l" 15 | if line2 == "" then 16 | break 17 | else 18 | if line == "" then 19 | line = line .. line2 20 | else 21 | line = line .. "\n" .. line2 22 | end 23 | end 24 | io.write">> " 25 | end 26 | local p = LAT.Lua51.Parser:new() 27 | local ok, ret = pcall(p.Parse, p, line, "LASM Interactive Chunk") 28 | if not ok then 29 | print("Syntax Error: " .. ret) 30 | else 31 | local bCode 32 | local ok, ret2 = pcall(function() bCode = ret:Compile() end) 33 | if not ok then 34 | print("Bytecode compilation error: " .. ret2) 35 | else 36 | local ok, ret2 = loadstring(bCode) 37 | if not ok then 38 | print("Bytecode compilation error: " .. ret2) 39 | else 40 | local a, b = pcall(ok) 41 | if not a then 42 | print("Execution error: " .. b) 43 | else 44 | print("Result: " .. (b or "")) 45 | end 46 | end 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /LuaAssemblyTools/LasmInterpreter52.lua: -------------------------------------------------------------------------------- 1 | require'LAT' 2 | 3 | -- 1.0 - Original 4 | -- 1.1 - makes it not continue attempting to execute chunk if one step fails 5 | 6 | print"LASM Interpreter version 1.1" 7 | print"Copyright (C) 2012 LODC" 8 | print"Press twice (empty line) to run LASM chunk" 9 | 10 | while true do 11 | io.write">> " 12 | local line = "" 13 | while true do 14 | local line2 = io.read"*l" 15 | if line2 == "" then 16 | break 17 | else 18 | if line == "" then 19 | line = line .. line2 20 | else 21 | line = line .. "\n" .. line2 22 | end 23 | end 24 | io.write">> " 25 | end 26 | local p = LAT.Lua52.Parser:new() 27 | local ok, ret = pcall(p.Parse, p, line, "LASM Interactive Chunk") 28 | if not ok then 29 | print("Syntax Error: " .. ret) 30 | else 31 | local bCode 32 | local ok, ret2 = pcall(function() bCode = ret:Compile() end) 33 | if not ok then 34 | print("Bytecode compilation error: " .. ret2) 35 | else 36 | local ok, ret2 = loadstring(bCode) 37 | if not ok then 38 | print("Bytecode compilation error: " .. ret2) 39 | else 40 | local a, b = pcall(ok) 41 | if not a then 42 | print("Execution error: " .. b) 43 | else 44 | print("Result: " .. (b or "")) 45 | end 46 | end 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /LuaAssemblyTools/etc/LASM Compiler Suite/LASM_Lexer.lua: -------------------------------------------------------------------------------- 1 | function _G.CreateLexer(source) 2 | local lexer = {} 3 | local ptr = 1 4 | local ptrstack = {} 5 | ----- 6 | local function at(i) 7 | return source:sub(i, i) 8 | end 9 | ----- 10 | lexer.IsAlpha = function() 11 | local c = at(ptr) 12 | local n = string.byte(c) 13 | return (n >= 97 and n <= 122) or (n >= 65 and n <= 90) or c == "_" 14 | end 15 | lexer.IsDigit = function() 16 | local n = string.byte(at(ptr)) 17 | return (n >= 48 and n <= 57) 18 | end 19 | lexer.Is = function(a) 20 | if #a == 1 then 21 | return at(ptr) == a 22 | else 23 | return source:sub(ptr, ptr+(#a)-1) == a 24 | end 25 | end 26 | ----- 27 | lexer.Push = function() 28 | ptrstack[#ptrstack+1] = ptr 29 | end 30 | lexer.Pop = function() 31 | ptr = ptrstack[#ptrstack] 32 | ptrstack[#ptrstack] = nil 33 | end 34 | lexer.Pull = function() 35 | ptrstack[#ptrstack] = nil 36 | end 37 | ----- 38 | return lexer 39 | end 40 | 41 | -------------------------------------------------------------------------------- /LuaAssemblyTools/etc/LASM Compiler Suite/bit_lib.lua: -------------------------------------------------------------------------------- 1 | _G.bit = { 2 | new = function(str) 3 | return tonumber(str, 2) 4 | end, 5 | get = function(num, n, n2) 6 | if n2 then 7 | local total = 0 8 | local digitn = 0 9 | for i = n, n2 do 10 | total = total + 2^digitn*bit.get(num, i) 11 | digitn = digitn + 1 12 | end 13 | return total 14 | else 15 | local pn = 2^(n-1) 16 | return (num % (pn + pn) >= pn) and 1 or 0 17 | end 18 | end, 19 | getstring = function(num, mindigit, sep) 20 | mindigit = mindigit or 0 21 | local pow = 0 22 | local tot = 1 23 | while tot <= num do 24 | tot = tot * 2 25 | pow = pow + 1 26 | end 27 | --- 28 | if pow < mindigit then pow = mindigit end 29 | --- 30 | local str = "" 31 | for i = pow, 1, -1 do 32 | str = str..bit.get(num, i)..(i==1 and "" or (sep or "-")) 33 | end 34 | return str 35 | end 36 | } 37 | -------------------------------------------------------------------------------- /LuaAssemblyTools/etc/LASM Compiler Suite/example script.lua: -------------------------------------------------------------------------------- 1 | wait(0.1) 2 | local chunk = aChunk("MainFunction", 0) { --> the main function should have 0 args 3 | aGETGLOBAL(0, aK("game")), 4 | aGETTABLE(0, 0, aK("Workspace")), -- get game.Workspace to register 0 5 | aGETGLOBAL(1, aK("Instance")), 6 | aGETTABLE(1, 1, aK("new")), 7 | aLOADK(2, aK("Part")), 8 | aCALL(1, 2, 2), -- register 1 = Instance.new("Part") 9 | aSETTABLE(1, aK("Parent"), 0), --(register 1).Parent = (register 0) 10 | -------------------- 11 | ---now some math 12 | aChunk("AddingFunction", 1) { --takes 1 argument 13 | aADD(0, 0, aK(10)), --add 10 to first arg 14 | aRETURN(0, 2), --return result 15 | }, 16 | aCLOSURE(0, aProto("AddingFunction")), --make an instance of the adding func in register 0 17 | aGETGLOBAL(1, aK("_G")), --get the global environment 18 | aSETTABLE(1, aK("AddTen"), 0), --set the global addten to the function 19 | } 20 | local func = chunk.Compile() --compile the chunk 21 | _G.TestFunc = func --save it to _G so it can be called from the command line 22 | -------------------------------------------------------------------------------- /LuaAssemblyTools/etc/StackSteal.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/etc/StackSteal.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/etc/docs/ANoFrillsIntroToLua51VMInstructions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/etc/docs/ANoFrillsIntroToLua51VMInstructions.pdf -------------------------------------------------------------------------------- /LuaAssemblyTools/samples/consteval.bat: -------------------------------------------------------------------------------- 1 | @del consteval_test.luac 2 | @cd .. 3 | @LasmCompiler51.lua -o samples\consteval_test.luac samples\consteval_test.lasm 4 | @samples\consteval.lua samples\consteval_test.luac 5 | @Decompiler51 samples\consteval_test.luac 6 | @cd samples 7 | @echo Output: 8 | @consteval_test.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/samples/consteval_test.lasm: -------------------------------------------------------------------------------- 1 | loadk 0 k(10) 2 | loadk 1 k(5) 3 | ADD 1 0 1 4 | getglobal 0 'print' 5 | call 0 2 1 -------------------------------------------------------------------------------- /LuaAssemblyTools/samples/consteval_test.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/samples/consteval_test.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/src/Lua52/TODO.txt: -------------------------------------------------------------------------------- 1 | - Implement DumpBinary.Opcode for Ax 2 | - TFORCALL OpcodeParams 3 | - EXTRAARG OpcodeParams -------------------------------------------------------------------------------- /LuaAssemblyTools/src/Lua52/tests/a.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/src/Lua52/tests/a.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/src/Lua52/tests/b.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/src/Lua52/tests/b.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/src/lua50/ANoFrillsIntroToLua5VMInstructions.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/src/lua50/ANoFrillsIntroToLua5VMInstructions.odt -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/51/LASM_JumpWithLabel.lasm: -------------------------------------------------------------------------------- 1 | ::start:: 2 | GETGLOBAL 0 'print' 3 | LOADK 1 'hi' 4 | CALL 0 2 1 5 | JMP start -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/51/LASM_JumpWithLabel.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/tests/51/LASM_JumpWithLabel.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/51/LasmTests.bat: -------------------------------------------------------------------------------- 1 | @cd ..\.. 2 | LasmCompiler51 -o tests\51\LASM_JumpWithLabel.luac tests\51\LASM_JumpWithLabel.lasm 3 | @cd tests\51 -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/51/RoundTripBinTest.lua: -------------------------------------------------------------------------------- 1 | require"LAT" 2 | 3 | -- Takes a luac file, decompiles it, recompiles it, and then loads both chunks to verify. 4 | 5 | print"File: " 6 | f = io.open(io.read("*l"), "rb") 7 | if not f then error("Unable to open file") end 8 | binary = f:read("*a") 9 | f:close() 10 | 11 | a = LAT.Lua51.Disassemble(binary) 12 | b = a:Compile() 13 | print(loadstring(binary)) 14 | print(loadstring(b)) 15 | print("Equal:", assert(binary == b)) 16 | -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/51/RoundTripDecompilerAndLasmParserTest.lua: -------------------------------------------------------------------------------- 1 | require"LAT" 2 | 3 | -- Take a binary file, load it, decompile it to lasm, parse the lasm, compile all chunks to verify 4 | 5 | print"File: " 6 | f = io.open(io.read("*l"), "rb") 7 | if not f then error("Unable to open file") end 8 | binary = f:read("*a") 9 | f:close() 10 | 11 | a = Disassemble(binary) 12 | str = Decompile.LASM(a) -- a LuaFile 13 | print("Decompiled: " .. str) 14 | print"" 15 | p = Parser:new() 16 | b = p:Parse(str) 17 | print(loadstring(binary)) 18 | print(loadstring(a:Compile())) 19 | print(loadstring(b:Compile())) 20 | 21 | --[[ 22 | print(a:Compile() == b:Compile()) 23 | print(a:Compile() == binary) 24 | print(b:Compile() == binary) 25 | print("Equal: ", assert(a:Compile() == b:Compile() == binary)) 26 | ]] 27 | -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/51/RoundTrip_LasmCompiler.bat: -------------------------------------------------------------------------------- 1 | cd .. 2 | luac -o LasmCompiler.luac LasmCompiler.lua 3 | Decompiler LasmCompiler.luac >LasmCompiler.lasm 4 | LasmCompiler -o LasmCompiler_Lasm.luac LasmCompiler.lasm 5 | lua -e "pcall(dofile, 'LasmCompiler_Lasm.luac') print('Success!')" 6 | del LasmCompiler.luac 7 | del LasmCompiler.lasm 8 | del LasmCompiler_Lasm.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/51/RoundTrip_LasmCompiler_SharpLua.bat: -------------------------------------------------------------------------------- 1 | @cd ..\.. 2 | sluac -o LasmCompiler.luac LasmCompiler.lua 3 | slua Decompiler51.lua LasmCompiler.luac >LasmCompiler.lasm 4 | slua LasmCompiler51.lua -o LasmCompiler_Lasm.luac LasmCompiler.lasm 5 | slua -e "pcall(dofile, 'LasmCompiler_Lasm.luac') print('Success!')" 6 | del LasmCompiler.luac 7 | del LasmCompiler.lasm 8 | del LasmCompiler_Lasm.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/51/RunTests.bat: -------------------------------------------------------------------------------- 1 | @cd ..\.. 2 | for %%f in (tests\51\*.lua) do "%%f" 3 | @cd tests\51 4 | pause -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/52/BuildAndRun.bat: -------------------------------------------------------------------------------- 1 | @cd ..\.. 2 | @Lua52bin\lua52 LasmCompiler52.lua -o tests\52\HelloWorld.luac tests\52\HelloWorld.lasm 3 | @echo Output: 4 | @Lua52bin\lua52 tests\52\helloworld.luac 5 | @cd tests\52 6 | -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/52/HelloWorld.lasm: -------------------------------------------------------------------------------- 1 | .upval '_ENV' 1 0 2 | .const 'print' 3 | .const 'Hello World' 4 | gettabup 0 0 256 5 | loadk 1 1 6 | call 0 2 1 -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/52/HelloWorld.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/tests/52/HelloWorld.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/Any/add.lasm: -------------------------------------------------------------------------------- 1 | 2 | .func 'AF' 3 | .options 0 1 4 | add 0 0 k(10) 5 | return 0 2 6 | .end 7 | 8 | closure 0 p'AF' 9 | getglobal 1 '_G' 10 | settable 1 'AddTen' 0 11 | -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/Any/add.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/tests/Any/add.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/Any/l.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/tests/Any/l.out -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/Any/lasm.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/tests/Any/lasm.luac -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/Any/lasm.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/LuaAssemblyTools/tests/Any/lasm.out -------------------------------------------------------------------------------- /LuaAssemblyTools/tests/Any/test.lasm: -------------------------------------------------------------------------------- 1 | .const "print" 2 | .const "Hello" 3 | getglobal 0 0 4 | loadk 1 1 5 | call 0 2 1 6 | return 0 1 -------------------------------------------------------------------------------- /bin/ChunkSpy51.bat: -------------------------------------------------------------------------------- 1 | @lua51 ..\ChunkSpy\ChunkSpy51.lua --auto %1 %2 %3 %4 %5 %6 %7 %8 %9 2 | -------------------------------------------------------------------------------- /bin/ChunkSpy52.bat: -------------------------------------------------------------------------------- 1 | @lua52 ..\ChunkSpy\ChunkSpy52.lua --auto %1 %2 %3 %4 %5 %6 %7 %8 %9 2 | -------------------------------------------------------------------------------- /bin/ChunkSpy53.bat: -------------------------------------------------------------------------------- 1 | @lua53 ..\ChunkSpy\ChunkSpy53.lua --auto %1 %2 %3 %4 %5 %6 %7 %8 %9 2 | -------------------------------------------------------------------------------- /bin/allopcodes-5.1.lua: -------------------------------------------------------------------------------- 1 | -- allopcodes-5.1.lua 2 | local u1,u2,u3 3 | function f1(a1,a2,...) 4 | local l0 = a1; -- move 5 | local l1 = 1 -- loadk 6 | local l2 = true -- loadbool 7 | local l3 = nil -- loadnil 8 | local l4 = u1[g1] -- gettupval, getglobal, gettable 9 | g1 = l1 -- setglobal 10 | u2 = l2 -- setupval 11 | l3[l2] = l1 -- settable 12 | local l5 = { -- newtable 13 | l1, l2; -- move, setlist 14 | x = l2 -- settable 15 | } 16 | local l6 = l5:x() -- self, call 17 | local l7 = -((l0+l1-l2)*l3/l4%l5)^l6 -- add, sub, mul, div, mod, pow, unm 18 | local l8 = #(not l7) -- not, len 19 | local l9 = l7..l8 -- concat 20 | if l1==l2 and l2=255 50 | return f1() -- return, tailcall 51 | end 52 | -------------------------------------------------------------------------------- /bin/bin2c.lua: -------------------------------------------------------------------------------- 1 | local ipairs = ipairs 2 | local string_byte = string.byte 3 | local string_format = string.format 4 | local table_concat = table.concat 5 | 6 | local filename, varname = ... 7 | 8 | local f = assert(io.open(filename, "rb")) 9 | 10 | print("unsigned char "..varname.."[] = {") 11 | 12 | local len = 0 13 | local fline = f:read(16) 14 | while fline do 15 | local fline_len = #fline 16 | len = len + fline_len 17 | local t = { string_byte(fline, 1, fline_len) } 18 | for k, v in ipairs(t) do 19 | t[k] = string_format("0x%02x", v) 20 | end 21 | fline = f:read(16) 22 | if fline then 23 | print(" "..table_concat(t, ", ")..",") 24 | else 25 | print(" "..table_concat(t, ", ").."") 26 | end 27 | end 28 | 29 | print("};") 30 | print(string_format("unsigned int %s_len = %d;", varname, len)) 31 | 32 | f:close() 33 | -------------------------------------------------------------------------------- /bin/fun_check_count.lua: -------------------------------------------------------------------------------- 1 | local string_find = string.find 2 | 3 | local files, passed, failed, uncompilable = 0, 0, 0, 0 4 | 5 | local filename = ... 6 | local f = filename and assert(io.open(filename, "r")) or io.stdin 7 | for line in f:lines() do 8 | if string_find(line, '^%s*-- function check pass') then 9 | passed = passed + 1 10 | elseif string_find(line, '^%s*-- function check fail') then 11 | failed = failed + 1 12 | if string_find(line, '^%s*-- function check fail [%d_]+ : cannot compile') then 13 | uncompilable = uncompilable + 1 14 | end 15 | elseif string_find(line, '^%s*-- function check Command line') then 16 | files = files + 1 17 | end 18 | end 19 | f:close() 20 | 21 | local fmt = "files: %d, functions: %d, passed: %d, failed: %d, uncompilable: %d, pass rate: %.2f%%" 22 | print(fmt:format(files, passed + failed, passed, failed, uncompilable, 100*passed/(passed + failed))) 23 | -------------------------------------------------------------------------------- /bin/ilua.bat: -------------------------------------------------------------------------------- 1 | @lua ..\ilua\ilua.lua %1 %2 %3 %4 %5 %6 %7 %8 %9 2 | -------------------------------------------------------------------------------- /bin/issue41_gen_large_table.lua: -------------------------------------------------------------------------------- 1 | -- setlist c=0 when top>=25550 2 | -- when top==2^18-1, lua51 cannot compile, but lua52 53 generate code without loadkx 3 | -- loadkx and extraarg when top>=2^18 4 | 5 | print("local x={") 6 | 7 | local top = arg[1] or 2^18+1 8 | local count = 0 9 | for i = 0, top do 10 | io.stdout:write(i,",") 11 | count = count + 1 12 | if count == 20 then 13 | io.stdout:write("\n") 14 | count = 0 15 | end 16 | end 17 | if count ~= 0 then 18 | io.stdout:write("\n") 19 | end 20 | print("}") 21 | -------------------------------------------------------------------------------- /bin/lasmc.bat: -------------------------------------------------------------------------------- 1 | @lua LasmCompiler51.lua %1 %2 %3 %4 %5 %6 %7 %8 %9 2 | -------------------------------------------------------------------------------- /bin/lasmd.bat: -------------------------------------------------------------------------------- 1 | @lua Decompiler51.lua %1 %2 %3 %4 %5 %6 %7 %8 %9 2 | -------------------------------------------------------------------------------- /ilua/LICENSE.txt: -------------------------------------------------------------------------------- 1 | ILUA License 2 | ------------ 3 | 4 | ILUA is licensed under the terms of the MIT license reproduced below. 5 | This means that Lua is free software and can be used for both academic 6 | and commercial purposes at absolutely no cost. 7 | 8 | =============================================================================== 9 | 10 | Copyright (C) 2007-2010 Steve Donovan, Chris Hixon 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. 29 | 30 | =============================================================================== 31 | 32 | -------------------------------------------------------------------------------- /ilua/TODO.txt: -------------------------------------------------------------------------------- 1 | TODO: 2 | ----- 3 | - documentation, usage 4 | - ilua-defs include works but is loaded in global enviroment instead of ilua environment 5 | - provide an option to use global environment 6 | - presets for pretty printing 7 | - separate "main" and create a launcher and lib? possibly move some of launcher into lib 8 | -------------------------------------------------------------------------------- /ilua/readline.c: -------------------------------------------------------------------------------- 1 | // build@ cc -shared readline.c -o readline.so 2 | // Completely and absolutely minimal binding to the readline library 3 | // Steve Donovan, 2007 4 | #include 5 | #include 6 | #include "lua.h" 7 | #include "lauxlib.h" 8 | #include "lualib.h" 9 | #include 10 | #include 11 | 12 | static int f_readline(lua_State* L) 13 | { 14 | const char* prompt = lua_tostring(L,1); 15 | const char* line = readline(prompt); 16 | lua_pushstring(L,line); 17 | (void)free((void *)line); // Lua makes a copy... 18 | return 1; 19 | } 20 | 21 | static int f_add_history(lua_State* L) 22 | { 23 | if (lua_strlen(L,1) > 0) 24 | add_history(lua_tostring(L, 1)); 25 | return 0; 26 | } 27 | 28 | static const struct luaL_reg lib[] = { 29 | {"readline", f_readline}, 30 | {"add_history",f_add_history}, 31 | {NULL, NULL}, 32 | }; 33 | 34 | int luaopen_readline (lua_State *L) { 35 | luaL_openlib (L, "readline", lib, 0); 36 | return 1; 37 | } 38 | -------------------------------------------------------------------------------- /lua-5.1/.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | -------------------------------------------------------------------------------- /lua-5.1/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Lua License 2 | ----------- 3 | 4 | Lua is licensed under the terms of the MIT license reproduced below. 5 | This means that Lua is free software and can be used for both academic 6 | and commercial purposes at absolutely no cost. 7 | 8 | For details and rationale, see http://www.lua.org/license.html . 9 | 10 | =============================================================================== 11 | 12 | Copyright (C) 1994-2012 Lua.org, PUC-Rio. 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | 32 | =============================================================================== 33 | 34 | (end of COPYRIGHT) 35 | -------------------------------------------------------------------------------- /lua-5.1/README: -------------------------------------------------------------------------------- 1 | README for Lua 5.1 2 | 3 | See INSTALL for installation instructions. 4 | See HISTORY for a summary of changes since the last released version. 5 | 6 | * What is Lua? 7 | ------------ 8 | Lua is a powerful, light-weight programming language designed for extending 9 | applications. Lua is also frequently used as a general-purpose, stand-alone 10 | language. Lua is free software. 11 | 12 | For complete information, visit Lua's web site at http://www.lua.org/ . 13 | For an executive summary, see http://www.lua.org/about.html . 14 | 15 | Lua has been used in many different projects around the world. 16 | For a short list, see http://www.lua.org/uses.html . 17 | 18 | * Availability 19 | ------------ 20 | Lua is freely available for both academic and commercial purposes. 21 | See COPYRIGHT and http://www.lua.org/license.html for details. 22 | Lua can be downloaded at http://www.lua.org/download.html . 23 | 24 | * Installation 25 | ------------ 26 | Lua is implemented in pure ANSI C, and compiles unmodified in all known 27 | platforms that have an ANSI C compiler. In most Unix-like platforms, simply 28 | do "make" with a suitable target. See INSTALL for detailed instructions. 29 | 30 | * Origin 31 | ------ 32 | Lua is developed at Lua.org, a laboratory of the Department of Computer 33 | Science of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro 34 | in Brazil). 35 | For more information about the authors, see http://www.lua.org/authors.html . 36 | 37 | (end of README) 38 | -------------------------------------------------------------------------------- /lua-5.1/doc/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/lua-5.1/doc/cover.png -------------------------------------------------------------------------------- /lua-5.1/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/lua-5.1/doc/logo.gif -------------------------------------------------------------------------------- /lua-5.1/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | padding-top: 0.4em ; 20 | padding-bottom: 0.4em ; 21 | padding-left: 30px ; 22 | margin-left: -30px ; 23 | background-color: #E0E0FF ; 24 | } 25 | -------------------------------------------------------------------------------- /lua-5.1/doc/readme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Lua documentation 4 | 5 | 6 | 7 | 8 | 9 |
10 |

11 | Lua 12 | Documentation 13 |

14 | 15 | This is the documentation included in the source distribution of Lua 5.1.5. 16 | 17 | 25 | 26 | Lua's 27 | official web site 28 | contains updated documentation, 29 | especially the 30 | reference manual. 31 |

32 | 33 |


34 | 35 | Last update: 36 | Fri Feb 3 09:44:42 BRST 2012 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /lua-5.1/etc/Makefile: -------------------------------------------------------------------------------- 1 | # makefile for Lua etc 2 | 3 | TOP= .. 4 | LIB= $(TOP)/src 5 | INC= $(TOP)/src 6 | BIN= $(TOP)/src 7 | SRC= $(TOP)/src 8 | TST= $(TOP)/test 9 | 10 | CC= gcc 11 | CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS) 12 | MYCFLAGS= 13 | MYLDFLAGS= -Wl,-E 14 | MYLIBS= -lm 15 | #MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses 16 | RM= rm -f 17 | 18 | default: 19 | @echo 'Please choose a target: min noparser one strict clean' 20 | 21 | min: min.c 22 | $(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS) 23 | echo 'print"Hello there!"' | ./a.out 24 | 25 | noparser: noparser.o 26 | $(CC) noparser.o $(SRC)/lua.o -L$(LIB) -llua $(MYLIBS) 27 | $(BIN)/luac $(TST)/hello.lua 28 | -./a.out luac.out 29 | -./a.out -e'a=1' 30 | 31 | one: 32 | $(CC) $(CFLAGS) all.c $(MYLIBS) 33 | ./a.out $(TST)/hello.lua 34 | 35 | strict: 36 | -$(BIN)/lua -e 'print(a);b=2' 37 | -$(BIN)/lua -lstrict -e 'print(a)' 38 | -$(BIN)/lua -e 'function f() b=2 end f()' 39 | -$(BIN)/lua -lstrict -e 'function f() b=2 end f()' 40 | 41 | clean: 42 | $(RM) a.out core core.* *.o luac.out 43 | 44 | .PHONY: default min noparser one strict clean 45 | -------------------------------------------------------------------------------- /lua-5.1/etc/README: -------------------------------------------------------------------------------- 1 | This directory contains some useful files and code. 2 | Unlike the code in ../src, everything here is in the public domain. 3 | 4 | If any of the makes fail, you're probably not using the same libraries 5 | used to build Lua. Set MYLIBS in Makefile accordingly. 6 | 7 | all.c 8 | Full Lua interpreter in a single file. 9 | Do "make one" for a demo. 10 | 11 | lua.hpp 12 | Lua header files for C++ using 'extern "C"'. 13 | 14 | lua.ico 15 | A Lua icon for Windows (and web sites: save as favicon.ico). 16 | Drawn by hand by Markus Gritsch . 17 | 18 | lua.pc 19 | pkg-config data for Lua 20 | 21 | luavs.bat 22 | Script to build Lua under "Visual Studio .NET Command Prompt". 23 | Run it from the toplevel as etc\luavs.bat. 24 | 25 | min.c 26 | A minimal Lua interpreter. 27 | Good for learning and for starting your own. 28 | Do "make min" for a demo. 29 | 30 | noparser.c 31 | Linking with noparser.o avoids loading the parsing modules in lualib.a. 32 | Do "make noparser" for a demo. 33 | 34 | strict.lua 35 | Traps uses of undeclared global variables. 36 | Do "make strict" for a demo. 37 | 38 | -------------------------------------------------------------------------------- /lua-5.1/etc/all.c: -------------------------------------------------------------------------------- 1 | /* 2 | * all.c -- Lua core, libraries and interpreter in a single file 3 | */ 4 | 5 | #define luaall_c 6 | 7 | #include "lapi.c" 8 | #include "lcode.c" 9 | #include "ldebug.c" 10 | #include "ldo.c" 11 | #include "ldump.c" 12 | #include "lfunc.c" 13 | #include "lgc.c" 14 | #include "llex.c" 15 | #include "lmem.c" 16 | #include "lobject.c" 17 | #include "lopcodes.c" 18 | #include "lparser.c" 19 | #include "lstate.c" 20 | #include "lstring.c" 21 | #include "ltable.c" 22 | #include "ltm.c" 23 | #include "lundump.c" 24 | #include "lvm.c" 25 | #include "lzio.c" 26 | 27 | #include "lauxlib.c" 28 | #include "lbaselib.c" 29 | #include "ldblib.c" 30 | #include "liolib.c" 31 | #include "linit.c" 32 | #include "lmathlib.c" 33 | #include "loadlib.c" 34 | #include "loslib.c" 35 | #include "lstrlib.c" 36 | #include "ltablib.c" 37 | 38 | #include "lua.c" 39 | -------------------------------------------------------------------------------- /lua-5.1/etc/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /lua-5.1/etc/lua.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/lua-5.1/etc/lua.ico -------------------------------------------------------------------------------- /lua-5.1/etc/lua.pc: -------------------------------------------------------------------------------- 1 | # lua.pc -- pkg-config data for Lua 2 | 3 | # vars from install Makefile 4 | 5 | # grep '^V=' ../Makefile 6 | V= 5.1 7 | # grep '^R=' ../Makefile 8 | R= 5.1.5 9 | 10 | # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/' 11 | prefix= /usr/local 12 | INSTALL_BIN= ${prefix}/bin 13 | INSTALL_INC= ${prefix}/include 14 | INSTALL_LIB= ${prefix}/lib 15 | INSTALL_MAN= ${prefix}/man/man1 16 | INSTALL_LMOD= ${prefix}/share/lua/${V} 17 | INSTALL_CMOD= ${prefix}/lib/lua/${V} 18 | 19 | # canonical vars 20 | exec_prefix=${prefix} 21 | libdir=${exec_prefix}/lib 22 | includedir=${prefix}/include 23 | 24 | Name: Lua 25 | Description: An Extensible Extension Language 26 | Version: ${R} 27 | Requires: 28 | Libs: -L${libdir} -llua -lm 29 | Cflags: -I${includedir} 30 | 31 | # (end of lua.pc) 32 | -------------------------------------------------------------------------------- /lua-5.1/etc/luavs.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build Lua under "Visual Studio .NET Command Prompt". 2 | @rem Do not run from this directory; run it from the toplevel: etc\luavs.bat . 3 | @rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src. 4 | @rem (contributed by David Manura and Mike Pall) 5 | 6 | @setlocal 7 | @set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE 8 | @set MYLINK=link /nologo 9 | @set MYMT=mt /nologo 10 | 11 | cd src 12 | %MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c 13 | del lua.obj luac.obj 14 | %MYLINK% /DLL /out:lua51.dll l*.obj 15 | if exist lua51.dll.manifest^ 16 | %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2 17 | %MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c 18 | %MYLINK% /out:lua.exe lua.obj lua51.lib 19 | if exist lua.exe.manifest^ 20 | %MYMT% -manifest lua.exe.manifest -outputresource:lua.exe 21 | %MYCOMPILE% l*.c print.c 22 | del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj^ 23 | loslib.obj ltablib.obj lstrlib.obj loadlib.obj 24 | %MYLINK% /out:luac.exe *.obj 25 | if exist luac.exe.manifest^ 26 | %MYMT% -manifest luac.exe.manifest -outputresource:luac.exe 27 | del *.obj *.manifest 28 | cd .. 29 | -------------------------------------------------------------------------------- /lua-5.1/etc/min.c: -------------------------------------------------------------------------------- 1 | /* 2 | * min.c -- a minimal Lua interpreter 3 | * loads stdin only with minimal error handling. 4 | * no interaction, and no standard library, only a "print" function. 5 | */ 6 | 7 | #include 8 | 9 | #include "lua.h" 10 | #include "lauxlib.h" 11 | 12 | static int print(lua_State *L) 13 | { 14 | int n=lua_gettop(L); 15 | int i; 16 | for (i=1; i<=n; i++) 17 | { 18 | if (i>1) printf("\t"); 19 | if (lua_isstring(L,i)) 20 | printf("%s",lua_tostring(L,i)); 21 | else if (lua_isnil(L,i)) 22 | printf("%s","nil"); 23 | else if (lua_isboolean(L,i)) 24 | printf("%s",lua_toboolean(L,i) ? "true" : "false"); 25 | else 26 | printf("%s:%p",luaL_typename(L,i),lua_topointer(L,i)); 27 | } 28 | printf("\n"); 29 | return 0; 30 | } 31 | 32 | int main(void) 33 | { 34 | lua_State *L=lua_open(); 35 | lua_register(L,"print",print); 36 | if (luaL_dofile(L,NULL)!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1)); 37 | lua_close(L); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /lua-5.1/etc/noparser.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The code below can be used to make a Lua core that does not contain the 3 | * parsing modules (lcode, llex, lparser), which represent 35% of the total core. 4 | * You'll only be able to load binary files and strings, precompiled with luac. 5 | * (Of course, you'll have to build luac with the original parsing modules!) 6 | * 7 | * To use this module, simply compile it ("make noparser" does that) and list 8 | * its object file before the Lua libraries. The linker should then not load 9 | * the parsing modules. To try it, do "make luab". 10 | * 11 | * If you also want to avoid the dump module (ldump.o), define NODUMP. 12 | * #define NODUMP 13 | */ 14 | 15 | #define LUA_CORE 16 | 17 | #include "llex.h" 18 | #include "lparser.h" 19 | #include "lzio.h" 20 | 21 | LUAI_FUNC void luaX_init (lua_State *L) { 22 | UNUSED(L); 23 | } 24 | 25 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { 26 | UNUSED(z); 27 | UNUSED(buff); 28 | UNUSED(name); 29 | lua_pushliteral(L,"parser not loaded"); 30 | lua_error(L); 31 | return NULL; 32 | } 33 | 34 | #ifdef NODUMP 35 | #include "lundump.h" 36 | 37 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) { 38 | UNUSED(f); 39 | UNUSED(w); 40 | UNUSED(data); 41 | UNUSED(strip); 42 | #if 1 43 | UNUSED(L); 44 | return 0; 45 | #else 46 | lua_pushliteral(L,"dumper not loaded"); 47 | lua_error(L); 48 | #endif 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /lua-5.1/etc/strict.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- strict.lua 3 | -- checks uses of undeclared global variables 4 | -- All global variables must be 'declared' through a regular assignment 5 | -- (even assigning nil will do) in a main chunk before being used 6 | -- anywhere or assigned to inside a function. 7 | -- 8 | 9 | local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget 10 | 11 | local mt = getmetatable(_G) 12 | if mt == nil then 13 | mt = {} 14 | setmetatable(_G, mt) 15 | end 16 | 17 | mt.__declared = {} 18 | 19 | local function what () 20 | local d = getinfo(3, "S") 21 | return d and d.what or "C" 22 | end 23 | 24 | mt.__newindex = function (t, n, v) 25 | if not mt.__declared[n] then 26 | local w = what() 27 | if w ~= "main" and w ~= "C" then 28 | error("assign to undeclared variable '"..n.."'", 2) 29 | end 30 | mt.__declared[n] = true 31 | end 32 | rawset(t, n, v) 33 | end 34 | 35 | mt.__index = function (t, n) 36 | if not mt.__declared[n] and what() ~= "C" then 37 | error("variable '"..n.."' is not declared", 2) 38 | end 39 | return rawget(t, n) 40 | end 41 | 42 | -------------------------------------------------------------------------------- /lua-5.1/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /lua-5.1/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); 24 | LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, 25 | const TValue *p2); 26 | LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, 27 | const TValue *p2); 28 | LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); 29 | LUAI_FUNC void luaG_errormsg (lua_State *L); 30 | LUAI_FUNC int luaG_checkcode (const Proto *pt); 31 | LUAI_FUNC int luaG_checkopenop (Instruction i); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lua-5.1/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); 29 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 30 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 31 | int pc); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lua-5.1/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Initialization of libraries for lua.c 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | #include "lua.h" 12 | 13 | #include "lualib.h" 14 | #include "lauxlib.h" 15 | 16 | 17 | static const luaL_Reg lualibs[] = { 18 | {"", luaopen_base}, 19 | {LUA_LOADLIBNAME, luaopen_package}, 20 | {LUA_TABLIBNAME, luaopen_table}, 21 | {LUA_IOLIBNAME, luaopen_io}, 22 | {LUA_OSLIBNAME, luaopen_os}, 23 | {LUA_STRLIBNAME, luaopen_string}, 24 | {LUA_MATHLIBNAME, luaopen_math}, 25 | {LUA_DBLIBNAME, luaopen_debug}, 26 | {NULL, NULL} 27 | }; 28 | 29 | 30 | LUALIB_API void luaL_openlibs (lua_State *L) { 31 | const luaL_Reg *lib = lualibs; 32 | for (; lib->func; lib++) { 33 | lua_pushcfunction(L, lib->func); 34 | lua_pushstring(L, lib->name); 35 | lua_call(L, 1, 0); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /lua-5.1/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | 11 | #include "lgc.h" 12 | #include "lobject.h" 13 | #include "lstate.h" 14 | 15 | 16 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 17 | 18 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 19 | 20 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 25 | 26 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 27 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 28 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /lua-5.1/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gkey(n) (&(n)->i_key.nk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define key2tval(n) (&(n)->i_key.tvk) 19 | 20 | 21 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); 22 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); 23 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 24 | LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); 25 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 26 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 27 | LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); 28 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 29 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 30 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 31 | LUAI_FUNC int luaH_getn (Table *t); 32 | 33 | 34 | #if defined(LUA_DEBUG) 35 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 36 | LUAI_FUNC int luaH_isdummy (Node *n); 37 | #endif 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /lua-5.1/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_EQ, /* last tag method with `fast' access */ 24 | TM_ADD, 25 | TM_SUB, 26 | TM_MUL, 27 | TM_DIV, 28 | TM_MOD, 29 | TM_POW, 30 | TM_UNM, 31 | TM_LEN, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | LUAI_DATA const char *const luaT_typenames[]; 47 | 48 | 49 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 50 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 51 | TMS event); 52 | LUAI_FUNC void luaT_init (lua_State *L); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /lua-5.1/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* Key to file-handle type */ 15 | #define LUA_FILEHANDLE "FILE*" 16 | 17 | 18 | #define LUA_COLIBNAME "coroutine" 19 | LUALIB_API int (luaopen_base) (lua_State *L); 20 | 21 | #define LUA_TABLIBNAME "table" 22 | LUALIB_API int (luaopen_table) (lua_State *L); 23 | 24 | #define LUA_IOLIBNAME "io" 25 | LUALIB_API int (luaopen_io) (lua_State *L); 26 | 27 | #define LUA_OSLIBNAME "os" 28 | LUALIB_API int (luaopen_os) (lua_State *L); 29 | 30 | #define LUA_STRLIBNAME "string" 31 | LUALIB_API int (luaopen_string) (lua_State *L); 32 | 33 | #define LUA_MATHLIBNAME "math" 34 | LUALIB_API int (luaopen_math) (lua_State *L); 35 | 36 | #define LUA_DBLIBNAME "debug" 37 | LUALIB_API int (luaopen_debug) (lua_State *L); 38 | 39 | #define LUA_LOADLIBNAME "package" 40 | LUALIB_API int (luaopen_package) (lua_State *L); 41 | 42 | 43 | /* open all previous libraries */ 44 | LUALIB_API void (luaL_openlibs) (lua_State *L); 45 | 46 | 47 | 48 | #ifndef lua_assert 49 | #define lua_assert(x) ((void)0) 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /lua-5.1/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | /* load one chunk; from lundump.c */ 14 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 15 | 16 | /* make header; from lundump.c */ 17 | LUAI_FUNC void luaU_header (char* h); 18 | 19 | /* dump one chunk; from ldump.c */ 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 21 | 22 | #ifdef luac_c 23 | /* print one chunk; from print.c */ 24 | LUAI_FUNC void luaU_print (const Proto* f, int full); 25 | #endif 26 | 27 | /* for header of binary files -- this is Lua 5.1 */ 28 | #define LUAC_VERSION 0x51 29 | 30 | /* for header of binary files -- this is the official format */ 31 | #define LUAC_FORMAT 0 32 | 33 | /* size of header of binary files */ 34 | #define LUAC_HEADERSIZE 12 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lua-5.1/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ 19 | (((o) = luaV_tonumber(o,n)) != NULL)) 20 | 21 | #define equalobj(L,o1,o2) \ 22 | (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) 23 | 24 | 25 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 26 | LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); 27 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 28 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 29 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 30 | StkId val); 31 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 32 | StkId val); 33 | LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); 34 | LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lua-5.1/test/README: -------------------------------------------------------------------------------- 1 | These are simple tests for Lua. Some of them contain useful code. 2 | They are meant to be run to make sure Lua is built correctly and also 3 | to be read, to see how Lua programs look. 4 | 5 | Here is a one-line summary of each program: 6 | 7 | bisect.lua bisection method for solving non-linear equations 8 | cf.lua temperature conversion table (celsius to farenheit) 9 | echo.lua echo command line arguments 10 | env.lua environment variables as automatic global variables 11 | factorial.lua factorial without recursion 12 | fib.lua fibonacci function with cache 13 | fibfor.lua fibonacci numbers with coroutines and generators 14 | globals.lua report global variable usage 15 | hello.lua the first program in every language 16 | life.lua Conway's Game of Life 17 | luac.lua bare-bones luac 18 | printf.lua an implementation of printf 19 | readonly.lua make global variables readonly 20 | sieve.lua the sieve of of Eratosthenes programmed with coroutines 21 | sort.lua two implementations of a sort function 22 | table.lua make table, grouping all data for the same item 23 | trace-calls.lua trace calls 24 | trace-globals.lua trace assigments to global variables 25 | xd.lua hex dump 26 | 27 | -------------------------------------------------------------------------------- /lua-5.1/test/bisect.lua: -------------------------------------------------------------------------------- 1 | -- bisection method for solving non-linear equations 2 | 3 | delta=1e-6 -- tolerance 4 | 5 | function bisect(f,a,b,fa,fb) 6 | local c=(a+b)/2 7 | io.write(n," c=",c," a=",a," b=",b,"\n") 8 | if c==a or c==b or math.abs(a-b)>> ",string.rep(" ",level)) 9 | if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end 10 | t=debug.getinfo(2) 11 | if event=="call" then 12 | level=level+1 13 | else 14 | level=level-1 if level<0 then level=0 end 15 | end 16 | if t.what=="main" then 17 | if event=="call" then 18 | io.write("begin ",t.short_src) 19 | else 20 | io.write("end ",t.short_src) 21 | end 22 | elseif t.what=="Lua" then 23 | -- table.foreach(t,print) 24 | io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") 25 | else 26 | io.write(event," ",t.name or "(C)"," [",t.what,"] ") 27 | end 28 | io.write("\n") 29 | end 30 | 31 | debug.sethook(hook,"cr") 32 | level=0 33 | -------------------------------------------------------------------------------- /lua-5.1/test/trace-globals.lua: -------------------------------------------------------------------------------- 1 | -- trace assigments to global variables 2 | 3 | do 4 | -- a tostring that quotes strings. note the use of the original tostring. 5 | local _tostring=tostring 6 | local tostring=function(a) 7 | if type(a)=="string" then 8 | return string.format("%q",a) 9 | else 10 | return _tostring(a) 11 | end 12 | end 13 | 14 | local log=function (name,old,new) 15 | local t=debug.getinfo(3,"Sl") 16 | local line=t.currentline 17 | io.write(t.short_src) 18 | if line>=0 then io.write(":",line) end 19 | io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n") 20 | end 21 | 22 | local g={} 23 | local set=function (t,name,value) 24 | log(name,g[name],value) 25 | g[name]=value 26 | end 27 | setmetatable(getfenv(),{__index=g,__newindex=set}) 28 | end 29 | 30 | -- an example 31 | 32 | a=1 33 | b=2 34 | a=10 35 | b=20 36 | b=nil 37 | b=200 38 | print(a,b,c) 39 | -------------------------------------------------------------------------------- /lua-5.1/test/xd.lua: -------------------------------------------------------------------------------- 1 | -- hex dump 2 | -- usage: lua xd.lua < file 3 | 4 | local offset=0 5 | while true do 6 | local s=io.read(16) 7 | if s==nil then return end 8 | io.write(string.format("%08X ",offset)) 9 | string.gsub(s,"(.)", 10 | function (c) io.write(string.format("%02X ",string.byte(c))) end) 11 | io.write(string.rep(" ",3*(16-string.len(s)))) 12 | io.write(" ",string.gsub(s,"%c","."),"\n") 13 | offset=offset+16 14 | end 15 | -------------------------------------------------------------------------------- /lua-5.2/.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | -------------------------------------------------------------------------------- /lua-5.2/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.2.4, released on 25 Feb 2015. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /lua-5.2/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/lua-5.2/doc/logo.gif -------------------------------------------------------------------------------- /lua-5.2/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | font-style: normal ; 20 | padding-top: 0.4em ; 21 | padding-bottom: 0.4em ; 22 | padding-left: 16px ; 23 | margin-left: -16px ; 24 | background-color: #D0D0FF ; 25 | border-radius: 8px ; 26 | border: solid #000080 1px ; 27 | } 28 | -------------------------------------------------------------------------------- /lua-5.2/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/lua-5.2/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /lua-5.2/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.7.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /lua-5.2/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.7.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | /* Active Lua function (given call info) */ 21 | #define ci_func(ci) (clLvalue((ci)->func)) 22 | 23 | 24 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 25 | const char *opname); 26 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2); 27 | LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, 28 | const TValue *p2); 29 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 30 | const TValue *p2); 31 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 32 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lua-5.2/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.8.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 29 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 30 | int pc); 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lua-5.2/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.49.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 16 | 17 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 18 | 19 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 20 | (sizeof(s)/sizeof(char))-1)) 21 | 22 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 23 | 24 | 25 | /* 26 | ** test whether a string is a reserved word 27 | */ 28 | #define isreserved(s) ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0) 29 | 30 | 31 | /* 32 | ** equality for short strings, which are always internalized 33 | */ 34 | #define eqshrstr(a,b) check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b)) 35 | 36 | 37 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC int luaS_eqstr (TString *a, TString *b); 40 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 41 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 42 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 43 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /lua-5.2/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.16.1.2 2013/08/30 15:49:41 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gkey(n) (&(n)->i_key.tvk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define invalidateTMcache(t) ((t)->flags = 0) 19 | 20 | /* returns the key, given the value of a table entry */ 21 | #define keyfromval(v) \ 22 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 23 | 24 | 25 | LUAI_FUNC const TValue *luaH_getint (Table *t, int key); 26 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value); 27 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 28 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 29 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 30 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 31 | LUAI_FUNC Table *luaH_new (lua_State *L); 32 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize); 33 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 34 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 35 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 36 | LUAI_FUNC int luaH_getn (Table *t); 37 | 38 | 39 | #if defined(LUA_DEBUG) 40 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 41 | LUAI_FUNC int luaH_isdummy (Node *n); 42 | #endif 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /lua-5.2/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.11.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with `fast' access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_DIV, 29 | TM_MOD, 30 | TM_POW, 31 | TM_UNM, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | #define ttypename(x) luaT_typenames_[(x) + 1] 47 | #define objtypename(x) ttypename(ttypenv(x)) 48 | 49 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 50 | 51 | 52 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 53 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 54 | TMS event); 55 | LUAI_FUNC void luaT_init (lua_State *L); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /lua-5.2/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /lua-5.2/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.43.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); 16 | 17 | #define LUA_COLIBNAME "coroutine" 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 19 | 20 | #define LUA_TABLIBNAME "table" 21 | LUAMOD_API int (luaopen_table) (lua_State *L); 22 | 23 | #define LUA_IOLIBNAME "io" 24 | LUAMOD_API int (luaopen_io) (lua_State *L); 25 | 26 | #define LUA_OSLIBNAME "os" 27 | LUAMOD_API int (luaopen_os) (lua_State *L); 28 | 29 | #define LUA_STRLIBNAME "string" 30 | LUAMOD_API int (luaopen_string) (lua_State *L); 31 | 32 | #define LUA_BITLIBNAME "bit32" 33 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 34 | 35 | #define LUA_MATHLIBNAME "math" 36 | LUAMOD_API int (luaopen_math) (lua_State *L); 37 | 38 | #define LUA_DBLIBNAME "debug" 39 | LUAMOD_API int (luaopen_debug) (lua_State *L); 40 | 41 | #define LUA_LOADLIBNAME "package" 42 | LUAMOD_API int (luaopen_package) (lua_State *L); 43 | 44 | 45 | /* open all previous libraries */ 46 | LUALIB_API void (luaL_openlibs) (lua_State *L); 47 | 48 | 49 | 50 | #if !defined(lua_assert) 51 | #define lua_assert(x) ((void)0) 52 | #endif 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /lua-5.2/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.39.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | /* load one chunk; from lundump.c */ 14 | LUAI_FUNC Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 15 | 16 | /* make header; from lundump.c */ 17 | LUAI_FUNC void luaU_header (lu_byte* h); 18 | 19 | /* dump one chunk; from ldump.c */ 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 21 | 22 | /* data to catch conversion errors */ 23 | #define LUAC_TAIL "\x19\x93\r\n\x1a\n" 24 | 25 | /* size in bytes of header of binary files */ 26 | #define LUAC_HEADERSIZE (sizeof(LUA_SIGNATURE)-sizeof(char)+2+6+sizeof(LUAC_TAIL)-sizeof(char)) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /lua-5.2/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.18.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #define tostring(L,o) (ttisstring(o) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL)) 19 | 20 | #define equalobj(L,o1,o2) (ttisequal(o1, o2) && luaV_equalobj_(L, o1, o2)) 21 | 22 | #define luaV_rawequalobj(o1,o2) equalobj(NULL,o1,o2) 23 | 24 | 25 | /* not to called directly */ 26 | LUAI_FUNC int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2); 27 | 28 | 29 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 30 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 31 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 32 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 33 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 34 | StkId val); 35 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 36 | StkId val); 37 | LUAI_FUNC void luaV_finishOp (lua_State *L); 38 | LUAI_FUNC void luaV_execute (lua_State *L); 39 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 40 | LUAI_FUNC void luaV_arith (lua_State *L, StkId ra, const TValue *rb, 41 | const TValue *rc, TMS op); 42 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /lua-5.3/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.3.5, released on 26 Jun 2018. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /lua-5.3/doc/index.css: -------------------------------------------------------------------------------- 1 | ul { 2 | list-style-type: none ; 3 | } 4 | 5 | ul.contents { 6 | padding: 0 ; 7 | } 8 | 9 | table { 10 | border: none ; 11 | border-spacing: 0 ; 12 | border-collapse: collapse ; 13 | } 14 | 15 | td { 16 | vertical-align: top ; 17 | padding: 0 ; 18 | text-align: left ; 19 | line-height: 1.25 ; 20 | width: 15% ; 21 | } 22 | -------------------------------------------------------------------------------- /lua-5.3/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/lua-5.3/doc/logo.gif -------------------------------------------------------------------------------- /lua-5.3/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | color: gray ; 12 | float: right ; 13 | font-family: inherit ; 14 | font-style: normal ; 15 | font-size: small ; 16 | } 17 | 18 | h2:before { 19 | content: "" ; 20 | padding-right: 0em ; 21 | } 22 | -------------------------------------------------------------------------------- /lua-5.3/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/lua-5.3/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /lua-5.3/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /lua-5.3/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 24 | const TValue *p2); 25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 26 | const TValue *p2, 27 | const char *msg); 28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 29 | const TValue *p2); 30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 31 | const TValue *p2); 32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 34 | TString *src, int line); 35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 36 | LUAI_FUNC void luaG_traceexec (lua_State *L); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /lua-5.3/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /lua-5.3/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.61.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) 16 | 17 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 18 | #define sizeudata(u) sizeludata((u)->len) 19 | 20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 21 | (sizeof(s)/sizeof(char))-1)) 22 | 23 | 24 | /* 25 | ** test whether a string is a reserved word 26 | */ 27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 28 | 29 | 30 | /* 31 | ** equality for short strings, which are always internalized 32 | */ 33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 34 | 35 | 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 40 | LUAI_FUNC void luaS_clearcache (global_State *g); 41 | LUAI_FUNC void luaS_init (lua_State *L); 42 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 43 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 44 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 45 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 46 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /lua-5.3/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /lua-5.3/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_BITLIBNAME "bit32" 39 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 40 | 41 | #define LUA_MATHLIBNAME "math" 42 | LUAMOD_API int (luaopen_math) (lua_State *L); 43 | 44 | #define LUA_DBLIBNAME "debug" 45 | LUAMOD_API int (luaopen_debug) (lua_State *L); 46 | 47 | #define LUA_LOADLIBNAME "package" 48 | LUAMOD_API int (luaopen_package) (lua_State *L); 49 | 50 | 51 | /* open all previous libraries */ 52 | LUALIB_API void (luaL_openlibs) (lua_State *L); 53 | 54 | 55 | 56 | #if !defined(lua_assert) 57 | #define lua_assert(x) ((void)0) 58 | #endif 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /lua-5.3/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #if LUAC_COMPATIBLE_FORMAT 24 | #define LUAC_FORMAT 1 25 | #else 26 | #define LUAC_FORMAT 0 /* this is the official format */ 27 | #endif 28 | 29 | /* load one chunk; from lundump.c */ 30 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 31 | 32 | /* dump one chunk; from ldump.c */ 33 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 34 | void* data, int strip); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lua-5.3/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.37.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /luadec/allopcodes.luac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/luadec/allopcodes.luac -------------------------------------------------------------------------------- /luadec/common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef LUADEC_COMMON_H 4 | #define LUADEC_COMMON_H 5 | 6 | #ifdef _DEBUG 7 | 8 | #if defined MEMCHECK_VLD 9 | #include 10 | #include 11 | #elif defined MEMCHECK_MEMWATCH 12 | #define MEMWATCH 13 | #define MW_STDIO 14 | #include 15 | #include "memwatch.h" 16 | #endif 17 | 18 | #endif // #ifdef _DEBUG 19 | 20 | #define MACRO_STR_RAW(tok) #tok 21 | #define MACRO_STR(tok) MACRO_STR_RAW(tok) 22 | 23 | #ifndef cast 24 | #define cast(t,exp) ((t)(exp)) 25 | #endif // #ifndef cast 26 | 27 | #ifndef NULL 28 | #define NULL ((void *)0) 29 | #endif // #ifndef NULL 30 | 31 | #endif // #ifndef LUADEC_COMMON_H 32 | -------------------------------------------------------------------------------- /luadec/decompile.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/luadec/decompile.c -------------------------------------------------------------------------------- /luadec/disassemble.h: -------------------------------------------------------------------------------- 1 | #ifndef LUADEC_DISASSEMBLE_H 2 | #define LUADEC_DISASSEMBLE_H 3 | 4 | #include "lua.h" 5 | #include "lobject.h" 6 | 7 | #define CC(r) (ISK((r)) ? 'K' : 'R') 8 | #define CV(r) (ISK((r)) ? INDEXK(r) : r) 9 | 10 | #define RK(r) (RegOrConst(f, r)) 11 | 12 | #define MAXCONSTSIZE 1024 13 | 14 | void luadec_disassemble(Proto* fwork, int dflag, const char* name); 15 | 16 | void luadec_disassembleSubFunction(Proto* f, int dflag, const char* funcnumstr); 17 | 18 | char* RegOrConst(const Proto* f, int r); 19 | 20 | #endif // #ifndef LUADEC_DISASSEMBLE_H 21 | -------------------------------------------------------------------------------- /luadec/gen-allopcodes-h.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | set OUTDIR=%1 3 | set LUAFILE=%2 4 | echo copying %LUAFILE% 5 | copy /y ..\bin\%LUAFILE% allopcodes.lua 6 | echo generating allopcodes.luac 7 | %OUTDIR%\luac -o allopcodes.luac allopcodes.lua 8 | echo generating allopcodes_lua.h 9 | %OUTDIR%\lua ..\bin\bin2c.lua allopcodes.lua allopcodes_lua > allopcodes_lua.h 10 | echo generating allopcodes_luac.h 11 | %OUTDIR%\lua ..\bin\bin2c.lua allopcodes.luac allopcodes_luac > allopcodes_luac.h 12 | @echo on 13 | -------------------------------------------------------------------------------- /luadec/gen-git-srcversion.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | if not defined TERM (set TERM=msys) 3 | echo generating srcversion.h using "git log -n 1 --format=format:%%%%h" 4 | git log -n 1 --format=format:%%h%%n 5 | (echo #ifndef LUADEC_SRCVERSION_H) > srcversion.h 6 | (echo #define LUADEC_SRCVERSION_H) >> srcversion.h 7 | (echo.) >> srcversion.h 8 | (echo|set /p=#define SRCVERSION ^") >> srcversion.h 9 | git log -n 1 --format=format:%%h >> srcversion.h 10 | (echo ^") >> srcversion.h 11 | (echo.) >> srcversion.h 12 | (echo #endif // #ifndef LUADEC_SRCVERSION_H) >> srcversion.h 13 | @echo on 14 | -------------------------------------------------------------------------------- /luadec/gen-svn-srcversion.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo generating srcversion.h using "svnversion -n ." 3 | svnversion -n . 4 | (echo #ifndef LUADEC_SRCVERSION_H) > srcversion.h 5 | (echo #define LUADEC_SRCVERSION_H) >> srcversion.h 6 | (echo.) >> srcversion.h 7 | (echo|set /p=#define SRCVERSION ^") >> srcversion.h 8 | svnversion -n . >> srcversion.h 9 | (echo ^") >> srcversion.h 10 | (echo.) >> srcversion.h 11 | (echo #endif // #ifndef LUADEC_SRCVERSION_H) >> srcversion.h 12 | @echo on 13 | -------------------------------------------------------------------------------- /luadec/macro-array.c: -------------------------------------------------------------------------------- 1 | #include "lobject.h" 2 | 3 | #define T int 4 | #define TArray_IMPLEMENT 5 | #include "macro-array.h" 6 | #undef T 7 | 8 | #define T LocVar 9 | #define TArray_IMPLEMENT 10 | #include "macro-array.h" 11 | #undef T 12 | -------------------------------------------------------------------------------- /luadec/proto.h: -------------------------------------------------------------------------------- 1 | #ifndef LUADEC_PROTO_H 2 | #define LUADEC_PROTO_H 3 | 4 | #include "ldebug.h" 5 | #include "lobject.h" 6 | #include "lopcodes.h" 7 | #include "lundump.h" 8 | 9 | #define ASCII 437 10 | #define GB2312 20936 11 | #define GBK 936 12 | #define GB18030 54936 13 | #define BIG5 950 14 | #define UTF8 65001 15 | 16 | #define ENCODINGS "ASCII GB2312 GBK GB18030 BIG5 UTF8" 17 | 18 | #define GLOBAL(r) ((char*)svalue(&f->k[r])) 19 | #define opstr(o) ((o)==OP_EQ?"==":(o)==OP_LE?"<=":(o)==OP_LT?"<":(((o)==OP_TEST)||((o)==OP_TESTSET))?NULL:"?") // Lua5.1 specific 20 | #define invopstr(o) ((o)==OP_EQ?"~=":(o)==OP_LE?">":(o)==OP_LT?">=":(((o)==OP_TEST)||((o)==OP_TESTSET))?"not":"?") // Lua5.1 specific 21 | #define IsMain(f) ((f)==glproto) 22 | 23 | extern const char* operators[]; 24 | 25 | extern int priorities[]; 26 | 27 | extern int string_encoding; 28 | 29 | typedef struct Inst_ Inst; 30 | struct Inst_ { 31 | OpCode op; 32 | int a; 33 | int b; 34 | int c; 35 | int bx; 36 | int sbx; 37 | #if LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 38 | int ax; 39 | #endif 40 | }; 41 | 42 | Inst extractInstruction(Instruction i); 43 | Instruction assembleInstruction(Inst inst); 44 | 45 | void InitOperators(); 46 | 47 | int getEncoding(const char* src); 48 | 49 | char* DecompileString(const TValue* o); 50 | 51 | char* DecompileConstant(const Proto* f, int i); 52 | 53 | #endif // #ifndef LUADEC_PROTO_H 54 | -------------------------------------------------------------------------------- /luadec/srcversion.h: -------------------------------------------------------------------------------- 1 | #ifndef LUADEC_SRCVERSION_H 2 | #define LUADEC_SRCVERSION_H 3 | 4 | #define SRCVERSION "f9dfcf6" 5 | 6 | #endif // #ifndef LUADEC_SRCVERSION_H 7 | -------------------------------------------------------------------------------- /luadec/srcversion.h.template: -------------------------------------------------------------------------------- 1 | #ifndef LUADEC_SRCVERSION_H 2 | #define LUADEC_SRCVERSION_H 3 | 4 | #define SRCVERSION "$WCREV$" 5 | 6 | #endif // #ifndef LUADEC_SRCVERSION_H 7 | -------------------------------------------------------------------------------- /memwatch/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | $(CC) -DMEMWATCH -DMW_STDIO test.c memwatch.c 3 | -------------------------------------------------------------------------------- /memwatch/memwatch.lsm: -------------------------------------------------------------------------------- 1 | Begin3 2 | Title: memwatch 3 | Version: 2.71 4 | Entered-date: 2002-09-18 5 | Description: fault tolerant ANSI-C source code memory leak and corruption detection 6 | Keywords: memwatch debugging library memory leak source code ansi c 7 | Author: johan@linkdata.se 8 | Maintained-by: johan@linkdata.se 9 | Primary-site: ftp.linkdata.se /pub/memwatch 10 | 42K memwatch-2.71.tar.gz 11 | Alternate-site: 12 | Original-site: ftp.linkdata.se /pub/memwatch 13 | Platforms: all 14 | Copying-policy: GPL 15 | End 16 | -------------------------------------------------------------------------------- /test-compiled/lua-5.1/JX3_BF_Base_BigFoot.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/JX3_BF_Base_BigFoot.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/JX3_BF_ChannelsSimulator.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/JX3_BF_ChannelsSimulator.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/JX3_BF_InfoBox.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/JX3_BF_InfoBox.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/JX3_BF_QuestPlus.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/JX3_BF_QuestPlus.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/JX3_BF_Quest_Data.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/JX3_BF_Quest_Data.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/JX3_Xu_MacroFHX_Main.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/JX3_Xu_MacroFHX_Main.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/c01_daisy01.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/c01_daisy01.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/config.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/config.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/cont.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/cont.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/cont_game.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/cont_game.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/crystal.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/crystal.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/game.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/game.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/help_reload.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/help_reload.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/invite.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/invite.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/kpi.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/kpi.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/main.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/main.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/modstatus.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/modstatus.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/modstatus1.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/modstatus1.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/powerup.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/powerup.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/stage.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/stage.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/status.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/status.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/status4.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/status4.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/defense_witches/title.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/defense_witches/title.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/dialer_md5_encrypt_data.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/dialer_md5_encrypt_data.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/gcode1_db_m.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/gcode1_db_m.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/gcode7_cave.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/gcode7_cave.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/gcode9_WeightStation.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/gcode9_WeightStation.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/pangu_formula_action_formula_c.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/pangu_formula_action_formula_c.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/pangu_formula_gossip_lingshou.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/pangu_formula_gossip_lingshou.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/popup_hint.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/popup_hint.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/Button.xml.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/Button.xml.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/CheckBox.xml.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/CheckBox.xml.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/DownloaderAssistantWnd.xml.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/DownloaderAssistantWnd.xml.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/DownloaderHelper.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/DownloaderHelper.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/DownloaderMainWnd.xml.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/DownloaderMainWnd.xml.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/DownloaderMainWnd727.xml.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/DownloaderMainWnd727.xml.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/DownloaderMessageBox.xml.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/DownloaderMessageBox.xml.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/ImageButton.xml.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/ImageButton.xml.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/Progress.xml.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/Progress.xml.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/Root.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/Root.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/TextLink.xml.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/TextLink.xml.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/checkEnv.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/checkEnv.lua -------------------------------------------------------------------------------- /test-compiled/lua-5.1/xunlei/onload.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test-compiled/lua-5.1/xunlei/onload.lua -------------------------------------------------------------------------------- /test/0512/if.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | --while a > 0 do 4 | print(a) 5 | if b > 0 then 6 | print(c) 7 | --break 8 | end 9 | --end 10 | 11 | print(c) -------------------------------------------------------------------------------- /test/0512/repeat-for.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | repeat 4 | for i = 1,100,5 do 5 | a = a + i 6 | end 7 | until false -------------------------------------------------------------------------------- /test/0512/repeat-repeat.lua: -------------------------------------------------------------------------------- 1 | local a, b, c = nil, nil, nil 2 | repeat 3 | repeat 4 | repeat 5 | print(a) 6 | until a > 0 7 | do break end 8 | until b > 0 9 | c = a + b 10 | until d > 0 -------------------------------------------------------------------------------- /test/0512/repeat-until.lua: -------------------------------------------------------------------------------- 1 | local a,b 2 | repeat 3 | if a>0 then 4 | break 5 | end 6 | print(a) 7 | until b<0 -------------------------------------------------------------------------------- /test/0512/repeat.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | repeat 4 | print(a) 5 | if b > 0 then 6 | print(c) 7 | end 8 | until a > 0 -------------------------------------------------------------------------------- /test/0512/repeat4.lua: -------------------------------------------------------------------------------- 1 | local function a1() 2 | local a,b,c 3 | repeat 4 | repeat 5 | print(a) 6 | until c > 0 7 | afunc() 8 | until false 9 | end 10 | 11 | local function a2() 12 | local a,b,c 13 | repeat 14 | print(a) 15 | if c > 0 then 16 | afunc() 17 | end 18 | until false 19 | end 20 | 21 | 22 | local function a3() 23 | local a,b,c 24 | repeat 25 | repeat 26 | print(a) 27 | until c > 0 28 | afunc() 29 | until a > 0 30 | end 31 | 32 | local function a4() 33 | local a,b,c 34 | repeat 35 | print(a) 36 | if c > 0 then 37 | afunc() 38 | end 39 | until a > 0 40 | end -------------------------------------------------------------------------------- /test/0512/upvalue-list.lua: -------------------------------------------------------------------------------- 1 | local up 2 | 3 | local function a() 4 | up = {2,3,4} 5 | local x = 3 6 | local z = function() 7 | return up, x 8 | end 9 | return z 10 | end 11 | 12 | local function b() 13 | end -------------------------------------------------------------------------------- /test/0512/while-error.lua: -------------------------------------------------------------------------------- 1 | local i, cBits, cPos = 0, 0, 1 2 | --local i, cBits, cPos 3 | while i < 30 do 4 | while cBits < 8 do 5 | cPos = cPos + 1 6 | end 7 | while cBits >= 8 do 8 | i = i + 1 9 | end 10 | end 11 | return v 12 | -------------------------------------------------------------------------------- /test/0512/while-error2.lua: -------------------------------------------------------------------------------- 1 | --local i, cBits, cPos = 0, 0, 1 2 | local i, cBits, cPos 3 | while i < 30 do 4 | while cBits < 8 do 5 | cPos = cPos + 1 6 | end 7 | while cBits >= 8 do 8 | i = i + 1 9 | end 10 | end 11 | return v 12 | -------------------------------------------------------------------------------- /test/0512/while.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | while a > 0 do 4 | while b > 2 do 5 | c=c+1 --print(b) 6 | end 7 | while b <= 2 do 8 | c=c-1 --print(c) 9 | end 10 | end 11 | return a 12 | 13 | -------------------------------------------------------------------------------- /test/0512/while1-while1-error.lua: -------------------------------------------------------------------------------- 1 | local a, b, c = nil, nil, nil 2 | repeat 3 | repeat 4 | repeat 5 | print(a) 6 | until c > 0 7 | do break end 8 | until false 9 | c = a + b 10 | until false -------------------------------------------------------------------------------- /test/0512/while1-while1.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | while 1 do 3 | while 1 do 4 | print(a) 5 | if c > 0 then 6 | break 7 | end 8 | end 9 | c = a + b 10 | end -------------------------------------------------------------------------------- /test/0512/while2-error.lua: -------------------------------------------------------------------------------- 1 | local a, b, c 2 | 3 | repeat 4 | repeat 5 | print(a) 6 | until b > 0 7 | print(c) 8 | until a>0 9 | 10 | print(c) -------------------------------------------------------------------------------- /test/0512/while2.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | repeat 4 | print(a) 5 | if b > 0 then 6 | print(c) 7 | --break 8 | end 9 | until a>0 10 | 11 | print(c) -------------------------------------------------------------------------------- /test/0512/while3.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | while a > 0 and b > 0 do 4 | print(c) 5 | end 6 | -------------------------------------------------------------------------------- /test/0512/while4.lua: -------------------------------------------------------------------------------- 1 | local function a1() 2 | local a,b,c 3 | while 1 do 4 | print(a) 5 | if c > 0 then 6 | break 7 | end 8 | end 9 | end 10 | 11 | local function a2() 12 | local a,b,c 13 | while a > 0 do 14 | print(a) 15 | if c > 0 then 16 | break 17 | end 18 | end 19 | end -------------------------------------------------------------------------------- /test/0512/while5.lua: -------------------------------------------------------------------------------- 1 | local function a1() 2 | local a,b,c 3 | while 1 do 4 | repeat 5 | print(a) 6 | until c > 0 7 | do break end 8 | end 9 | end 10 | 11 | local function a2() 12 | local a,b,c 13 | while 1 do 14 | print(a) 15 | if c > 0 then 16 | break 17 | end 18 | end 19 | end 20 | 21 | local function a3() 22 | local a,b,c 23 | repeat 24 | print(a) 25 | until c > 0 26 | end -------------------------------------------------------------------------------- /test/0512/while6.lua: -------------------------------------------------------------------------------- 1 | local function a1() 2 | local a,b,c 3 | while 1 do 4 | repeat 5 | print(a) 6 | until c > 0 7 | print(b) 8 | end 9 | end -------------------------------------------------------------------------------- /test/20130707/_logic_leaks.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,d,e,f,g 2 | local w,x,y,z 3 | 4 | --w = c or a == b --0 5 | 6 | --x = a == b and c --0 7 | 8 | y = a > b or c --2 9 | --[[ 10 | z = a < b and c and d --2 11 | 12 | w = a == b and c and d and e --2 13 | 14 | x = a == b and c and d or e --0 15 | --]] 16 | -------------------------------------------------------------------------------- /test/20130707/_nestif.lua: -------------------------------------------------------------------------------- 1 | local a,b 2 | 3 | if a >= 0 then 4 | if b >= 0 then 5 | b = 1 6 | else 7 | b = 2 8 | end 9 | end -------------------------------------------------------------------------------- /test/20130707/_repeat_repeat.lua: -------------------------------------------------------------------------------- 1 | local a,b,c; 2 | repeat 3 | repeat 4 | a = a+1 5 | until a > 4 6 | a=a+3 7 | until a > 5 -------------------------------------------------------------------------------- /test/20130707/_while.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | function f1() 3 | local a,b; 4 | --ok 5 | while a and b do 6 | f() 7 | end 8 | --[1] test 0 0 ; if R0 then to [3] 9 | --[2] jmp 5 ; to [8] 10 | --[3] test 1 0 ; if R1 then to [5] 11 | --[4] jmp 3 ; to [8] 12 | --[5] getglobal 2 0 ; R2 := f 13 | --[6] call 2 1 1 ; R2() 14 | --[7] jmp -7 ; to [1] 15 | --[8] return 0 1 ; return 16 | end 17 | --]] 18 | 19 | function f2() 20 | local a,b; 21 | --error 22 | while a do 23 | if b then 24 | f() 25 | end 26 | end 27 | --[1] test 0 0 ; if R0 then to [3] 28 | --[2] jmp 5 ; to [8] 29 | --[3] test 1 0 ; if R1 then to [5] 30 | --[4] jmp -4 ; to [1] 31 | --[5] getglobal 2 0 ; R2 := f 32 | --[6] call 2 1 1 ; R2() 33 | --[7] jmp -7 ; to [1] 34 | --[8] return 0 1 ; return 35 | end 36 | 37 | --[[ 38 | function f3() 39 | local a,b; 40 | --error 41 | while a do 42 | while b do 43 | f() 44 | end 45 | end 46 | --[1] test 0 0 ; if R0 then to [3] 47 | --[2] jmp 6 ; to [9] 48 | --[3] test 1 0 ; if R1 then to [5] 49 | --[4] jmp -4 ; to [1] 50 | --[5] getglobal 2 0 ; R2 := f 51 | --[6] call 2 1 1 ; R2() 52 | --[7] jmp -5 ; to [3] 53 | --[8] jmp -8 ; to [1] 54 | --[9] return 0 1 ; return 55 | end 56 | --]] -------------------------------------------------------------------------------- /test/20130707/_while_if.lua: -------------------------------------------------------------------------------- 1 | local a,b,c; 2 | while 1 do 3 | if(a) then 4 | b=3 5 | else 6 | --b=4 7 | break; 8 | end 9 | b=b+3 10 | end 11 | 12 | -- 0 [-]: TEST R0 0 ; if R0 then PC := 2 else PC := 6 13 | -- 1 [-]: JMP 6 ; PC := 6 14 | -- 2 [-]: LOADK R1 K0 ; R1 := 3 15 | -- 3 [-]: JMP 0 ; PC := 0 16 | -- 4 [-]: JMP 6 ; PC := 6 17 | -- 5 [-]: JMP 0 ; PC := 0 18 | -- 6 [-]: RETURN R0 1 ; return 19 | -------------------------------------------------------------------------------- /test/error_nested_if/doreturnend.lua: -------------------------------------------------------------------------------- 1 | if a then 2 | else 3 | if b then 4 | c=0 5 | end 6 | end 7 | --[[ 8 | -- Decompiled using luadec 2.2 GBK R5bf00c7 9 | if a then 10 | 11 | -- DECOMPILER ERROR: 2 unprocessed JMP targets 12 | end 13 | --]] 14 | -------------------------------------------------------------------------------- /test/error_nested_if/doreturnend2.lua: -------------------------------------------------------------------------------- 1 | local function x() 2 | if a then 3 | else 4 | if b then 5 | c=0 6 | end 7 | end 8 | end 9 | 10 | local function x() 11 | if not a then 12 | if b then 13 | c=0 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /test/error_nested_if/doreturnend3.lua: -------------------------------------------------------------------------------- 1 | local function x() 2 | if a then 3 | else 4 | if b then 5 | c=0 6 | end 7 | end 8 | print(a) 9 | end 10 | 11 | --[[ 12 | -- Decompiled using luadec 2.2 GBK R5bf00c7 13 | 14 | local x = function() 15 | if a then 16 | do return end 17 | end 18 | if b then 19 | c = 0 20 | end 21 | print(a) 22 | end 23 | ]]-- -------------------------------------------------------------------------------- /test/error_nested_if/if1.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,d,e 2 | 3 | if a then 4 | if not b or c then 5 | e=102 6 | end 7 | else 8 | if d then 9 | e=102 10 | end 11 | end 12 | 13 | --[[ 14 | -- Decompiled using luadec 2.2 GBK R5bf00c7 15 | 16 | local a, b, c, d, e = nil 17 | if a and (not b or c) then 18 | e = 102 19 | end 20 | 21 | -- DECOMPILER ERROR: 2 unprocessed JMP targets 22 | ]]-- 23 | -------------------------------------------------------------------------------- /test/error_nested_if/if2.lua: -------------------------------------------------------------------------------- 1 | if a == b then 2 | print(a) 3 | if c then 4 | print(c) 5 | end 6 | else 7 | local hnd = d 8 | if hnd then 9 | print(d) 10 | end 11 | end -------------------------------------------------------------------------------- /test/error_nested_if/logic/if.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | local p1,p2,p3,p4 3 | 4 | --1001,error 5 | if a then 6 | if b then 7 | p1() 8 | end 9 | else 10 | p3() 11 | end 12 | 13 | --[[ 14 | -- Decompiled using luadec 2.2 GBK R5bf00c7 15 | 16 | local a, b, c, p1, p2, p3, p4 = nil 17 | if a and b then 18 | p1() 19 | end 20 | 21 | -- DECOMPILER ERROR: 2 unprocessed JMP targets 22 | --]] 23 | -------------------------------------------------------------------------------- /test/error_nested_if/logic/if2.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | local p1,p2,p3,p4 3 | 4 | --1100 5 | if a then 6 | if b then 7 | p1() 8 | else 9 | p2() 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /test/error_nested_if/logic/if_all.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | local p1,p2,p3,p4 3 | 4 | -- 0100 5 | if a then 6 | p1() 7 | end 8 | 9 | -- 1000 10 | if a then 11 | if b then 12 | p1() 13 | end 14 | end 15 | 16 | --1100 17 | if a then 18 | if b then 19 | p1() 20 | else 21 | p2() 22 | end 23 | end 24 | 25 | --1010, error 26 | if a then 27 | if b then 28 | p1() 29 | end 30 | else 31 | if c then 32 | p3() 33 | end 34 | end 35 | 36 | --0110 37 | if a then 38 | p1() 39 | else 40 | if c then 41 | p3() 42 | end 43 | end 44 | 45 | --1001,error 46 | if a then 47 | if b then 48 | p1() 49 | end 50 | else 51 | p3() 52 | end 53 | 54 | --0101 55 | if a then 56 | p1() 57 | else 58 | p3() 59 | end 60 | 61 | --1110 62 | if a then 63 | if b then 64 | p1() 65 | else 66 | p2() 67 | end 68 | else 69 | if c then 70 | p3() 71 | end 72 | end 73 | 74 | --1101 75 | if a then 76 | if b then 77 | p1() 78 | else 79 | p2() 80 | end 81 | else 82 | p3() 83 | end 84 | 85 | --1011,error 86 | if a then 87 | if b then 88 | p1() 89 | end 90 | else 91 | if c then 92 | p3() 93 | else 94 | p4() 95 | end 96 | end 97 | 98 | --0111 99 | if a then 100 | p1() 101 | else 102 | if c then 103 | p3() 104 | else 105 | p4() 106 | end 107 | end 108 | 109 | --1111 110 | if a then 111 | if b then 112 | p1() 113 | else 114 | p2() 115 | end 116 | else 117 | if c then 118 | p3() 119 | else 120 | p4() 121 | end 122 | end -------------------------------------------------------------------------------- /test/error_nested_if/logic/if_error.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | local p1,p2,p3,p4 3 | 4 | --1010, error 5 | if a then 6 | if b then 7 | p1() 8 | end 9 | else 10 | if c then 11 | p3() 12 | end 13 | end 14 | 15 | --1001,error 16 | if a then 17 | if b then 18 | p1() 19 | end 20 | else 21 | p3() 22 | end 23 | 24 | --1011,error 25 | if a then 26 | if b then 27 | p1() 28 | end 29 | else 30 | if c then 31 | p3() 32 | else 33 | p4() 34 | end 35 | end -------------------------------------------------------------------------------- /test/error_nested_if/logic/logic.lua: -------------------------------------------------------------------------------- 1 | --local a=true 2 | --local b="a" 3 | --local c= b and 0 or 3 4 | local d= (b and a) or ((not c) and ( a or not b)) 5 | --print(b) 6 | 7 | --[[ 8 | -- Decompiled using luadec 2.2 GBK R5bf00c7 9 | 10 | local a = true 11 | local b = "a" 12 | local c = b and 0 or 3 13 | -- DECOMPILER ERROR: unhandled construct in 'MakeBoolean' 14 | 15 | -- DECOMPILER ERROR: unhandled construct in 'MakeBoolean' 16 | 17 | do 18 | local d = (not b or not a) and c 19 | -- DECOMPILER ERROR: 2 unprocessed JMP targets 20 | end 21 | --]] -------------------------------------------------------------------------------- /test/issues/issue13_direct_call.lua: -------------------------------------------------------------------------------- 1 | ( 2 | function() 3 | print("abc") 4 | end 5 | )() 6 | ;-- must output this 7 | ( 8 | function(a) 9 | print(type(a)) 10 | end 11 | )(function() 12 | print("abe") 13 | end) 14 | 15 | 16 | -- may not decompile 17 | local a = (function() print(1) end)+1 18 | 19 | ((function() print(1) end)+(function() print(2) end))() 20 | ; 21 | (1+(function() print(1) end)+2)() 22 | ; 23 | 24 | local b=f; 25 | ((function() print(1) end)+(function() print(2) end))() 26 | -------------------------------------------------------------------------------- /test/issues/issue15_fn_upvalue.lua: -------------------------------------------------------------------------------- 1 | local a, b 2 | 3 | function f() 4 | a,b=nil 5 | return false 6 | end; 7 | -------------------------------------------------------------------------------- /test/issues/issue17_self_call.lua: -------------------------------------------------------------------------------- 1 | -- OP_GETTABLE MakeIndex( DOT ) 2 | local x = (1+a).f4 3 | x = ({0,1}).a 4 | x = ({2,3,4}+5)[6] 5 | 6 | -- OP_SETTABLE MakeIndex( DOT ) 7 | ;(1+a).f3 = x 8 | --;({0,1}).a = x 9 | ;({2,3,4}+5)[6] = x 10 | 11 | -- OP_CALL 12 | _a22_2_a() 13 | a() 14 | a.f3() 15 | ;(1+a)(s) 16 | ;(function(f) print(type(f)) end)(3) 17 | 18 | --OP_SELF MakeIndex( SELF ) 19 | a:f() 20 | a:f3() 21 | ;(2+a):f3() 22 | -------------------------------------------------------------------------------- /test/issues/issue22_exp_settable.lua: -------------------------------------------------------------------------------- 1 | -- OP_SETTABLE MakeIndex( DOT ) 2 | -- DECOMPILER ERROR: Confused about usage of registers! 3 | (1+a).f3 = x 4 | -- DECOMPILER ERROR: Confused about usage of registers! 5 | ;({2,3,4}+5)[6] =x 6 | -- DECOMPILER ERROR: Overwrote pending register. 7 | ;({0,1}).a = x 8 | local y =4 -- need to output last statement with error 9 | -- local y = {0, 1; a = x} 10 | -------------------------------------------------------------------------------- /test/issues/issue23_cannot_jmp_out_else.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,f 2 | 3 | function ok1() 4 | local a,b,c,f 5 | --ok 6 | if b==1 then 7 | c = 11 8 | elseif b==2 then 9 | c = 12 10 | else 11 | c = 13 12 | end 13 | print(f) 14 | if b==4 then 15 | c = 14 16 | end 17 | end 18 | 19 | function error1() 20 | local a,b,c,f 21 | --ok 22 | if b==1 then 23 | c = 11 24 | elseif b==2 then 25 | c = 12 26 | else 27 | c = 13 28 | end 29 | --print(f) 30 | if b==4 then 31 | c = 14 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /test/issues/issue24_while_if.lua: -------------------------------------------------------------------------------- 1 | local a,b; 2 | 3 | while a and b do 4 | f() 5 | end 6 | 7 | while a do 8 | if b then 9 | f() 10 | end 11 | end 12 | 13 | while a do 14 | while b do 15 | f() 16 | end 17 | end -------------------------------------------------------------------------------- /test/issues/issue27_and_or_or.lua: -------------------------------------------------------------------------------- 1 | -- Command line: -fc -fn 0_10 E:\cbprojects\luadec\angrybirds_lua\scripts\menus\level_end.lua 2 | 3 | Decompiled_0_10 = function (p) 4 | local a,b,c,d 5 | if ((a and b) or c or d) then 6 | p = 3 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /test/issues/issue28_lt_le_const.lua: -------------------------------------------------------------------------------- 1 | function lt_const(a,b,c) 2 | b = a>3 3 | b = 3=a) 6 | end 7 | 8 | function lt_if(a,b,c) 9 | if a>3 then 10 | b() 11 | end 12 | if not (a<=3) then 13 | c() 14 | end 15 | end 16 | 17 | function eq_const(a,b,c) 18 | b = a==3 19 | b = 3==a 20 | end 21 | 22 | function lt_function(a,b,c) 23 | a = b()>c() 24 | a = c()=b()) 27 | end 28 | -------------------------------------------------------------------------------- /test/issues/issue29_vararg.lua: -------------------------------------------------------------------------------- 1 | -- 5.1 main always is_vararg=2 2 | -- 5.2 main always is_vararg=1 3 | local a; 4 | 5 | (function() 6 | -- 5.2 don't has arg 7 | for k,v in ipairs(_G.arg) do 8 | print(v) 9 | end 10 | end)() 11 | 12 | for k,v in ipairs({...}) do 13 | print(v) 14 | end 15 | 16 | -- 5.2 don't has arg 17 | for k,v in ipairs(arg) do 18 | print(v) 19 | end 20 | 21 | -- is_vararg=0 22 | function f0() 23 | local x=arg 24 | end 25 | 26 | -- 5.1 is_vararg=7 27 | -- 5.2 is_vararg=1 28 | function f1(...) 29 | local x=arg 30 | end 31 | 32 | -- 5.1 is_vararg=3, not use arg, but put arg as param 33 | -- 5.2 is_vararg=1 34 | function f2(...) 35 | local x=... 36 | end 37 | 38 | -- 5.1 is_vararg=3 39 | -- 5.2 is_vararg=1 40 | function f3(...) 41 | local x=arg 42 | local y=... 43 | end 44 | 45 | -- 5.1 is_vararg=3 46 | -- 5.2 is_vararg=1 47 | function f4(x, ...) 48 | local x=arg 49 | local y=... 50 | end 51 | -------------------------------------------------------------------------------- /test/issues/issue30_local_reuse.lua: -------------------------------------------------------------------------------- 1 | for i = 1, 10 do 2 | local a,b,c,d = i,i+1,i+2; 3 | print(a); 4 | end 5 | local c=... 6 | local b,a=3,4; 7 | print(a) 8 | 9 | for i = 1, 10 do 10 | local x,y,z 11 | f[i] = function() x=x+1; print(y); z=i; end 12 | end 13 | 14 | do 15 | local a1 = 0 16 | print(a1) 17 | end 18 | local b1 = 1 19 | 20 | local t = {a,b,c} 21 | -------------------------------------------------------------------------------- /test/issues/issue32_global_or_to_if.lua: -------------------------------------------------------------------------------- 1 | function a0 (b) 2 | c = c or {} 3 | return b 4 | end 5 | 6 | function a1 (b) 7 | if not c then 8 | c = {} 9 | end 10 | return b 11 | end -------------------------------------------------------------------------------- /test/issues/issue33_if_if.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,d,e 2 | 3 | if a then 4 | b() 5 | if c then 6 | d() 7 | end 8 | end 9 | e() 10 | -------------------------------------------------------------------------------- /test/issues/issue42_function_local_scope.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | do 4 | local x = 3 5 | end 6 | 7 | do 8 | local x 9 | x = a(b) + c 10 | end 11 | 12 | do 13 | local x = a(b) + c 14 | end 15 | 16 | do 17 | local x 18 | x = a(b) + c 19 | function z() 20 | return x 21 | end 22 | end 23 | 24 | function z(a1,a2) 25 | local a3 26 | a3 = 4 + 5 27 | end 28 | 29 | function z2(a1,a2) 30 | local a3 = 3 31 | end 32 | 33 | function z3(a1,a2) 34 | local a3 = 3 35 | return a3 36 | end 37 | 38 | function z4(a1,a2) 39 | local a3 40 | do 41 | local a4 42 | end 43 | return a1 44 | end 45 | 46 | function z5(a1,a2) 47 | local a3 48 | do 49 | local a4 50 | a3 = a4 51 | end 52 | return a1 53 | end -------------------------------------------------------------------------------- /test/issues/issue43_local_func_as_upval.lua: -------------------------------------------------------------------------------- 1 | do 2 | local z=function() return 1 end 3 | end 4 | 5 | do 6 | local function z() return 1 end 7 | end 8 | 9 | do 10 | local z=function() return z end 11 | end 12 | 13 | do 14 | local function z() return z end 15 | end 16 | -------------------------------------------------------------------------------- /test/issues/issue4_jmp_loadbool.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/issues/issue4_jmp_loadbool.lua -------------------------------------------------------------------------------- /test/issues/issue4_jmp_loadbool_all.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/issues/issue4_jmp_loadbool_all.lua -------------------------------------------------------------------------------- /test/loop_structure/4while1.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,d,e,f,g 2 | 3 | while 1 do 4 | a() 5 | 6 | while 1 do 7 | b() 8 | end 9 | 10 | f() 11 | 12 | while 1 do 13 | c() 14 | while 1 do 15 | d() 16 | end 17 | e() 18 | end 19 | 20 | g() 21 | end -------------------------------------------------------------------------------- /test/loop_structure/complex_while.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | while (a > 0 or b>0) and c>0 do 3 | print(a) 4 | if a+b > 0 then 5 | break 6 | end 7 | print(b) 8 | end 9 | -------------------------------------------------------------------------------- /test/loop_structure/complex_while2.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | while (a > 0 or b>0) and c>0 do 3 | print(a) 4 | break; 5 | end -------------------------------------------------------------------------------- /test/loop_structure/for.lua: -------------------------------------------------------------------------------- 1 | for i = 1, 10 do 2 | print(i) 3 | end 4 | -------------------------------------------------------------------------------- /test/loop_structure/repeat-for.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | repeat 3 | for i = 1, 10 do 4 | print(i) 5 | end 6 | until a>0 -------------------------------------------------------------------------------- /test/loop_structure/repeat-while.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | repeat 4 | while (a > 0 or b>0) and c>0 do 5 | if a+b>0 then 6 | break; 7 | end 8 | end 9 | until a>0 -------------------------------------------------------------------------------- /test/loop_structure/repeat.lua: -------------------------------------------------------------------------------- 1 | local a 2 | repeat 3 | print(a) 4 | until a > 0 -------------------------------------------------------------------------------- /test/loop_structure/tfor.lua: -------------------------------------------------------------------------------- 1 | for k,v in pairs(a) do 2 | print(k,v) 3 | end 4 | -------------------------------------------------------------------------------- /test/loop_structure/until1.lua: -------------------------------------------------------------------------------- 1 | local a 2 | repeat 3 | a() 4 | until false 5 | -------------------------------------------------------------------------------- /test/loop_structure/while-while.lua: -------------------------------------------------------------------------------- 1 | local a, b 2 | while a > 0 do 3 | print(a) 4 | while b > 0 do 5 | print(b) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/loop_structure/while.lua: -------------------------------------------------------------------------------- 1 | local a 2 | while a > 0 do 3 | print(a) 4 | end 5 | -------------------------------------------------------------------------------- /test/loop_structure/while1-if.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,f 2 | 3 | while 1 do 4 | f(b) 5 | if c then 6 | f(a) 7 | end 8 | end -------------------------------------------------------------------------------- /test/loop_structure/while1-until.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,f 2 | 3 | while 1 do 4 | repeat 5 | f(b) 6 | until c 7 | f(a) 8 | end -------------------------------------------------------------------------------- /test/loop_structure/while1-while1.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,f 2 | 3 | while 1 do 4 | f(a) 5 | end 6 | 7 | while 1 do 8 | f(b) 9 | end -------------------------------------------------------------------------------- /test/loop_structure/while1.lua: -------------------------------------------------------------------------------- 1 | local a 2 | while 1 do 3 | a() 4 | end -------------------------------------------------------------------------------- /test/lua-5.1-test/README: -------------------------------------------------------------------------------- 1 | These are simple tests for Lua. Some of them contain useful code. 2 | They are meant to be run to make sure Lua is built correctly and also 3 | to be read, to see how Lua programs look. 4 | 5 | Here is a one-line summary of each program: 6 | 7 | bisect.lua bisection method for solving non-linear equations 8 | cf.lua temperature conversion table (celsius to farenheit) 9 | echo.lua echo command line arguments 10 | env.lua environment variables as automatic global variables 11 | factorial.lua factorial without recursion 12 | fib.lua fibonacci function with cache 13 | fibfor.lua fibonacci numbers with coroutines and generators 14 | globals.lua report global variable usage 15 | hello.lua the first program in every language 16 | life.lua Conway's Game of Life 17 | luac.lua bare-bones luac 18 | printf.lua an implementation of printf 19 | readonly.lua make global variables readonly 20 | sieve.lua the sieve of of Eratosthenes programmed with coroutines 21 | sort.lua two implementations of a sort function 22 | table.lua make table, grouping all data for the same item 23 | trace-calls.lua trace calls 24 | trace-globals.lua trace assigments to global variables 25 | xd.lua hex dump 26 | 27 | -------------------------------------------------------------------------------- /test/lua-5.1-test/bisect.lua: -------------------------------------------------------------------------------- 1 | -- bisection method for solving non-linear equations 2 | 3 | delta=1e-6 -- tolerance 4 | 5 | function bisect(f,a,b,fa,fb) 6 | local c=(a+b)/2 7 | io.write(n," c=",c," a=",a," b=",b,"\n") 8 | if c==a or c==b or math.abs(a-b)>> ",string.rep(" ",level)) 9 | if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end 10 | t=debug.getinfo(2) 11 | if event=="call" then 12 | level=level+1 13 | else 14 | level=level-1 if level<0 then level=0 end 15 | end 16 | if t.what=="main" then 17 | if event=="call" then 18 | io.write("begin ",t.short_src) 19 | else 20 | io.write("end ",t.short_src) 21 | end 22 | elseif t.what=="Lua" then 23 | -- table.foreach(t,print) 24 | io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") 25 | else 26 | io.write(event," ",t.name or "(C)"," [",t.what,"] ") 27 | end 28 | io.write("\n") 29 | end 30 | 31 | debug.sethook(hook,"cr") 32 | level=0 33 | -------------------------------------------------------------------------------- /test/lua-5.1-test/trace-globals.lua: -------------------------------------------------------------------------------- 1 | -- trace assigments to global variables 2 | 3 | do 4 | -- a tostring that quotes strings. note the use of the original tostring. 5 | local _tostring=tostring 6 | local tostring=function(a) 7 | if type(a)=="string" then 8 | return string.format("%q",a) 9 | else 10 | return _tostring(a) 11 | end 12 | end 13 | 14 | local log=function (name,old,new) 15 | local t=debug.getinfo(3,"Sl") 16 | local line=t.currentline 17 | io.write(t.short_src) 18 | if line>=0 then io.write(":",line) end 19 | io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n") 20 | end 21 | 22 | local g={} 23 | local set=function (t,name,value) 24 | log(name,g[name],value) 25 | g[name]=value 26 | end 27 | setmetatable(getfenv(),{__index=g,__newindex=set}) 28 | end 29 | 30 | -- an example 31 | 32 | a=1 33 | b=2 34 | a=10 35 | b=20 36 | b=nil 37 | b=200 38 | print(a,b,c) 39 | -------------------------------------------------------------------------------- /test/lua-5.1-test/xd.lua: -------------------------------------------------------------------------------- 1 | -- hex dump 2 | -- usage: lua xd.lua < file 3 | 4 | local offset=0 5 | while true do 6 | local s=io.read(16) 7 | if s==nil then return end 8 | io.write(string.format("%08X ",offset)) 9 | string.gsub(s,"(.)", 10 | function (c) io.write(string.format("%02X ",string.byte(c))) end) 11 | io.write(string.rep(" ",3*(16-string.len(s)))) 12 | io.write(" ",string.gsub(s,"%c","."),"\n") 13 | offset=offset+16 14 | end 15 | -------------------------------------------------------------------------------- /test/lua-5.1-tests/db.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.1-tests/db.lua -------------------------------------------------------------------------------- /test/lua-5.1-tests/files.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.1-tests/files.lua -------------------------------------------------------------------------------- /test/lua-5.1-tests/libs/P1/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /test/lua-5.1-tests/literals.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.1-tests/literals.lua -------------------------------------------------------------------------------- /test/lua-5.1-tests/pm.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.1-tests/pm.lua -------------------------------------------------------------------------------- /test/lua-5.1-tests/sort.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.1-tests/sort.lua -------------------------------------------------------------------------------- /test/lua-5.1-tests/strings.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.1-tests/strings.lua -------------------------------------------------------------------------------- /test/lua-5.2-tests/db.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.2-tests/db.lua -------------------------------------------------------------------------------- /test/lua-5.2-tests/files.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.2-tests/files.lua -------------------------------------------------------------------------------- /test/lua-5.2-tests/libs/P1/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /test/lua-5.2-tests/libs/lib1.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** compile with 3 | ** Linux: gcc -Wall -O2 -I.. -ansi -shared -o lib1.so lib1.c 4 | ** Mac OS X: export MACOSX_DEPLOYMENT_TARGET=10.3 5 | ** gcc -bundle -undefined dynamic_lookup -Wall -O2 -o lib1.so lib1.c 6 | */ 7 | 8 | 9 | #include "lua.h" 10 | #include "lauxlib.h" 11 | 12 | static int id (lua_State *L) { 13 | return lua_gettop(L); 14 | } 15 | 16 | 17 | static const struct luaL_Reg funcs[] = { 18 | {"id", id}, 19 | {NULL, NULL} 20 | }; 21 | 22 | 23 | /* function used by lib11.c */ 24 | int lib1_export (lua_State *L) { 25 | lua_pushstring(L, "exported"); 26 | return 1; 27 | } 28 | 29 | 30 | int onefunction (lua_State *L) { 31 | lua_settop(L, 2); 32 | lua_pushvalue(L, 1); 33 | return 2; 34 | } 35 | 36 | 37 | int anotherfunc (lua_State *L) { 38 | lua_pushfstring(L, "%f%f\n", lua_tonumber(L, 1), lua_tonumber(L, 2)); 39 | return 1; 40 | } 41 | 42 | 43 | int luaopen_lib1_sub (lua_State *L) { 44 | lua_setglobal(L, "y"); 45 | lua_setglobal(L, "x"); 46 | luaL_newlib(L, funcs); 47 | return 1; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /test/lua-5.2-tests/libs/lib11.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** compile with 3 | ** Linux: gcc -Wall -O2 -I.. -ansi -shared -o lib1.so lib1.c 4 | ** Mac OS X: export MACOSX_DEPLOYMENT_TARGET=10.3 5 | ** gcc -bundle -undefined dynamic_lookup -Wall -O2 -o lib1.so lib1.c 6 | */ 7 | 8 | 9 | #include "lua.h" 10 | 11 | /* function from lib1.c */ 12 | int lib1_export (lua_State *L); 13 | 14 | int luaopen_lib11 (lua_State *L) { 15 | return lib1_export(L); 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/lua-5.2-tests/libs/lib2.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** compile with 3 | ** gcc -Wall -O2 -I.. -ansi -shared -o lib1.so lib1.c 4 | */ 5 | 6 | 7 | #include "lua.h" 8 | #include "lauxlib.h" 9 | 10 | static int id (lua_State *L) { 11 | return lua_gettop(L); 12 | } 13 | 14 | 15 | static const struct luaL_Reg funcs[] = { 16 | {"id", id}, 17 | {NULL, NULL} 18 | }; 19 | 20 | 21 | int luaopen_lib2 (lua_State *L) { 22 | lua_settop(L, 2); 23 | lua_setglobal(L, "y"); /* y gets 2nd parameter */ 24 | lua_setglobal(L, "x"); /* x gets 1st parameter */ 25 | luaL_newlib(L, funcs); 26 | return 1; 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /test/lua-5.2-tests/libs/lib21.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** compile with 3 | ** Linux: gcc -Wall -O2 -I.. -ansi -shared -o lib1.so lib1.c 4 | ** Mac OS X: export MACOSX_DEPLOYMENT_TARGET=10.3 5 | ** gcc -bundle -undefined dynamic_lookup -Wall -O2 -o lib1.so lib1.c 6 | */ 7 | 8 | 9 | #include "lua.h" 10 | 11 | 12 | int luaopen_lib2 (lua_State *L); 13 | 14 | int luaopen_lib21 (lua_State *L) { 15 | return luaopen_lib2(L); 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/lua-5.2-tests/libs/makefile: -------------------------------------------------------------------------------- 1 | # change this variable to point to the directory with Lua headers 2 | # of the version being tested 3 | LUA_DIR = ../.. 4 | 5 | CC = gcc 6 | 7 | # compilation should generate Dynamic-Link Libraries 8 | CFLAGS = -Wall -O2 -I$(LUA_DIR) -ansi -fpic -shared 9 | 10 | # libraries used by the tests 11 | all: lib1.so lib11.so lib2.so lib21.so v-lib2.so 12 | 13 | lib1.so: lib1.c 14 | $(CC) $(CFLAGS) -o lib1.so lib1.c 15 | 16 | lib11.so: lib11.c 17 | $(CC) $(CFLAGS) -o lib11.so lib11.c 18 | 19 | lib2.so: lib2.c 20 | $(CC) $(CFLAGS) -o lib2.so lib2.c 21 | 22 | lib21.so: lib21.c 23 | $(CC) $(CFLAGS) -o lib21.so lib21.c 24 | 25 | v-lib2.so: lib2.so 26 | mv lib2.so ./v-lib2.so 27 | -------------------------------------------------------------------------------- /test/lua-5.2-tests/literals.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.2-tests/literals.lua -------------------------------------------------------------------------------- /test/lua-5.2-tests/pm.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.2-tests/pm.lua -------------------------------------------------------------------------------- /test/lua-5.2-tests/sort.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.2-tests/sort.lua -------------------------------------------------------------------------------- /test/lua-5.2-tests/strings.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.2-tests/strings.lua -------------------------------------------------------------------------------- /test/lua-5.3-tests/db.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.3-tests/db.lua -------------------------------------------------------------------------------- /test/lua-5.3-tests/files.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.3-tests/files.lua -------------------------------------------------------------------------------- /test/lua-5.3-tests/libs/P1/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /test/lua-5.3-tests/libs/lib1.c: -------------------------------------------------------------------------------- 1 | #include "lua.h" 2 | #include "lauxlib.h" 3 | 4 | static int id (lua_State *L) { 5 | return lua_gettop(L); 6 | } 7 | 8 | 9 | static const struct luaL_Reg funcs[] = { 10 | {"id", id}, 11 | {NULL, NULL} 12 | }; 13 | 14 | 15 | /* function used by lib11.c */ 16 | LUAMOD_API int lib1_export (lua_State *L) { 17 | lua_pushstring(L, "exported"); 18 | return 1; 19 | } 20 | 21 | 22 | LUAMOD_API int onefunction (lua_State *L) { 23 | luaL_checkversion(L); 24 | lua_settop(L, 2); 25 | lua_pushvalue(L, 1); 26 | return 2; 27 | } 28 | 29 | 30 | LUAMOD_API int anotherfunc (lua_State *L) { 31 | luaL_checkversion(L); 32 | lua_pushfstring(L, "%d%%%d\n", (int)lua_tointeger(L, 1), 33 | (int)lua_tointeger(L, 2)); 34 | return 1; 35 | } 36 | 37 | 38 | LUAMOD_API int luaopen_lib1_sub (lua_State *L) { 39 | lua_setglobal(L, "y"); /* 2nd arg: extra value (file name) */ 40 | lua_setglobal(L, "x"); /* 1st arg: module name */ 41 | luaL_newlib(L, funcs); 42 | return 1; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /test/lua-5.3-tests/libs/lib11.c: -------------------------------------------------------------------------------- 1 | #include "lua.h" 2 | 3 | /* function from lib1.c */ 4 | int lib1_export (lua_State *L); 5 | 6 | LUAMOD_API int luaopen_lib11 (lua_State *L) { 7 | return lib1_export(L); 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/lua-5.3-tests/libs/lib2.c: -------------------------------------------------------------------------------- 1 | #include "lua.h" 2 | #include "lauxlib.h" 3 | 4 | static int id (lua_State *L) { 5 | return lua_gettop(L); 6 | } 7 | 8 | 9 | static const struct luaL_Reg funcs[] = { 10 | {"id", id}, 11 | {NULL, NULL} 12 | }; 13 | 14 | 15 | LUAMOD_API int luaopen_lib2 (lua_State *L) { 16 | lua_settop(L, 2); 17 | lua_setglobal(L, "y"); /* y gets 2nd parameter */ 18 | lua_setglobal(L, "x"); /* x gets 1st parameter */ 19 | luaL_newlib(L, funcs); 20 | return 1; 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/lua-5.3-tests/libs/lib21.c: -------------------------------------------------------------------------------- 1 | #include "lua.h" 2 | 3 | 4 | int luaopen_lib2 (lua_State *L); 5 | 6 | LUAMOD_API int luaopen_lib21 (lua_State *L) { 7 | return luaopen_lib2(L); 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/lua-5.3-tests/libs/makefile: -------------------------------------------------------------------------------- 1 | # change this variable to point to the directory with Lua headers 2 | # of the version being tested 3 | LUA_DIR = ../.. 4 | 5 | CC = gcc 6 | 7 | # compilation should generate Dynamic-Link Libraries 8 | CFLAGS = -Wall -std=gnu99 -O2 -I$(LUA_DIR) -fpic -shared 9 | 10 | # libraries used by the tests 11 | all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so 12 | 13 | lib1.so: lib1.c 14 | $(CC) $(CFLAGS) -o lib1.so lib1.c 15 | 16 | lib11.so: lib11.c 17 | $(CC) $(CFLAGS) -o lib11.so lib11.c 18 | 19 | lib2.so: lib2.c 20 | $(CC) $(CFLAGS) -o lib2.so lib2.c 21 | 22 | lib21.so: lib21.c 23 | $(CC) $(CFLAGS) -o lib21.so lib21.c 24 | 25 | lib2-v2.so: lib2.so 26 | mv lib2.so ./lib2-v2.so 27 | -------------------------------------------------------------------------------- /test/lua-5.3-tests/pm.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.3-tests/pm.lua -------------------------------------------------------------------------------- /test/lua-5.3-tests/sort.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.3-tests/sort.lua -------------------------------------------------------------------------------- /test/lua-5.3-tests/strings.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/test/lua-5.3-tests/strings.lua -------------------------------------------------------------------------------- /test/ok_declare/a_er.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a=234 -------------------------------------------------------------------------------- /test/ok_declare/a_ok.lua: -------------------------------------------------------------------------------- 1 | local a=234 -------------------------------------------------------------------------------- /test/ok_declare/a_ok2.lua: -------------------------------------------------------------------------------- 1 | local a 2 | print() 3 | a=234 -------------------------------------------------------------------------------- /test/other/_60000funs_simple.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | local f = function(self) 3 | local a,b,c --1 4 | --local a,b=1,c --1 5 | --local a=1,b,c --1 6 | --local a=1,b=1,c --0 7 | --local d = (a == c and b) --1 8 | return (a == c and b) --1 9 | end 10 | --]] 11 | 12 | local a,b,c --1 13 | --local a,b=1,c --1 14 | --local a=1,b,c --1 15 | --local a=1,b=1,c --0 16 | local d = (a == c and b) --1 17 | 18 | -------------------------------------------------------------------------------- /test/other/_simple_logic.lua: -------------------------------------------------------------------------------- 1 | local a,b 2 | b = (a ~= 0) -------------------------------------------------------------------------------- /test/other/constructs.lua: -------------------------------------------------------------------------------- 1 | 2 | assert(-(1 or 2) == -1 and (1 and 2)+(-1.25 or -4) == 0.75); 3 | -------------------------------------------------------------------------------- /test/other/fortest.lua: -------------------------------------------------------------------------------- 1 | for v = 8,18,1 do 2 | print(v) 3 | end -------------------------------------------------------------------------------- /test/other/fun.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | local b 4 | local function a() 5 | 6 | local c = 0 7 | local function get() 8 | c=c+1 9 | return c 10 | end 11 | return get 12 | end -------------------------------------------------------------------------------- /test/other/function_compare.lua: -------------------------------------------------------------------------------- 1 | local a, b, c 2 | 3 | function f1() 4 | print('ddd') 5 | end 6 | 7 | function f2(a,b) 8 | print(a,b) 9 | end 10 | 11 | function f3() 12 | local z=a 13 | local y=b 14 | print(z,y) 15 | end 16 | 17 | 18 | function f4(...) 19 | print(...) 20 | local z=a 21 | local y=b 22 | return z,y 23 | end 24 | 25 | function f5(x,y,...) 26 | local f6=function() 27 | print('dfd') 28 | print('dfds') 29 | end 30 | 31 | local f7=function() 32 | f6() 33 | end 34 | 35 | local f8=function() 36 | f6(a,b) 37 | end 38 | end 39 | 40 | -------------------------------------------------------------------------------- /test/other/getmop.lua: -------------------------------------------------------------------------------- 1 | --json = (loadfile "jfjson.lua")() 2 | --json = require("sbjson") 3 | --json = require("json") 4 | json = require("dkjson") 5 | socket = require("socket") 6 | socket.http = require("socket.http") 7 | 8 | local rname=arg[1]; 9 | 10 | local jsonfile = io.open("mop/"..rname..".json","r"); 11 | local jsonstr = jsonfile:read("*a"); 12 | jsonfile:close(); 13 | 14 | local recipes = json.decode(jsonstr); 15 | 16 | function sleep(n) 17 | if n > 0 then os.execute("ping -n " .. tonumber(n + 1) .. " localhost > NUL") end 18 | end 19 | 20 | local success = io.open("mop/"..rname.."/success.txt","w") 21 | local fail = io.open("mop/"..rname.."/fail.txt","w") 22 | 23 | for k,v in ipairs(recipes) do 24 | 25 | local sn = math.random(3,10) 26 | 27 | sleep(sn) 28 | 29 | local name = v.name 30 | local itemno = v.id 31 | print("getting id="..itemno.." name="..name) 32 | local b, c, h = socket.http.request("http://www.wowhead.com/spell="..itemno) 33 | 34 | if b == nil then 35 | print(" fail") 36 | fail:write(itemno, name, "\n") 37 | else 38 | local itemfile,msg = io.open("mop/"..rname.."/spell-"..itemno..".html","w") 39 | itemfile:write(b) 40 | itemfile:close() 41 | print(" success") 42 | success:write(itemno, name, "\n") 43 | end 44 | end 45 | 46 | success:close() 47 | fail:close() -------------------------------------------------------------------------------- /test/other/if_else.lua: -------------------------------------------------------------------------------- 1 | function a(b,c,d) 2 | if b>3 then 3 | c = 4 4 | else 5 | c = 5 6 | end 7 | print(c) 8 | end -------------------------------------------------------------------------------- /test/other/if_else_if.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,d,e 2 | local print = print 3 | if a then 4 | print(a) 5 | elseif b then 6 | print(b) 7 | elseif c then 8 | print(c) 9 | end 10 | 11 | xxx() -------------------------------------------------------------------------------- /test/other/if_not_else.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a=234 3 | local function b() 4 | local print = print 5 | print(a) 6 | if not a then 7 | a=1 8 | else 9 | a=a+1 10 | end 11 | print(a) 12 | end 13 | 14 | return b -------------------------------------------------------------------------------- /test/other/local_and_set.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a=234 -------------------------------------------------------------------------------- /test/other/logic.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,d,e,f,g 2 | 3 | local a = b>c 4 | local d = (e==f) 5 | 6 | --local d = (a and b ) or (not c) -------------------------------------------------------------------------------- /test/other/producelua.lua: -------------------------------------------------------------------------------- 1 | local out = 'local dummy' 2 | local i,j 3 | for i = string.byte('a'),string.byte('a')+21 do 4 | for j = 0,8 do 5 | out = out..' ,'..string.char(i)..j 6 | end 7 | end 8 | print(out) 9 | 10 | out = 'dummy = {"pre"' 11 | for j = 0,100 do 12 | out = out..' ,'..j 13 | end 14 | out = out..'}' 15 | print(out) 16 | -------------------------------------------------------------------------------- /test/other/readchunk.lua: -------------------------------------------------------------------------------- 1 | local chunk = assert(loadfile(arg[1])) 2 | 3 | if chunk then 4 | local out = assert(io.open(arg[2], "wb")) 5 | out:write(string.dump(chunk)) 6 | out:close() 7 | end 8 | -------------------------------------------------------------------------------- /test/other/serialize.lua: -------------------------------------------------------------------------------- 1 | function serialize(t) 2 | local mark={} 3 | local assign={} 4 | 5 | local function ser_table(tbl,parent) 6 | mark[tbl]=parent 7 | local tmp={} 8 | for k,v in pairs(tbl) do 9 | local key= type(k)=="number" and "["..k.."]" or k 10 | if type(v)=="table" then 11 | local dotkey= parent..(type(k)=="number" and key or "."..key) 12 | if mark[v] then 13 | table.insert(assign,dotkey.."="..mark[v]) 14 | else 15 | table.insert(tmp, key.."="..ser_table(v,dotkey)) 16 | end 17 | else 18 | table.insert(tmp, key.."="..v) 19 | end 20 | end 21 | return "{\n"..table.concat(tmp,",").."}\n" 22 | end 23 | 24 | return "do local ret="..ser_table(t,"ret")..table.concat(assign," ").." return ret end" 25 | end 26 | 27 | BFQuest={} 28 | loadfile("todo\\data.luac")() 29 | print(serialize(BFQuest)) 30 | -------------------------------------------------------------------------------- /test/other/table.lua: -------------------------------------------------------------------------------- 1 | local a = {a='ab', b='bc',1,2,3,4,5,6,7,8,9,10,c='cd',11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,d='de'} 2 | 3 | local b = {a='ab', b='bc',c='cd',d='de'} -------------------------------------------------------------------------------- /test/other/test.lua: -------------------------------------------------------------------------------- 1 | local chunk = loadfile("f.lua") 2 | 3 | if chunk then 4 | local b=chunk() 5 | local out = assert(io.open(arg[1], "wb")) 6 | local cb=string.dump(b) 7 | out:write(cb) 8 | out:close() 9 | b() 10 | local fb=loadstring(cb) 11 | fb() 12 | fb() 13 | b() 14 | fb() 15 | end 16 | -------------------------------------------------------------------------------- /test/other/testall.lua: -------------------------------------------------------------------------------- 1 | --is_vararg = 2 2 | --main function is always is_vararg = 2, and can't use arg, arg will be treat as a globol table. 3 | local a,b,n = arg[1],arg[2],arg.n 4 | local c,d = ... 5 | local x = 3 6 | 7 | --is_vararg = 0 8 | local function a() 9 | local x=3 10 | return x 11 | end 12 | 13 | --is_vararg = 3, if ... is used in function 14 | local function b(...) 15 | local a,b,n = arg[1],arg[2],arg.n 16 | local c,d = ... 17 | end 18 | 19 | --is_vararg = 3 20 | local function c(...) 21 | local c,d = ... 22 | end 23 | 24 | --is_vararg = 7, if ... is not used in function 25 | local function d(...) 26 | local a,b,n = arg[1],arg[2],arg.n 27 | end 28 | 29 | --is_vararg = 7 30 | local function e(...) 31 | local x=3 32 | return x 33 | end 34 | 35 | local function f(...) 36 | local x={...} 37 | return x 38 | end 39 | 40 | --table 41 | 42 | -------------------------------------------------------------------------------- /test/other/testindex.lua: -------------------------------------------------------------------------------- 1 | local a,b,c,d,e,f 2 | 3 | local t={ 4 | a=1,[" a"]=2,["not"]=3,[a]=4, 5 | f=function(self) 6 | print(self.a); 7 | end 8 | } 9 | 10 | t.a=5 11 | t[" a"]=6 12 | t["not"]=7 13 | t[a]=8 14 | 15 | b=t.a 16 | c=t[" a"] 17 | d=t["not"] 18 | e=t[a] 19 | 20 | t:f() 21 | -------------------------------------------------------------------------------- /test/other/testup.lua: -------------------------------------------------------------------------------- 1 | local cc, dd=3,4 2 | print(cc+dd) 3 | local a=3 4 | local b=4 5 | 6 | function c() 7 | local c = a+b 8 | return c 9 | end -------------------------------------------------------------------------------- /test/other/txt.lua: -------------------------------------------------------------------------------- 1 | S=[[]] 2 | T={} 3 | C=coroutine.create(function() end) 4 | print(type(S),type(T),type(C)) 5 | print(S>> testC not active: skipping API tests <<<\n\a') 3 | return 4 | end 5 | 6 | ----------- 7 | 8 | do 9 | local map = {} 10 | local t = {__eq = function (a,b) return map[a] == map[b] end} 11 | local function f(x) 12 | local u = T.newuserdata(0) 13 | debug.setmetatable(u, t) 14 | map[u] = x 15 | return u 16 | end 17 | assert(f(10) == f(10)) 18 | assert(f(10) ~= f(11)) 19 | assert(T.testC("equal 2 3; return 1", f(10), f(10))) 20 | assert(not T.testC("equal 2 3; return 1", f(10), f(20))) 21 | t.__eq = nil 22 | assert(f(10) ~= f(10)) 23 | end 24 | 25 | -------------- 26 | 27 | if not a and not string.find(b, "memory") then -- `real' error? 28 | T.totalmem(1000000000) -- restore high limit 29 | error(b, 0) 30 | end 31 | 32 | -------------- 33 | 34 | testamem("dump/undump", function () 35 | local a = loadstring(testprog) 36 | local b = a and string.dump(a) 37 | a = b and loadstring(b) 38 | return a and a() 39 | end) 40 | 41 | ---------------- 42 | 43 | if not trylocale("collate") then 44 | print("locale not supported") 45 | else 46 | assert("alo" < "o" and "o" < "amo") 47 | end 48 | 49 | ----------------- 50 | 51 | local f = function(x,y) 52 | return nil 53 | end -------------------------------------------------------------------------------- /test/todo/vararg.lua: -------------------------------------------------------------------------------- 1 | local function f(...) 2 | local a,b 3 | a,b = ... 4 | c,d = ... 5 | end -------------------------------------------------------------------------------- /test/unluac-test/adjust01.lua: -------------------------------------------------------------------------------- 1 | f((g())) -------------------------------------------------------------------------------- /test/unluac-test/adjust02.lua: -------------------------------------------------------------------------------- 1 | function f(...) 2 | return (g((...))) 3 | end -------------------------------------------------------------------------------- /test/unluac-test/adjust03.lua: -------------------------------------------------------------------------------- 1 | function f(...) 2 | return (g(...)) 3 | end -------------------------------------------------------------------------------- /test/unluac-test/adjust04.lua: -------------------------------------------------------------------------------- 1 | return f() -------------------------------------------------------------------------------- /test/unluac-test/adjust05.lua: -------------------------------------------------------------------------------- 1 | for x in (pairs(t)) do 2 | print(x) 3 | end -------------------------------------------------------------------------------- /test/unluac-test/assign.lua: -------------------------------------------------------------------------------- 1 | local a = 1 2 | local b = 2 3 | local c = 3 4 | -------------------------------------------------------------------------------- /test/unluac-test/booleanassign01.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = x or y 3 | a = x and y 4 | -------------------------------------------------------------------------------- /test/unluac-test/booleanassign02.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = w and x and y and z 3 | a = w or x or y or z 4 | a = w and x or y and z 5 | a = (w or x) and (y or z) 6 | a = (b and c or d and e) and (f and g or h and i) or (j and k or l and m) and (n and o or p and q) 7 | -------------------------------------------------------------------------------- /test/unluac-test/booleanassign03.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = d and e and f and a and g and h and i 3 | a = d or e or f or a or g or h or i 4 | -------------------------------------------------------------------------------- /test/unluac-test/booleanassign04.lua: -------------------------------------------------------------------------------- 1 | x = a and b 2 | x = a or b 3 | x = a and b and c and d 4 | x = a or b or c or d 5 | -------------------------------------------------------------------------------- /test/unluac-test/booleanassign05.lua: -------------------------------------------------------------------------------- 1 | local value = thing.a or thing.b or "default" 2 | print(value) -------------------------------------------------------------------------------- /test/unluac-test/booleanassign06.lua: -------------------------------------------------------------------------------- 1 | if not thing.a and not thing.b then 2 | local value = "default" 3 | end -------------------------------------------------------------------------------- /test/unluac-test/booleanassign07.lua: -------------------------------------------------------------------------------- 1 | if not thing.a and not thing.b then 2 | side_effects() 3 | local value = "default" 4 | end -------------------------------------------------------------------------------- /test/unluac-test/booleanassign08.lua: -------------------------------------------------------------------------------- 1 | local value = "initial" 2 | print(value) 3 | value = thing.a or thing.b or "default" 4 | print(value) -------------------------------------------------------------------------------- /test/unluac-test/booleanassign09.lua: -------------------------------------------------------------------------------- 1 | local result = a < b and not c 2 | print(result) -------------------------------------------------------------------------------- /test/unluac-test/booleanassign10.lua: -------------------------------------------------------------------------------- 1 | local x 2 | if x == nil then 3 | x = (not y) or (z == w) 4 | end 5 | print(x) -------------------------------------------------------------------------------- /test/unluac-test/booleanexpression01.lua: -------------------------------------------------------------------------------- 1 | print(a or b) 2 | print(a and b) 3 | -------------------------------------------------------------------------------- /test/unluac-test/booleanexpression02.lua: -------------------------------------------------------------------------------- 1 | print(a and b, a or b) 2 | -------------------------------------------------------------------------------- /test/unluac-test/booleanexpression03.lua: -------------------------------------------------------------------------------- 1 | print(x == 0 or a.first and a.record.field == value) -------------------------------------------------------------------------------- /test/unluac-test/booleanexpression04.lua: -------------------------------------------------------------------------------- 1 | print((not x) and (a == b) and (y < z)) -------------------------------------------------------------------------------- /test/unluac-test/booleanexpression05.lua: -------------------------------------------------------------------------------- 1 | print(a == b and (c == d or c == e) and f == g) -------------------------------------------------------------------------------- /test/unluac-test/booleanmultiassign01.lua: -------------------------------------------------------------------------------- 1 | local a, b 2 | a, b = a and b, a or b 3 | a, b = a or b, a and b 4 | a, b = b and a, b or a 5 | a, b = b or a, b and a 6 | a, b = x and y, x or y 7 | -------------------------------------------------------------------------------- /test/unluac-test/booleanselfassign01.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = a or x 3 | a = a and x 4 | y = y or x 5 | y = y and x 6 | -------------------------------------------------------------------------------- /test/unluac-test/closure.lua: -------------------------------------------------------------------------------- 1 | f = function(a, b) 2 | local c = a + b 3 | return c ^ 2 4 | end 5 | print(f(3, 4)) 6 | -------------------------------------------------------------------------------- /test/unluac-test/combinebexpression01.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = b < c or d < e or f 3 | -------------------------------------------------------------------------------- /test/unluac-test/combinebexpression02.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = b or c or d == e 3 | -------------------------------------------------------------------------------- /test/unluac-test/combinebexpression03.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = b or c == d or e 3 | -------------------------------------------------------------------------------- /test/unluac-test/combinebexpression04.lua: -------------------------------------------------------------------------------- 1 | print(a or b or c == d) 2 | print(a or b == c or d) 3 | print(a and b == c or d) 4 | print(a or b == c and d) 5 | print(a or b ~= c or d) 6 | print(a == b or c or d) 7 | print(a < b and c or d) 8 | print(a ~= b or c and d) 9 | print(a == b and c and d) 10 | -------------------------------------------------------------------------------- /test/unluac-test/compareassign01.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = x < y 3 | -------------------------------------------------------------------------------- /test/unluac-test/compareexpression.lua: -------------------------------------------------------------------------------- 1 | print(x == y) 2 | print(x < y) 3 | print(x <= y) 4 | -------------------------------------------------------------------------------- /test/unluac-test/compareorder01.lua: -------------------------------------------------------------------------------- 1 | if a < b then 2 | print("a < b") 3 | end 4 | if b > a then 5 | print("b > a") 6 | end 7 | -------------------------------------------------------------------------------- /test/unluac-test/compareorder02.lua: -------------------------------------------------------------------------------- 1 | -- In the case of two constants: 2 | -- comparison order is impossible to reproduce from bytecode 3 | -- this case seems unlikely to occur in production code though 4 | -- perhaps guess by the index of the constants? 5 | -- (that could work if both constants are fresh) 6 | if 1 < 2 then 7 | print("1 < 2") 8 | end 9 | if 2 > 1 then 10 | print("2 > 1") 11 | end 12 | -------------------------------------------------------------------------------- /test/unluac-test/compareorder03.lua: -------------------------------------------------------------------------------- 1 | if a < 2 then 2 | print("a < 2") 3 | end 4 | if 2 > a then 5 | print("2 > a") 6 | end 7 | -------------------------------------------------------------------------------- /test/unluac-test/compareorder04.lua: -------------------------------------------------------------------------------- 1 | print("begin") 2 | if not (math.random(100) > chance) then 3 | print("then") 4 | end 5 | print("end") -------------------------------------------------------------------------------- /test/unluac-test/compareorder05.lua: -------------------------------------------------------------------------------- 1 | print("begin") 2 | if math.random(100) <= chance then 3 | print("then") 4 | end 5 | print("end") -------------------------------------------------------------------------------- /test/unluac-test/complexassign01.lua: -------------------------------------------------------------------------------- 1 | if buffer then 2 | print("hello") 3 | end 4 | local single1 = 1 5 | local single2 = 2 6 | local single3 = 3 7 | if buffer then 8 | print("hello") 9 | end 10 | local single4 = 4 11 | local single5 = 5 12 | local single6 = 6 13 | -------------------------------------------------------------------------------- /test/unluac-test/complexassign02.lua: -------------------------------------------------------------------------------- 1 | if buffer then 2 | print("hello") 3 | end 4 | local expr1 = a + b + c + d 5 | local expr2 = expr1 + a + b + c + d 6 | local expr3 = a + b + c + d + expr2 7 | -------------------------------------------------------------------------------- /test/unluac-test/complexassign03.lua: -------------------------------------------------------------------------------- 1 | if buffer then 2 | print("hello") 3 | end 4 | local multi1a, multi1b, multi1c = 1, 2, 3 5 | local multi2a, multi2b, multi2c = multi_return() 6 | local multi3a, multi3b, multi3c = multi_return(x, y, z) 7 | -------------------------------------------------------------------------------- /test/unluac-test/condition.lua: -------------------------------------------------------------------------------- 1 | if a == b and c == d then 2 | f() 3 | end 4 | if a == b or c == d then 5 | f() 6 | end 7 | if a < b then 8 | f() 9 | end 10 | if a <= b then 11 | f() 12 | end 13 | if not a then 14 | f() 15 | end 16 | -------------------------------------------------------------------------------- /test/unluac-test/control01.lua: -------------------------------------------------------------------------------- 1 | if a then 2 | while b do 3 | f() 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /test/unluac-test/control02.lua: -------------------------------------------------------------------------------- 1 | if a then 2 | local x = 3 3 | if b then 4 | print(a, b) 5 | end 6 | print(x) 7 | end -------------------------------------------------------------------------------- /test/unluac-test/control03.lua: -------------------------------------------------------------------------------- 1 | if a then 2 | local x = 3 3 | if b then 4 | print(a, b) 5 | end 6 | end -------------------------------------------------------------------------------- /test/unluac-test/control04.lua: -------------------------------------------------------------------------------- 1 | local y 2 | if x then 3 | while y do 4 | print("hello") 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /test/unluac-test/control05.lua: -------------------------------------------------------------------------------- 1 | for i = 1, 10 do 2 | local x = f() 3 | if a then 4 | local y = g() 5 | if b then 6 | print(b) 7 | end 8 | break 9 | end 10 | end -------------------------------------------------------------------------------- /test/unluac-test/control06.lua: -------------------------------------------------------------------------------- 1 | for item in iter() do 2 | if complicated_condition() then 3 | f() 4 | if additional() then 5 | g() 6 | end 7 | break 8 | end 9 | end -------------------------------------------------------------------------------- /test/unluac-test/control07.lua: -------------------------------------------------------------------------------- 1 | repeat 2 | repeat 3 | f() 4 | until b 5 | g() 6 | until a -------------------------------------------------------------------------------- /test/unluac-test/declare.lua: -------------------------------------------------------------------------------- 1 | local a, b, c 2 | a = 1 3 | b = 2 4 | local d 5 | d = 3 6 | f() 7 | summon = function(bid, count) 8 | if type(bid) == "string" then 9 | bid = beings[bid].nid 10 | end 11 | local last_being 12 | for i = 1, count or 1 do 13 | last_being = Level.drop_being(bid, Level.empty_coord()) 14 | end 15 | return last_being 16 | end 17 | f() 18 | --a, b = a and b, a or b 19 | f() 20 | 21 | --[[while a < c do 22 | if(a == b) then 23 | a = c 24 | else 25 | break 26 | end 27 | end]] --TODO 28 | 29 | --[[while a < c do 30 | if a==b then 31 | c = 3 32 | if c == b then 33 | d = 6 34 | end 35 | end 36 | end]] --FIXED! 37 | 38 | --[[if a==b then 39 | if c==d then 40 | a = 4 41 | if a == c then 42 | a, b = 2, 3 43 | end 44 | end 45 | else 46 | c = 6 47 | end]] --FIXED! 48 | 49 | --[[while a == b do 50 | if c == d then 51 | c = 6 52 | end 53 | break 54 | end]] --OKAY because compiles as 55 | --[[while a == b and c == d do 56 | c = 6 57 | break 58 | end]] 59 | 60 | a, b, c, d = b, c, d, a 61 | return f() -------------------------------------------------------------------------------- /test/unluac-test/declare02.lua: -------------------------------------------------------------------------------- 1 | print("begin") 2 | local x, y, z 3 | print("begin") 4 | local a, b, c 5 | c = 4 6 | print(c) 7 | local d, e, f 8 | d = 8 9 | print(d) -------------------------------------------------------------------------------- /test/unluac-test/declare03.lua: -------------------------------------------------------------------------------- 1 | print("begin") 2 | local x, y, z -------------------------------------------------------------------------------- /test/unluac-test/doend01.lua: -------------------------------------------------------------------------------- 1 | do 2 | local a = 512 3 | print(a) 4 | end 5 | do 6 | local b = 255 7 | print(b) 8 | end -------------------------------------------------------------------------------- /test/unluac-test/doend02.lua: -------------------------------------------------------------------------------- 1 | while x do 2 | local v, w = 0 3 | print(w, v) 4 | end -------------------------------------------------------------------------------- /test/unluac-test/doend03.lua: -------------------------------------------------------------------------------- 1 | for x, y in pairs(t) do 2 | local v, w = 0 3 | print(w, v) 4 | end -------------------------------------------------------------------------------- /test/unluac-test/doend04.lua: -------------------------------------------------------------------------------- 1 | for z=1,6 do 2 | local v, w = 0 3 | print(w, v, z) 4 | end -------------------------------------------------------------------------------- /test/unluac-test/doend05.lua: -------------------------------------------------------------------------------- 1 | repeat 2 | local v, w = 0 3 | print(w, v) 4 | until x < 100 5 | -------------------------------------------------------------------------------- /test/unluac-test/ellipsis.lua: -------------------------------------------------------------------------------- 1 | local a, b, c 2 | a = ... 3 | a, b = ... 4 | a, b = ..., 2 5 | a, b, c = 1, ... 6 | a, b, c = ... 7 | -------------------------------------------------------------------------------- /test/unluac-test/expression.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = x + y + z 3 | a = x + (y + z) 4 | a = x + y - z 5 | a = x - y + z 6 | a = x - y - z 7 | a = x - (y - z) 8 | a = x * y * z 9 | a = x * (y * z) 10 | a = x + y * z 11 | a = (z + y) / z 12 | a = x % (y + z) 13 | a = x ^ y ^ z 14 | a = (x ^ y) ^ z 15 | a = x .. y .. z 16 | a = (x .. y) .. z 17 | -------------------------------------------------------------------------------- /test/unluac-test/final01.lua: -------------------------------------------------------------------------------- 1 | if x then 2 | do return end 3 | print(x) 4 | end -------------------------------------------------------------------------------- /test/unluac-test/final02.lua: -------------------------------------------------------------------------------- 1 | while x > 0 do 2 | do break end 3 | print(x) 4 | x = x - 1 5 | end -------------------------------------------------------------------------------- /test/unluac-test/functioncall.lua: -------------------------------------------------------------------------------- 1 | local a, b, c 2 | a = f(1, 2, 3) 3 | a = f(x, y, z) 4 | a, b = f(1, 2, 3) 5 | a, b, c = 1, f(1, 2, 3) 6 | a, b, c = f(1, 2, 3), 1, 2 7 | a = f(g()) 8 | -------------------------------------------------------------------------------- /test/unluac-test/ifthen.lua: -------------------------------------------------------------------------------- 1 | local a, b 2 | if a then 3 | print(a) 4 | end 5 | if a == b then 6 | local c = a + b 7 | print(c ^ 2) 8 | end 9 | if a and b and x and y then 10 | print(a + x, b + y) 11 | end 12 | if a or b or x or y then 13 | print(a * x, b * y) 14 | end 15 | if (a or b) and (x or y) then 16 | print(a * x, b - y) 17 | end 18 | -------------------------------------------------------------------------------- /test/unluac-test/ifthenelse.lua: -------------------------------------------------------------------------------- 1 | if a then 2 | f() 3 | else 4 | g() 5 | end 6 | if b then 7 | f() 8 | if a then 9 | g() 10 | end 11 | else 12 | h() 13 | end 14 | if a then 15 | if b then 16 | f() 17 | else 18 | h() 19 | end 20 | g() 21 | end 22 | -------------------------------------------------------------------------------- /test/unluac-test/literal.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = 5 3 | a = 2.5 4 | a = "hello" 5 | a = false 6 | a = true 7 | a = nil 8 | -------------------------------------------------------------------------------- /test/unluac-test/literallist.lua: -------------------------------------------------------------------------------- 1 | x = {1, 2 | 2, 3 | 7, 4 | "frog", 5 | z, 6 | y * w, 7 | 99} 8 | -------------------------------------------------------------------------------- /test/unluac-test/localbooleanassign.lua: -------------------------------------------------------------------------------- 1 | local armor = being.eq.armor 2 | local boots = being.eq.boots 3 | if not armor and not boots then 4 | being:msg( "You have no armor to fix! Nothing happens." ) 5 | return 6 | end 7 | local damaged_armor = armor and armor:is_damaged() 8 | local damaged_boots = boots and boots:is_damaged() 9 | if not damaged_armor and not damaged_boots then 10 | being:msg( "You have no armor that needs fixing! Nothing happens." ) 11 | return 12 | end 13 | ui.blink( YELLOW, 20 ) 14 | -------------------------------------------------------------------------------- /test/unluac-test/localfunction01.lua: -------------------------------------------------------------------------------- 1 | local function factorial(n) 2 | if n == 0 then 3 | return 1 4 | else 5 | return factorial(n - 1) * n 6 | end 7 | end 8 | print(factorial(10)) 9 | -------------------------------------------------------------------------------- /test/unluac-test/localfunction02.lua: -------------------------------------------------------------------------------- 1 | local factorial = function(n) 2 | if n == 0 then 3 | return 1 4 | else 5 | return factorial(n - 1) * n 6 | end 7 | end 8 | print(factorial(10)) 9 | -------------------------------------------------------------------------------- /test/unluac-test/localfunction03.lua: -------------------------------------------------------------------------------- 1 | local function factorial(n) 2 | return "not recursive" 3 | end 4 | print(factorial(10)) 5 | -------------------------------------------------------------------------------- /test/unluac-test/localfunction04.lua: -------------------------------------------------------------------------------- 1 | local factorial = function(n) 2 | return "not recursive" 3 | end 4 | print(factorial(10)) 5 | -------------------------------------------------------------------------------- /test/unluac-test/method01.lua: -------------------------------------------------------------------------------- 1 | function class:method(x) 2 | self:other_method(x) 3 | end -------------------------------------------------------------------------------- /test/unluac-test/multiassign.lua: -------------------------------------------------------------------------------- 1 | local a, b, c, d 2 | a, b = b, a 3 | a, b, c, d = b, c, d, a 4 | -------------------------------------------------------------------------------- /test/unluac-test/multiliteraltarget.lua: -------------------------------------------------------------------------------- 1 | local a 2 | a = {f()} 3 | -------------------------------------------------------------------------------- /test/unluac-test/nestedif.lua: -------------------------------------------------------------------------------- 1 | if x and y then 2 | f() 3 | if z then 4 | g() 5 | end 6 | end 7 | if x and y then 8 | if z then 9 | g() 10 | end 11 | f() 12 | end 13 | if x then 14 | f() 15 | if y then 16 | if z then 17 | g() 18 | end 19 | h() 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /test/unluac-test/nestedif02.lua: -------------------------------------------------------------------------------- 1 | if a then 2 | print(a) 3 | if b then 4 | print(b) 5 | if c then 6 | print(c) 7 | else 8 | print(z) 9 | end 10 | else 11 | print(y) 12 | end 13 | else 14 | print(x) 15 | end -------------------------------------------------------------------------------- /test/unluac-test/repeat.lua: -------------------------------------------------------------------------------- 1 | repeat 2 | f() 3 | until a 4 | repeat 5 | if b then 6 | f() 7 | end 8 | until a 9 | repeat 10 | repeat 11 | f() 12 | until b 13 | g() 14 | until a 15 | repeat 16 | f() 17 | repeat 18 | g() 19 | until b 20 | until a 21 | -------------------------------------------------------------------------------- /test/unluac-test/table01.lua: -------------------------------------------------------------------------------- 1 | local x 2 | x = {} 3 | x.first = 1 4 | x.second = 2 5 | x.third = 3 6 | y = {first = 1, 7 | second = 2, 8 | third = 3} 9 | -------------------------------------------------------------------------------- /test/unluac-test/table02.lua: -------------------------------------------------------------------------------- 1 | if buffer then 2 | print("buffer") 3 | end 4 | local x = {table_elt = 6} 5 | local list = {1, 6 | 6, 7 | 3, 8 | 2, 9 | 6, 10 | 3, 11 | 2, 12 | 6, 13 | 6} 14 | -------------------------------------------------------------------------------- /test/unluac-test/while.lua: -------------------------------------------------------------------------------- 1 | while a do 2 | f() 3 | end 4 | while a do 5 | if b then 6 | f() 7 | end 8 | end 9 | while a do 10 | while b do 11 | f() 12 | end 13 | g() 14 | end 15 | while a do 16 | f() 17 | while b do 18 | g() 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /test/while/if_while_break.lua: -------------------------------------------------------------------------------- 1 | if a then 2 | while 1 do 3 | f1() 4 | break 5 | end 6 | end 7 | 8 | f() 9 | 10 | if a then 11 | f1() 12 | else 13 | while 1 do 14 | f2() 15 | break 16 | end 17 | end 18 | 19 | f() 20 | 21 | -------------------------------------------------------------------------------- /test/while/until.lua: -------------------------------------------------------------------------------- 1 | function a() 2 | local a,b,c 3 | repeat 4 | a = 3 5 | until b and f() 6 | end 7 | 8 | function b() 9 | local a,b,c 10 | repeat 11 | repeat 12 | a = 3 13 | until b 14 | until f() 15 | end -------------------------------------------------------------------------------- /test/while/while-if.lua: -------------------------------------------------------------------------------- 1 | local a,b; 2 | 3 | while a and b do 4 | f() 5 | end 6 | 7 | while a do 8 | if b then 9 | f() 10 | end 11 | end 12 | 13 | while a do 14 | while b do 15 | f() 16 | end 17 | end -------------------------------------------------------------------------------- /test/while/while1-if-else-break.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | while 1 do 4 | if a then 5 | print(a) 6 | else 7 | break 8 | end 9 | print(c) 10 | end 11 | -------------------------------------------------------------------------------- /test/while/while1-if-else.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | while 1 do 4 | if a then 5 | print(a) 6 | else 7 | print(b) 8 | end 9 | print(c) 10 | end -------------------------------------------------------------------------------- /test/while/while1-if.lua: -------------------------------------------------------------------------------- 1 | local a,b 2 | 3 | while 1 do 4 | if a then 5 | print(a) 6 | end 7 | print(b) 8 | end 9 | -------------------------------------------------------------------------------- /test/while/while1-while.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | while 1 do 4 | while a do 5 | print(a) 6 | end 7 | print(c) 8 | end 9 | 10 | --[[ 11 | while 1 do 12 | if a then 13 | print(a) 14 | continue 15 | end 16 | print(c) 17 | end 18 | --]] 19 | 20 | --[[ 21 | while a do 22 | xxx 23 | end 24 | 25 | while 1 do 26 | if a then 27 | donothing 28 | else 29 | break; 30 | end 31 | xxx 32 | end 33 | --]] -------------------------------------------------------------------------------- /test/while/while1.lua: -------------------------------------------------------------------------------- 1 | local a,b,c 2 | 3 | while 1 do 4 | local d,e 5 | print(c) 6 | end -------------------------------------------------------------------------------- /vcproj-5.3/UpgradeLog.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hc20k/fucklua/02fc8ca0b124d43040b9e754236c188dbafb62d8/vcproj-5.3/UpgradeLog.htm -------------------------------------------------------------------------------- /vcproj-5.3/lua.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vcproj-5.3/lua.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /vcproj-5.3/luac.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vcproj-5.3/luac.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /vcproj-5.3/luadec.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -l2 LDS2 "C:\Users\hpluto\Documents\GitHub\luadec\vcproj-5.3\Debug\bin\rawbin.dat" 5 | WindowsLocalDebugger 6 | 7 | -------------------------------------------------------------------------------- /vcproj-5.3/luadll.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /vcproj-5.3/lualib.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /vcproj-5.3/luaopswap.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {03C05628-E311-4517-8885-86E8466ABD6A} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {2E7D8E22-0A4F-4F32-9E47-894AFB6ED11A} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {80ED7455-11AE-46FE-9736-4B4BD0ABC08B} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /vcproj-5.3/luaopswap.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /vcproj-5.3/luareplace.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {A69A3EA4-9DFA-448B-9BF0-CF585E0D77E1} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {9FD27AFD-035B-40AA-8473-3C100B863A08} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {CC441EC9-BFA2-42CA-A427-DA3777480501} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /vcproj-5.3/luareplace.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | --------------------------------------------------------------------------------