├── .gitignore ├── LICENSE ├── README.md ├── Scripts ├── AutoUnpause.lua ├── DisplayText.lua ├── GameState.lua ├── GetUnits.lua └── JassStringSample.lua ├── war3-lua-engine.sln └── war3-lua-engine ├── Game.cpp ├── Game.h ├── Jass.h ├── LuaBridge ├── LuaBridge.h ├── RefCountedObject.h ├── RefCountedPtr.h └── detail │ ├── CFunctions.h │ ├── ClassInfo.h │ ├── Constructor.h │ ├── FuncTraits.h │ ├── Iterator.h │ ├── LuaException.h │ ├── LuaHelpers.h │ ├── LuaRef.h │ ├── Namespace.h │ ├── Stack.h │ ├── TypeList.h │ ├── TypeTraits.h │ ├── Userdata.h │ └── dump.h ├── LuaJIT ├── COPYRIGHT ├── Makefile ├── README ├── dynasm │ ├── dasm_arm.h │ ├── dasm_arm.lua │ ├── dasm_mips.h │ ├── dasm_mips.lua │ ├── dasm_ppc.h │ ├── dasm_ppc.lua │ ├── dasm_proto.h │ ├── dasm_x64.lua │ ├── dasm_x86.h │ ├── dasm_x86.lua │ └── dynasm.lua ├── etc │ ├── luajit.1 │ └── luajit.pc └── src │ ├── Makefile │ ├── Makefile.dep │ ├── host │ ├── README │ ├── buildvm.c │ ├── buildvm.h │ ├── buildvm_arch.h │ ├── buildvm_asm.c │ ├── buildvm_fold.c │ ├── buildvm_lib.c │ ├── buildvm_peobj.c │ ├── genminilua.lua │ └── minilua.c │ ├── jit │ ├── bc.lua │ ├── bcsave.lua │ ├── dis_arm.lua │ ├── dis_mips.lua │ ├── dis_mipsel.lua │ ├── dis_ppc.lua │ ├── dis_x64.lua │ ├── dis_x86.lua │ ├── dump.lua │ ├── v.lua │ └── vmdef.lua │ ├── lauxlib.h │ ├── lib_aux.c │ ├── lib_base.c │ ├── lib_bit.c │ ├── lib_debug.c │ ├── lib_ffi.c │ ├── lib_init.c │ ├── lib_io.c │ ├── lib_jit.c │ ├── lib_math.c │ ├── lib_os.c │ ├── lib_package.c │ ├── lib_string.c │ ├── lib_table.c │ ├── lj.supp │ ├── lj_alloc.c │ ├── lj_alloc.h │ ├── lj_api.c │ ├── lj_arch.h │ ├── lj_asm.c │ ├── lj_asm.h │ ├── lj_asm_arm.h │ ├── lj_asm_mips.h │ ├── lj_asm_ppc.h │ ├── lj_asm_x86.h │ ├── lj_bc.c │ ├── lj_bc.h │ ├── lj_bcdef.h │ ├── lj_bcdump.h │ ├── lj_bcread.c │ ├── lj_bcwrite.c │ ├── lj_carith.c │ ├── lj_carith.h │ ├── lj_ccall.c │ ├── lj_ccall.h │ ├── lj_ccallback.c │ ├── lj_ccallback.h │ ├── lj_cconv.c │ ├── lj_cconv.h │ ├── lj_cdata.c │ ├── lj_cdata.h │ ├── lj_char.c │ ├── lj_char.h │ ├── lj_clib.c │ ├── lj_clib.h │ ├── lj_cparse.c │ ├── lj_cparse.h │ ├── lj_crecord.c │ ├── lj_crecord.h │ ├── lj_ctype.c │ ├── lj_ctype.h │ ├── lj_debug.c │ ├── lj_debug.h │ ├── lj_def.h │ ├── lj_dispatch.c │ ├── lj_dispatch.h │ ├── lj_emit_arm.h │ ├── lj_emit_mips.h │ ├── lj_emit_ppc.h │ ├── lj_emit_x86.h │ ├── lj_err.c │ ├── lj_err.h │ ├── lj_errmsg.h │ ├── lj_ff.h │ ├── lj_ffdef.h │ ├── lj_ffrecord.c │ ├── lj_ffrecord.h │ ├── lj_folddef.h │ ├── lj_frame.h │ ├── lj_func.c │ ├── lj_func.h │ ├── lj_gc.c │ ├── lj_gc.h │ ├── lj_gdbjit.c │ ├── lj_gdbjit.h │ ├── lj_ir.c │ ├── lj_ir.h │ ├── lj_ircall.h │ ├── lj_iropt.h │ ├── lj_jit.h │ ├── lj_lex.c │ ├── lj_lex.h │ ├── lj_lib.c │ ├── lj_lib.h │ ├── lj_libdef.h │ ├── lj_load.c │ ├── lj_mcode.c │ ├── lj_mcode.h │ ├── lj_meta.c │ ├── lj_meta.h │ ├── lj_obj.c │ ├── lj_obj.h │ ├── lj_opt_dce.c │ ├── lj_opt_fold.c │ ├── lj_opt_loop.c │ ├── lj_opt_mem.c │ ├── lj_opt_narrow.c │ ├── lj_opt_sink.c │ ├── lj_opt_split.c │ ├── lj_parse.c │ ├── lj_parse.h │ ├── lj_recdef.h │ ├── lj_record.c │ ├── lj_record.h │ ├── lj_snap.c │ ├── lj_snap.h │ ├── lj_state.c │ ├── lj_state.h │ ├── lj_str.c │ ├── lj_str.h │ ├── lj_strscan.c │ ├── lj_strscan.h │ ├── lj_tab.c │ ├── lj_tab.h │ ├── lj_target.h │ ├── lj_target_arm.h │ ├── lj_target_mips.h │ ├── lj_target_ppc.h │ ├── lj_target_x86.h │ ├── lj_trace.c │ ├── lj_trace.h │ ├── lj_traceerr.h │ ├── lj_udata.c │ ├── lj_udata.h │ ├── lj_vm.h │ ├── lj_vmevent.c │ ├── lj_vmevent.h │ ├── lj_vmmath.c │ ├── ljamalg.c │ ├── lua.h │ ├── lua.hpp │ ├── lua51.dll │ ├── lua51.exp │ ├── lua51.lib │ ├── luaconf.h │ ├── luajit.c │ ├── luajit.exe │ ├── luajit.exp │ ├── luajit.h │ ├── luajit.lib │ ├── lualib.h │ ├── msvcbuild.bat │ ├── vm_arm.dasc │ ├── vm_mips.dasc │ ├── vm_ppc.dasc │ ├── vm_ppcspe.dasc │ ├── vm_x86.dasc │ └── xedkbuild.bat ├── Makefile ├── Offsets.cpp ├── Offsets.h ├── Scripts.cpp ├── Scripts.h ├── Variables.cpp ├── Variables.h ├── dllmain.cpp ├── resource.h ├── stdafx.h ├── war3-lua-engine.aps ├── war3-lua-engine.cpp ├── war3-lua-engine.rc ├── war3-lua-engine.vcxproj ├── war3-lua-engine.vcxproj.filters ├── war3-lua-engine.vcxproj.user └── war3_lua_engine.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | 16 | ## Ignore Visual Studio temporary files, build results, and 17 | ## files generated by popular Visual Studio add-ons. 18 | 19 | # User-specific files 20 | *.suo 21 | *.user 22 | *.sln.docstates 23 | 24 | # Build results 25 | 26 | [Dd]ebug/ 27 | [Rr]elease/ 28 | x64/ 29 | build/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | 33 | # ========================= 34 | # Windows detritus 35 | # ========================= 36 | 37 | # Windows image file caches 38 | Thumbs.db 39 | ehthumbs.db 40 | 41 | # Folder config file 42 | Desktop.ini 43 | 44 | # Recycle Bin used on file shares 45 | $RECYCLE.BIN/ 46 | 47 | # Mac crap 48 | .DS_Store 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | war3-lua-engine 2 | =============== 3 | 4 | An lua scripting engine for Warcraft3 5 | -------------------------------------------------------------------------------- /Scripts/AutoUnpause.lua: -------------------------------------------------------------------------------- 1 | local CurrentState = 0 2 | local CGameObject = CGame() 3 | 4 | while true do 5 | CurrentState = CGameObject:GetGameState() 6 | 7 | if CurrentState == GS.PAUSED then -- Someone paused the game -- 8 | Sleep(3000) -- Wait 3 seconds before unpause -- 9 | 10 | -- Check if it's still paused -- 11 | CurrentState = CGameObject:GetGameState() 12 | 13 | if CurrentState == GS.PAUSED then 14 | CGameObject:ResumeGame() 15 | end 16 | end 17 | 18 | Sleep(100) 19 | end 20 | -------------------------------------------------------------------------------- /Scripts/DisplayText.lua: -------------------------------------------------------------------------------- 1 | local CurrentState = 0 2 | local PreviousState = 0 3 | local hPlayer = nil 4 | local CGameObject = CGame() 5 | local CJassObject = CJass() 6 | 7 | CJassObject:Initialize() 8 | 9 | while true do 10 | CurrentState = CGameObject:GetGameState() 11 | 12 | if CurrentState == GS.INGAME then -- We Are In Game -- 13 | Sleep(1000) 14 | hPlayer = CJassObject:GetLocalPlayer() 15 | CJassObject:DisplayTimedTextToPlayer(hPlayer, 0, 0, 10, "We are sending this text with |CFF8989DEWarcraft Lua Engine|R") 16 | break 17 | end 18 | 19 | Sleep(100) 20 | end -------------------------------------------------------------------------------- /Scripts/GameState.lua: -------------------------------------------------------------------------------- 1 | local CurrentState = 0 2 | local PreviousState = 0 3 | local StateName = nil 4 | local CGameObject = CGame() 5 | 6 | 7 | while true do 8 | CurrentState = CGameObject:GetGameState() 9 | 10 | if CurrentState == GS.NOTHING then StateName = "GS_NOTHING" 11 | elseif CurrentState == GS.LOBBY then StateName = "GS_LOBBY" 12 | elseif CurrentState == GS.LOADING then StateName = "GS_LOADING" 13 | elseif CurrentState == GS.INGAME then StateName = "GS_INGAME" 14 | elseif CurrentState == GS.PAUSED then StateName = "GS_PAUSED" 15 | end 16 | 17 | if CurrentState ~= PreviousState then -- State Changed -- 18 | ShowMessage("Game state has been changed to " .. StateName) 19 | end 20 | 21 | PreviousState = CurrentState 22 | Sleep(100) 23 | end -------------------------------------------------------------------------------- /Scripts/GetUnits.lua: -------------------------------------------------------------------------------- 1 | local CGameObject = CGame() 2 | 3 | function Check() 4 | local hUnits = CGameObject:GetDotaUnits() 5 | 6 | for _,creep in ipairs(hUnits) do 7 | -- Do anything you want with "creep" 8 | end 9 | 10 | end 11 | 12 | while true do 13 | local GameState = CGameObject:GetGameState() 14 | 15 | if GameState == GS.INGAME then 16 | Check() 17 | end 18 | 19 | Sleep(100) 20 | end -------------------------------------------------------------------------------- /Scripts/JassStringSample.lua: -------------------------------------------------------------------------------- 1 | local CJassObject = CJass() 2 | local CGameObject = CGame() 3 | local GameState = nil 4 | 5 | CJassObject:Initialize() 6 | 7 | while true do 8 | GameState = CGameObject:GetGameState() 9 | 10 | if GameState == GS.INGAME then 11 | local hPlayer = CJassObject:GetLocalPlayer() 12 | local sPlayerName = CJassObject:GetPlayerName(hPlayer) 13 | CJassObject:DisplayTimedTextToPlayer(hPlayer, 0, 0, 10, "Local player name is " .. sPlayerName) 14 | break 15 | end 16 | 17 | Sleep(100) 18 | end -------------------------------------------------------------------------------- /war3-lua-engine.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "war3-lua-engine", "war3-lua-engine\war3-lua-engine.vcxproj", "{3A7F16F7-17E0-435F-A05A-812C6AA6A872}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {3A7F16F7-17E0-435F-A05A-812C6AA6A872}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {3A7F16F7-17E0-435F-A05A-812C6AA6A872}.Debug|Win32.Build.0 = Debug|Win32 14 | {3A7F16F7-17E0-435F-A05A-812C6AA6A872}.Release|Win32.ActiveCfg = Release|Win32 15 | {3A7F16F7-17E0-435F-A05A-812C6AA6A872}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /war3-lua-engine/Game.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/Game.cpp -------------------------------------------------------------------------------- /war3-lua-engine/Game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "stdafx.h" 3 | 4 | #define ADDR(X,REG)\ 5 | __asm MOV REG,DWORD PTR DS:[X] \ 6 | __asm MOV REG,DWORD PTR DS:[REG] 7 | 8 | static int GS_NOTHING = 0; 9 | static int GS_LOBBY = 1; 10 | static int GS_LOADING = 3; 11 | static int GS_INGAME = 4; 12 | static int GS_PAUSED = 6; 13 | 14 | static int STAT_HP = 0; 15 | static int STAT_MAXHP = 1; 16 | static int STAT_MANA = 2; 17 | static int STAT_MAXMANA = 3; 18 | 19 | #define FLAG_ILLUSION 0x40000000; 20 | #define FLAG_INVIS 0x1000000; 21 | #define FLAG_DEAD 0x100; 22 | 23 | static DWORD CMD_MOVE = 0xD0003; 24 | static DWORD CMD_ATTACK = 0xD000F; 25 | static DWORD CMD_HOLD = 0xD0019; 26 | static DWORD CMD_STOP = 0xD0004; 27 | 28 | struct Unit 29 | { 30 | DWORD dwDummy[3]; 31 | DWORD dwID1; 32 | DWORD dwID2; 33 | BYTE _1[0x1C]; 34 | DWORD dwClassId; 35 | BYTE _2[0x1C]; 36 | DWORD HealthBar; 37 | DWORD UNK; 38 | DWORD dwOwnerSlot; 39 | }; 40 | 41 | struct Location 42 | { 43 | float X; 44 | float Y; 45 | float Z; 46 | }; 47 | 48 | struct MmapLoc 49 | { 50 | DWORD X; 51 | DWORD Y; 52 | }; 53 | 54 | union Float 55 | { 56 | float fl; 57 | DWORD dw; 58 | }; -------------------------------------------------------------------------------- /war3-lua-engine/LuaBridge/LuaBridge.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | 5 | Copyright 2012, Vinnie Falco 6 | Copyright 2007, Nathan Reed 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | #ifndef LUABRIDGE_LUABRIDGE_HEADER 31 | #define LUABRIDGE_LUABRIDGE_HEADER 32 | 33 | // All #include dependencies are listed here 34 | // instead of in the individual header files. 35 | // 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #define LUABRIDGE_MAJOR_VERSION 2 43 | #define LUABRIDGE_MINOR_VERSION 0 44 | #define LUABRIDGE_VERSION 200 45 | 46 | namespace luabridge 47 | { 48 | 49 | // Forward declaration 50 | // 51 | template 52 | struct Stack; 53 | 54 | #include "detail/LuaHelpers.h" 55 | 56 | #include "detail/TypeTraits.h" 57 | #include "detail/TypeList.h" 58 | #include "detail/FuncTraits.h" 59 | #include "detail/Constructor.h" 60 | #include "detail/Stack.h" 61 | #include "detail/ClassInfo.h" 62 | 63 | class LuaRef; 64 | 65 | #include "detail/LuaException.h" 66 | #include "detail/LuaRef.h" 67 | #include "detail/Iterator.h" 68 | 69 | //------------------------------------------------------------------------------ 70 | /** 71 | security options. 72 | */ 73 | class Security 74 | { 75 | public: 76 | static bool hideMetatables () 77 | { 78 | return getSettings().hideMetatables; 79 | } 80 | 81 | static void setHideMetatables (bool shouldHide) 82 | { 83 | getSettings().hideMetatables = shouldHide; 84 | } 85 | 86 | private: 87 | struct Settings 88 | { 89 | Settings () : hideMetatables (true) 90 | { 91 | } 92 | 93 | bool hideMetatables; 94 | }; 95 | 96 | static Settings& getSettings () 97 | { 98 | static Settings settings; 99 | return settings; 100 | } 101 | }; 102 | 103 | #include "detail/Userdata.h" 104 | #include "detail/CFunctions.h" 105 | #include "detail/Namespace.h" 106 | 107 | //------------------------------------------------------------------------------ 108 | /** 109 | Push an object onto the Lua stack. 110 | */ 111 | template 112 | inline void push (lua_State* L, T t) 113 | { 114 | Stack ::push (L, t); 115 | } 116 | 117 | //------------------------------------------------------------------------------ 118 | /** 119 | Set a global value in the lua_State. 120 | 121 | @note This works on any type specialized by `Stack`, including `LuaRef` and 122 | its table proxies. 123 | */ 124 | template 125 | inline void setGlobal (lua_State* L, T t, char const* name) 126 | { 127 | push (L, t); 128 | lua_setglobal (L, name); 129 | } 130 | 131 | //------------------------------------------------------------------------------ 132 | /** 133 | Change whether or not metatables are hidden (on by default). 134 | */ 135 | inline void setHideMetatables (bool shouldHide) 136 | { 137 | Security::setHideMetatables (shouldHide); 138 | } 139 | 140 | } 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaBridge/detail/ClassInfo.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | 5 | Copyright 2012, Vinnie Falco 6 | 7 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | */ 27 | //============================================================================== 28 | 29 | /** Unique Lua registry keys for a class. 30 | 31 | Each registered class inserts three keys into the registry, whose 32 | values are the corresponding static, class, and const metatables. This 33 | allows a quick and reliable lookup for a metatable from a template type. 34 | */ 35 | template 36 | class ClassInfo 37 | { 38 | public: 39 | /** Get the key for the static table. 40 | 41 | The static table holds the static data members, static properties, and 42 | static member functions for a class. 43 | */ 44 | static void const* getStaticKey () 45 | { 46 | static char value; 47 | return &value; 48 | } 49 | 50 | /** Get the key for the class table. 51 | 52 | The class table holds the data members, properties, and member functions 53 | of a class. Read-only data and properties, and const member functions are 54 | also placed here (to save a lookup in the const table). 55 | */ 56 | static void const* getClassKey () 57 | { 58 | static char value; 59 | return &value; 60 | } 61 | 62 | /** Get the key for the const table. 63 | 64 | The const table holds read-only data members and properties, and const 65 | member functions of a class. 66 | */ 67 | static void const* getConstKey () 68 | { 69 | static char value; 70 | return &value; 71 | } 72 | }; 73 | 74 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaBridge/detail/Iterator.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | 5 | Copyright 2012, Vinnie Falco 6 | 7 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | */ 27 | //============================================================================== 28 | 29 | /** Allows table iteration. 30 | */ 31 | class Iterator 32 | { 33 | private: 34 | lua_State* m_L; 35 | LuaRef m_table; 36 | LuaRef m_key; 37 | LuaRef m_value; 38 | 39 | void next () 40 | { 41 | m_table.push(m_L); 42 | m_key.push (m_L); 43 | if (lua_next (m_L, -2)) 44 | { 45 | m_value.pop (m_L); 46 | m_key.pop (m_L); 47 | } 48 | else 49 | { 50 | m_key = Nil(); 51 | m_value = Nil(); 52 | } 53 | lua_pop(m_L, 1); 54 | } 55 | 56 | public: 57 | explicit Iterator (LuaRef table) 58 | : m_L (table.state ()) 59 | , m_table (table) 60 | , m_key (table.state ()) // m_key is nil 61 | , m_value (table.state ()) // m_value is nil 62 | { 63 | next (); // get the first (key, value) pair from table 64 | } 65 | 66 | lua_State* state () const 67 | { 68 | return m_L; 69 | } 70 | 71 | LuaRef operator* () const 72 | { 73 | return m_value; 74 | } 75 | 76 | LuaRef operator-> () const 77 | { 78 | return m_value; 79 | } 80 | 81 | Iterator& operator++ () 82 | { 83 | if (isNil()) 84 | { 85 | // if the iterator reaches the end, do nothing 86 | return *this; 87 | } 88 | else 89 | { 90 | next(); 91 | return *this; 92 | } 93 | } 94 | 95 | inline bool isNil () const 96 | { 97 | return m_key.isNil (); 98 | } 99 | 100 | inline LuaRef key () const 101 | { 102 | return m_key; 103 | } 104 | 105 | inline LuaRef value () const 106 | { 107 | return m_value; 108 | } 109 | 110 | private: 111 | // Don't use postfix increment, it is less efficient 112 | Iterator operator++ (int); 113 | }; 114 | 115 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaBridge/detail/LuaException.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | 5 | Copyright 2012, Vinnie Falco 6 | Copyright 2008, Nigel Atkinson 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | class LuaException : public std::exception 31 | { 32 | private: 33 | lua_State* m_L; 34 | std::string m_what; 35 | 36 | public: 37 | //---------------------------------------------------------------------------- 38 | /** 39 | Construct a LuaException after a lua_pcall(). 40 | */ 41 | LuaException (lua_State* L, int /*code*/) 42 | : m_L (L) 43 | { 44 | whatFromStack (); 45 | } 46 | 47 | //---------------------------------------------------------------------------- 48 | 49 | LuaException (lua_State *L, 50 | char const*, 51 | char const*, 52 | long) 53 | : m_L (L) 54 | { 55 | whatFromStack (); 56 | } 57 | 58 | //---------------------------------------------------------------------------- 59 | 60 | ~LuaException() throw () 61 | { 62 | } 63 | 64 | //---------------------------------------------------------------------------- 65 | 66 | char const* what() const throw () 67 | { 68 | return m_what.c_str(); 69 | } 70 | 71 | //============================================================================ 72 | /** 73 | Throw an exception. 74 | 75 | This centralizes all the exceptions thrown, so that we can set 76 | breakpoints before the stack is unwound, or otherwise customize the 77 | behavior. 78 | */ 79 | template 80 | static void Throw (Exception e) 81 | { 82 | throw e; 83 | } 84 | 85 | //---------------------------------------------------------------------------- 86 | /** 87 | Wrapper for lua_pcall that throws. 88 | */ 89 | static void pcall (lua_State* L, int nargs = 0, int nresults = 0, int msgh = 0) 90 | { 91 | int code = lua_pcall (L, nargs, nresults, msgh); 92 | 93 | if (code != LUABRIDGE_LUA_OK) 94 | Throw (LuaException (L, code)); 95 | } 96 | 97 | //---------------------------------------------------------------------------- 98 | 99 | protected: 100 | void whatFromStack () 101 | { 102 | if (lua_gettop (m_L) > 0) 103 | { 104 | char const* s = lua_tostring (m_L, -1); 105 | m_what = s ? s : ""; 106 | } 107 | else 108 | { 109 | // stack is empty 110 | m_what = "missing error"; 111 | } 112 | } 113 | }; 114 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaBridge/detail/LuaHelpers.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | 5 | Copyright 2012, Vinnie Falco 6 | Copyright 2007, Nathan Reed 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | // These are for Lua versions prior to 5.2.0. 31 | // 32 | #if LUA_VERSION_NUM < 502 33 | inline int lua_absindex (lua_State* L, int idx) 34 | { 35 | if (idx > LUA_REGISTRYINDEX && idx < 0) 36 | return lua_gettop (L) + idx + 1; 37 | else 38 | return idx; 39 | } 40 | 41 | inline void lua_rawgetp (lua_State* L, int idx, void const* p) 42 | { 43 | idx = lua_absindex (L, idx); 44 | lua_pushlightuserdata (L, const_cast (p)); 45 | lua_rawget (L,idx); 46 | } 47 | 48 | inline void lua_rawsetp (lua_State* L, int idx, void const* p) 49 | { 50 | idx = lua_absindex (L, idx); 51 | lua_pushlightuserdata (L, const_cast (p)); 52 | // put key behind value 53 | lua_insert (L, -2); 54 | lua_rawset (L, idx); 55 | } 56 | 57 | #define LUA_OPEQ 1 58 | #define LUA_OPLT 2 59 | #define LUA_OPLE 3 60 | 61 | inline int lua_compare (lua_State* L, int idx1, int idx2, int op) 62 | { 63 | switch (op) 64 | { 65 | case LUA_OPEQ: 66 | return lua_equal (L, idx1, idx2); 67 | break; 68 | 69 | case LUA_OPLT: 70 | return lua_lessthan (L, idx1, idx2); 71 | break; 72 | 73 | case LUA_OPLE: 74 | return lua_equal (L, idx1, idx2) || lua_lessthan (L, idx1, idx2); 75 | break; 76 | 77 | default: 78 | return 0; 79 | }; 80 | } 81 | 82 | inline int get_length (lua_State* L, int idx) 83 | { 84 | return int (lua_objlen (L, idx)); 85 | } 86 | 87 | #else 88 | inline int get_length (lua_State* L, int idx) 89 | { 90 | lua_len (L, idx); 91 | int len = int (luaL_checknumber (L, -1)); 92 | lua_pop (L, 1); 93 | return len; 94 | } 95 | 96 | #endif 97 | 98 | #ifndef LUA_OK 99 | # define LUABRIDGE_LUA_OK 0 100 | #else 101 | # define LUABRIDGE_LUA_OK LUA_OK 102 | #endif 103 | 104 | /** Get a table value, bypassing metamethods. 105 | */ 106 | inline void rawgetfield (lua_State* L, int index, char const* key) 107 | { 108 | assert (lua_istable (L, index)); 109 | index = lua_absindex (L, index); 110 | lua_pushstring (L, key); 111 | lua_rawget (L, index); 112 | } 113 | 114 | /** Set a table value, bypassing metamethods. 115 | */ 116 | inline void rawsetfield (lua_State* L, int index, char const* key) 117 | { 118 | assert (lua_istable (L, index)); 119 | index = lua_absindex (L, index); 120 | lua_pushstring (L, key); 121 | lua_insert (L, -2); 122 | lua_rawset (L, index); 123 | } 124 | 125 | /** Returns true if the value is a full userdata (not light). 126 | */ 127 | inline bool isfulluserdata (lua_State* L, int index) 128 | { 129 | return lua_isuserdata (L, index) && !lua_islightuserdata (L, index); 130 | } 131 | 132 | /** Test lua_State objects for global equality. 133 | 134 | This can determine if two different lua_State objects really point 135 | to the same global state, such as when using coroutines. 136 | 137 | @note This is used for assertions. 138 | */ 139 | inline bool equalstates (lua_State* L1, lua_State* L2) 140 | { 141 | return lua_topointer (L1, LUA_REGISTRYINDEX) == 142 | lua_topointer (L2, LUA_REGISTRYINDEX); 143 | } 144 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaBridge/detail/TypeList.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | 5 | Copyright 2012, Vinnie Falco 6 | Copyright 2007, Nathan Reed 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | This file incorporates work covered by the following copyright and 29 | permission notice: 30 | 31 | The Loki Library 32 | Copyright (c) 2001 by Andrei Alexandrescu 33 | This code accompanies the book: 34 | Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design 35 | Patterns Applied". Copyright (c) 2001. Addison-Wesley. 36 | Permission to use, copy, modify, distribute and sell this software for any 37 | purpose is hereby granted without fee, provided that the above copyright 38 | notice appear in all copies and that both that copyright notice and this 39 | permission notice appear in supporting documentation. 40 | The author or Addison-Welsey Longman make no representations about the 41 | suitability of this software for any purpose. It is provided "as is" 42 | without express or implied warranty. 43 | */ 44 | //============================================================================== 45 | 46 | /** 47 | None type means void parameters or return value. 48 | */ 49 | typedef void None; 50 | 51 | template 52 | struct TypeList 53 | { 54 | }; 55 | 56 | /** 57 | A TypeList with actual values. 58 | */ 59 | template 60 | struct TypeListValues 61 | { 62 | static std::string const tostring (bool) 63 | { 64 | return ""; 65 | } 66 | }; 67 | 68 | /** 69 | TypeListValues recursive template definition. 70 | */ 71 | template 72 | struct TypeListValues > 73 | { 74 | Head hd; 75 | TypeListValues tl; 76 | 77 | TypeListValues (Head hd_, TypeListValues const& tl_) 78 | : hd (hd_), tl (tl_) 79 | { 80 | } 81 | 82 | static std::string const tostring (bool comma = false) 83 | { 84 | std::string s; 85 | 86 | if (comma) 87 | s = ", "; 88 | 89 | s = s + typeid (Head).name (); 90 | 91 | return s + TypeListValues ::tostring (true); 92 | } 93 | }; 94 | 95 | // Specializations of type/value list for head types that are references and 96 | // const-references. We need to handle these specially since we can't count 97 | // on the referenced object hanging around for the lifetime of the list. 98 | 99 | template 100 | struct TypeListValues > 101 | { 102 | Head hd; 103 | TypeListValues tl; 104 | 105 | TypeListValues (Head& hd_, TypeListValues const& tl_) 106 | : hd (hd_), tl (tl_) 107 | { 108 | } 109 | 110 | static std::string const tostring (bool comma = false) 111 | { 112 | std::string s; 113 | 114 | if (comma) 115 | s = ", "; 116 | 117 | s = s + typeid (Head).name () + "&"; 118 | 119 | return s + TypeListValues ::tostring (true); 120 | } 121 | }; 122 | 123 | template 124 | struct TypeListValues > 125 | { 126 | Head hd; 127 | TypeListValues tl; 128 | 129 | TypeListValues (Head const& hd_, const TypeListValues & tl_) 130 | : hd (hd_), tl (tl_) 131 | { 132 | } 133 | 134 | static std::string const tostring (bool comma = false) 135 | { 136 | std::string s; 137 | 138 | if (comma) 139 | s = ", "; 140 | 141 | s = s + typeid (Head).name () + " const&"; 142 | 143 | return s + TypeListValues ::tostring (true); 144 | } 145 | }; 146 | 147 | //============================================================================== 148 | /** 149 | Subclass of a TypeListValues constructable from the Lua stack. 150 | */ 151 | 152 | template 153 | struct ArgList 154 | { 155 | }; 156 | 157 | template 158 | struct ArgList : public TypeListValues 159 | { 160 | ArgList (lua_State*) 161 | { 162 | } 163 | }; 164 | 165 | template 166 | struct ArgList , Start> 167 | : public TypeListValues > 168 | { 169 | ArgList (lua_State* L) 170 | : TypeListValues > (Stack ::get (L, Start), 171 | ArgList (L)) 172 | { 173 | } 174 | }; 175 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaBridge/detail/TypeTraits.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | 5 | Copyright 2012, Vinnie Falco 6 | 7 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | */ 27 | //============================================================================== 28 | 29 | #ifndef LUABRIDGE_TYPEINFO_HEADER 30 | #define LUABRIDGE_TYPEINFO_HEADER 31 | 32 | //------------------------------------------------------------------------------ 33 | /** 34 | Container traits. 35 | 36 | Unspecialized ContainerTraits has the isNotContainer typedef for SFINAE. 37 | All user defined containers must supply an appropriate specialization for 38 | ContinerTraits (without the typedef isNotContainer). The containers that 39 | come with LuaBridge also come with the appropriate ContainerTraits 40 | specialization. See the corresponding declaration for details. 41 | 42 | A specialization of ContainerTraits for some generic type ContainerType 43 | looks like this: 44 | 45 | template 46 | struct ContainerTraits > 47 | { 48 | typedef typename T Type; 49 | 50 | static T* get (ContainerType const& c) 51 | { 52 | return c.get (); // Implementation-dependent on ContainerType 53 | } 54 | }; 55 | */ 56 | template 57 | struct ContainerTraits 58 | { 59 | typedef bool isNotContainer; 60 | }; 61 | 62 | //------------------------------------------------------------------------------ 63 | /** 64 | Type traits. 65 | 66 | Specializations return information about a type. 67 | */ 68 | struct TypeTraits 69 | { 70 | /** Determine if type T is a container. 71 | 72 | To be considered a container, there must be a specialization of 73 | ContainerTraits with the required fields. 74 | */ 75 | template 76 | class isContainer 77 | { 78 | private: 79 | typedef char yes[1]; // sizeof (yes) == 1 80 | typedef char no [2]; // sizeof (no) == 2 81 | 82 | template 83 | static no& test (typename C::isNotContainer*); 84 | 85 | template 86 | static yes& test (...); 87 | 88 | public: 89 | static const bool value = sizeof (test >(0)) == sizeof (yes); 90 | }; 91 | 92 | /** Determine if T is const qualified. 93 | */ 94 | /** @{ */ 95 | template 96 | struct isConst 97 | { 98 | static bool const value = false; 99 | }; 100 | 101 | template 102 | struct isConst 103 | { 104 | static bool const value = true; 105 | }; 106 | /** @} */ 107 | 108 | /** Remove the const qualifier from T. 109 | */ 110 | /** @{ */ 111 | template 112 | struct removeConst 113 | { 114 | typedef T Type; 115 | }; 116 | 117 | template 118 | struct removeConst 119 | { 120 | typedef T Type; 121 | }; 122 | /**@}*/ 123 | }; 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaBridge/detail/dump.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | std::string dumpLuaState(lua_State *L) { 5 | std::stringstream ostr; 6 | int i; 7 | int top = lua_gettop(L); 8 | ostr << "top=" << top << ":\n"; 9 | for (i = 1; i <= top; ++i) { 10 | int t = lua_type(L, i); 11 | switch(t) { 12 | case LUA_TSTRING: 13 | ostr << " " << i << ": '" << lua_tostring(L, i) << "'\n"; 14 | break; 15 | case LUA_TBOOLEAN: 16 | ostr << " " << i << ": " << 17 | (lua_toboolean(L, i) ? "true" : "false") << "\n"; 18 | break; 19 | case LUA_TNUMBER: 20 | ostr << " " << i << ": " << lua_tonumber(L, i) << "\n"; 21 | break; 22 | default: 23 | ostr << " " << i << ": TYPE=" << lua_typename(L, t) << "\n"; 24 | break; 25 | } 26 | } 27 | return ostr.str(); 28 | } 29 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/COPYRIGHT: -------------------------------------------------------------------------------- 1 | =============================================================================== 2 | LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ 3 | 4 | Copyright (C) 2005-2013 Mike Pall. All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | 24 | [ MIT license: http://www.opensource.org/licenses/mit-license.php ] 25 | 26 | =============================================================================== 27 | [ LuaJIT includes code from Lua 5.1/5.2, which has this license statement: ] 28 | 29 | Copyright (C) 1994-2012 Lua.org, PUC-Rio. 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a copy 32 | of this software and associated documentation files (the "Software"), to deal 33 | in the Software without restriction, including without limitation the rights 34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 35 | copies of the Software, and to permit persons to whom the Software is 36 | furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included in 39 | all copies or substantial portions of the Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 47 | THE SOFTWARE. 48 | 49 | =============================================================================== 50 | [ LuaJIT includes code from dlmalloc, which has this license statement: ] 51 | 52 | This is a version (aka dlmalloc) of malloc/free/realloc written by 53 | Doug Lea and released to the public domain, as explained at 54 | http://creativecommons.org/licenses/publicdomain 55 | 56 | =============================================================================== 57 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # LuaJIT top level Makefile for installation. Requires GNU Make. 3 | # 4 | # Please read doc/install.html before changing any variables! 5 | # 6 | # Suitable for POSIX platforms (Linux, *BSD, OSX etc.). 7 | # Note: src/Makefile has many more configurable options. 8 | # 9 | # ##### This Makefile is NOT useful for Windows! ##### 10 | # For MSVC, please follow the instructions given in src/msvcbuild.bat. 11 | # For MinGW and Cygwin, cd to src and run make with the Makefile there. 12 | # 13 | # Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 14 | ############################################################################## 15 | 16 | MAJVER= 2 17 | MINVER= 0 18 | RELVER= 2 19 | VERSION= $(MAJVER).$(MINVER).$(RELVER) 20 | ABIVER= 5.1 21 | 22 | ############################################################################## 23 | # 24 | # Change the installation path as needed. This automatically adjusts 25 | # the paths in src/luaconf.h, too. Note: PREFIX must be an absolute path! 26 | # 27 | export PREFIX= /usr/local 28 | ############################################################################## 29 | 30 | DPREFIX= $(DESTDIR)$(PREFIX) 31 | INSTALL_BIN= $(DPREFIX)/bin 32 | INSTALL_LIB= $(DPREFIX)/lib 33 | INSTALL_SHARE= $(DPREFIX)/share 34 | INSTALL_INC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER) 35 | 36 | INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION) 37 | INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit 38 | INSTALL_LMODD= $(INSTALL_SHARE)/lua 39 | INSTALL_LMOD= $(INSTALL_LMODD)/$(ABIVER) 40 | INSTALL_CMODD= $(INSTALL_LIB)/lua 41 | INSTALL_CMOD= $(INSTALL_CMODD)/$(ABIVER) 42 | INSTALL_MAN= $(INSTALL_SHARE)/man/man1 43 | INSTALL_PKGCONFIG= $(INSTALL_LIB)/pkgconfig 44 | 45 | INSTALL_TNAME= luajit-$(VERSION) 46 | INSTALL_TSYMNAME= luajit 47 | INSTALL_ANAME= libluajit-$(ABIVER).a 48 | INSTALL_SONAME= libluajit-$(ABIVER).so.$(MAJVER).$(MINVER).$(RELVER) 49 | INSTALL_SOSHORT= libluajit-$(ABIVER).so 50 | INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).$(MINVER).$(RELVER).dylib 51 | INSTALL_DYLIBSHORT1= libluajit-$(ABIVER).dylib 52 | INSTALL_DYLIBSHORT2= libluajit-$(ABIVER).$(MAJVER).dylib 53 | INSTALL_PCNAME= luajit.pc 54 | 55 | INSTALL_STATIC= $(INSTALL_LIB)/$(INSTALL_ANAME) 56 | INSTALL_DYN= $(INSTALL_LIB)/$(INSTALL_SONAME) 57 | INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_SOSHORT) 58 | INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_SOSHORT) 59 | INSTALL_T= $(INSTALL_BIN)/$(INSTALL_TNAME) 60 | INSTALL_TSYM= $(INSTALL_BIN)/$(INSTALL_TSYMNAME) 61 | INSTALL_PC= $(INSTALL_PKGCONFIG)/$(INSTALL_PCNAME) 62 | 63 | INSTALL_DIRS= $(INSTALL_BIN) $(INSTALL_LIB) $(INSTALL_INC) $(INSTALL_MAN) \ 64 | $(INSTALL_PKGCONFIG) $(INSTALL_JITLIB) $(INSTALL_LMOD) $(INSTALL_CMOD) 65 | UNINSTALL_DIRS= $(INSTALL_JITLIB) $(INSTALL_LJLIBD) $(INSTALL_INC) \ 66 | $(INSTALL_LMOD) $(INSTALL_LMODD) $(INSTALL_CMOD) $(INSTALL_CMODD) 67 | 68 | RM= rm -f 69 | MKDIR= mkdir -p 70 | RMDIR= rmdir 2>/dev/null 71 | SYMLINK= ln -sf 72 | INSTALL_X= install -m 0755 73 | INSTALL_F= install -m 0644 74 | UNINSTALL= $(RM) 75 | LDCONFIG= ldconfig -n 76 | SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" 77 | 78 | FILE_T= luajit 79 | FILE_A= libluajit.a 80 | FILE_SO= libluajit.so 81 | FILE_MAN= luajit.1 82 | FILE_PC= luajit.pc 83 | FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h 84 | FILES_JITLIB= bc.lua v.lua dump.lua dis_x86.lua dis_x64.lua dis_arm.lua \ 85 | dis_ppc.lua dis_mips.lua dis_mipsel.lua bcsave.lua vmdef.lua 86 | 87 | ifeq (,$(findstring Windows,$(OS))) 88 | ifeq (Darwin,$(shell uname -s)) 89 | INSTALL_SONAME= $(INSTALL_DYLIBNAME) 90 | INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_DYLIBSHORT1) 91 | INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_DYLIBSHORT2) 92 | LDCONFIG= : 93 | endif 94 | endif 95 | 96 | ############################################################################## 97 | 98 | INSTALL_DEP= src/luajit 99 | 100 | default all $(INSTALL_DEP): 101 | @echo "==== Building LuaJIT $(VERSION) ====" 102 | $(MAKE) -C src 103 | @echo "==== Successfully built LuaJIT $(VERSION) ====" 104 | 105 | install: $(INSTALL_DEP) 106 | @echo "==== Installing LuaJIT $(VERSION) to $(PREFIX) ====" 107 | $(MKDIR) $(INSTALL_DIRS) 108 | cd src && $(INSTALL_X) $(FILE_T) $(INSTALL_T) 109 | cd src && test -f $(FILE_A) && $(INSTALL_F) $(FILE_A) $(INSTALL_STATIC) || : 110 | $(RM) $(INSTALL_TSYM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) 111 | cd src && test -f $(FILE_SO) && \ 112 | $(INSTALL_X) $(FILE_SO) $(INSTALL_DYN) && \ 113 | $(LDCONFIG) $(INSTALL_LIB) && \ 114 | $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \ 115 | $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || : 116 | cd etc && $(INSTALL_F) $(FILE_MAN) $(INSTALL_MAN) 117 | cd etc && $(SED_PC) $(FILE_PC) > $(FILE_PC).tmp && \ 118 | $(INSTALL_F) $(FILE_PC).tmp $(INSTALL_PC) && \ 119 | $(RM) $(FILE_PC).tmp 120 | cd src && $(INSTALL_F) $(FILES_INC) $(INSTALL_INC) 121 | cd src/jit && $(INSTALL_F) $(FILES_JITLIB) $(INSTALL_JITLIB) 122 | $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM) 123 | @echo "==== Successfully installed LuaJIT $(VERSION) to $(PREFIX) ====" 124 | 125 | uninstall: 126 | @echo "==== Uninstalling LuaJIT $(VERSION) from $(PREFIX) ====" 127 | $(UNINSTALL) $(INSTALL_TSYM) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC) 128 | for file in $(FILES_JITLIB); do \ 129 | $(UNINSTALL) $(INSTALL_JITLIB)/$$file; \ 130 | done 131 | for file in $(FILES_INC); do \ 132 | $(UNINSTALL) $(INSTALL_INC)/$$file; \ 133 | done 134 | $(LDCONFIG) $(INSTALL_LIB) 135 | $(RMDIR) $(UNINSTALL_DIRS) || : 136 | @echo "==== Successfully uninstalled LuaJIT $(VERSION) from $(PREFIX) ====" 137 | 138 | ############################################################################## 139 | 140 | amalg: 141 | @echo "Building LuaJIT $(VERSION)" 142 | $(MAKE) -C src amalg 143 | 144 | clean: 145 | $(MAKE) -C src clean 146 | 147 | .PHONY: all install amalg clean 148 | 149 | ############################################################################## 150 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/README: -------------------------------------------------------------------------------- 1 | README for LuaJIT 2.0.2 2 | ----------------------- 3 | 4 | LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language. 5 | 6 | Project Homepage: http://luajit.org/ 7 | 8 | LuaJIT is Copyright (C) 2005-2013 Mike Pall. 9 | LuaJIT is free software, released under the MIT license. 10 | See full Copyright Notice in the COPYRIGHT file or in luajit.h. 11 | 12 | Documentation for LuaJIT is available in HTML format. 13 | Please point your favorite browser to: 14 | 15 | doc/luajit.html 16 | 17 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/dynasm/dasm_proto.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** DynASM encoding engine prototypes. 3 | ** Copyright (C) 2005-2013 Mike Pall. All rights reserved. 4 | ** Released under the MIT license. See dynasm.lua for full copyright notice. 5 | */ 6 | 7 | #ifndef _DASM_PROTO_H 8 | #define _DASM_PROTO_H 9 | 10 | #include 11 | #include 12 | 13 | #define DASM_IDENT "DynASM 1.3.0" 14 | #define DASM_VERSION 10300 /* 1.3.0 */ 15 | 16 | #ifndef Dst_DECL 17 | #define Dst_DECL dasm_State **Dst 18 | #endif 19 | 20 | #ifndef Dst_REF 21 | #define Dst_REF (*Dst) 22 | #endif 23 | 24 | #ifndef DASM_FDEF 25 | #define DASM_FDEF extern 26 | #endif 27 | 28 | #ifndef DASM_M_GROW 29 | #define DASM_M_GROW(ctx, t, p, sz, need) \ 30 | do { \ 31 | size_t _sz = (sz), _need = (need); \ 32 | if (_sz < _need) { \ 33 | if (_sz < 16) _sz = 16; \ 34 | while (_sz < _need) _sz += _sz; \ 35 | (p) = (t *)realloc((p), _sz); \ 36 | if ((p) == NULL) exit(1); \ 37 | (sz) = _sz; \ 38 | } \ 39 | } while(0) 40 | #endif 41 | 42 | #ifndef DASM_M_FREE 43 | #define DASM_M_FREE(ctx, p, sz) free(p) 44 | #endif 45 | 46 | /* Internal DynASM encoder state. */ 47 | typedef struct dasm_State dasm_State; 48 | 49 | 50 | /* Initialize and free DynASM state. */ 51 | DASM_FDEF void dasm_init(Dst_DECL, int maxsection); 52 | DASM_FDEF void dasm_free(Dst_DECL); 53 | 54 | /* Setup global array. Must be called before dasm_setup(). */ 55 | DASM_FDEF void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl); 56 | 57 | /* Grow PC label array. Can be called after dasm_setup(), too. */ 58 | DASM_FDEF void dasm_growpc(Dst_DECL, unsigned int maxpc); 59 | 60 | /* Setup encoder. */ 61 | DASM_FDEF void dasm_setup(Dst_DECL, const void *actionlist); 62 | 63 | /* Feed encoder with actions. Calls are generated by pre-processor. */ 64 | DASM_FDEF void dasm_put(Dst_DECL, int start, ...); 65 | 66 | /* Link sections and return the resulting size. */ 67 | DASM_FDEF int dasm_link(Dst_DECL, size_t *szp); 68 | 69 | /* Encode sections into buffer. */ 70 | DASM_FDEF int dasm_encode(Dst_DECL, void *buffer); 71 | 72 | /* Get PC label offset. */ 73 | DASM_FDEF int dasm_getpclabel(Dst_DECL, unsigned int pc); 74 | 75 | #ifdef DASM_CHECKS 76 | /* Optional sanity checker to call between isolated encoding steps. */ 77 | DASM_FDEF int dasm_checkstep(Dst_DECL, int secmatch); 78 | #else 79 | #define dasm_checkstep(a, b) 0 80 | #endif 81 | 82 | 83 | #endif /* _DASM_PROTO_H */ 84 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/dynasm/dasm_x64.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- DynASM x64 module. 3 | -- 4 | -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. 5 | -- See dynasm.lua for full copyright notice. 6 | ------------------------------------------------------------------------------ 7 | -- This module just sets 64 bit mode for the combined x86/x64 module. 8 | -- All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | x64 = true -- Using a global is an ugly, but effective solution. 12 | return require("dasm_x86") 13 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/etc/luajit.1: -------------------------------------------------------------------------------- 1 | .TH luajit 1 "" "" "LuaJIT documentation" 2 | .SH NAME 3 | luajit \- Just-In-Time Compiler for the Lua Language 4 | \fB 5 | .SH SYNOPSIS 6 | .B luajit 7 | [\fIoptions\fR]... [\fIscript\fR [\fIargs\fR]...] 8 | .SH "WEB SITE" 9 | .IR http://luajit.org 10 | .SH DESCRIPTION 11 | .PP 12 | This is the command-line program to run Lua programs with \fBLuaJIT\fR. 13 | .PP 14 | \fBLuaJIT\fR is a just-in-time (JIT) compiler for the Lua language. 15 | The virtual machine (VM) is based on a fast interpreter combined with 16 | a trace compiler. It can significantly improve the performance of Lua programs. 17 | .PP 18 | \fBLuaJIT\fR is API\- and ABI-compatible with the VM of the standard 19 | Lua\ 5.1 interpreter. When embedding the VM into an application, 20 | the built library can be used as a drop-in replacement. 21 | .SH OPTIONS 22 | .TP 23 | .BI "\-e " chunk 24 | Run the given chunk of Lua code. 25 | .TP 26 | .BI "\-l " library 27 | Load the named library, just like \fBrequire("\fR\fIlibrary\fR\fB")\fR. 28 | .TP 29 | .BI "\-b " ... 30 | Save or list bytecode. Run without arguments to get help on options. 31 | .TP 32 | .BI "\-j " command 33 | Perform LuaJIT control command (optional space after \fB\-j\fR). 34 | .TP 35 | .BI "\-O" [opt] 36 | Control LuaJIT optimizations. 37 | .TP 38 | .B "\-i" 39 | Run in interactive mode. 40 | .TP 41 | .B "\-v" 42 | Show \fBLuaJIT\fR version. 43 | .TP 44 | .B "\-E" 45 | Ignore environment variables. 46 | .TP 47 | .B "\-\-" 48 | Stop processing options. 49 | .TP 50 | .B "\-" 51 | Read script from stdin instead. 52 | .PP 53 | After all options are processed, the given \fIscript\fR is run. 54 | The arguments are passed in the global \fIarg\fR table. 55 | .PP 56 | Interactive mode is only entered, if no \fIscript\fR and no \fB\-e\fR 57 | option is given. Interactive mode can be left with EOF (\fICtrl\-Z\fB). 58 | .SH EXAMPLES 59 | .TP 60 | luajit hello.lua world 61 | 62 | Prints "Hello world", assuming \fIhello.lua\fR contains: 63 | .br 64 | print("Hello", arg[1]) 65 | .TP 66 | luajit \-e "local x=0; for i=1,1e9 do x=x+i end; print(x)" 67 | 68 | Calculates the sum of the numbers from 1 to 1000000000. 69 | .br 70 | And finishes in a reasonable amount of time, too. 71 | .TP 72 | luajit \-jv \-e "for i=1,10 do for j=1,10 do for k=1,100 do end end end" 73 | 74 | Runs some nested loops and shows the resulting traces. 75 | .SH COPYRIGHT 76 | .PP 77 | \fBLuaJIT\fR is Copyright \(co 2005-2013 Mike Pall. 78 | .br 79 | \fBLuaJIT\fR is open source software, released under the MIT license. 80 | .SH SEE ALSO 81 | .PP 82 | More details in the provided HTML docs or at: 83 | .IR http://luajit.org 84 | .br 85 | More about the Lua language can be found at: 86 | .IR http://lua.org/docs.html 87 | .PP 88 | lua(1) 89 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/etc/luajit.pc: -------------------------------------------------------------------------------- 1 | # Package information for LuaJIT to be used by pkg-config. 2 | majver=2 3 | minver=0 4 | relver=2 5 | version=${majver}.${minver}.${relver} 6 | abiver=5.1 7 | 8 | prefix=/usr/local 9 | exec_prefix=${prefix} 10 | libdir=${exec_prefix}/lib 11 | libname=luajit-${abiver} 12 | includedir=${prefix}/include/luajit-${majver}.${minver} 13 | 14 | INSTALL_LMOD=${prefix}/share/lua/${abiver} 15 | INSTALL_CMOD=${prefix}/lib/lua/${abiver} 16 | 17 | Name: LuaJIT 18 | Description: Just-in-time compiler for Lua 19 | URL: http://luajit.org 20 | Version: ${version} 21 | Requires: 22 | Libs: -L${libdir} -l${libname} 23 | Libs.private: -Wl,-E -lm -ldl 24 | Cflags: -I${includedir} 25 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/host/README: -------------------------------------------------------------------------------- 1 | The files in this directory are only used during the build process of LuaJIT. 2 | For cross-compilation, they must be executed on the host, not on the target. 3 | 4 | These files should NOT be installed! 5 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/host/buildvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** LuaJIT VM builder. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _BUILDVM_H 7 | #define _BUILDVM_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "lj_def.h" 16 | #include "lj_arch.h" 17 | 18 | /* Hardcoded limits. Increase as needed. */ 19 | #define BUILD_MAX_RELOC 200 /* Max. number of relocations. */ 20 | #define BUILD_MAX_FOLD 4096 /* Max. number of fold rules. */ 21 | 22 | /* Prefix for scanned library definitions. */ 23 | #define LIBDEF_PREFIX "LJLIB_" 24 | 25 | /* Prefix for scanned fold definitions. */ 26 | #define FOLDDEF_PREFIX "LJFOLD" 27 | 28 | /* Prefixes for generated labels. */ 29 | #define LABEL_PREFIX "lj_" 30 | #define LABEL_PREFIX_BC LABEL_PREFIX "BC_" 31 | #define LABEL_PREFIX_FF LABEL_PREFIX "ff_" 32 | #define LABEL_PREFIX_CF LABEL_PREFIX "cf_" 33 | #define LABEL_PREFIX_FFH LABEL_PREFIX "ffh_" 34 | #define LABEL_PREFIX_LIBCF LABEL_PREFIX "lib_cf_" 35 | #define LABEL_PREFIX_LIBINIT LABEL_PREFIX "lib_init_" 36 | 37 | /* Forward declaration. */ 38 | struct dasm_State; 39 | 40 | /* Build modes. */ 41 | #define BUILDDEF(_) \ 42 | _(elfasm) _(coffasm) _(machasm) _(peobj) _(raw) \ 43 | _(bcdef) _(ffdef) _(libdef) _(recdef) _(vmdef) \ 44 | _(folddef) 45 | 46 | typedef enum { 47 | #define BUILDENUM(name) BUILD_##name, 48 | BUILDDEF(BUILDENUM) 49 | #undef BUILDENUM 50 | BUILD__MAX 51 | } BuildMode; 52 | 53 | /* Code relocation. */ 54 | typedef struct BuildReloc { 55 | int32_t ofs; 56 | int sym; 57 | int type; 58 | } BuildReloc; 59 | 60 | typedef struct BuildSym { 61 | const char *name; 62 | int32_t ofs; 63 | } BuildSym; 64 | 65 | /* Build context structure. */ 66 | typedef struct BuildCtx { 67 | /* DynASM state pointer. Should be first member. */ 68 | struct dasm_State *D; 69 | /* Parsed command line. */ 70 | BuildMode mode; 71 | FILE *fp; 72 | const char *outname; 73 | char **args; 74 | /* Code and symbols generated by DynASM. */ 75 | uint8_t *code; 76 | size_t codesz; 77 | int npc, nglob, nsym, nreloc, nrelocsym; 78 | void **glob; 79 | BuildSym *sym; 80 | const char **relocsym; 81 | int32_t *bc_ofs; 82 | const char *beginsym; 83 | /* Strings generated by DynASM. */ 84 | const char *const *globnames; 85 | const char *dasm_ident; 86 | const char *dasm_arch; 87 | /* Relocations. */ 88 | BuildReloc reloc[BUILD_MAX_RELOC]; 89 | } BuildCtx; 90 | 91 | extern void owrite(BuildCtx *ctx, const void *ptr, size_t sz); 92 | extern void emit_asm(BuildCtx *ctx); 93 | extern void emit_peobj(BuildCtx *ctx); 94 | extern void emit_lib(BuildCtx *ctx); 95 | extern void emit_fold(BuildCtx *ctx); 96 | 97 | extern const char *const bc_names[]; 98 | extern const char *const ir_names[]; 99 | extern const char *const irt_names[]; 100 | extern const char *const irfpm_names[]; 101 | extern const char *const irfield_names[]; 102 | extern const char *const ircall_names[]; 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/jit/bc.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT bytecode listing module. 3 | -- 4 | -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- 8 | -- This module lists the bytecode of a Lua function. If it's loaded by -jbc 9 | -- it hooks into the parser and lists all functions of a chunk as they 10 | -- are parsed. 11 | -- 12 | -- Example usage: 13 | -- 14 | -- luajit -jbc -e 'local x=0; for i=1,1e6 do x=x+i end; print(x)' 15 | -- luajit -jbc=- foo.lua 16 | -- luajit -jbc=foo.list foo.lua 17 | -- 18 | -- Default output is to stderr. To redirect the output to a file, pass a 19 | -- filename as an argument (use '-' for stdout) or set the environment 20 | -- variable LUAJIT_LISTFILE. The file is overwritten every time the module 21 | -- is started. 22 | -- 23 | -- This module can also be used programmatically: 24 | -- 25 | -- local bc = require("jit.bc") 26 | -- 27 | -- local function foo() print("hello") end 28 | -- 29 | -- bc.dump(foo) --> -- BYTECODE -- [...] 30 | -- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello" 31 | -- 32 | -- local out = { 33 | -- -- Do something with each line: 34 | -- write = function(t, ...) io.write(...) end, 35 | -- close = function(t) end, 36 | -- flush = function(t) end, 37 | -- } 38 | -- bc.dump(foo, out) 39 | -- 40 | ------------------------------------------------------------------------------ 41 | 42 | -- Cache some library functions and objects. 43 | local jit = require("jit") 44 | assert(jit.version_num == 20002, "LuaJIT core/library version mismatch") 45 | local jutil = require("jit.util") 46 | local vmdef = require("jit.vmdef") 47 | local bit = require("bit") 48 | local sub, gsub, format = string.sub, string.gsub, string.format 49 | local byte, band, shr = string.byte, bit.band, bit.rshift 50 | local funcinfo, funcbc, funck = jutil.funcinfo, jutil.funcbc, jutil.funck 51 | local funcuvname = jutil.funcuvname 52 | local bcnames = vmdef.bcnames 53 | local stdout, stderr = io.stdout, io.stderr 54 | 55 | ------------------------------------------------------------------------------ 56 | 57 | local function ctlsub(c) 58 | if c == "\n" then return "\\n" 59 | elseif c == "\r" then return "\\r" 60 | elseif c == "\t" then return "\\t" 61 | else return format("\\%03d", byte(c)) 62 | end 63 | end 64 | 65 | -- Return one bytecode line. 66 | local function bcline(func, pc, prefix) 67 | local ins, m = funcbc(func, pc) 68 | if not ins then return end 69 | local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128) 70 | local a = band(shr(ins, 8), 0xff) 71 | local oidx = 6*band(ins, 0xff) 72 | local op = sub(bcnames, oidx+1, oidx+6) 73 | local s = format("%04d %s %-6s %3s ", 74 | pc, prefix or " ", op, ma == 0 and "" or a) 75 | local d = shr(ins, 16) 76 | if mc == 13*128 then -- BCMjump 77 | return format("%s=> %04d\n", s, pc+d-0x7fff) 78 | end 79 | if mb ~= 0 then 80 | d = band(d, 0xff) 81 | elseif mc == 0 then 82 | return s.."\n" 83 | end 84 | local kc 85 | if mc == 10*128 then -- BCMstr 86 | kc = funck(func, -d-1) 87 | kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub)) 88 | elseif mc == 9*128 then -- BCMnum 89 | kc = funck(func, d) 90 | if op == "TSETM " then kc = kc - 2^52 end 91 | elseif mc == 12*128 then -- BCMfunc 92 | local fi = funcinfo(funck(func, -d-1)) 93 | if fi.ffid then 94 | kc = vmdef.ffnames[fi.ffid] 95 | else 96 | kc = fi.loc 97 | end 98 | elseif mc == 5*128 then -- BCMuv 99 | kc = funcuvname(func, d) 100 | end 101 | if ma == 5 then -- BCMuv 102 | local ka = funcuvname(func, a) 103 | if kc then kc = ka.." ; "..kc else kc = ka end 104 | end 105 | if mb ~= 0 then 106 | local b = shr(ins, 24) 107 | if kc then return format("%s%3d %3d ; %s\n", s, b, d, kc) end 108 | return format("%s%3d %3d\n", s, b, d) 109 | end 110 | if kc then return format("%s%3d ; %s\n", s, d, kc) end 111 | if mc == 7*128 and d > 32767 then d = d - 65536 end -- BCMlits 112 | return format("%s%3d\n", s, d) 113 | end 114 | 115 | -- Collect branch targets of a function. 116 | local function bctargets(func) 117 | local target = {} 118 | for pc=1,1000000000 do 119 | local ins, m = funcbc(func, pc) 120 | if not ins then break end 121 | if band(m, 15*128) == 13*128 then target[pc+shr(ins, 16)-0x7fff] = true end 122 | end 123 | return target 124 | end 125 | 126 | -- Dump bytecode instructions of a function. 127 | local function bcdump(func, out, all) 128 | if not out then out = stdout end 129 | local fi = funcinfo(func) 130 | if all and fi.children then 131 | for n=-1,-1000000000,-1 do 132 | local k = funck(func, n) 133 | if not k then break end 134 | if type(k) == "proto" then bcdump(k, out, true) end 135 | end 136 | end 137 | out:write(format("-- BYTECODE -- %s-%d\n", fi.loc, fi.lastlinedefined)) 138 | local target = bctargets(func) 139 | for pc=1,1000000000 do 140 | local s = bcline(func, pc, target[pc] and "=>") 141 | if not s then break end 142 | out:write(s) 143 | end 144 | out:write("\n") 145 | out:flush() 146 | end 147 | 148 | ------------------------------------------------------------------------------ 149 | 150 | -- Active flag and output file handle. 151 | local active, out 152 | 153 | -- List handler. 154 | local function h_list(func) 155 | return bcdump(func, out) 156 | end 157 | 158 | -- Detach list handler. 159 | local function bclistoff() 160 | if active then 161 | active = false 162 | jit.attach(h_list) 163 | if out and out ~= stdout and out ~= stderr then out:close() end 164 | out = nil 165 | end 166 | end 167 | 168 | -- Open the output file and attach list handler. 169 | local function bcliston(outfile) 170 | if active then bclistoff() end 171 | if not outfile then outfile = os.getenv("LUAJIT_LISTFILE") end 172 | if outfile then 173 | out = outfile == "-" and stdout or assert(io.open(outfile, "w")) 174 | else 175 | out = stderr 176 | end 177 | jit.attach(h_list, "bc") 178 | active = true 179 | end 180 | 181 | -- Public module functions. 182 | module(...) 183 | 184 | line = bcline 185 | dump = bcdump 186 | targets = bctargets 187 | 188 | on = bcliston 189 | off = bclistoff 190 | start = bcliston -- For -j command line option. 191 | 192 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/jit/dis_mipsel.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPSEL disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the little-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local require = require 12 | 13 | module(...) 14 | 15 | local dis_mips = require(_PACKAGE.."dis_mips") 16 | 17 | create = dis_mips.create_el 18 | disass = dis_mips.disass_el 19 | regname = dis_mips.regname 20 | 21 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/jit/dis_x64.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT x64 disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the 64 bit functions from the combined 8 | -- x86/x64 disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local require = require 12 | 13 | module(...) 14 | 15 | local dis_x86 = require(_PACKAGE.."dis_x86") 16 | 17 | create = dis_x86.create64 18 | disass = dis_x86.disass64 19 | regname = dis_x86.regname64 20 | 21 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/jit/v.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- Verbose mode of the LuaJIT compiler. 3 | -- 4 | -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- 8 | -- This module shows verbose information about the progress of the 9 | -- JIT compiler. It prints one line for each generated trace. This module 10 | -- is useful to see which code has been compiled or where the compiler 11 | -- punts and falls back to the interpreter. 12 | -- 13 | -- Example usage: 14 | -- 15 | -- luajit -jv -e "for i=1,1000 do for j=1,1000 do end end" 16 | -- luajit -jv=myapp.out myapp.lua 17 | -- 18 | -- Default output is to stderr. To redirect the output to a file, pass a 19 | -- filename as an argument (use '-' for stdout) or set the environment 20 | -- variable LUAJIT_VERBOSEFILE. The file is overwritten every time the 21 | -- module is started. 22 | -- 23 | -- The output from the first example should look like this: 24 | -- 25 | -- [TRACE 1 (command line):1 loop] 26 | -- [TRACE 2 (1/3) (command line):1 -> 1] 27 | -- 28 | -- The first number in each line is the internal trace number. Next are 29 | -- the file name ('(command line)') and the line number (':1') where the 30 | -- trace has started. Side traces also show the parent trace number and 31 | -- the exit number where they are attached to in parentheses ('(1/3)'). 32 | -- An arrow at the end shows where the trace links to ('-> 1'), unless 33 | -- it loops to itself. 34 | -- 35 | -- In this case the inner loop gets hot and is traced first, generating 36 | -- a root trace. Then the last exit from the 1st trace gets hot, too, 37 | -- and triggers generation of the 2nd trace. The side trace follows the 38 | -- path along the outer loop and *around* the inner loop, back to its 39 | -- start, and then links to the 1st trace. Yes, this may seem unusual, 40 | -- if you know how traditional compilers work. Trace compilers are full 41 | -- of surprises like this -- have fun! :-) 42 | -- 43 | -- Aborted traces are shown like this: 44 | -- 45 | -- [TRACE --- foo.lua:44 -- leaving loop in root trace at foo:lua:50] 46 | -- 47 | -- Don't worry -- trace aborts are quite common, even in programs which 48 | -- can be fully compiled. The compiler may retry several times until it 49 | -- finds a suitable trace. 50 | -- 51 | -- Of course this doesn't work with features that are not-yet-implemented 52 | -- (NYI error messages). The VM simply falls back to the interpreter. This 53 | -- may not matter at all if the particular trace is not very high up in 54 | -- the CPU usage profile. Oh, and the interpreter is quite fast, too. 55 | -- 56 | -- Also check out the -jdump module, which prints all the gory details. 57 | -- 58 | ------------------------------------------------------------------------------ 59 | 60 | -- Cache some library functions and objects. 61 | local jit = require("jit") 62 | assert(jit.version_num == 20002, "LuaJIT core/library version mismatch") 63 | local jutil = require("jit.util") 64 | local vmdef = require("jit.vmdef") 65 | local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo 66 | local type, format = type, string.format 67 | local stdout, stderr = io.stdout, io.stderr 68 | 69 | -- Active flag and output file handle. 70 | local active, out 71 | 72 | ------------------------------------------------------------------------------ 73 | 74 | local startloc, startex 75 | 76 | local function fmtfunc(func, pc) 77 | local fi = funcinfo(func, pc) 78 | if fi.loc then 79 | return fi.loc 80 | elseif fi.ffid then 81 | return vmdef.ffnames[fi.ffid] 82 | elseif fi.addr then 83 | return format("C:%x", fi.addr) 84 | else 85 | return "(?)" 86 | end 87 | end 88 | 89 | -- Format trace error message. 90 | local function fmterr(err, info) 91 | if type(err) == "number" then 92 | if type(info) == "function" then info = fmtfunc(info) end 93 | err = format(vmdef.traceerr[err], info) 94 | end 95 | return err 96 | end 97 | 98 | -- Dump trace states. 99 | local function dump_trace(what, tr, func, pc, otr, oex) 100 | if what == "start" then 101 | startloc = fmtfunc(func, pc) 102 | startex = otr and "("..otr.."/"..oex..") " or "" 103 | else 104 | if what == "abort" then 105 | local loc = fmtfunc(func, pc) 106 | if loc ~= startloc then 107 | out:write(format("[TRACE --- %s%s -- %s at %s]\n", 108 | startex, startloc, fmterr(otr, oex), loc)) 109 | else 110 | out:write(format("[TRACE --- %s%s -- %s]\n", 111 | startex, startloc, fmterr(otr, oex))) 112 | end 113 | elseif what == "stop" then 114 | local info = traceinfo(tr) 115 | local link, ltype = info.link, info.linktype 116 | if ltype == "interpreter" then 117 | out:write(format("[TRACE %3s %s%s -- fallback to interpreter]\n", 118 | tr, startex, startloc)) 119 | elseif link == tr or link == 0 then 120 | out:write(format("[TRACE %3s %s%s %s]\n", 121 | tr, startex, startloc, ltype)) 122 | elseif ltype == "root" then 123 | out:write(format("[TRACE %3s %s%s -> %d]\n", 124 | tr, startex, startloc, link)) 125 | else 126 | out:write(format("[TRACE %3s %s%s -> %d %s]\n", 127 | tr, startex, startloc, link, ltype)) 128 | end 129 | else 130 | out:write(format("[TRACE %s]\n", what)) 131 | end 132 | out:flush() 133 | end 134 | end 135 | 136 | ------------------------------------------------------------------------------ 137 | 138 | -- Detach dump handlers. 139 | local function dumpoff() 140 | if active then 141 | active = false 142 | jit.attach(dump_trace) 143 | if out and out ~= stdout and out ~= stderr then out:close() end 144 | out = nil 145 | end 146 | end 147 | 148 | -- Open the output file and attach dump handlers. 149 | local function dumpon(outfile) 150 | if active then dumpoff() end 151 | if not outfile then outfile = os.getenv("LUAJIT_VERBOSEFILE") end 152 | if outfile then 153 | out = outfile == "-" and stdout or assert(io.open(outfile, "w")) 154 | else 155 | out = stderr 156 | end 157 | jit.attach(dump_trace, "trace") 158 | active = true 159 | end 160 | 161 | -- Public module functions. 162 | module(...) 163 | 164 | on = dumpon 165 | off = dumpoff 166 | start = dumpon -- For -j command line option. 167 | 168 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lib_bit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bit manipulation library. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lib_bit_c 7 | #define LUA_LIB 8 | 9 | #include "lua.h" 10 | #include "lauxlib.h" 11 | #include "lualib.h" 12 | 13 | #include "lj_obj.h" 14 | #include "lj_err.h" 15 | #include "lj_str.h" 16 | #include "lj_lib.h" 17 | 18 | /* ------------------------------------------------------------------------ */ 19 | 20 | #define LJLIB_MODULE_bit 21 | 22 | LJLIB_ASM(bit_tobit) LJLIB_REC(bit_unary IR_TOBIT) 23 | { 24 | lj_lib_checknumber(L, 1); 25 | return FFH_RETRY; 26 | } 27 | LJLIB_ASM_(bit_bnot) LJLIB_REC(bit_unary IR_BNOT) 28 | LJLIB_ASM_(bit_bswap) LJLIB_REC(bit_unary IR_BSWAP) 29 | 30 | LJLIB_ASM(bit_lshift) LJLIB_REC(bit_shift IR_BSHL) 31 | { 32 | lj_lib_checknumber(L, 1); 33 | lj_lib_checkbit(L, 2); 34 | return FFH_RETRY; 35 | } 36 | LJLIB_ASM_(bit_rshift) LJLIB_REC(bit_shift IR_BSHR) 37 | LJLIB_ASM_(bit_arshift) LJLIB_REC(bit_shift IR_BSAR) 38 | LJLIB_ASM_(bit_rol) LJLIB_REC(bit_shift IR_BROL) 39 | LJLIB_ASM_(bit_ror) LJLIB_REC(bit_shift IR_BROR) 40 | 41 | LJLIB_ASM(bit_band) LJLIB_REC(bit_nary IR_BAND) 42 | { 43 | int i = 0; 44 | do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top); 45 | return FFH_RETRY; 46 | } 47 | LJLIB_ASM_(bit_bor) LJLIB_REC(bit_nary IR_BOR) 48 | LJLIB_ASM_(bit_bxor) LJLIB_REC(bit_nary IR_BXOR) 49 | 50 | /* ------------------------------------------------------------------------ */ 51 | 52 | LJLIB_CF(bit_tohex) 53 | { 54 | uint32_t b = (uint32_t)lj_lib_checkbit(L, 1); 55 | int32_t i, n = L->base+1 >= L->top ? 8 : lj_lib_checkbit(L, 2); 56 | const char *hexdigits = "0123456789abcdef"; 57 | char buf[8]; 58 | if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; } 59 | if (n > 8) n = 8; 60 | for (i = n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; } 61 | lua_pushlstring(L, buf, (size_t)n); 62 | return 1; 63 | } 64 | 65 | /* ------------------------------------------------------------------------ */ 66 | 67 | #include "lj_libdef.h" 68 | 69 | LUALIB_API int luaopen_bit(lua_State *L) 70 | { 71 | LJ_LIB_REG(L, LUA_BITLIBNAME, bit); 72 | return 1; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lib_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Library initialization. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | ** 5 | ** Major parts taken verbatim from the Lua interpreter. 6 | ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h 7 | */ 8 | 9 | #define lib_init_c 10 | #define LUA_LIB 11 | 12 | #include "lua.h" 13 | #include "lauxlib.h" 14 | #include "lualib.h" 15 | 16 | #include "lj_arch.h" 17 | 18 | static const luaL_Reg lj_lib_load[] = { 19 | { "", luaopen_base }, 20 | { LUA_LOADLIBNAME, luaopen_package }, 21 | { LUA_TABLIBNAME, luaopen_table }, 22 | { LUA_IOLIBNAME, luaopen_io }, 23 | { LUA_OSLIBNAME, luaopen_os }, 24 | { LUA_STRLIBNAME, luaopen_string }, 25 | { LUA_MATHLIBNAME, luaopen_math }, 26 | { LUA_DBLIBNAME, luaopen_debug }, 27 | { LUA_BITLIBNAME, luaopen_bit }, 28 | { LUA_JITLIBNAME, luaopen_jit }, 29 | { NULL, NULL } 30 | }; 31 | 32 | static const luaL_Reg lj_lib_preload[] = { 33 | #if LJ_HASFFI 34 | { LUA_FFILIBNAME, luaopen_ffi }, 35 | #endif 36 | { NULL, NULL } 37 | }; 38 | 39 | LUALIB_API void luaL_openlibs(lua_State *L) 40 | { 41 | const luaL_Reg *lib; 42 | for (lib = lj_lib_load; lib->func; lib++) { 43 | lua_pushcfunction(L, lib->func); 44 | lua_pushstring(L, lib->name); 45 | lua_call(L, 1, 0); 46 | } 47 | luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", 48 | sizeof(lj_lib_preload)/sizeof(lj_lib_preload[0])-1); 49 | for (lib = lj_lib_preload; lib->func; lib++) { 50 | lua_pushcfunction(L, lib->func); 51 | lua_setfield(L, -2, lib->name); 52 | } 53 | lua_pop(L, 1); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj.supp: -------------------------------------------------------------------------------- 1 | # Valgrind suppression file for LuaJIT 2.0. 2 | { 3 | Optimized string compare 4 | Memcheck:Addr4 5 | fun:lj_str_cmp 6 | } 7 | { 8 | Optimized string compare 9 | Memcheck:Addr1 10 | fun:lj_str_cmp 11 | } 12 | { 13 | Optimized string compare 14 | Memcheck:Addr4 15 | fun:lj_str_new 16 | } 17 | { 18 | Optimized string compare 19 | Memcheck:Addr1 20 | fun:lj_str_new 21 | } 22 | { 23 | Optimized string compare 24 | Memcheck:Cond 25 | fun:lj_str_new 26 | } 27 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bundled memory allocator. 3 | ** Donated to the public domain. 4 | */ 5 | 6 | #ifndef _LJ_ALLOC_H 7 | #define _LJ_ALLOC_H 8 | 9 | #include "lj_def.h" 10 | 11 | #ifndef LUAJIT_USE_SYSMALLOC 12 | LJ_FUNC void *lj_alloc_create(void); 13 | LJ_FUNC void lj_alloc_destroy(void *msp); 14 | LJ_FUNC void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize); 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_asm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** IR assembler (SSA IR -> machine code). 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_ASM_H 7 | #define _LJ_ASM_H 8 | 9 | #include "lj_jit.h" 10 | 11 | #if LJ_HASJIT 12 | LJ_FUNC void lj_asm_trace(jit_State *J, GCtrace *T); 13 | LJ_FUNC void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, 14 | MCode *target); 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_bc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bytecode instruction modes. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_bc_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | #include "lj_bc.h" 11 | 12 | /* Bytecode offsets and bytecode instruction modes. */ 13 | #include "lj_bcdef.h" 14 | 15 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_bcdef.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file. DO NOT EDIT! */ 2 | 3 | LJ_DATADEF const uint16_t lj_bc_ofs[] = { 4 | 0, 5 | 65, 6 | 130, 7 | 195, 8 | 260, 9 | 387, 10 | 517, 11 | 577, 12 | 637, 13 | 701, 14 | 765, 15 | 816, 16 | 866, 17 | 916, 18 | 966, 19 | 1006, 20 | 1046, 21 | 1077, 22 | 1108, 23 | 1144, 24 | 1212, 25 | 1255, 26 | 1298, 27 | 1341, 28 | 1384, 29 | 1432, 30 | 1475, 31 | 1518, 32 | 1561, 33 | 1604, 34 | 1632, 35 | 1686, 36 | 1740, 37 | 1794, 38 | 1848, 39 | 1887, 40 | 1946, 41 | 2034, 42 | 2067, 43 | 2100, 44 | 2123, 45 | 2146, 46 | 2169, 47 | 2211, 48 | 2251, 49 | 2334, 50 | 2412, 51 | 2444, 52 | 2476, 53 | 2526, 54 | 2596, 55 | 2709, 56 | 2796, 57 | 2812, 58 | 2828, 59 | 2976, 60 | 3102, 61 | 3205, 62 | 3376, 63 | 3615, 64 | 3741, 65 | 3883, 66 | 3928, 67 | 3969, 68 | 3973, 69 | 4119, 70 | 4194, 71 | 4364, 72 | 4552, 73 | 4639, 74 | 4643, 75 | 4772, 76 | 4859, 77 | 4964, 78 | 5041, 79 | 5126, 80 | 5145, 81 | 5200, 82 | 5252, 83 | 5271, 84 | 5314, 85 | 5352, 86 | 5371, 87 | 5388, 88 | 5418, 89 | 5442, 90 | 5461, 91 | 5522, 92 | 5575, 93 | 5575, 94 | 5692, 95 | 5693, 96 | 5769, 97 | 7416, 98 | 7487, 99 | 7961, 100 | 8081, 101 | 8138, 102 | 8253, 103 | 7536, 104 | 7678, 105 | 7768, 106 | 7835, 107 | 7861, 108 | 8308, 109 | 8348, 110 | 8980, 111 | 8403, 112 | 8719, 113 | 9022, 114 | 9122, 115 | 9141, 116 | 9160, 117 | 9218, 118 | 9248, 119 | 9279, 120 | 9307, 121 | 9335, 122 | 9365, 123 | 9403, 124 | 9443, 125 | 9473, 126 | 9511, 127 | 9549, 128 | 9703, 129 | 9838, 130 | 9188, 131 | 9587, 132 | 9587, 133 | 9619, 134 | 9974, 135 | 9926, 136 | 9660, 137 | 10018, 138 | 10065, 139 | 10972, 140 | 11297, 141 | 11254, 142 | 11358, 143 | 11426, 144 | 11497, 145 | 11568, 146 | 11639, 147 | 11016, 148 | 11098, 149 | 11180, 150 | 10119, 151 | 10148, 152 | 10199, 153 | 10313, 154 | 10478, 155 | 10603, 156 | 10709, 157 | 10820, 158 | 10931 159 | }; 160 | 161 | LJ_DATADEF const uint16_t lj_bc_mode[] = { 162 | BCDEF(BCMODE) 163 | BCMODE_FF, 164 | BCMODE_FF, 165 | BCMODE_FF, 166 | BCMODE_FF, 167 | BCMODE_FF, 168 | BCMODE_FF, 169 | BCMODE_FF, 170 | BCMODE_FF, 171 | BCMODE_FF, 172 | BCMODE_FF, 173 | BCMODE_FF, 174 | BCMODE_FF, 175 | BCMODE_FF, 176 | BCMODE_FF, 177 | BCMODE_FF, 178 | BCMODE_FF, 179 | BCMODE_FF, 180 | BCMODE_FF, 181 | BCMODE_FF, 182 | BCMODE_FF, 183 | BCMODE_FF, 184 | BCMODE_FF, 185 | BCMODE_FF, 186 | BCMODE_FF, 187 | BCMODE_FF, 188 | BCMODE_FF, 189 | BCMODE_FF, 190 | BCMODE_FF, 191 | BCMODE_FF, 192 | BCMODE_FF, 193 | BCMODE_FF, 194 | BCMODE_FF, 195 | BCMODE_FF, 196 | BCMODE_FF, 197 | BCMODE_FF, 198 | BCMODE_FF, 199 | BCMODE_FF, 200 | BCMODE_FF, 201 | BCMODE_FF, 202 | BCMODE_FF, 203 | BCMODE_FF, 204 | BCMODE_FF, 205 | BCMODE_FF, 206 | BCMODE_FF, 207 | BCMODE_FF, 208 | BCMODE_FF, 209 | BCMODE_FF, 210 | BCMODE_FF, 211 | BCMODE_FF, 212 | BCMODE_FF, 213 | BCMODE_FF, 214 | BCMODE_FF, 215 | BCMODE_FF, 216 | BCMODE_FF, 217 | BCMODE_FF, 218 | BCMODE_FF, 219 | BCMODE_FF, 220 | BCMODE_FF, 221 | BCMODE_FF, 222 | BCMODE_FF, 223 | BCMODE_FF, 224 | BCMODE_FF 225 | }; 226 | 227 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_bcdump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bytecode dump definitions. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_BCDUMP_H 7 | #define _LJ_BCDUMP_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_lex.h" 11 | 12 | /* -- Bytecode dump format ------------------------------------------------ */ 13 | 14 | /* 15 | ** dump = header proto+ 0U 16 | ** header = ESC 'L' 'J' versionB flagsU [namelenU nameB*] 17 | ** proto = lengthU pdata 18 | ** pdata = phead bcinsW* uvdataH* kgc* knum* [debugB*] 19 | ** phead = flagsB numparamsB framesizeB numuvB numkgcU numknU numbcU 20 | ** [debuglenU [firstlineU numlineU]] 21 | ** kgc = kgctypeU { ktab | (loU hiU) | (rloU rhiU iloU ihiU) | strB* } 22 | ** knum = intU0 | (loU1 hiU) 23 | ** ktab = narrayU nhashU karray* khash* 24 | ** karray = ktabk 25 | ** khash = ktabk ktabk 26 | ** ktabk = ktabtypeU { intU | (loU hiU) | strB* } 27 | ** 28 | ** B = 8 bit, H = 16 bit, W = 32 bit, U = ULEB128 of W, U0/U1 = ULEB128 of W+1 29 | */ 30 | 31 | /* Bytecode dump header. */ 32 | #define BCDUMP_HEAD1 0x1b 33 | #define BCDUMP_HEAD2 0x4c 34 | #define BCDUMP_HEAD3 0x4a 35 | 36 | /* If you perform *any* kind of private modifications to the bytecode itself 37 | ** or to the dump format, you *must* set BCDUMP_VERSION to 0x80 or higher. 38 | */ 39 | #define BCDUMP_VERSION 1 40 | 41 | /* Compatibility flags. */ 42 | #define BCDUMP_F_BE 0x01 43 | #define BCDUMP_F_STRIP 0x02 44 | #define BCDUMP_F_FFI 0x04 45 | 46 | #define BCDUMP_F_KNOWN (BCDUMP_F_FFI*2-1) 47 | 48 | /* Type codes for the GC constants of a prototype. Plus length for strings. */ 49 | enum { 50 | BCDUMP_KGC_CHILD, BCDUMP_KGC_TAB, BCDUMP_KGC_I64, BCDUMP_KGC_U64, 51 | BCDUMP_KGC_COMPLEX, BCDUMP_KGC_STR 52 | }; 53 | 54 | /* Type codes for the keys/values of a constant table. */ 55 | enum { 56 | BCDUMP_KTAB_NIL, BCDUMP_KTAB_FALSE, BCDUMP_KTAB_TRUE, 57 | BCDUMP_KTAB_INT, BCDUMP_KTAB_NUM, BCDUMP_KTAB_STR 58 | }; 59 | 60 | /* -- Bytecode reader/writer ---------------------------------------------- */ 61 | 62 | LJ_FUNC int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, 63 | void *data, int strip); 64 | LJ_FUNC GCproto *lj_bcread(LexState *ls); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_carith.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C data arithmetic. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CARITH_H 7 | #define _LJ_CARITH_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASFFI 12 | 13 | LJ_FUNC int lj_carith_op(lua_State *L, MMS mm); 14 | 15 | #if LJ_32 && LJ_HASJIT 16 | LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k); 17 | #endif 18 | LJ_FUNC uint64_t lj_carith_divu64(uint64_t a, uint64_t b); 19 | LJ_FUNC int64_t lj_carith_divi64(int64_t a, int64_t b); 20 | LJ_FUNC uint64_t lj_carith_modu64(uint64_t a, uint64_t b); 21 | LJ_FUNC int64_t lj_carith_modi64(int64_t a, int64_t b); 22 | LJ_FUNC uint64_t lj_carith_powu64(uint64_t x, uint64_t k); 23 | LJ_FUNC int64_t lj_carith_powi64(int64_t x, int64_t k); 24 | 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_ccall.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C call handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CCALL_H 7 | #define _LJ_CCALL_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_ctype.h" 11 | 12 | #if LJ_HASFFI 13 | 14 | /* -- C calling conventions ----------------------------------------------- */ 15 | 16 | #if LJ_TARGET_X86ORX64 17 | 18 | #if LJ_TARGET_X86 19 | #define CCALL_NARG_GPR 2 /* For fastcall arguments. */ 20 | #define CCALL_NARG_FPR 0 21 | #define CCALL_NRET_GPR 2 22 | #define CCALL_NRET_FPR 1 /* For FP results on x87 stack. */ 23 | #define CCALL_ALIGN_STACKARG 0 /* Don't align argument on stack. */ 24 | #elif LJ_ABI_WIN 25 | #define CCALL_NARG_GPR 4 26 | #define CCALL_NARG_FPR 4 27 | #define CCALL_NRET_GPR 1 28 | #define CCALL_NRET_FPR 1 29 | #define CCALL_SPS_EXTRA 4 30 | #else 31 | #define CCALL_NARG_GPR 6 32 | #define CCALL_NARG_FPR 8 33 | #define CCALL_NRET_GPR 2 34 | #define CCALL_NRET_FPR 2 35 | #define CCALL_VECTOR_REG 1 /* Pass vectors in registers. */ 36 | #endif 37 | 38 | #define CCALL_SPS_FREE 1 39 | #define CCALL_ALIGN_CALLSTATE 16 40 | 41 | typedef LJ_ALIGN(16) union FPRArg { 42 | double d[2]; 43 | float f[4]; 44 | uint8_t b[16]; 45 | uint16_t s[8]; 46 | int i[4]; 47 | int64_t l[2]; 48 | } FPRArg; 49 | 50 | typedef intptr_t GPRArg; 51 | 52 | #elif LJ_TARGET_ARM 53 | 54 | #define CCALL_NARG_GPR 4 55 | #define CCALL_NRET_GPR 2 /* For softfp double. */ 56 | #if LJ_ABI_SOFTFP 57 | #define CCALL_NARG_FPR 0 58 | #define CCALL_NRET_FPR 0 59 | #else 60 | #define CCALL_NARG_FPR 8 61 | #define CCALL_NRET_FPR 4 62 | #endif 63 | #define CCALL_SPS_FREE 0 64 | 65 | typedef intptr_t GPRArg; 66 | typedef union FPRArg { 67 | double d; 68 | float f[2]; 69 | } FPRArg; 70 | 71 | #elif LJ_TARGET_PPC 72 | 73 | #define CCALL_NARG_GPR 8 74 | #define CCALL_NARG_FPR 8 75 | #define CCALL_NRET_GPR 4 /* For complex double. */ 76 | #define CCALL_NRET_FPR 1 77 | #define CCALL_SPS_EXTRA 4 78 | #define CCALL_SPS_FREE 0 79 | 80 | typedef intptr_t GPRArg; 81 | typedef double FPRArg; 82 | 83 | #elif LJ_TARGET_PPCSPE 84 | 85 | #define CCALL_NARG_GPR 8 86 | #define CCALL_NARG_FPR 0 87 | #define CCALL_NRET_GPR 4 /* For softfp complex double. */ 88 | #define CCALL_NRET_FPR 0 89 | #define CCALL_SPS_FREE 0 /* NYI */ 90 | 91 | typedef intptr_t GPRArg; 92 | 93 | #elif LJ_TARGET_MIPS 94 | 95 | #define CCALL_NARG_GPR 4 96 | #define CCALL_NARG_FPR 2 97 | #define CCALL_NRET_GPR 2 98 | #define CCALL_NRET_FPR 2 99 | #define CCALL_SPS_EXTRA 7 100 | #define CCALL_SPS_FREE 1 101 | 102 | typedef intptr_t GPRArg; 103 | typedef union FPRArg { 104 | double d; 105 | struct { LJ_ENDIAN_LOHI(float f; , float g;) }; 106 | } FPRArg; 107 | 108 | #else 109 | #error "Missing calling convention definitions for this architecture" 110 | #endif 111 | 112 | #ifndef CCALL_SPS_EXTRA 113 | #define CCALL_SPS_EXTRA 0 114 | #endif 115 | #ifndef CCALL_VECTOR_REG 116 | #define CCALL_VECTOR_REG 0 117 | #endif 118 | #ifndef CCALL_ALIGN_STACKARG 119 | #define CCALL_ALIGN_STACKARG 1 120 | #endif 121 | #ifndef CCALL_ALIGN_CALLSTATE 122 | #define CCALL_ALIGN_CALLSTATE 8 123 | #endif 124 | 125 | #define CCALL_NUM_GPR \ 126 | (CCALL_NARG_GPR > CCALL_NRET_GPR ? CCALL_NARG_GPR : CCALL_NRET_GPR) 127 | #define CCALL_NUM_FPR \ 128 | (CCALL_NARG_FPR > CCALL_NRET_FPR ? CCALL_NARG_FPR : CCALL_NRET_FPR) 129 | 130 | /* Check against constants in lj_ctype.h. */ 131 | LJ_STATIC_ASSERT(CCALL_NUM_GPR <= CCALL_MAX_GPR); 132 | LJ_STATIC_ASSERT(CCALL_NUM_FPR <= CCALL_MAX_FPR); 133 | 134 | #define CCALL_MAXSTACK 32 135 | 136 | /* -- C call state -------------------------------------------------------- */ 137 | 138 | typedef LJ_ALIGN(CCALL_ALIGN_CALLSTATE) struct CCallState { 139 | void (*func)(void); /* Pointer to called function. */ 140 | uint32_t spadj; /* Stack pointer adjustment. */ 141 | uint8_t nsp; /* Number of stack slots. */ 142 | uint8_t retref; /* Return value by reference. */ 143 | #if LJ_TARGET_X64 144 | uint8_t ngpr; /* Number of arguments in GPRs. */ 145 | uint8_t nfpr; /* Number of arguments in FPRs. */ 146 | #elif LJ_TARGET_X86 147 | uint8_t resx87; /* Result on x87 stack: 1:float, 2:double. */ 148 | #elif LJ_TARGET_PPC 149 | uint8_t nfpr; /* Number of arguments in FPRs. */ 150 | #endif 151 | #if LJ_32 152 | int32_t align1; 153 | #endif 154 | #if CCALL_NUM_FPR 155 | FPRArg fpr[CCALL_NUM_FPR]; /* Arguments/results in FPRs. */ 156 | #endif 157 | GPRArg gpr[CCALL_NUM_GPR]; /* Arguments/results in GPRs. */ 158 | GPRArg stack[CCALL_MAXSTACK]; /* Stack slots. */ 159 | } CCallState; 160 | 161 | /* -- C call handling ----------------------------------------------------- */ 162 | 163 | /* Really belongs to lj_vm.h. */ 164 | LJ_ASMF void LJ_FASTCALL lj_vm_ffi_call(CCallState *cc); 165 | 166 | LJ_FUNC CTypeID lj_ccall_ctid_vararg(CTState *cts, cTValue *o); 167 | LJ_FUNC int lj_ccall_func(lua_State *L, GCcdata *cd); 168 | 169 | #endif 170 | 171 | #endif 172 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_ccallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C callback handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CCALLBACK_H 7 | #define _LJ_CCALLBACK_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_ctype.h" 11 | 12 | #if LJ_HASFFI 13 | 14 | /* Really belongs to lj_vm.h. */ 15 | LJ_ASMF void lj_vm_ffi_callback(void); 16 | 17 | LJ_FUNC MSize lj_ccallback_ptr2slot(CTState *cts, void *p); 18 | LJ_FUNCA lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf); 19 | LJ_FUNCA void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o); 20 | LJ_FUNC void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn); 21 | LJ_FUNC void lj_ccallback_mcode_free(CTState *cts); 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_cconv.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C type conversions. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CCONV_H 7 | #define _LJ_CCONV_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_ctype.h" 11 | 12 | #if LJ_HASFFI 13 | 14 | /* Compressed C type index. ORDER CCX. */ 15 | enum { 16 | CCX_B, /* Bool. */ 17 | CCX_I, /* Integer. */ 18 | CCX_F, /* Floating-point number. */ 19 | CCX_C, /* Complex. */ 20 | CCX_V, /* Vector. */ 21 | CCX_P, /* Pointer. */ 22 | CCX_A, /* Refarray. */ 23 | CCX_S /* Struct/union. */ 24 | }; 25 | 26 | /* Convert C type info to compressed C type index. ORDER CT. ORDER CCX. */ 27 | static LJ_AINLINE uint32_t cconv_idx(CTInfo info) 28 | { 29 | uint32_t idx = ((info >> 26) & 15u); /* Dispatch bits. */ 30 | lua_assert(ctype_type(info) <= CT_MAYCONVERT); 31 | #if LJ_64 32 | idx = ((U64x(f436fff5,fff7f021) >> 4*idx) & 15u); 33 | #else 34 | idx = (((idx < 8 ? 0xfff7f021u : 0xf436fff5) >> 4*(idx & 7u)) & 15u); 35 | #endif 36 | lua_assert(idx < 8); 37 | return idx; 38 | } 39 | 40 | #define cconv_idx2(dinfo, sinfo) \ 41 | ((cconv_idx((dinfo)) << 3) + cconv_idx((sinfo))) 42 | 43 | #define CCX(dst, src) ((CCX_##dst << 3) + CCX_##src) 44 | 45 | /* Conversion flags. */ 46 | #define CCF_CAST 0x00000001u 47 | #define CCF_FROMTV 0x00000002u 48 | #define CCF_SAME 0x00000004u 49 | #define CCF_IGNQUAL 0x00000008u 50 | 51 | #define CCF_ARG_SHIFT 8 52 | #define CCF_ARG(n) ((n) << CCF_ARG_SHIFT) 53 | #define CCF_GETARG(f) ((f) >> CCF_ARG_SHIFT) 54 | 55 | LJ_FUNC int lj_cconv_compatptr(CTState *cts, CType *d, CType *s, CTInfo flags); 56 | LJ_FUNC void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, 57 | uint8_t *dp, uint8_t *sp, CTInfo flags); 58 | LJ_FUNC int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, 59 | TValue *o, uint8_t *sp); 60 | LJ_FUNC int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp); 61 | LJ_FUNC void lj_cconv_ct_tv(CTState *cts, CType *d, 62 | uint8_t *dp, TValue *o, CTInfo flags); 63 | LJ_FUNC void lj_cconv_bf_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o); 64 | LJ_FUNC int lj_cconv_multi_init(CTState *cts, CType *d, TValue *o); 65 | LJ_FUNC void lj_cconv_ct_init(CTState *cts, CType *d, CTSize sz, 66 | uint8_t *dp, TValue *o, MSize len); 67 | 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_cdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C data management. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CDATA_H 7 | #define _LJ_CDATA_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_gc.h" 11 | #include "lj_ctype.h" 12 | 13 | #if LJ_HASFFI 14 | 15 | /* Get C data pointer. */ 16 | static LJ_AINLINE void *cdata_getptr(void *p, CTSize sz) 17 | { 18 | if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ 19 | return ((void *)(uintptr_t)*(uint32_t *)p); 20 | } else { 21 | lua_assert(sz == CTSIZE_PTR); 22 | return *(void **)p; 23 | } 24 | } 25 | 26 | /* Set C data pointer. */ 27 | static LJ_AINLINE void cdata_setptr(void *p, CTSize sz, const void *v) 28 | { 29 | if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ 30 | *(uint32_t *)p = (uint32_t)(uintptr_t)v; 31 | } else { 32 | lua_assert(sz == CTSIZE_PTR); 33 | *(void **)p = (void *)v; 34 | } 35 | } 36 | 37 | /* Allocate fixed-size C data object. */ 38 | static LJ_AINLINE GCcdata *lj_cdata_new(CTState *cts, CTypeID id, CTSize sz) 39 | { 40 | GCcdata *cd; 41 | #ifdef LUA_USE_ASSERT 42 | CType *ct = ctype_raw(cts, id); 43 | lua_assert((ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR) == sz); 44 | #endif 45 | cd = (GCcdata *)lj_mem_newgco(cts->L, sizeof(GCcdata) + sz); 46 | cd->gct = ~LJ_TCDATA; 47 | cd->ctypeid = ctype_check(cts, id); 48 | return cd; 49 | } 50 | 51 | /* Variant which works without a valid CTState. */ 52 | static LJ_AINLINE GCcdata *lj_cdata_new_(lua_State *L, CTypeID id, CTSize sz) 53 | { 54 | GCcdata *cd = (GCcdata *)lj_mem_newgco(L, sizeof(GCcdata) + sz); 55 | cd->gct = ~LJ_TCDATA; 56 | cd->ctypeid = id; 57 | return cd; 58 | } 59 | 60 | LJ_FUNC GCcdata *lj_cdata_newref(CTState *cts, const void *pp, CTypeID id); 61 | LJ_FUNC GCcdata *lj_cdata_newv(CTState *cts, CTypeID id, CTSize sz, 62 | CTSize align); 63 | 64 | LJ_FUNC void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd); 65 | LJ_FUNCA TValue * LJ_FASTCALL lj_cdata_setfin(lua_State *L, GCcdata *cd); 66 | 67 | LJ_FUNC CType *lj_cdata_index(CTState *cts, GCcdata *cd, cTValue *key, 68 | uint8_t **pp, CTInfo *qual); 69 | LJ_FUNC int lj_cdata_get(CTState *cts, CType *s, TValue *o, uint8_t *sp); 70 | LJ_FUNC void lj_cdata_set(CTState *cts, CType *d, uint8_t *dp, TValue *o, 71 | CTInfo qual); 72 | 73 | #endif 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_char.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Character types. 3 | ** Donated to the public domain. 4 | ** 5 | ** This is intended to replace the problematic libc single-byte NLS functions. 6 | ** These just don't make sense anymore with UTF-8 locales becoming the norm 7 | ** on POSIX systems. It never worked too well on Windows systems since hardly 8 | ** anyone bothered to call setlocale(). 9 | ** 10 | ** This table is hardcoded for ASCII. Identifiers include the characters 11 | ** 128-255, too. This allows for the use of all non-ASCII chars as identifiers 12 | ** in the lexer. This is a broad definition, but works well in practice 13 | ** for both UTF-8 locales and most single-byte locales (such as ISO-8859-*). 14 | ** 15 | ** If you really need proper character types for UTF-8 strings, please use 16 | ** an add-on library such as slnunicode: http://luaforge.net/projects/sln/ 17 | */ 18 | 19 | #define lj_char_c 20 | #define LUA_CORE 21 | 22 | #include "lj_char.h" 23 | 24 | LJ_DATADEF const uint8_t lj_char_bits[257] = { 25 | 0, 26 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 27 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 28 | 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29 | 152,152,152,152,152,152,152,152,152,152, 4, 4, 4, 4, 4, 4, 30 | 4,176,176,176,176,176,176,160,160,160,160,160,160,160,160,160, 31 | 160,160,160,160,160,160,160,160,160,160,160, 4, 4, 4, 4,132, 32 | 4,208,208,208,208,208,208,192,192,192,192,192,192,192,192,192, 33 | 192,192,192,192,192,192,192,192,192,192,192, 4, 4, 4, 4, 1, 34 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 35 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 36 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 37 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 38 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 39 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 40 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 41 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_char.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Character types. 3 | ** Donated to the public domain. 4 | */ 5 | 6 | #ifndef _LJ_CHAR_H 7 | #define _LJ_CHAR_H 8 | 9 | #include "lj_def.h" 10 | 11 | #define LJ_CHAR_CNTRL 0x01 12 | #define LJ_CHAR_SPACE 0x02 13 | #define LJ_CHAR_PUNCT 0x04 14 | #define LJ_CHAR_DIGIT 0x08 15 | #define LJ_CHAR_XDIGIT 0x10 16 | #define LJ_CHAR_UPPER 0x20 17 | #define LJ_CHAR_LOWER 0x40 18 | #define LJ_CHAR_IDENT 0x80 19 | #define LJ_CHAR_ALPHA (LJ_CHAR_LOWER|LJ_CHAR_UPPER) 20 | #define LJ_CHAR_ALNUM (LJ_CHAR_ALPHA|LJ_CHAR_DIGIT) 21 | #define LJ_CHAR_GRAPH (LJ_CHAR_ALNUM|LJ_CHAR_PUNCT) 22 | 23 | /* Only pass -1 or 0..255 to these macros. Never pass a signed char! */ 24 | #define lj_char_isa(c, t) ((lj_char_bits+1)[(c)] & t) 25 | #define lj_char_iscntrl(c) lj_char_isa((c), LJ_CHAR_CNTRL) 26 | #define lj_char_isspace(c) lj_char_isa((c), LJ_CHAR_SPACE) 27 | #define lj_char_ispunct(c) lj_char_isa((c), LJ_CHAR_PUNCT) 28 | #define lj_char_isdigit(c) lj_char_isa((c), LJ_CHAR_DIGIT) 29 | #define lj_char_isxdigit(c) lj_char_isa((c), LJ_CHAR_XDIGIT) 30 | #define lj_char_isupper(c) lj_char_isa((c), LJ_CHAR_UPPER) 31 | #define lj_char_islower(c) lj_char_isa((c), LJ_CHAR_LOWER) 32 | #define lj_char_isident(c) lj_char_isa((c), LJ_CHAR_IDENT) 33 | #define lj_char_isalpha(c) lj_char_isa((c), LJ_CHAR_ALPHA) 34 | #define lj_char_isalnum(c) lj_char_isa((c), LJ_CHAR_ALNUM) 35 | #define lj_char_isgraph(c) lj_char_isa((c), LJ_CHAR_GRAPH) 36 | 37 | #define lj_char_toupper(c) ((c) - (lj_char_islower(c) >> 1)) 38 | #define lj_char_tolower(c) ((c) + lj_char_isupper(c)) 39 | 40 | LJ_DATA const uint8_t lj_char_bits[257]; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_clib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C library loader. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CLIB_H 7 | #define _LJ_CLIB_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASFFI 12 | 13 | /* Namespace for C library indexing. */ 14 | #define CLNS_INDEX ((1u<env. */ 20 | } CLibrary; 21 | 22 | LJ_FUNC TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name); 23 | LJ_FUNC void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global); 24 | LJ_FUNC void lj_clib_unload(CLibrary *cl); 25 | LJ_FUNC void lj_clib_default(lua_State *L, GCtab *mt); 26 | 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_cparse.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C declaration parser. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CPARSE_H 7 | #define _LJ_CPARSE_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_ctype.h" 11 | 12 | #if LJ_HASFFI 13 | 14 | /* C parser limits. */ 15 | #define CPARSE_MAX_BUF 32768 /* Max. token buffer size. */ 16 | #define CPARSE_MAX_DECLSTACK 100 /* Max. declaration stack depth. */ 17 | #define CPARSE_MAX_DECLDEPTH 20 /* Max. recursive declaration depth. */ 18 | #define CPARSE_MAX_PACKSTACK 7 /* Max. pack pragma stack depth. */ 19 | 20 | /* Flags for C parser mode. */ 21 | #define CPARSE_MODE_MULTI 1 /* Process multiple declarations. */ 22 | #define CPARSE_MODE_ABSTRACT 2 /* Accept abstract declarators. */ 23 | #define CPARSE_MODE_DIRECT 4 /* Accept direct declarators. */ 24 | #define CPARSE_MODE_FIELD 8 /* Accept field width in bits, too. */ 25 | #define CPARSE_MODE_NOIMPLICIT 16 /* Reject implicit declarations. */ 26 | #define CPARSE_MODE_SKIP 32 /* Skip definitions, ignore errors. */ 27 | 28 | typedef int CPChar; /* C parser character. Unsigned ext. from char. */ 29 | typedef int CPToken; /* C parser token. */ 30 | 31 | /* C parser internal value representation. */ 32 | typedef struct CPValue { 33 | union { 34 | int32_t i32; /* Value for CTID_INT32. */ 35 | uint32_t u32; /* Value for CTID_UINT32. */ 36 | }; 37 | CTypeID id; /* C Type ID of the value. */ 38 | } CPValue; 39 | 40 | /* C parser state. */ 41 | typedef struct CPState { 42 | CPChar c; /* Current character. */ 43 | CPToken tok; /* Current token. */ 44 | CPValue val; /* Token value. */ 45 | GCstr *str; /* Interned string of identifier/keyword. */ 46 | CType *ct; /* C type table entry. */ 47 | const char *p; /* Current position in input buffer. */ 48 | SBuf sb; /* String buffer for tokens. */ 49 | lua_State *L; /* Lua state. */ 50 | CTState *cts; /* C type state. */ 51 | TValue *param; /* C type parameters. */ 52 | const char *srcname; /* Current source name. */ 53 | BCLine linenumber; /* Input line counter. */ 54 | int depth; /* Recursive declaration depth. */ 55 | uint32_t tmask; /* Type mask for next identifier. */ 56 | uint32_t mode; /* C parser mode. */ 57 | uint8_t packstack[CPARSE_MAX_PACKSTACK]; /* Stack for pack pragmas. */ 58 | uint8_t curpack; /* Current position in pack pragma stack. */ 59 | } CPState; 60 | 61 | LJ_FUNC int lj_cparse(CPState *cp); 62 | 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_crecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace recorder for C data operations. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CRECORD_H 7 | #define _LJ_CRECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | #include "lj_ffrecord.h" 12 | 13 | #if LJ_HASJIT && LJ_HASFFI 14 | LJ_FUNC void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd); 15 | LJ_FUNC void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd); 16 | LJ_FUNC void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd); 17 | LJ_FUNC void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd); 18 | LJ_FUNC void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd); 19 | LJ_FUNC void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd); 20 | LJ_FUNC void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd); 21 | LJ_FUNC void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd); 22 | LJ_FUNC void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd); 23 | LJ_FUNC void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd); 24 | LJ_FUNC void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd); 25 | LJ_FUNC void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd); 26 | LJ_FUNC void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd); 27 | LJ_FUNC void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd); 28 | LJ_FUNC void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd); 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Debugging and introspection. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_DEBUG_H 7 | #define _LJ_DEBUG_H 8 | 9 | #include "lj_obj.h" 10 | 11 | typedef struct lj_Debug { 12 | /* Common fields. Must be in the same order as in lua.h. */ 13 | int event; 14 | const char *name; 15 | const char *namewhat; 16 | const char *what; 17 | const char *source; 18 | int currentline; 19 | int nups; 20 | int linedefined; 21 | int lastlinedefined; 22 | char short_src[LUA_IDSIZE]; 23 | int i_ci; 24 | /* Extended fields. Only valid if lj_debug_getinfo() is called with ext = 1.*/ 25 | int nparams; 26 | int isvararg; 27 | } lj_Debug; 28 | 29 | LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size); 30 | LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc); 31 | LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx); 32 | LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp); 33 | LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc, 34 | BCReg slot, const char **name); 35 | LJ_FUNC const char *lj_debug_funcname(lua_State *L, TValue *frame, 36 | const char **name); 37 | LJ_FUNC void lj_debug_shortname(char *out, GCstr *str); 38 | LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg, 39 | cTValue *frame, cTValue *nextframe); 40 | LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc); 41 | LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, 42 | int ext); 43 | 44 | /* Fixed internal variable names. */ 45 | #define VARNAMEDEF(_) \ 46 | _(FOR_IDX, "(for index)") \ 47 | _(FOR_STOP, "(for limit)") \ 48 | _(FOR_STEP, "(for step)") \ 49 | _(FOR_GEN, "(for generator)") \ 50 | _(FOR_STATE, "(for state)") \ 51 | _(FOR_CTL, "(for control)") 52 | 53 | enum { 54 | VARNAME_END, 55 | #define VARNAMEENUM(name, str) VARNAME_##name, 56 | VARNAMEDEF(VARNAMEENUM) 57 | #undef VARNAMEENUM 58 | VARNAME__MAX 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_dispatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Instruction dispatch handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_DISPATCH_H 7 | #define _LJ_DISPATCH_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_bc.h" 11 | #if LJ_HASJIT 12 | #include "lj_jit.h" 13 | #endif 14 | 15 | #if LJ_TARGET_MIPS 16 | /* Need our own global offset table for the dreaded MIPS calling conventions. */ 17 | #if LJ_HASJIT 18 | #define JITGOTDEF(_) _(lj_trace_exit) _(lj_trace_hot) 19 | #else 20 | #define JITGOTDEF(_) 21 | #endif 22 | #if LJ_HASFFI 23 | #define FFIGOTDEF(_) \ 24 | _(lj_meta_equal_cd) _(lj_ccallback_enter) _(lj_ccallback_leave) 25 | #else 26 | #define FFIGOTDEF(_) 27 | #endif 28 | #define GOTDEF(_) \ 29 | _(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \ 30 | _(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \ 31 | _(pow) _(fmod) _(ldexp) \ 32 | _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_err_throw) \ 33 | _(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \ 34 | _(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \ 35 | _(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \ 36 | _(lj_meta_for) _(lj_meta_len) _(lj_meta_tget) _(lj_meta_tset) \ 37 | _(lj_state_growstack) _(lj_str_fromnum) _(lj_str_fromnumber) _(lj_str_new) \ 38 | _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) _(lj_tab_new) \ 39 | _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \ 40 | JITGOTDEF(_) FFIGOTDEF(_) 41 | 42 | enum { 43 | #define GOTENUM(name) LJ_GOT_##name, 44 | GOTDEF(GOTENUM) 45 | #undef GOTENUM 46 | LJ_GOT__MAX 47 | }; 48 | #endif 49 | 50 | /* Type of hot counter. Must match the code in the assembler VM. */ 51 | /* 16 bits are sufficient. Only 0.0015% overhead with maximum slot penalty. */ 52 | typedef uint16_t HotCount; 53 | 54 | /* Number of hot counter hash table entries (must be a power of two). */ 55 | #define HOTCOUNT_SIZE 64 56 | #define HOTCOUNT_PCMASK ((HOTCOUNT_SIZE-1)*sizeof(HotCount)) 57 | 58 | /* Hotcount decrements. */ 59 | #define HOTCOUNT_LOOP 2 60 | #define HOTCOUNT_CALL 1 61 | 62 | /* This solves a circular dependency problem -- bump as needed. Sigh. */ 63 | #define GG_NUM_ASMFF 62 64 | 65 | #define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) 66 | #define GG_LEN_SDISP BC_FUNCF 67 | #define GG_LEN_DISP (GG_LEN_DDISP + GG_LEN_SDISP) 68 | 69 | /* Global state, main thread and extra fields are allocated together. */ 70 | typedef struct GG_State { 71 | lua_State L; /* Main thread. */ 72 | global_State g; /* Global state. */ 73 | #if LJ_TARGET_MIPS 74 | ASMFunction got[LJ_GOT__MAX]; /* Global offset table. */ 75 | #endif 76 | #if LJ_HASJIT 77 | jit_State J; /* JIT state. */ 78 | HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ 79 | #endif 80 | ASMFunction dispatch[GG_LEN_DISP]; /* Instruction dispatch tables. */ 81 | BCIns bcff[GG_NUM_ASMFF]; /* Bytecode for ASM fast functions. */ 82 | } GG_State; 83 | 84 | #define GG_OFS(field) ((int)offsetof(GG_State, field)) 85 | #define G2GG(gl) ((GG_State *)((char *)(gl) - GG_OFS(g))) 86 | #define J2GG(j) ((GG_State *)((char *)(j) - GG_OFS(J))) 87 | #define L2GG(L) (G2GG(G(L))) 88 | #define J2G(J) (&J2GG(J)->g) 89 | #define G2J(gl) (&G2GG(gl)->J) 90 | #define L2J(L) (&L2GG(L)->J) 91 | #define GG_G2DISP (GG_OFS(dispatch) - GG_OFS(g)) 92 | #define GG_DISP2G (GG_OFS(g) - GG_OFS(dispatch)) 93 | #define GG_DISP2J (GG_OFS(J) - GG_OFS(dispatch)) 94 | #define GG_DISP2HOT (GG_OFS(hotcount) - GG_OFS(dispatch)) 95 | #define GG_DISP2STATIC (GG_LEN_DDISP*(int)sizeof(ASMFunction)) 96 | 97 | #define hotcount_get(gg, pc) \ 98 | (gg)->hotcount[(u32ptr(pc)>>2) & (HOTCOUNT_SIZE-1)] 99 | #define hotcount_set(gg, pc, val) \ 100 | (hotcount_get((gg), (pc)) = (HotCount)(val)) 101 | 102 | /* Dispatch table management. */ 103 | LJ_FUNC void lj_dispatch_init(GG_State *GG); 104 | #if LJ_HASJIT 105 | LJ_FUNC void lj_dispatch_init_hotcount(global_State *g); 106 | #endif 107 | LJ_FUNC void lj_dispatch_update(global_State *g); 108 | 109 | /* Instruction dispatch callback for hooks or when recording. */ 110 | LJ_FUNCA void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc); 111 | LJ_FUNCA ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns*pc); 112 | LJ_FUNCA void LJ_FASTCALL lj_dispatch_return(lua_State *L, const BCIns *pc); 113 | 114 | #if LJ_HASFFI && !defined(_BUILDVM_H) 115 | /* Save/restore errno and GetLastError() around hooks, exits and recording. */ 116 | #include 117 | #if LJ_TARGET_WINDOWS 118 | #define WIN32_LEAN_AND_MEAN 119 | #include 120 | #define ERRNO_SAVE int olderr = errno; DWORD oldwerr = GetLastError(); 121 | #define ERRNO_RESTORE errno = olderr; SetLastError(oldwerr); 122 | #else 123 | #define ERRNO_SAVE int olderr = errno; 124 | #define ERRNO_RESTORE errno = olderr; 125 | #endif 126 | #else 127 | #define ERRNO_SAVE 128 | #define ERRNO_RESTORE 129 | #endif 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Error handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_ERR_H 7 | #define _LJ_ERR_H 8 | 9 | #include 10 | 11 | #include "lj_obj.h" 12 | 13 | typedef enum { 14 | #define ERRDEF(name, msg) \ 15 | LJ_ERR_##name, LJ_ERR_##name##_ = LJ_ERR_##name + sizeof(msg)-1, 16 | #include "lj_errmsg.h" 17 | LJ_ERR__MAX 18 | } ErrMsg; 19 | 20 | LJ_DATA const char *lj_err_allmsg; 21 | #define err2msg(em) (lj_err_allmsg+(int)(em)) 22 | 23 | LJ_FUNC GCstr *lj_err_str(lua_State *L, ErrMsg em); 24 | LJ_FUNCA_NORET void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode); 25 | LJ_FUNC_NORET void lj_err_mem(lua_State *L); 26 | LJ_FUNC_NORET void lj_err_run(lua_State *L); 27 | LJ_FUNC_NORET void lj_err_msg(lua_State *L, ErrMsg em); 28 | LJ_FUNC_NORET void lj_err_lex(lua_State *L, GCstr *src, const char *tok, 29 | BCLine line, ErrMsg em, va_list argp); 30 | LJ_FUNC_NORET void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm); 31 | LJ_FUNC_NORET void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2); 32 | LJ_FUNC_NORET void lj_err_optype_call(lua_State *L, TValue *o); 33 | LJ_FUNC_NORET void lj_err_callermsg(lua_State *L, const char *msg); 34 | LJ_FUNC_NORET void lj_err_callerv(lua_State *L, ErrMsg em, ...); 35 | LJ_FUNC_NORET void lj_err_caller(lua_State *L, ErrMsg em); 36 | LJ_FUNC_NORET void lj_err_arg(lua_State *L, int narg, ErrMsg em); 37 | LJ_FUNC_NORET void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...); 38 | LJ_FUNC_NORET void lj_err_argtype(lua_State *L, int narg, const char *xname); 39 | LJ_FUNC_NORET void lj_err_argt(lua_State *L, int narg, int tt); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_ff.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Fast function IDs. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FF_H 7 | #define _LJ_FF_H 8 | 9 | /* Fast function ID. */ 10 | typedef enum { 11 | FF_LUA_ = FF_LUA, /* Lua function (must be 0). */ 12 | FF_C_ = FF_C, /* Regular C function (must be 1). */ 13 | #define FFDEF(name) FF_##name, 14 | #include "lj_ffdef.h" 15 | FF__MAX 16 | } FastFunc; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_ffdef.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file. DO NOT EDIT! */ 2 | 3 | FFDEF(assert) 4 | FFDEF(type) 5 | FFDEF(next) 6 | FFDEF(pairs) 7 | FFDEF(ipairs_aux) 8 | FFDEF(ipairs) 9 | FFDEF(getmetatable) 10 | FFDEF(setmetatable) 11 | FFDEF(getfenv) 12 | FFDEF(setfenv) 13 | FFDEF(rawget) 14 | FFDEF(rawset) 15 | FFDEF(rawequal) 16 | FFDEF(unpack) 17 | FFDEF(select) 18 | FFDEF(tonumber) 19 | FFDEF(tostring) 20 | FFDEF(error) 21 | FFDEF(pcall) 22 | FFDEF(xpcall) 23 | FFDEF(loadfile) 24 | FFDEF(load) 25 | FFDEF(loadstring) 26 | FFDEF(dofile) 27 | FFDEF(gcinfo) 28 | FFDEF(collectgarbage) 29 | FFDEF(newproxy) 30 | FFDEF(print) 31 | FFDEF(coroutine_status) 32 | FFDEF(coroutine_running) 33 | FFDEF(coroutine_create) 34 | FFDEF(coroutine_yield) 35 | FFDEF(coroutine_resume) 36 | FFDEF(coroutine_wrap_aux) 37 | FFDEF(coroutine_wrap) 38 | FFDEF(math_abs) 39 | FFDEF(math_floor) 40 | FFDEF(math_ceil) 41 | FFDEF(math_sqrt) 42 | FFDEF(math_log10) 43 | FFDEF(math_exp) 44 | FFDEF(math_sin) 45 | FFDEF(math_cos) 46 | FFDEF(math_tan) 47 | FFDEF(math_asin) 48 | FFDEF(math_acos) 49 | FFDEF(math_atan) 50 | FFDEF(math_sinh) 51 | FFDEF(math_cosh) 52 | FFDEF(math_tanh) 53 | FFDEF(math_frexp) 54 | FFDEF(math_modf) 55 | FFDEF(math_log) 56 | FFDEF(math_deg) 57 | FFDEF(math_rad) 58 | FFDEF(math_atan2) 59 | FFDEF(math_pow) 60 | FFDEF(math_fmod) 61 | FFDEF(math_ldexp) 62 | FFDEF(math_min) 63 | FFDEF(math_max) 64 | FFDEF(math_random) 65 | FFDEF(math_randomseed) 66 | FFDEF(bit_tobit) 67 | FFDEF(bit_bnot) 68 | FFDEF(bit_bswap) 69 | FFDEF(bit_lshift) 70 | FFDEF(bit_rshift) 71 | FFDEF(bit_arshift) 72 | FFDEF(bit_rol) 73 | FFDEF(bit_ror) 74 | FFDEF(bit_band) 75 | FFDEF(bit_bor) 76 | FFDEF(bit_bxor) 77 | FFDEF(bit_tohex) 78 | FFDEF(string_len) 79 | FFDEF(string_byte) 80 | FFDEF(string_char) 81 | FFDEF(string_sub) 82 | FFDEF(string_rep) 83 | FFDEF(string_reverse) 84 | FFDEF(string_lower) 85 | FFDEF(string_upper) 86 | FFDEF(string_dump) 87 | FFDEF(string_find) 88 | FFDEF(string_match) 89 | FFDEF(string_gmatch_aux) 90 | FFDEF(string_gmatch) 91 | FFDEF(string_gsub) 92 | FFDEF(string_format) 93 | FFDEF(table_foreachi) 94 | FFDEF(table_foreach) 95 | FFDEF(table_getn) 96 | FFDEF(table_maxn) 97 | FFDEF(table_insert) 98 | FFDEF(table_remove) 99 | FFDEF(table_concat) 100 | FFDEF(table_sort) 101 | FFDEF(io_method_close) 102 | FFDEF(io_method_read) 103 | FFDEF(io_method_write) 104 | FFDEF(io_method_flush) 105 | FFDEF(io_method_seek) 106 | FFDEF(io_method_setvbuf) 107 | FFDEF(io_method_lines) 108 | FFDEF(io_method___gc) 109 | FFDEF(io_method___tostring) 110 | FFDEF(io_open) 111 | FFDEF(io_popen) 112 | FFDEF(io_tmpfile) 113 | FFDEF(io_close) 114 | FFDEF(io_read) 115 | FFDEF(io_write) 116 | FFDEF(io_flush) 117 | FFDEF(io_input) 118 | FFDEF(io_output) 119 | FFDEF(io_lines) 120 | FFDEF(io_type) 121 | FFDEF(os_execute) 122 | FFDEF(os_remove) 123 | FFDEF(os_rename) 124 | FFDEF(os_tmpname) 125 | FFDEF(os_getenv) 126 | FFDEF(os_exit) 127 | FFDEF(os_clock) 128 | FFDEF(os_date) 129 | FFDEF(os_time) 130 | FFDEF(os_difftime) 131 | FFDEF(os_setlocale) 132 | FFDEF(debug_getregistry) 133 | FFDEF(debug_getmetatable) 134 | FFDEF(debug_setmetatable) 135 | FFDEF(debug_getfenv) 136 | FFDEF(debug_setfenv) 137 | FFDEF(debug_getinfo) 138 | FFDEF(debug_getlocal) 139 | FFDEF(debug_setlocal) 140 | FFDEF(debug_getupvalue) 141 | FFDEF(debug_setupvalue) 142 | FFDEF(debug_upvalueid) 143 | FFDEF(debug_upvaluejoin) 144 | FFDEF(debug_sethook) 145 | FFDEF(debug_gethook) 146 | FFDEF(debug_debug) 147 | FFDEF(debug_traceback) 148 | FFDEF(jit_on) 149 | FFDEF(jit_off) 150 | FFDEF(jit_flush) 151 | FFDEF(jit_status) 152 | FFDEF(jit_attach) 153 | FFDEF(jit_util_funcinfo) 154 | FFDEF(jit_util_funcbc) 155 | FFDEF(jit_util_funck) 156 | FFDEF(jit_util_funcuvname) 157 | FFDEF(jit_util_traceinfo) 158 | FFDEF(jit_util_traceir) 159 | FFDEF(jit_util_tracek) 160 | FFDEF(jit_util_tracesnap) 161 | FFDEF(jit_util_tracemc) 162 | FFDEF(jit_util_traceexitstub) 163 | FFDEF(jit_util_ircalladdr) 164 | FFDEF(jit_opt_start) 165 | FFDEF(ffi_meta___index) 166 | FFDEF(ffi_meta___newindex) 167 | FFDEF(ffi_meta___eq) 168 | FFDEF(ffi_meta___len) 169 | FFDEF(ffi_meta___lt) 170 | FFDEF(ffi_meta___le) 171 | FFDEF(ffi_meta___concat) 172 | FFDEF(ffi_meta___call) 173 | FFDEF(ffi_meta___add) 174 | FFDEF(ffi_meta___sub) 175 | FFDEF(ffi_meta___mul) 176 | FFDEF(ffi_meta___div) 177 | FFDEF(ffi_meta___mod) 178 | FFDEF(ffi_meta___pow) 179 | FFDEF(ffi_meta___unm) 180 | FFDEF(ffi_meta___tostring) 181 | FFDEF(ffi_meta___pairs) 182 | FFDEF(ffi_meta___ipairs) 183 | FFDEF(ffi_clib___index) 184 | FFDEF(ffi_clib___newindex) 185 | FFDEF(ffi_clib___gc) 186 | FFDEF(ffi_callback_free) 187 | FFDEF(ffi_callback_set) 188 | FFDEF(ffi_cdef) 189 | FFDEF(ffi_new) 190 | FFDEF(ffi_cast) 191 | FFDEF(ffi_typeof) 192 | FFDEF(ffi_istype) 193 | FFDEF(ffi_sizeof) 194 | FFDEF(ffi_alignof) 195 | FFDEF(ffi_offsetof) 196 | FFDEF(ffi_errno) 197 | FFDEF(ffi_string) 198 | FFDEF(ffi_copy) 199 | FFDEF(ffi_fill) 200 | FFDEF(ffi_abi) 201 | FFDEF(ffi_metatype) 202 | FFDEF(ffi_gc) 203 | FFDEF(ffi_load) 204 | 205 | #undef FFDEF 206 | 207 | #ifndef FF_NUM_ASMFUNC 208 | #define FF_NUM_ASMFUNC 62 209 | #endif 210 | 211 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_ffrecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Fast function call recorder. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FFRECORD_H 7 | #define _LJ_FFRECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | /* Data used by handlers to record a fast function. */ 14 | typedef struct RecordFFData { 15 | TValue *argv; /* Runtime argument values. */ 16 | ptrdiff_t nres; /* Number of returned results (defaults to 1). */ 17 | uint32_t data; /* Per-ffid auxiliary data (opcode, literal etc.). */ 18 | } RecordFFData; 19 | 20 | LJ_FUNC int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv); 21 | LJ_FUNC void lj_ffrecord_func(jit_State *J); 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_func.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Function handling (prototypes, functions and upvalues). 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FUNC_H 7 | #define _LJ_FUNC_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Prototypes. */ 12 | LJ_FUNC void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt); 13 | 14 | /* Upvalues. */ 15 | LJ_FUNCA void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level); 16 | LJ_FUNC void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv); 17 | 18 | /* Functions (closures). */ 19 | LJ_FUNC GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env); 20 | LJ_FUNC GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env); 21 | LJ_FUNCA GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent); 22 | LJ_FUNC void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *c); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_gc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Garbage collector. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_GC_H 7 | #define _LJ_GC_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Garbage collector states. Order matters. */ 12 | enum { 13 | GCSpause, GCSpropagate, GCSatomic, GCSsweepstring, GCSsweep, GCSfinalize 14 | }; 15 | 16 | /* Bitmasks for marked field of GCobj. */ 17 | #define LJ_GC_WHITE0 0x01 18 | #define LJ_GC_WHITE1 0x02 19 | #define LJ_GC_BLACK 0x04 20 | #define LJ_GC_FINALIZED 0x08 21 | #define LJ_GC_WEAKKEY 0x08 22 | #define LJ_GC_WEAKVAL 0x10 23 | #define LJ_GC_CDATA_FIN 0x10 24 | #define LJ_GC_FIXED 0x20 25 | #define LJ_GC_SFIXED 0x40 26 | 27 | #define LJ_GC_WHITES (LJ_GC_WHITE0 | LJ_GC_WHITE1) 28 | #define LJ_GC_COLORS (LJ_GC_WHITES | LJ_GC_BLACK) 29 | #define LJ_GC_WEAK (LJ_GC_WEAKKEY | LJ_GC_WEAKVAL) 30 | 31 | /* Macros to test and set GCobj colors. */ 32 | #define iswhite(x) ((x)->gch.marked & LJ_GC_WHITES) 33 | #define isblack(x) ((x)->gch.marked & LJ_GC_BLACK) 34 | #define isgray(x) (!((x)->gch.marked & (LJ_GC_BLACK|LJ_GC_WHITES))) 35 | #define tviswhite(x) (tvisgcv(x) && iswhite(gcV(x))) 36 | #define otherwhite(g) (g->gc.currentwhite ^ LJ_GC_WHITES) 37 | #define isdead(g, v) ((v)->gch.marked & otherwhite(g) & LJ_GC_WHITES) 38 | 39 | #define curwhite(g) ((g)->gc.currentwhite & LJ_GC_WHITES) 40 | #define newwhite(g, x) (obj2gco(x)->gch.marked = (uint8_t)curwhite(g)) 41 | #define makewhite(g, x) \ 42 | ((x)->gch.marked = ((x)->gch.marked & (uint8_t)~LJ_GC_COLORS) | curwhite(g)) 43 | #define flipwhite(x) ((x)->gch.marked ^= LJ_GC_WHITES) 44 | #define black2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_BLACK) 45 | #define fixstring(s) ((s)->marked |= LJ_GC_FIXED) 46 | #define markfinalized(x) ((x)->gch.marked |= LJ_GC_FINALIZED) 47 | 48 | /* Collector. */ 49 | LJ_FUNC size_t lj_gc_separateudata(global_State *g, int all); 50 | LJ_FUNC void lj_gc_finalize_udata(lua_State *L); 51 | #if LJ_HASFFI 52 | LJ_FUNC void lj_gc_finalize_cdata(lua_State *L); 53 | #else 54 | #define lj_gc_finalize_cdata(L) UNUSED(L) 55 | #endif 56 | LJ_FUNC void lj_gc_freeall(global_State *g); 57 | LJ_FUNCA int LJ_FASTCALL lj_gc_step(lua_State *L); 58 | LJ_FUNCA void LJ_FASTCALL lj_gc_step_fixtop(lua_State *L); 59 | #if LJ_HASJIT 60 | LJ_FUNC int LJ_FASTCALL lj_gc_step_jit(global_State *g, MSize steps); 61 | #endif 62 | LJ_FUNC void lj_gc_fullgc(lua_State *L); 63 | 64 | /* GC check: drive collector forward if the GC threshold has been reached. */ 65 | #define lj_gc_check(L) \ 66 | { if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \ 67 | lj_gc_step(L); } 68 | #define lj_gc_check_fixtop(L) \ 69 | { if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \ 70 | lj_gc_step_fixtop(L); } 71 | 72 | /* Write barriers. */ 73 | LJ_FUNC void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v); 74 | LJ_FUNCA void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv); 75 | LJ_FUNC void lj_gc_closeuv(global_State *g, GCupval *uv); 76 | #if LJ_HASJIT 77 | LJ_FUNC void lj_gc_barriertrace(global_State *g, uint32_t traceno); 78 | #endif 79 | 80 | /* Move the GC propagation frontier back for tables (make it gray again). */ 81 | static LJ_AINLINE void lj_gc_barrierback(global_State *g, GCtab *t) 82 | { 83 | GCobj *o = obj2gco(t); 84 | lua_assert(isblack(o) && !isdead(g, o)); 85 | lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); 86 | black2gray(o); 87 | setgcrefr(t->gclist, g->gc.grayagain); 88 | setgcref(g->gc.grayagain, o); 89 | } 90 | 91 | /* Barrier for stores to table objects. TValue and GCobj variant. */ 92 | #define lj_gc_anybarriert(L, t) \ 93 | { if (LJ_UNLIKELY(isblack(obj2gco(t)))) lj_gc_barrierback(G(L), (t)); } 94 | #define lj_gc_barriert(L, t, tv) \ 95 | { if (tviswhite(tv) && isblack(obj2gco(t))) \ 96 | lj_gc_barrierback(G(L), (t)); } 97 | #define lj_gc_objbarriert(L, t, o) \ 98 | { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) \ 99 | lj_gc_barrierback(G(L), (t)); } 100 | 101 | /* Barrier for stores to any other object. TValue and GCobj variant. */ 102 | #define lj_gc_barrier(L, p, tv) \ 103 | { if (tviswhite(tv) && isblack(obj2gco(p))) \ 104 | lj_gc_barrierf(G(L), obj2gco(p), gcV(tv)); } 105 | #define lj_gc_objbarrier(L, p, o) \ 106 | { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ 107 | lj_gc_barrierf(G(L), obj2gco(p), obj2gco(o)); } 108 | 109 | /* Allocator. */ 110 | LJ_FUNC void *lj_mem_realloc(lua_State *L, void *p, MSize osz, MSize nsz); 111 | LJ_FUNC void * LJ_FASTCALL lj_mem_newgco(lua_State *L, MSize size); 112 | LJ_FUNC void *lj_mem_grow(lua_State *L, void *p, 113 | MSize *szp, MSize lim, MSize esz); 114 | 115 | #define lj_mem_new(L, s) lj_mem_realloc(L, NULL, 0, (s)) 116 | 117 | static LJ_AINLINE void lj_mem_free(global_State *g, void *p, size_t osize) 118 | { 119 | g->gc.total -= (MSize)osize; 120 | g->allocf(g->allocd, p, osize, 0); 121 | } 122 | 123 | #define lj_mem_newvec(L, n, t) ((t *)lj_mem_new(L, (MSize)((n)*sizeof(t)))) 124 | #define lj_mem_reallocvec(L, p, on, n, t) \ 125 | ((p) = (t *)lj_mem_realloc(L, p, (on)*sizeof(t), (MSize)((n)*sizeof(t)))) 126 | #define lj_mem_growvec(L, p, n, m, t) \ 127 | ((p) = (t *)lj_mem_grow(L, (p), &(n), (m), (MSize)sizeof(t))) 128 | #define lj_mem_freevec(g, p, n, t) lj_mem_free(g, (p), (n)*sizeof(t)) 129 | 130 | #define lj_mem_newobj(L, t) ((t *)lj_mem_newgco(L, sizeof(t))) 131 | #define lj_mem_newt(L, s, t) ((t *)lj_mem_new(L, (s))) 132 | #define lj_mem_freet(g, p) lj_mem_free(g, (p), sizeof(*(p))) 133 | 134 | #endif 135 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_gdbjit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Client for the GDB JIT API. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_GDBJIT_H 7 | #define _LJ_GDBJIT_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT && defined(LUAJIT_USE_GDBJIT) 13 | 14 | LJ_FUNC void lj_gdbjit_addtrace(jit_State *J, GCtrace *T); 15 | LJ_FUNC void lj_gdbjit_deltrace(jit_State *J, GCtrace *T); 16 | 17 | #else 18 | #define lj_gdbjit_addtrace(J, T) UNUSED(T) 19 | #define lj_gdbjit_deltrace(J, T) UNUSED(T) 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_lex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Lexical analyzer. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_LEX_H 7 | #define _LJ_LEX_H 8 | 9 | #include 10 | 11 | #include "lj_obj.h" 12 | #include "lj_err.h" 13 | 14 | /* Lua lexer tokens. */ 15 | #define TKDEF(_, __) \ 16 | _(and) _(break) _(do) _(else) _(elseif) _(end) _(false) \ 17 | _(for) _(function) _(goto) _(if) _(in) _(local) _(nil) _(not) _(or) \ 18 | _(repeat) _(return) _(then) _(true) _(until) _(while) \ 19 | __(concat, ..) __(dots, ...) __(eq, ==) __(ge, >=) __(le, <=) __(ne, ~=) \ 20 | __(label, ::) __(number, ) __(name, ) __(string, ) \ 21 | __(eof, ) 22 | 23 | enum { 24 | TK_OFS = 256, 25 | #define TKENUM1(name) TK_##name, 26 | #define TKENUM2(name, sym) TK_##name, 27 | TKDEF(TKENUM1, TKENUM2) 28 | #undef TKENUM1 29 | #undef TKENUM2 30 | TK_RESERVED = TK_while - TK_OFS 31 | }; 32 | 33 | typedef int LexToken; 34 | 35 | /* Combined bytecode ins/line. Only used during bytecode generation. */ 36 | typedef struct BCInsLine { 37 | BCIns ins; /* Bytecode instruction. */ 38 | BCLine line; /* Line number for this bytecode. */ 39 | } BCInsLine; 40 | 41 | /* Info for local variables. Only used during bytecode generation. */ 42 | typedef struct VarInfo { 43 | GCRef name; /* Local variable name or goto/label name. */ 44 | BCPos startpc; /* First point where the local variable is active. */ 45 | BCPos endpc; /* First point where the local variable is dead. */ 46 | uint8_t slot; /* Variable slot. */ 47 | uint8_t info; /* Variable/goto/label info. */ 48 | } VarInfo; 49 | 50 | /* Lua lexer state. */ 51 | typedef struct LexState { 52 | struct FuncState *fs; /* Current FuncState. Defined in lj_parse.c. */ 53 | struct lua_State *L; /* Lua state. */ 54 | TValue tokenval; /* Current token value. */ 55 | TValue lookaheadval; /* Lookahead token value. */ 56 | int current; /* Current character (charint). */ 57 | LexToken token; /* Current token. */ 58 | LexToken lookahead; /* Lookahead token. */ 59 | MSize n; /* Bytes left in input buffer. */ 60 | const char *p; /* Current position in input buffer. */ 61 | SBuf sb; /* String buffer for tokens. */ 62 | lua_Reader rfunc; /* Reader callback. */ 63 | void *rdata; /* Reader callback data. */ 64 | BCLine linenumber; /* Input line counter. */ 65 | BCLine lastline; /* Line of last token. */ 66 | GCstr *chunkname; /* Current chunk name (interned string). */ 67 | const char *chunkarg; /* Chunk name argument. */ 68 | const char *mode; /* Allow loading bytecode (b) and/or source text (t). */ 69 | VarInfo *vstack; /* Stack for names and extents of local variables. */ 70 | MSize sizevstack; /* Size of variable stack. */ 71 | MSize vtop; /* Top of variable stack. */ 72 | BCInsLine *bcstack; /* Stack for bytecode instructions/line numbers. */ 73 | MSize sizebcstack; /* Size of bytecode stack. */ 74 | uint32_t level; /* Syntactical nesting level. */ 75 | } LexState; 76 | 77 | LJ_FUNC int lj_lex_setup(lua_State *L, LexState *ls); 78 | LJ_FUNC void lj_lex_cleanup(lua_State *L, LexState *ls); 79 | LJ_FUNC void lj_lex_next(LexState *ls); 80 | LJ_FUNC LexToken lj_lex_lookahead(LexState *ls); 81 | LJ_FUNC const char *lj_lex_token2str(LexState *ls, LexToken token); 82 | LJ_FUNC_NORET void lj_lex_error(LexState *ls, LexToken token, ErrMsg em, ...); 83 | LJ_FUNC void lj_lex_init(lua_State *L); 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Library function support. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_LIB_H 7 | #define _LJ_LIB_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* 12 | ** A fallback handler is called by the assembler VM if the fast path fails: 13 | ** 14 | ** - too few arguments: unrecoverable. 15 | ** - wrong argument type: recoverable, if coercion succeeds. 16 | ** - bad argument value: unrecoverable. 17 | ** - stack overflow: recoverable, if stack reallocation succeeds. 18 | ** - extra handling: recoverable. 19 | ** 20 | ** The unrecoverable cases throw an error with lj_err_arg(), lj_err_argtype(), 21 | ** lj_err_caller() or lj_err_callermsg(). 22 | ** The recoverable cases return 0 or the number of results + 1. 23 | ** The assembler VM retries the fast path only if 0 is returned. 24 | ** This time the fallback must not be called again or it gets stuck in a loop. 25 | */ 26 | 27 | /* Return values from fallback handler. */ 28 | #define FFH_RETRY 0 29 | #define FFH_UNREACHABLE FFH_RETRY 30 | #define FFH_RES(n) ((n)+1) 31 | #define FFH_TAILCALL (-1) 32 | 33 | LJ_FUNC TValue *lj_lib_checkany(lua_State *L, int narg); 34 | LJ_FUNC GCstr *lj_lib_checkstr(lua_State *L, int narg); 35 | LJ_FUNC GCstr *lj_lib_optstr(lua_State *L, int narg); 36 | #if LJ_DUALNUM 37 | LJ_FUNC void lj_lib_checknumber(lua_State *L, int narg); 38 | #else 39 | #define lj_lib_checknumber(L, narg) lj_lib_checknum((L), (narg)) 40 | #endif 41 | LJ_FUNC lua_Number lj_lib_checknum(lua_State *L, int narg); 42 | LJ_FUNC int32_t lj_lib_checkint(lua_State *L, int narg); 43 | LJ_FUNC int32_t lj_lib_optint(lua_State *L, int narg, int32_t def); 44 | LJ_FUNC int32_t lj_lib_checkbit(lua_State *L, int narg); 45 | LJ_FUNC GCfunc *lj_lib_checkfunc(lua_State *L, int narg); 46 | LJ_FUNC GCtab *lj_lib_checktab(lua_State *L, int narg); 47 | LJ_FUNC GCtab *lj_lib_checktabornil(lua_State *L, int narg); 48 | LJ_FUNC int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst); 49 | 50 | /* Avoid including lj_frame.h. */ 51 | #define lj_lib_upvalue(L, n) \ 52 | (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1]) 53 | 54 | #if LJ_TARGET_WINDOWS 55 | #define lj_lib_checkfpu(L) \ 56 | do { setnumV(L->top++, (lua_Number)1437217655); \ 57 | if (lua_tointeger(L, -1) != 1437217655) lj_err_caller(L, LJ_ERR_BADFPU); \ 58 | L->top--; } while (0) 59 | #else 60 | #define lj_lib_checkfpu(L) UNUSED(L) 61 | #endif 62 | 63 | /* Push internal function on the stack. */ 64 | static LJ_AINLINE void lj_lib_pushcc(lua_State *L, lua_CFunction f, 65 | int id, int n) 66 | { 67 | GCfunc *fn; 68 | lua_pushcclosure(L, f, n); 69 | fn = funcV(L->top-1); 70 | fn->c.ffid = (uint8_t)id; 71 | setmref(fn->c.pc, &G(L)->bc_cfunc_int); 72 | } 73 | 74 | #define lj_lib_pushcf(L, fn, id) (lj_lib_pushcc(L, (fn), (id), 0)) 75 | 76 | /* Library function declarations. Scanned by buildvm. */ 77 | #define LJLIB_CF(name) static int lj_cf_##name(lua_State *L) 78 | #define LJLIB_ASM(name) static int lj_ffh_##name(lua_State *L) 79 | #define LJLIB_ASM_(name) 80 | #define LJLIB_SET(name) 81 | #define LJLIB_PUSH(arg) 82 | #define LJLIB_REC(handler) 83 | #define LJLIB_NOREGUV 84 | #define LJLIB_NOREG 85 | 86 | #define LJ_LIB_REG(L, regname, name) \ 87 | lj_lib_register(L, regname, lj_lib_init_##name, lj_lib_cf_##name) 88 | 89 | LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, 90 | const uint8_t *init, const lua_CFunction *cf); 91 | 92 | /* Library init data tags. */ 93 | #define LIBINIT_LENMASK 0x3f 94 | #define LIBINIT_TAGMASK 0xc0 95 | #define LIBINIT_CF 0x00 96 | #define LIBINIT_ASM 0x40 97 | #define LIBINIT_ASM_ 0x80 98 | #define LIBINIT_STRING 0xc0 99 | #define LIBINIT_MAXSTR 0x39 100 | #define LIBINIT_SET 0xfa 101 | #define LIBINIT_NUMBER 0xfb 102 | #define LIBINIT_COPY 0xfc 103 | #define LIBINIT_LASTCL 0xfd 104 | #define LIBINIT_FFID 0xfe 105 | #define LIBINIT_END 0xff 106 | 107 | /* Exported library functions. */ 108 | 109 | typedef struct RandomState RandomState; 110 | LJ_FUNC uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs); 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_load.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Load and dump code. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | #define lj_load_c 10 | #define LUA_CORE 11 | 12 | #include "lua.h" 13 | #include "lauxlib.h" 14 | 15 | #include "lj_obj.h" 16 | #include "lj_gc.h" 17 | #include "lj_err.h" 18 | #include "lj_str.h" 19 | #include "lj_func.h" 20 | #include "lj_frame.h" 21 | #include "lj_vm.h" 22 | #include "lj_lex.h" 23 | #include "lj_bcdump.h" 24 | #include "lj_parse.h" 25 | 26 | /* -- Load Lua source code and bytecode ----------------------------------- */ 27 | 28 | static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud) 29 | { 30 | LexState *ls = (LexState *)ud; 31 | GCproto *pt; 32 | GCfunc *fn; 33 | int bc; 34 | UNUSED(dummy); 35 | cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ 36 | bc = lj_lex_setup(L, ls); 37 | if (ls->mode && !strchr(ls->mode, bc ? 'b' : 't')) { 38 | setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XMODE)); 39 | lj_err_throw(L, LUA_ERRSYNTAX); 40 | } 41 | pt = bc ? lj_bcread(ls) : lj_parse(ls); 42 | fn = lj_func_newL_empty(L, pt, tabref(L->env)); 43 | /* Don't combine above/below into one statement. */ 44 | setfuncV(L, L->top++, fn); 45 | return NULL; 46 | } 47 | 48 | LUA_API int lua_loadx(lua_State *L, lua_Reader reader, void *data, 49 | const char *chunkname, const char *mode) 50 | { 51 | LexState ls; 52 | int status; 53 | ls.rfunc = reader; 54 | ls.rdata = data; 55 | ls.chunkarg = chunkname ? chunkname : "?"; 56 | ls.mode = mode; 57 | lj_str_initbuf(&ls.sb); 58 | status = lj_vm_cpcall(L, NULL, &ls, cpparser); 59 | lj_lex_cleanup(L, &ls); 60 | lj_gc_check(L); 61 | return status; 62 | } 63 | 64 | LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, 65 | const char *chunkname) 66 | { 67 | return lua_loadx(L, reader, data, chunkname, NULL); 68 | } 69 | 70 | typedef struct FileReaderCtx { 71 | FILE *fp; 72 | char buf[LUAL_BUFFERSIZE]; 73 | } FileReaderCtx; 74 | 75 | static const char *reader_file(lua_State *L, void *ud, size_t *size) 76 | { 77 | FileReaderCtx *ctx = (FileReaderCtx *)ud; 78 | UNUSED(L); 79 | if (feof(ctx->fp)) return NULL; 80 | *size = fread(ctx->buf, 1, sizeof(ctx->buf), ctx->fp); 81 | return *size > 0 ? ctx->buf : NULL; 82 | } 83 | 84 | LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename, 85 | const char *mode) 86 | { 87 | FileReaderCtx ctx; 88 | int status; 89 | const char *chunkname; 90 | if (filename) { 91 | ctx.fp = fopen(filename, "rb"); 92 | if (ctx.fp == NULL) { 93 | lua_pushfstring(L, "cannot open %s: %s", filename, strerror(errno)); 94 | return LUA_ERRFILE; 95 | } 96 | chunkname = lua_pushfstring(L, "@%s", filename); 97 | } else { 98 | ctx.fp = stdin; 99 | chunkname = "=stdin"; 100 | } 101 | status = lua_loadx(L, reader_file, &ctx, chunkname, mode); 102 | if (ferror(ctx.fp)) { 103 | L->top -= filename ? 2 : 1; 104 | lua_pushfstring(L, "cannot read %s: %s", chunkname+1, strerror(errno)); 105 | if (filename) 106 | fclose(ctx.fp); 107 | return LUA_ERRFILE; 108 | } 109 | if (filename) { 110 | L->top--; 111 | copyTV(L, L->top-1, L->top); 112 | fclose(ctx.fp); 113 | } 114 | return status; 115 | } 116 | 117 | LUALIB_API int luaL_loadfile(lua_State *L, const char *filename) 118 | { 119 | return luaL_loadfilex(L, filename, NULL); 120 | } 121 | 122 | typedef struct StringReaderCtx { 123 | const char *str; 124 | size_t size; 125 | } StringReaderCtx; 126 | 127 | static const char *reader_string(lua_State *L, void *ud, size_t *size) 128 | { 129 | StringReaderCtx *ctx = (StringReaderCtx *)ud; 130 | UNUSED(L); 131 | if (ctx->size == 0) return NULL; 132 | *size = ctx->size; 133 | ctx->size = 0; 134 | return ctx->str; 135 | } 136 | 137 | LUALIB_API int luaL_loadbufferx(lua_State *L, const char *buf, size_t size, 138 | const char *name, const char *mode) 139 | { 140 | StringReaderCtx ctx; 141 | ctx.str = buf; 142 | ctx.size = size; 143 | return lua_loadx(L, reader_string, &ctx, name, mode); 144 | } 145 | 146 | LUALIB_API int luaL_loadbuffer(lua_State *L, const char *buf, size_t size, 147 | const char *name) 148 | { 149 | return luaL_loadbufferx(L, buf, size, name, NULL); 150 | } 151 | 152 | LUALIB_API int luaL_loadstring(lua_State *L, const char *s) 153 | { 154 | return luaL_loadbuffer(L, s, strlen(s), s); 155 | } 156 | 157 | /* -- Dump bytecode ------------------------------------------------------- */ 158 | 159 | LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data) 160 | { 161 | cTValue *o = L->top-1; 162 | api_check(L, L->top > L->base); 163 | if (tvisfunc(o) && isluafunc(funcV(o))) 164 | return lj_bcwrite(L, funcproto(funcV(o)), writer, data, 0); 165 | else 166 | return 1; 167 | } 168 | 169 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_mcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Machine code management. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_MCODE_H 7 | #define _LJ_MCODE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT || LJ_HASFFI 12 | LJ_FUNC void lj_mcode_sync(void *start, void *end); 13 | #endif 14 | 15 | #if LJ_HASJIT 16 | 17 | #include "lj_jit.h" 18 | 19 | LJ_FUNC void lj_mcode_free(jit_State *J); 20 | LJ_FUNC MCode *lj_mcode_reserve(jit_State *J, MCode **lim); 21 | LJ_FUNC void lj_mcode_commit(jit_State *J, MCode *m); 22 | LJ_FUNC void lj_mcode_abort(jit_State *J); 23 | LJ_FUNC MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish); 24 | LJ_FUNC_NORET void lj_mcode_limiterr(jit_State *J, size_t need); 25 | 26 | #define lj_mcode_commitbot(J, m) (J->mcbot = (m)) 27 | 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_meta.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Metamethod handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_META_H 7 | #define _LJ_META_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Metamethod handling */ 12 | LJ_FUNC void lj_meta_init(lua_State *L); 13 | LJ_FUNC cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name); 14 | LJ_FUNC cTValue *lj_meta_lookup(lua_State *L, cTValue *o, MMS mm); 15 | #if LJ_HASFFI 16 | LJ_FUNC int lj_meta_tailcall(lua_State *L, cTValue *tv); 17 | #endif 18 | 19 | #define lj_meta_fastg(g, mt, mm) \ 20 | ((mt) == NULL ? NULL : ((mt)->nomm & (1u<<(mm))) ? NULL : \ 21 | lj_meta_cache(mt, mm, mmname_str(g, mm))) 22 | #define lj_meta_fast(L, mt, mm) lj_meta_fastg(G(L), mt, mm) 23 | 24 | /* C helpers for some instructions, called from assembler VM. */ 25 | LJ_FUNCA cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k); 26 | LJ_FUNCA TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k); 27 | LJ_FUNCA TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, 28 | cTValue *rc, BCReg op); 29 | LJ_FUNCA TValue *lj_meta_cat(lua_State *L, TValue *top, int left); 30 | LJ_FUNCA TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o); 31 | LJ_FUNCA TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne); 32 | LJ_FUNCA TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins); 33 | LJ_FUNCA TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op); 34 | LJ_FUNCA void lj_meta_call(lua_State *L, TValue *func, TValue *top); 35 | LJ_FUNCA void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_obj.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Miscellaneous object handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_obj_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Object type names. */ 12 | LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */ 13 | "no value", "nil", "boolean", "userdata", "number", "string", 14 | "table", "function", "userdata", "thread", "proto", "cdata" 15 | }; 16 | 17 | LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */ 18 | "nil", "boolean", "boolean", "userdata", "string", "upval", "thread", 19 | "proto", "function", "trace", "cdata", "table", "userdata", "number" 20 | }; 21 | 22 | /* Compare two objects without calling metamethods. */ 23 | int lj_obj_equal(cTValue *o1, cTValue *o2) 24 | { 25 | if (itype(o1) == itype(o2)) { 26 | if (tvispri(o1)) 27 | return 1; 28 | if (!tvisnum(o1)) 29 | return gcrefeq(o1->gcr, o2->gcr); 30 | } else if (!tvisnumber(o1) || !tvisnumber(o2)) { 31 | return 0; 32 | } 33 | return numberVnum(o1) == numberVnum(o2); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_opt_dce.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** DCE: Dead Code Elimination. Pre-LOOP only -- ASM already performs DCE. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_opt_dce_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT 12 | 13 | #include "lj_ir.h" 14 | #include "lj_jit.h" 15 | #include "lj_iropt.h" 16 | 17 | /* Some local macros to save typing. Undef'd at the end. */ 18 | #define IR(ref) (&J->cur.ir[(ref)]) 19 | 20 | /* Scan through all snapshots and mark all referenced instructions. */ 21 | static void dce_marksnap(jit_State *J) 22 | { 23 | SnapNo i, nsnap = J->cur.nsnap; 24 | for (i = 0; i < nsnap; i++) { 25 | SnapShot *snap = &J->cur.snap[i]; 26 | SnapEntry *map = &J->cur.snapmap[snap->mapofs]; 27 | MSize n, nent = snap->nent; 28 | for (n = 0; n < nent; n++) { 29 | IRRef ref = snap_ref(map[n]); 30 | if (ref >= REF_FIRST) 31 | irt_setmark(IR(ref)->t); 32 | } 33 | } 34 | } 35 | 36 | /* Backwards propagate marks. Replace unused instructions with NOPs. */ 37 | static void dce_propagate(jit_State *J) 38 | { 39 | IRRef1 *pchain[IR__MAX]; 40 | IRRef ins; 41 | uint32_t i; 42 | for (i = 0; i < IR__MAX; i++) pchain[i] = &J->chain[i]; 43 | for (ins = J->cur.nins-1; ins >= REF_FIRST; ins--) { 44 | IRIns *ir = IR(ins); 45 | if (irt_ismarked(ir->t)) { 46 | irt_clearmark(ir->t); 47 | pchain[ir->o] = &ir->prev; 48 | } else if (!ir_sideeff(ir)) { 49 | *pchain[ir->o] = ir->prev; /* Reroute original instruction chain. */ 50 | ir->t.irt = IRT_NIL; 51 | ir->o = IR_NOP; /* Replace instruction with NOP. */ 52 | ir->op1 = ir->op2 = 0; 53 | ir->prev = 0; 54 | continue; 55 | } 56 | if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); 57 | if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); 58 | } 59 | } 60 | 61 | /* Dead Code Elimination. 62 | ** 63 | ** First backpropagate marks for all used instructions. Then replace 64 | ** the unused ones with a NOP. Note that compressing the IR to eliminate 65 | ** the NOPs does not pay off. 66 | */ 67 | void lj_opt_dce(jit_State *J) 68 | { 69 | if ((J->flags & JIT_F_OPT_DCE)) { 70 | dce_marksnap(J); 71 | dce_propagate(J); 72 | } 73 | } 74 | 75 | #undef IR 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Lua parser (source code -> bytecode). 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_PARSE_H 7 | #define _LJ_PARSE_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_lex.h" 11 | 12 | LJ_FUNC GCproto *lj_parse(LexState *ls); 13 | LJ_FUNC GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t l); 14 | #if LJ_HASFFI 15 | LJ_FUNC void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd); 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_recdef.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file. DO NOT EDIT! */ 2 | 3 | static const uint16_t recff_idmap[] = { 4 | 0, 5 | 0x0100, 6 | 0x0200, 7 | 0x0300, 8 | 0, 9 | 0, 10 | 0x0400, 11 | 0x0500, 12 | 0x0600, 13 | 0x0700, 14 | 0, 15 | 0, 16 | 0x0800, 17 | 0x0900, 18 | 0x0a00, 19 | 0, 20 | 0x0b00, 21 | 0x0c00, 22 | 0x0d00, 23 | 0, 24 | 0x0e00, 25 | 0x0f00, 26 | 0, 27 | 0, 28 | 0, 29 | 0, 30 | 0, 31 | 0, 32 | 0, 33 | 0, 34 | 0, 35 | 0, 36 | 0, 37 | 0, 38 | 0, 39 | 0, 40 | 0, 41 | 0x1000, 42 | 0x1100+(IRFPM_FLOOR), 43 | 0x1100+(IRFPM_CEIL), 44 | 0x1200+(IRFPM_SQRT), 45 | 0x1200+(IRFPM_LOG10), 46 | 0x1200+(IRFPM_EXP), 47 | 0x1200+(IRFPM_SIN), 48 | 0x1200+(IRFPM_COS), 49 | 0x1200+(IRFPM_TAN), 50 | 0x1300+(FF_math_asin), 51 | 0x1300+(FF_math_acos), 52 | 0x1300+(FF_math_atan), 53 | 0x1400+(IRCALL_sinh), 54 | 0x1400+(IRCALL_cosh), 55 | 0x1400+(IRCALL_tanh), 56 | 0, 57 | 0x1500, 58 | 0x1600, 59 | 0x1700, 60 | 0x1700, 61 | 0x1800, 62 | 0x1900, 63 | 0, 64 | 0x1a00, 65 | 0x1b00+(IR_MIN), 66 | 0x1b00+(IR_MAX), 67 | 0x1c00, 68 | 0, 69 | 0x1d00+(IR_TOBIT), 70 | 0x1d00+(IR_BNOT), 71 | 0x1d00+(IR_BSWAP), 72 | 0x1e00+(IR_BSHL), 73 | 0x1e00+(IR_BSHR), 74 | 0x1e00+(IR_BSAR), 75 | 0x1e00+(IR_BROL), 76 | 0x1e00+(IR_BROR), 77 | 0x1f00+(IR_BAND), 78 | 0x1f00+(IR_BOR), 79 | 0x1f00+(IR_BXOR), 80 | 0, 81 | 0x2000, 82 | 0x2100+(0), 83 | 0, 84 | 0x2100+(1), 85 | 0, 86 | 0, 87 | 0, 88 | 0, 89 | 0, 90 | 0, 91 | 0, 92 | 0, 93 | 0, 94 | 0, 95 | 0, 96 | 0, 97 | 0, 98 | 0x2200, 99 | 0, 100 | 0x2300, 101 | 0x2400, 102 | 0, 103 | 0, 104 | 0, 105 | 0, 106 | 0x2500+(0), 107 | 0x2600+(0), 108 | 0, 109 | 0, 110 | 0, 111 | 0, 112 | 0, 113 | 0, 114 | 0, 115 | 0, 116 | 0, 117 | 0, 118 | 0x2500+(GCROOT_IO_OUTPUT), 119 | 0x2600+(GCROOT_IO_OUTPUT), 120 | 0, 121 | 0, 122 | 0, 123 | 0, 124 | 0, 125 | 0, 126 | 0, 127 | 0, 128 | 0, 129 | 0, 130 | 0, 131 | 0, 132 | 0, 133 | 0, 134 | 0, 135 | 0, 136 | 0, 137 | 0, 138 | 0, 139 | 0, 140 | 0, 141 | 0, 142 | 0, 143 | 0, 144 | 0, 145 | 0, 146 | 0, 147 | 0, 148 | 0, 149 | 0, 150 | 0, 151 | 0, 152 | 0, 153 | 0, 154 | 0, 155 | 0, 156 | 0, 157 | 0, 158 | 0, 159 | 0, 160 | 0, 161 | 0, 162 | 0, 163 | 0, 164 | 0, 165 | 0, 166 | 0, 167 | 0, 168 | 0x2700+(0), 169 | 0x2700+(1), 170 | 0x2800+(MM_eq), 171 | 0x2800+(MM_len), 172 | 0x2800+(MM_lt), 173 | 0x2800+(MM_le), 174 | 0x2800+(MM_concat), 175 | 0x2900, 176 | 0x2800+(MM_add), 177 | 0x2800+(MM_sub), 178 | 0x2800+(MM_mul), 179 | 0x2800+(MM_div), 180 | 0x2800+(MM_mod), 181 | 0x2800+(MM_pow), 182 | 0x2800+(MM_unm), 183 | 0, 184 | 0, 185 | 0, 186 | 0x2a00+(1), 187 | 0x2a00+(0), 188 | 0, 189 | 0, 190 | 0, 191 | 0, 192 | 0x2b00, 193 | 0x2b00, 194 | 0x2c00, 195 | 0x2d00, 196 | 0x2e00+(FF_ffi_sizeof), 197 | 0x2e00+(FF_ffi_alignof), 198 | 0x2e00+(FF_ffi_offsetof), 199 | 0x2f00, 200 | 0x3000, 201 | 0x3100, 202 | 0x3200, 203 | 0x3300, 204 | 0, 205 | 0x3400 206 | }; 207 | 208 | static const RecordFunc recff_func[] = { 209 | recff_nyi, 210 | recff_c, 211 | recff_assert, 212 | recff_type, 213 | recff_ipairs_aux, 214 | recff_ipairs, 215 | recff_getmetatable, 216 | recff_setmetatable, 217 | recff_rawget, 218 | recff_rawset, 219 | recff_rawequal, 220 | recff_select, 221 | recff_tonumber, 222 | recff_tostring, 223 | recff_pcall, 224 | recff_xpcall, 225 | recff_math_abs, 226 | recff_math_round, 227 | recff_math_unary, 228 | recff_math_atrig, 229 | recff_math_htrig, 230 | recff_math_modf, 231 | recff_math_log, 232 | recff_math_degrad, 233 | recff_math_atan2, 234 | recff_math_pow, 235 | recff_math_ldexp, 236 | recff_math_minmax, 237 | recff_math_random, 238 | recff_bit_unary, 239 | recff_bit_shift, 240 | recff_bit_nary, 241 | recff_string_len, 242 | recff_string_range, 243 | recff_table_getn, 244 | recff_table_insert, 245 | recff_table_remove, 246 | recff_io_write, 247 | recff_io_flush, 248 | recff_cdata_index, 249 | recff_cdata_arith, 250 | recff_cdata_call, 251 | recff_clib_index, 252 | recff_ffi_new, 253 | recff_ffi_typeof, 254 | recff_ffi_istype, 255 | recff_ffi_xof, 256 | recff_ffi_errno, 257 | recff_ffi_string, 258 | recff_ffi_copy, 259 | recff_ffi_fill, 260 | recff_ffi_abi, 261 | recff_ffi_gc 262 | }; 263 | 264 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_record.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace recorder (bytecode -> SSA IR). 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_RECORD_H 7 | #define _LJ_RECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | /* Context for recording an indexed load/store. */ 14 | typedef struct RecordIndex { 15 | TValue tabv; /* Runtime value of table (or indexed object). */ 16 | TValue keyv; /* Runtime value of key. */ 17 | TValue valv; /* Runtime value of stored value. */ 18 | TValue mobjv; /* Runtime value of metamethod object. */ 19 | GCtab *mtv; /* Runtime value of metatable object. */ 20 | cTValue *oldv; /* Runtime value of previously stored value. */ 21 | TRef tab; /* Table (or indexed object) reference. */ 22 | TRef key; /* Key reference. */ 23 | TRef val; /* Value reference for a store or 0 for a load. */ 24 | TRef mt; /* Metatable reference. */ 25 | TRef mobj; /* Metamethod object reference. */ 26 | int idxchain; /* Index indirections left or 0 for raw lookup. */ 27 | } RecordIndex; 28 | 29 | LJ_FUNC int lj_record_objcmp(jit_State *J, TRef a, TRef b, 30 | cTValue *av, cTValue *bv); 31 | LJ_FUNC TRef lj_record_constify(jit_State *J, cTValue *o); 32 | 33 | LJ_FUNC void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs); 34 | LJ_FUNC void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs); 35 | LJ_FUNC void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults); 36 | 37 | LJ_FUNC int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm); 38 | LJ_FUNC TRef lj_record_idx(jit_State *J, RecordIndex *ix); 39 | 40 | LJ_FUNC void lj_record_ins(jit_State *J); 41 | LJ_FUNC void lj_record_setup(jit_State *J); 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_snap.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Snapshot handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_SNAP_H 7 | #define _LJ_SNAP_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | LJ_FUNC void lj_snap_add(jit_State *J); 14 | LJ_FUNC void lj_snap_purge(jit_State *J); 15 | LJ_FUNC void lj_snap_shrink(jit_State *J); 16 | LJ_FUNC IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir); 17 | LJ_FUNC void lj_snap_replay(jit_State *J, GCtrace *T); 18 | LJ_FUNC const BCIns *lj_snap_restore(jit_State *J, void *exptr); 19 | LJ_FUNC void lj_snap_grow_buf_(jit_State *J, MSize need); 20 | LJ_FUNC void lj_snap_grow_map_(jit_State *J, MSize need); 21 | 22 | static LJ_AINLINE void lj_snap_grow_buf(jit_State *J, MSize need) 23 | { 24 | if (LJ_UNLIKELY(need > J->sizesnap)) lj_snap_grow_buf_(J, need); 25 | } 26 | 27 | static LJ_AINLINE void lj_snap_grow_map(jit_State *J, MSize need) 28 | { 29 | if (LJ_UNLIKELY(need > J->sizesnapmap)) lj_snap_grow_map_(J, need); 30 | } 31 | 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** State and stack handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STATE_H 7 | #define _LJ_STATE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #define incr_top(L) \ 12 | (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0)) 13 | 14 | #define savestack(L, p) ((char *)(p) - mref(L->stack, char)) 15 | #define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n))) 16 | 17 | LJ_FUNC void lj_state_relimitstack(lua_State *L); 18 | LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used); 19 | LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need); 20 | LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L); 21 | 22 | static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) 23 | { 24 | if ((mref(L->maxstack, char) - (char *)L->top) <= 25 | (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue)) 26 | lj_state_growstack(L, need); 27 | } 28 | 29 | LJ_FUNC lua_State *lj_state_new(lua_State *L); 30 | LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); 31 | #if LJ_64 32 | LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud); 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_str.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** String handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STR_H 7 | #define _LJ_STR_H 8 | 9 | #include 10 | 11 | #include "lj_obj.h" 12 | 13 | /* String interning. */ 14 | LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b); 15 | LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); 16 | LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); 17 | LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); 18 | 19 | #define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) 20 | #define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) 21 | 22 | /* Type conversions. */ 23 | LJ_FUNC size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o); 24 | LJ_FUNC char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k); 25 | LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np); 26 | LJ_FUNC GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k); 27 | LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o); 28 | 29 | #define LJ_STR_INTBUF (1+10) 30 | #define LJ_STR_NUMBUF LUAI_MAXNUMBER2STR 31 | 32 | /* String formatting. */ 33 | LJ_FUNC const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp); 34 | LJ_FUNC const char *lj_str_pushf(lua_State *L, const char *fmt, ...) 35 | #if defined(__GNUC__) 36 | __attribute__ ((format (printf, 2, 3))) 37 | #endif 38 | ; 39 | 40 | /* Resizable string buffers. Struct definition in lj_obj.h. */ 41 | LJ_FUNC char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz); 42 | 43 | #define lj_str_initbuf(sb) ((sb)->buf = NULL, (sb)->sz = 0) 44 | #define lj_str_resetbuf(sb) ((sb)->n = 0) 45 | #define lj_str_resizebuf(L, sb, size) \ 46 | ((sb)->buf = (char *)lj_mem_realloc(L, (sb)->buf, (sb)->sz, (size)), \ 47 | (sb)->sz = (size)) 48 | #define lj_str_freebuf(g, sb) lj_mem_free(g, (void *)(sb)->buf, (sb)->sz) 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_strscan.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** String scanning. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STRSCAN_H 7 | #define _LJ_STRSCAN_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Options for accepted/returned formats. */ 12 | #define STRSCAN_OPT_TOINT 0x01 /* Convert to int32_t, if possible. */ 13 | #define STRSCAN_OPT_TONUM 0x02 /* Always convert to double. */ 14 | #define STRSCAN_OPT_IMAG 0x04 15 | #define STRSCAN_OPT_LL 0x08 16 | #define STRSCAN_OPT_C 0x10 17 | 18 | /* Returned format. */ 19 | typedef enum { 20 | STRSCAN_ERROR, 21 | STRSCAN_NUM, STRSCAN_IMAG, 22 | STRSCAN_INT, STRSCAN_U32, STRSCAN_I64, STRSCAN_U64, 23 | } StrScanFmt; 24 | 25 | LJ_FUNC StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt); 26 | LJ_FUNC int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o); 27 | #if LJ_DUALNUM 28 | LJ_FUNC int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o); 29 | #else 30 | #define lj_strscan_number(s, o) lj_strscan_num((s), (o)) 31 | #endif 32 | 33 | /* Check for number or convert string to number/int in-place (!). */ 34 | static LJ_AINLINE int lj_strscan_numberobj(TValue *o) 35 | { 36 | return tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), o)); 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_tab.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Table handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_TAB_H 7 | #define _LJ_TAB_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Hash constants. Tuned using a brute force search. */ 12 | #define HASH_BIAS (-0x04c11db7) 13 | #define HASH_ROT1 14 14 | #define HASH_ROT2 5 15 | #define HASH_ROT3 13 16 | 17 | /* Scramble the bits of numbers and pointers. */ 18 | static LJ_AINLINE uint32_t hashrot(uint32_t lo, uint32_t hi) 19 | { 20 | #if LJ_TARGET_X86ORX64 21 | /* Prefer variant that compiles well for a 2-operand CPU. */ 22 | lo ^= hi; hi = lj_rol(hi, HASH_ROT1); 23 | lo -= hi; hi = lj_rol(hi, HASH_ROT2); 24 | hi ^= lo; hi -= lj_rol(lo, HASH_ROT3); 25 | #else 26 | lo ^= hi; 27 | lo = lo - lj_rol(hi, HASH_ROT1); 28 | hi = lo ^ lj_rol(hi, HASH_ROT1 + HASH_ROT2); 29 | hi = hi - lj_rol(lo, HASH_ROT3); 30 | #endif 31 | return hi; 32 | } 33 | 34 | #define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0) 35 | 36 | LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits); 37 | #if LJ_HASJIT 38 | LJ_FUNC GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize); 39 | #endif 40 | LJ_FUNCA GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt); 41 | LJ_FUNC void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t); 42 | LJ_FUNCA void lj_tab_reasize(lua_State *L, GCtab *t, uint32_t nasize); 43 | 44 | /* Caveat: all getters except lj_tab_get() can return NULL! */ 45 | 46 | LJ_FUNCA cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key); 47 | LJ_FUNC cTValue *lj_tab_getstr(GCtab *t, GCstr *key); 48 | LJ_FUNCA cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key); 49 | 50 | /* Caveat: all setters require a write barrier for the stored value. */ 51 | 52 | LJ_FUNCA TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key); 53 | LJ_FUNC TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key); 54 | LJ_FUNC TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key); 55 | LJ_FUNC TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key); 56 | 57 | #define inarray(t, key) ((MSize)(key) < (MSize)(t)->asize) 58 | #define arrayslot(t, i) (&tvref((t)->array)[(i)]) 59 | #define lj_tab_getint(t, key) \ 60 | (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_getinth((t), (key))) 61 | #define lj_tab_setint(L, t, key) \ 62 | (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_setinth(L, (t), (key))) 63 | 64 | LJ_FUNCA int lj_tab_next(lua_State *L, GCtab *t, TValue *key); 65 | LJ_FUNCA MSize LJ_FASTCALL lj_tab_len(GCtab *t); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace management. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_TRACE_H 7 | #define _LJ_TRACE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT 12 | #include "lj_jit.h" 13 | #include "lj_dispatch.h" 14 | 15 | /* Trace errors. */ 16 | typedef enum { 17 | #define TREDEF(name, msg) LJ_TRERR_##name, 18 | #include "lj_traceerr.h" 19 | LJ_TRERR__MAX 20 | } TraceError; 21 | 22 | LJ_FUNC_NORET void lj_trace_err(jit_State *J, TraceError e); 23 | LJ_FUNC_NORET void lj_trace_err_info(jit_State *J, TraceError e); 24 | 25 | /* Trace management. */ 26 | LJ_FUNC void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T); 27 | LJ_FUNC void lj_trace_reenableproto(GCproto *pt); 28 | LJ_FUNC void lj_trace_flushproto(global_State *g, GCproto *pt); 29 | LJ_FUNC void lj_trace_flush(jit_State *J, TraceNo traceno); 30 | LJ_FUNC int lj_trace_flushall(lua_State *L); 31 | LJ_FUNC void lj_trace_initstate(global_State *g); 32 | LJ_FUNC void lj_trace_freestate(global_State *g); 33 | 34 | /* Event handling. */ 35 | LJ_FUNC void lj_trace_ins(jit_State *J, const BCIns *pc); 36 | LJ_FUNCA void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc); 37 | LJ_FUNCA int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr); 38 | 39 | /* Signal asynchronous abort of trace or end of trace. */ 40 | #define lj_trace_abort(g) (G2J(g)->state &= ~LJ_TRACE_ACTIVE) 41 | #define lj_trace_end(J) (J->state = LJ_TRACE_END) 42 | 43 | #else 44 | 45 | #define lj_trace_flushall(L) (UNUSED(L), 0) 46 | #define lj_trace_initstate(g) UNUSED(g) 47 | #define lj_trace_freestate(g) UNUSED(g) 48 | #define lj_trace_abort(g) UNUSED(g) 49 | #define lj_trace_end(J) UNUSED(J) 50 | 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_traceerr.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace compiler error messages. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | /* This file may be included multiple times with different TREDEF macros. */ 7 | 8 | /* Recording. */ 9 | TREDEF(RECERR, "error thrown or hook called during recording") 10 | TREDEF(TRACEOV, "trace too long") 11 | TREDEF(STACKOV, "trace too deep") 12 | TREDEF(SNAPOV, "too many snapshots") 13 | TREDEF(BLACKL, "blacklisted") 14 | TREDEF(NYIBC, "NYI: bytecode %d") 15 | 16 | /* Recording loop ops. */ 17 | TREDEF(LLEAVE, "leaving loop in root trace") 18 | TREDEF(LINNER, "inner loop in root trace") 19 | TREDEF(LUNROLL, "loop unroll limit reached") 20 | 21 | /* Recording calls/returns. */ 22 | TREDEF(BADTYPE, "bad argument type") 23 | TREDEF(CJITOFF, "call to JIT-disabled function") 24 | TREDEF(CUNROLL, "call unroll limit reached") 25 | TREDEF(DOWNREC, "down-recursion, restarting") 26 | TREDEF(NYICF, "NYI: C function %p") 27 | TREDEF(NYIFF, "NYI: FastFunc %s") 28 | TREDEF(NYIFFU, "NYI: unsupported variant of FastFunc %s") 29 | TREDEF(NYIRETL, "NYI: return to lower frame") 30 | 31 | /* Recording indexed load/store. */ 32 | TREDEF(STORENN, "store with nil or NaN key") 33 | TREDEF(NOMM, "missing metamethod") 34 | TREDEF(IDXLOOP, "looping index lookup") 35 | TREDEF(NYITMIX, "NYI: mixed sparse/dense table") 36 | 37 | /* Recording C data operations. */ 38 | TREDEF(NOCACHE, "symbol not in cache") 39 | TREDEF(NYICONV, "NYI: unsupported C type conversion") 40 | TREDEF(NYICALL, "NYI: unsupported C function type") 41 | 42 | /* Optimizations. */ 43 | TREDEF(GFAIL, "guard would always fail") 44 | TREDEF(PHIOV, "too many PHIs") 45 | TREDEF(TYPEINS, "persistent type instability") 46 | 47 | /* Assembler. */ 48 | TREDEF(MCODEAL, "failed to allocate mcode memory") 49 | TREDEF(MCODEOV, "machine code too long") 50 | TREDEF(MCODELM, "hit mcode limit (retrying)") 51 | TREDEF(SPILLOV, "too many spill slots") 52 | TREDEF(BADRA, "inconsistent register allocation") 53 | TREDEF(NYIIR, "NYI: cannot assemble IR instruction %d") 54 | TREDEF(NYIPHI, "NYI: PHI shuffling too complex") 55 | TREDEF(NYICOAL, "NYI: register coalescing too complex") 56 | 57 | #undef TREDEF 58 | 59 | /* Detecting unused error messages: 60 | awk -F, '/^TREDEF/ { gsub(/TREDEF./, ""); printf "grep -q LJ_TRERR_%s *.[ch] || echo %s\n", $1, $1}' lj_traceerr.h | sh 61 | */ 62 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_udata.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Userdata handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_udata_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | #include "lj_gc.h" 11 | #include "lj_udata.h" 12 | 13 | GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env) 14 | { 15 | GCudata *ud = lj_mem_newt(L, sizeof(GCudata) + sz, GCudata); 16 | global_State *g = G(L); 17 | newwhite(g, ud); /* Not finalized. */ 18 | ud->gct = ~LJ_TUDATA; 19 | ud->udtype = UDTYPE_USERDATA; 20 | ud->len = sz; 21 | /* NOBARRIER: The GCudata is new (marked white). */ 22 | setgcrefnull(ud->metatable); 23 | setgcref(ud->env, obj2gco(env)); 24 | /* Chain to userdata list (after main thread). */ 25 | setgcrefr(ud->nextgc, mainthread(g)->nextgc); 26 | setgcref(mainthread(g)->nextgc, obj2gco(ud)); 27 | return ud; 28 | } 29 | 30 | void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud) 31 | { 32 | lj_mem_free(g, ud, sizeudata(ud)); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_udata.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Userdata handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_UDATA_H 7 | #define _LJ_UDATA_H 8 | 9 | #include "lj_obj.h" 10 | 11 | LJ_FUNC GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env); 12 | LJ_FUNC void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_vm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Assembler VM interface definitions. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_VM_H 7 | #define _LJ_VM_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Entry points for ASM parts of VM. */ 12 | LJ_ASMF void lj_vm_call(lua_State *L, TValue *base, int nres1); 13 | LJ_ASMF int lj_vm_pcall(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); 14 | typedef TValue *(*lua_CPFunction)(lua_State *L, lua_CFunction func, void *ud); 15 | LJ_ASMF int lj_vm_cpcall(lua_State *L, lua_CFunction func, void *ud, 16 | lua_CPFunction cp); 17 | LJ_ASMF int lj_vm_resume(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); 18 | LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_c(void *cframe, int errcode); 19 | LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_ff(void *cframe); 20 | LJ_ASMF void lj_vm_unwind_c_eh(void); 21 | LJ_ASMF void lj_vm_unwind_ff_eh(void); 22 | #if LJ_TARGET_X86ORX64 23 | LJ_ASMF void lj_vm_unwind_rethrow(void); 24 | #endif 25 | 26 | /* Miscellaneous functions. */ 27 | #if LJ_TARGET_X86ORX64 28 | LJ_ASMF int lj_vm_cpuid(uint32_t f, uint32_t res[4]); 29 | #endif 30 | #if LJ_TARGET_PPC 31 | void lj_vm_cachesync(void *start, void *end); 32 | #endif 33 | LJ_ASMF double lj_vm_foldarith(double x, double y, int op); 34 | #if LJ_HASJIT 35 | LJ_ASMF double lj_vm_foldfpm(double x, int op); 36 | #endif 37 | #if !LJ_ARCH_HASFPU 38 | /* Declared in lj_obj.h: LJ_ASMF int32_t lj_vm_tobit(double x); */ 39 | #endif 40 | 41 | /* Dispatch targets for recording and hooks. */ 42 | LJ_ASMF void lj_vm_record(void); 43 | LJ_ASMF void lj_vm_inshook(void); 44 | LJ_ASMF void lj_vm_rethook(void); 45 | LJ_ASMF void lj_vm_callhook(void); 46 | 47 | /* Trace exit handling. */ 48 | LJ_ASMF void lj_vm_exit_handler(void); 49 | LJ_ASMF void lj_vm_exit_interp(void); 50 | 51 | /* Internal math helper functions. */ 52 | #if LJ_TARGET_X86ORX64 || LJ_TARGET_PPC 53 | #define lj_vm_floor floor 54 | #define lj_vm_ceil ceil 55 | #else 56 | LJ_ASMF double lj_vm_floor(double); 57 | LJ_ASMF double lj_vm_ceil(double); 58 | #if LJ_TARGET_ARM 59 | LJ_ASMF double lj_vm_floor_sf(double); 60 | LJ_ASMF double lj_vm_ceil_sf(double); 61 | #endif 62 | #endif 63 | #if defined(LUAJIT_NO_LOG2) || LJ_TARGET_X86ORX64 64 | LJ_ASMF double lj_vm_log2(double); 65 | #else 66 | #define lj_vm_log2 log2 67 | #endif 68 | 69 | #if LJ_HASJIT 70 | #if LJ_TARGET_X86ORX64 71 | LJ_ASMF void lj_vm_floor_sse(void); 72 | LJ_ASMF void lj_vm_ceil_sse(void); 73 | LJ_ASMF void lj_vm_trunc_sse(void); 74 | LJ_ASMF void lj_vm_exp_x87(void); 75 | LJ_ASMF void lj_vm_exp2_x87(void); 76 | LJ_ASMF void lj_vm_pow_sse(void); 77 | LJ_ASMF void lj_vm_powi_sse(void); 78 | #else 79 | #if LJ_TARGET_PPC 80 | #define lj_vm_trunc trunc 81 | #else 82 | LJ_ASMF double lj_vm_trunc(double); 83 | #if LJ_TARGET_ARM 84 | LJ_ASMF double lj_vm_trunc_sf(double); 85 | #endif 86 | #endif 87 | LJ_ASMF double lj_vm_powi(double, int32_t); 88 | #ifdef LUAJIT_NO_EXP2 89 | LJ_ASMF double lj_vm_exp2(double); 90 | #else 91 | #define lj_vm_exp2 exp2 92 | #endif 93 | #endif 94 | LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t); 95 | #if LJ_HASFFI 96 | LJ_ASMF int lj_vm_errno(void); 97 | #endif 98 | #endif 99 | 100 | /* Continuations for metamethods. */ 101 | LJ_ASMF void lj_cont_cat(void); /* Continue with concatenation. */ 102 | LJ_ASMF void lj_cont_ra(void); /* Store result in RA from instruction. */ 103 | LJ_ASMF void lj_cont_nop(void); /* Do nothing, just continue execution. */ 104 | LJ_ASMF void lj_cont_condt(void); /* Branch if result is true. */ 105 | LJ_ASMF void lj_cont_condf(void); /* Branch if result is false. */ 106 | LJ_ASMF void lj_cont_hook(void); /* Continue from hook yield. */ 107 | 108 | enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */ 109 | 110 | /* Start of the ASM code. */ 111 | LJ_ASMF char lj_vm_asm_begin[]; 112 | 113 | /* Bytecode offsets are relative to lj_vm_asm_begin. */ 114 | #define makeasmfunc(ofs) ((ASMFunction)(lj_vm_asm_begin + (ofs))) 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_vmevent.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** VM event handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #include 7 | 8 | #define lj_vmevent_c 9 | #define LUA_CORE 10 | 11 | #include "lj_obj.h" 12 | #include "lj_str.h" 13 | #include "lj_tab.h" 14 | #include "lj_state.h" 15 | #include "lj_dispatch.h" 16 | #include "lj_vm.h" 17 | #include "lj_vmevent.h" 18 | 19 | ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev) 20 | { 21 | global_State *g = G(L); 22 | GCstr *s = lj_str_newlit(L, LJ_VMEVENTS_REGKEY); 23 | cTValue *tv = lj_tab_getstr(tabV(registry(L)), s); 24 | if (tvistab(tv)) { 25 | int hash = VMEVENT_HASH(ev); 26 | tv = lj_tab_getint(tabV(tv), hash); 27 | if (tv && tvisfunc(tv)) { 28 | lj_state_checkstack(L, LUA_MINSTACK); 29 | setfuncV(L, L->top++, funcV(tv)); 30 | return savestack(L, L->top); 31 | } 32 | } 33 | g->vmevmask &= ~VMEVENT_MASK(ev); /* No handler: cache this fact. */ 34 | return 0; 35 | } 36 | 37 | void lj_vmevent_call(lua_State *L, ptrdiff_t argbase) 38 | { 39 | global_State *g = G(L); 40 | uint8_t oldmask = g->vmevmask; 41 | uint8_t oldh = hook_save(g); 42 | int status; 43 | g->vmevmask = 0; /* Disable all events. */ 44 | hook_vmevent(g); 45 | status = lj_vm_pcall(L, restorestack(L, argbase), 0+1, 0); 46 | if (LJ_UNLIKELY(status)) { 47 | /* Really shouldn't use stderr here, but where else to complain? */ 48 | L->top--; 49 | fputs("VM handler failed: ", stderr); 50 | fputs(tvisstr(L->top) ? strVdata(L->top) : "?", stderr); 51 | fputc('\n', stderr); 52 | } 53 | hook_restore(g, oldh); 54 | if (g->vmevmask != VMEVENT_NOCACHE) 55 | g->vmevmask = oldmask; /* Restore event mask, but not if not modified. */ 56 | } 57 | 58 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_vmevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** VM event handling. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_VMEVENT_H 7 | #define _LJ_VMEVENT_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Registry key for VM event handler table. */ 12 | #define LJ_VMEVENTS_REGKEY "_VMEVENTS" 13 | #define LJ_VMEVENTS_HSIZE 4 14 | 15 | #define VMEVENT_MASK(ev) ((uint8_t)1 << ((int)(ev) & 7)) 16 | #define VMEVENT_HASH(ev) ((int)(ev) & ~7) 17 | #define VMEVENT_HASHIDX(h) ((int)(h) << 3) 18 | #define VMEVENT_NOCACHE 255 19 | 20 | #define VMEVENT_DEF(name, hash) \ 21 | LJ_VMEVENT_##name##_, \ 22 | LJ_VMEVENT_##name = ((LJ_VMEVENT_##name##_) & 7)|((hash) << 3) 23 | 24 | /* VM event IDs. */ 25 | typedef enum { 26 | VMEVENT_DEF(BC, 0x00003883), 27 | VMEVENT_DEF(TRACE, 0xb2d91467), 28 | VMEVENT_DEF(RECORD, 0x9284bf4f), 29 | VMEVENT_DEF(TEXIT, 0xb29df2b0), 30 | LJ_VMEVENT__MAX 31 | } VMEvent; 32 | 33 | #ifdef LUAJIT_DISABLE_VMEVENT 34 | #define lj_vmevent_send(L, ev, args) UNUSED(L) 35 | #define lj_vmevent_send_(L, ev, args, post) UNUSED(L) 36 | #else 37 | #define lj_vmevent_send(L, ev, args) \ 38 | if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ 39 | ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ 40 | if (argbase) { \ 41 | args \ 42 | lj_vmevent_call(L, argbase); \ 43 | } \ 44 | } 45 | #define lj_vmevent_send_(L, ev, args, post) \ 46 | if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ 47 | ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ 48 | if (argbase) { \ 49 | args \ 50 | lj_vmevent_call(L, argbase); \ 51 | post \ 52 | } \ 53 | } 54 | 55 | LJ_FUNC ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev); 56 | LJ_FUNC void lj_vmevent_call(lua_State *L, ptrdiff_t argbase); 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lj_vmmath.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Math helper functions for assembler VM. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_vmmath_c 7 | #define LUA_CORE 8 | 9 | #include 10 | #include 11 | 12 | #include "lj_obj.h" 13 | #include "lj_ir.h" 14 | #include "lj_vm.h" 15 | 16 | /* -- Helper functions for generated machine code ------------------------- */ 17 | 18 | #if LJ_TARGET_X86ORX64 19 | /* Wrapper functions to avoid linker issues on OSX. */ 20 | LJ_FUNCA double lj_vm_sinh(double x) { return sinh(x); } 21 | LJ_FUNCA double lj_vm_cosh(double x) { return cosh(x); } 22 | LJ_FUNCA double lj_vm_tanh(double x) { return tanh(x); } 23 | #endif 24 | 25 | #if !LJ_TARGET_X86ORX64 26 | double lj_vm_foldarith(double x, double y, int op) 27 | { 28 | switch (op) { 29 | case IR_ADD - IR_ADD: return x+y; break; 30 | case IR_SUB - IR_ADD: return x-y; break; 31 | case IR_MUL - IR_ADD: return x*y; break; 32 | case IR_DIV - IR_ADD: return x/y; break; 33 | case IR_MOD - IR_ADD: return x-lj_vm_floor(x/y)*y; break; 34 | case IR_POW - IR_ADD: return pow(x, y); break; 35 | case IR_NEG - IR_ADD: return -x; break; 36 | case IR_ABS - IR_ADD: return fabs(x); break; 37 | #if LJ_HASJIT 38 | case IR_ATAN2 - IR_ADD: return atan2(x, y); break; 39 | case IR_LDEXP - IR_ADD: return ldexp(x, (int)y); break; 40 | case IR_MIN - IR_ADD: return x > y ? y : x; break; 41 | case IR_MAX - IR_ADD: return x < y ? y : x; break; 42 | #endif 43 | default: return x; 44 | } 45 | } 46 | #endif 47 | 48 | #if LJ_HASJIT 49 | 50 | #ifdef LUAJIT_NO_LOG2 51 | double lj_vm_log2(double a) 52 | { 53 | return log(a) * 1.4426950408889634074; 54 | } 55 | #endif 56 | 57 | #ifdef LUAJIT_NO_EXP2 58 | double lj_vm_exp2(double a) 59 | { 60 | return exp(a * 0.6931471805599453); 61 | } 62 | #endif 63 | 64 | #if !(LJ_TARGET_ARM || LJ_TARGET_PPC) 65 | int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b) 66 | { 67 | uint32_t y, ua, ub; 68 | lua_assert(b != 0); /* This must be checked before using this function. */ 69 | ua = a < 0 ? (uint32_t)-a : (uint32_t)a; 70 | ub = b < 0 ? (uint32_t)-b : (uint32_t)b; 71 | y = ua % ub; 72 | if (y != 0 && (a^b) < 0) y = y - ub; 73 | if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y; 74 | return (int32_t)y; 75 | } 76 | #endif 77 | 78 | #if !LJ_TARGET_X86ORX64 79 | /* Unsigned x^k. */ 80 | static double lj_vm_powui(double x, uint32_t k) 81 | { 82 | double y; 83 | lua_assert(k != 0); 84 | for (; (k & 1) == 0; k >>= 1) x *= x; 85 | y = x; 86 | if ((k >>= 1) != 0) { 87 | for (;;) { 88 | x *= x; 89 | if (k == 1) break; 90 | if (k & 1) y *= x; 91 | k >>= 1; 92 | } 93 | y *= x; 94 | } 95 | return y; 96 | } 97 | 98 | /* Signed x^k. */ 99 | double lj_vm_powi(double x, int32_t k) 100 | { 101 | if (k > 1) 102 | return lj_vm_powui(x, (uint32_t)k); 103 | else if (k == 1) 104 | return x; 105 | else if (k == 0) 106 | return 1.0; 107 | else 108 | return 1.0 / lj_vm_powui(x, (uint32_t)-k); 109 | } 110 | 111 | /* Computes fpm(x) for extended math functions. */ 112 | double lj_vm_foldfpm(double x, int fpm) 113 | { 114 | switch (fpm) { 115 | case IRFPM_FLOOR: return lj_vm_floor(x); 116 | case IRFPM_CEIL: return lj_vm_ceil(x); 117 | case IRFPM_TRUNC: return lj_vm_trunc(x); 118 | case IRFPM_SQRT: return sqrt(x); 119 | case IRFPM_EXP: return exp(x); 120 | case IRFPM_EXP2: return lj_vm_exp2(x); 121 | case IRFPM_LOG: return log(x); 122 | case IRFPM_LOG2: return lj_vm_log2(x); 123 | case IRFPM_LOG10: return log10(x); 124 | case IRFPM_SIN: return sin(x); 125 | case IRFPM_COS: return cos(x); 126 | case IRFPM_TAN: return tan(x); 127 | default: lua_assert(0); 128 | } 129 | return 0; 130 | } 131 | #endif 132 | 133 | #if LJ_HASFFI 134 | int lj_vm_errno(void) 135 | { 136 | return errno; 137 | } 138 | #endif 139 | 140 | #endif 141 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/ljamalg.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** LuaJIT core and libraries amalgamation. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | /* 7 | +--------------------------------------------------------------------------+ 8 | | WARNING: Compiling the amalgamation needs a lot of virtual memory | 9 | | (around 200 MB with GCC 4.x)! If you don't have enough physical memory | 10 | | your machine will start swapping to disk and the compile will not finish | 11 | | within a reasonable amount of time. | 12 | | So either compile on a bigger machine or use the non-amalgamated build. | 13 | +--------------------------------------------------------------------------+ 14 | */ 15 | 16 | #define ljamalg_c 17 | #define LUA_CORE 18 | 19 | /* To get the mremap prototype. Must be defined before any system includes. */ 20 | #if defined(__linux__) && !defined(_GNU_SOURCE) 21 | #define _GNU_SOURCE 22 | #endif 23 | 24 | #ifndef WINVER 25 | #define WINVER 0x0500 26 | #endif 27 | 28 | #include "lua.h" 29 | #include "lauxlib.h" 30 | 31 | #include "lj_gc.c" 32 | #include "lj_err.c" 33 | #include "lj_char.c" 34 | #include "lj_bc.c" 35 | #include "lj_obj.c" 36 | #include "lj_str.c" 37 | #include "lj_tab.c" 38 | #include "lj_func.c" 39 | #include "lj_udata.c" 40 | #include "lj_meta.c" 41 | #include "lj_debug.c" 42 | #include "lj_state.c" 43 | #include "lj_dispatch.c" 44 | #include "lj_vmevent.c" 45 | #include "lj_vmmath.c" 46 | #include "lj_strscan.c" 47 | #include "lj_api.c" 48 | #include "lj_lex.c" 49 | #include "lj_parse.c" 50 | #include "lj_bcread.c" 51 | #include "lj_bcwrite.c" 52 | #include "lj_load.c" 53 | #include "lj_ctype.c" 54 | #include "lj_cdata.c" 55 | #include "lj_cconv.c" 56 | #include "lj_ccall.c" 57 | #include "lj_ccallback.c" 58 | #include "lj_carith.c" 59 | #include "lj_clib.c" 60 | #include "lj_cparse.c" 61 | #include "lj_lib.c" 62 | #include "lj_ir.c" 63 | #include "lj_opt_mem.c" 64 | #include "lj_opt_fold.c" 65 | #include "lj_opt_narrow.c" 66 | #include "lj_opt_dce.c" 67 | #include "lj_opt_loop.c" 68 | #include "lj_opt_split.c" 69 | #include "lj_opt_sink.c" 70 | #include "lj_mcode.c" 71 | #include "lj_snap.c" 72 | #include "lj_record.c" 73 | #include "lj_crecord.c" 74 | #include "lj_ffrecord.c" 75 | #include "lj_asm.c" 76 | #include "lj_trace.c" 77 | #include "lj_gdbjit.c" 78 | #include "lj_alloc.c" 79 | 80 | #include "lib_aux.c" 81 | #include "lib_base.c" 82 | #include "lib_math.c" 83 | #include "lib_string.c" 84 | #include "lib_table.c" 85 | #include "lib_io.c" 86 | #include "lib_os.c" 87 | #include "lib_package.c" 88 | #include "lib_debug.c" 89 | #include "lib_bit.c" 90 | #include "lib_jit.c" 91 | #include "lib_ffi.c" 92 | #include "lib_init.c" 93 | 94 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // C++ wrapper for LuaJIT header files. 2 | 3 | extern "C" { 4 | #include "lua.h" 5 | #include "lauxlib.h" 6 | #include "lualib.h" 7 | #include "luajit.h" 8 | } 9 | 10 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lua51.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/LuaJIT/src/lua51.dll -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lua51.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/LuaJIT/src/lua51.exp -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lua51.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/LuaJIT/src/lua51.lib -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/luaconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Configuration header. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef luaconf_h 7 | #define luaconf_h 8 | 9 | #include 10 | #include 11 | 12 | /* Default path for loading Lua and C modules with require(). */ 13 | #if defined(_WIN32) 14 | /* 15 | ** In Windows, any exclamation mark ('!') in the path is replaced by the 16 | ** path of the directory of the executable file of the current process. 17 | */ 18 | #define LUA_LDIR "!\\lua\\" 19 | #define LUA_CDIR "!\\" 20 | #define LUA_PATH_DEFAULT \ 21 | ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" 22 | #define LUA_CPATH_DEFAULT \ 23 | ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" 24 | #else 25 | /* 26 | ** Note to distribution maintainers: do NOT patch the following line! 27 | ** Please read ../doc/install.html#distro and pass PREFIX=/usr instead. 28 | */ 29 | #define LUA_ROOT "/usr/local/" 30 | #define LUA_LDIR LUA_ROOT "share/lua/5.1/" 31 | #define LUA_CDIR LUA_ROOT "lib/lua/5.1/" 32 | #ifdef LUA_XROOT 33 | #define LUA_JDIR LUA_XROOT "share/luajit-2.0.2/" 34 | #define LUA_XPATH \ 35 | ";" LUA_XROOT "share/lua/5.1/?.lua;" LUA_XROOT "share/lua/5.1/?/init.lua" 36 | #define LUA_XCPATH LUA_XROOT "lib/lua/5.1/?.so;" 37 | #else 38 | #define LUA_JDIR LUA_ROOT "share/luajit-2.0.2/" 39 | #define LUA_XPATH 40 | #define LUA_XCPATH 41 | #endif 42 | #define LUA_PATH_DEFAULT \ 43 | "./?.lua;" LUA_JDIR"?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua" LUA_XPATH 44 | #define LUA_CPATH_DEFAULT \ 45 | "./?.so;" LUA_CDIR"?.so;" LUA_XCPATH LUA_CDIR"loadall.so" 46 | #endif 47 | 48 | /* Environment variable names for path overrides and initialization code. */ 49 | #define LUA_PATH "LUA_PATH" 50 | #define LUA_CPATH "LUA_CPATH" 51 | #define LUA_INIT "LUA_INIT" 52 | 53 | /* Special file system characters. */ 54 | #if defined(_WIN32) 55 | #define LUA_DIRSEP "\\" 56 | #else 57 | #define LUA_DIRSEP "/" 58 | #endif 59 | #define LUA_PATHSEP ";" 60 | #define LUA_PATH_MARK "?" 61 | #define LUA_EXECDIR "!" 62 | #define LUA_IGMARK "-" 63 | #define LUA_PATH_CONFIG \ 64 | LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \ 65 | LUA_EXECDIR "\n" LUA_IGMARK 66 | 67 | /* Quoting in error messages. */ 68 | #define LUA_QL(x) "'" x "'" 69 | #define LUA_QS LUA_QL("%s") 70 | 71 | /* Various tunables. */ 72 | #define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */ 73 | #define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */ 74 | #define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */ 75 | #define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */ 76 | #define LUA_MAXCAPTURES 32 /* Max. pattern captures. */ 77 | 78 | /* Compatibility with older library function names. */ 79 | #define LUA_COMPAT_MOD /* OLD: math.mod, NEW: math.fmod */ 80 | #define LUA_COMPAT_GFIND /* OLD: string.gfind, NEW: string.gmatch */ 81 | 82 | /* Configuration for the frontend (the luajit executable). */ 83 | #if defined(luajit_c) 84 | #define LUA_PROGNAME "luajit" /* Fallback frontend name. */ 85 | #define LUA_PROMPT "> " /* Interactive prompt. */ 86 | #define LUA_PROMPT2 ">> " /* Continuation prompt. */ 87 | #define LUA_MAXINPUT 512 /* Max. input line length. */ 88 | #endif 89 | 90 | /* Note: changing the following defines breaks the Lua 5.1 ABI. */ 91 | #define LUA_INTEGER ptrdiff_t 92 | #define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */ 93 | /* 94 | ** Size of lauxlib and io.* on-stack buffers. Weird workaround to avoid using 95 | ** unreasonable amounts of stack space, but still retain ABI compatibility. 96 | ** Blame Lua for depending on BUFSIZ in the ABI, blame **** for wrecking it. 97 | */ 98 | #define LUAL_BUFFERSIZE (BUFSIZ > 16384 ? 8192 : BUFSIZ) 99 | 100 | /* The following defines are here only for compatibility with luaconf.h 101 | ** from the standard Lua distribution. They must not be changed for LuaJIT. 102 | */ 103 | #define LUA_NUMBER_DOUBLE 104 | #define LUA_NUMBER double 105 | #define LUAI_UACNUMBER double 106 | #define LUA_NUMBER_SCAN "%lf" 107 | #define LUA_NUMBER_FMT "%.14g" 108 | #define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n)) 109 | #define LUAI_MAXNUMBER2STR 32 110 | #define LUA_INTFRMLEN "l" 111 | #define LUA_INTFRM_T long 112 | 113 | /* Linkage of public API functions. */ 114 | #if defined(LUA_BUILD_AS_DLL) 115 | #if defined(LUA_CORE) || defined(LUA_LIB) 116 | #define LUA_API __declspec(dllexport) 117 | #else 118 | #define LUA_API __declspec(dllimport) 119 | #endif 120 | #else 121 | #define LUA_API extern 122 | #endif 123 | 124 | #define LUALIB_API LUA_API 125 | 126 | /* Support for internal assertions. */ 127 | #if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK) 128 | #include 129 | #endif 130 | #ifdef LUA_USE_ASSERT 131 | #define lua_assert(x) assert(x) 132 | #endif 133 | #ifdef LUA_USE_APICHECK 134 | #define luai_apicheck(L, o) { (void)L; assert(o); } 135 | #else 136 | #define luai_apicheck(L, o) { (void)L; } 137 | #endif 138 | 139 | #endif 140 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/luajit.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/LuaJIT/src/luajit.exe -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/luajit.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/LuaJIT/src/luajit.exp -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/luajit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ 3 | ** 4 | ** Copyright (C) 2005-2013 Mike Pall. All rights reserved. 5 | ** 6 | ** Permission is hereby granted, free of charge, to any person obtaining 7 | ** a copy of this software and associated documentation files (the 8 | ** "Software"), to deal in the Software without restriction, including 9 | ** without limitation the rights to use, copy, modify, merge, publish, 10 | ** distribute, sublicense, and/or sell copies of the Software, and to 11 | ** permit persons to whom the Software is furnished to do so, subject to 12 | ** the following conditions: 13 | ** 14 | ** The above copyright notice and this permission notice shall be 15 | ** included in all copies or substantial portions of the Software. 16 | ** 17 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | ** 25 | ** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] 26 | */ 27 | 28 | #ifndef _LUAJIT_H 29 | #define _LUAJIT_H 30 | 31 | #include "lua.h" 32 | 33 | #define LUAJIT_VERSION "LuaJIT 2.0.2" 34 | #define LUAJIT_VERSION_NUM 20002 /* Version 2.0.2 = 02.00.02. */ 35 | #define LUAJIT_VERSION_SYM luaJIT_version_2_0_2 36 | #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2013 Mike Pall" 37 | #define LUAJIT_URL "http://luajit.org/" 38 | 39 | /* Modes for luaJIT_setmode. */ 40 | #define LUAJIT_MODE_MASK 0x00ff 41 | 42 | enum { 43 | LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ 44 | LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ 45 | 46 | LUAJIT_MODE_FUNC, /* Change mode for a function. */ 47 | LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ 48 | LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ 49 | 50 | LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ 51 | 52 | LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ 53 | 54 | LUAJIT_MODE_MAX 55 | }; 56 | 57 | /* Flags or'ed in to the mode. */ 58 | #define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ 59 | #define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ 60 | #define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ 61 | 62 | /* LuaJIT public C API. */ 63 | 64 | /* Control the JIT engine. */ 65 | LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); 66 | 67 | /* Enforce (dynamic) linker error for version mismatches. Call from main. */ 68 | LUA_API void LUAJIT_VERSION_SYM(void); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/luajit.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/LuaJIT/src/luajit.lib -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Standard library header. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LUALIB_H 7 | #define _LUALIB_H 8 | 9 | #include "lua.h" 10 | 11 | #define LUA_FILEHANDLE "FILE*" 12 | 13 | #define LUA_COLIBNAME "coroutine" 14 | #define LUA_MATHLIBNAME "math" 15 | #define LUA_STRLIBNAME "string" 16 | #define LUA_TABLIBNAME "table" 17 | #define LUA_IOLIBNAME "io" 18 | #define LUA_OSLIBNAME "os" 19 | #define LUA_LOADLIBNAME "package" 20 | #define LUA_DBLIBNAME "debug" 21 | #define LUA_BITLIBNAME "bit" 22 | #define LUA_JITLIBNAME "jit" 23 | #define LUA_FFILIBNAME "ffi" 24 | 25 | LUALIB_API int luaopen_base(lua_State *L); 26 | LUALIB_API int luaopen_math(lua_State *L); 27 | LUALIB_API int luaopen_string(lua_State *L); 28 | LUALIB_API int luaopen_table(lua_State *L); 29 | LUALIB_API int luaopen_io(lua_State *L); 30 | LUALIB_API int luaopen_os(lua_State *L); 31 | LUALIB_API int luaopen_package(lua_State *L); 32 | LUALIB_API int luaopen_debug(lua_State *L); 33 | LUALIB_API int luaopen_bit(lua_State *L); 34 | LUALIB_API int luaopen_jit(lua_State *L); 35 | LUALIB_API int luaopen_ffi(lua_State *L); 36 | 37 | LUALIB_API void luaL_openlibs(lua_State *L); 38 | 39 | #ifndef lua_assert 40 | #define lua_assert(x) ((void)0) 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/msvcbuild.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build LuaJIT with MSVC. 2 | @rem Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 3 | @rem 4 | @rem Either open a "Visual Studio .NET Command Prompt" 5 | @rem (Note that the Express Edition does not contain an x64 compiler) 6 | @rem -or- 7 | @rem Open a "Windows SDK Command Shell" and set the compiler environment: 8 | @rem setenv /release /x86 9 | @rem -or- 10 | @rem setenv /release /x64 11 | @rem 12 | @rem Then cd to this directory and run this script. 13 | 14 | @if not defined INCLUDE goto :FAIL 15 | 16 | @setlocal 17 | @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE 18 | @set LJLINK=link /nologo 19 | @set LJMT=mt /nologo 20 | @set LJLIB=lib /nologo 21 | @set DASMDIR=..\dynasm 22 | @set DASM=%DASMDIR%\dynasm.lua 23 | @set LJDLLNAME=lua51.dll 24 | @set LJLIBNAME=lua51.lib 25 | @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 26 | 27 | %LJCOMPILE% host\minilua.c 28 | @if errorlevel 1 goto :BAD 29 | %LJLINK% /out:minilua.exe minilua.obj 30 | @if errorlevel 1 goto :BAD 31 | if exist minilua.exe.manifest^ 32 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe 33 | 34 | @set DASMFLAGS=-D WIN -D JIT -D FFI -D P64 35 | @set LJARCH=x64 36 | @minilua 37 | @if errorlevel 8 goto :X64 38 | @set DASMFLAGS=-D WIN -D JIT -D FFI 39 | @set LJARCH=x86 40 | :X64 41 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc 42 | @if errorlevel 1 goto :BAD 43 | 44 | %LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c 45 | @if errorlevel 1 goto :BAD 46 | %LJLINK% /out:buildvm.exe buildvm*.obj 47 | @if errorlevel 1 goto :BAD 48 | if exist buildvm.exe.manifest^ 49 | %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe 50 | 51 | buildvm -m peobj -o lj_vm.obj 52 | @if errorlevel 1 goto :BAD 53 | buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% 54 | @if errorlevel 1 goto :BAD 55 | buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% 56 | @if errorlevel 1 goto :BAD 57 | buildvm -m libdef -o lj_libdef.h %ALL_LIB% 58 | @if errorlevel 1 goto :BAD 59 | buildvm -m recdef -o lj_recdef.h %ALL_LIB% 60 | @if errorlevel 1 goto :BAD 61 | buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% 62 | @if errorlevel 1 goto :BAD 63 | buildvm -m folddef -o lj_folddef.h lj_opt_fold.c 64 | @if errorlevel 1 goto :BAD 65 | 66 | @if "%1" neq "debug" goto :NODEBUG 67 | @shift 68 | @set LJCOMPILE=%LJCOMPILE% /Zi 69 | @set LJLINK=%LJLINK% /debug 70 | :NODEBUG 71 | @if "%1"=="amalg" goto :AMALGDLL 72 | @if "%1"=="static" goto :STATIC 73 | %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c 74 | @if errorlevel 1 goto :BAD 75 | %LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj 76 | @if errorlevel 1 goto :BAD 77 | @goto :MTDLL 78 | :STATIC 79 | %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c 80 | @if errorlevel 1 goto :BAD 81 | %LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj 82 | @if errorlevel 1 goto :BAD 83 | @goto :MTDLL 84 | :AMALGDLL 85 | %LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c 86 | @if errorlevel 1 goto :BAD 87 | %LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj 88 | @if errorlevel 1 goto :BAD 89 | :MTDLL 90 | if exist %LJDLLNAME%.manifest^ 91 | %LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2 92 | 93 | %LJCOMPILE% luajit.c 94 | @if errorlevel 1 goto :BAD 95 | %LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME% 96 | @if errorlevel 1 goto :BAD 97 | if exist luajit.exe.manifest^ 98 | %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe 99 | 100 | @del *.obj *.manifest minilua.exe buildvm.exe 101 | @echo. 102 | @echo === Successfully built LuaJIT for Windows/%LJARCH% === 103 | 104 | @goto :END 105 | :BAD 106 | @echo. 107 | @echo ******************************************************* 108 | @echo *** Build FAILED -- Please check the error messages *** 109 | @echo ******************************************************* 110 | @goto :END 111 | :FAIL 112 | @echo You must open a "Visual Studio .NET Command Prompt" to run this script 113 | :END 114 | -------------------------------------------------------------------------------- /war3-lua-engine/LuaJIT/src/xedkbuild.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build LuaJIT with the Xbox 360 SDK. 2 | @rem Donated to the public domain. 3 | @rem 4 | @rem Open a "Visual Studio .NET Command Prompt" (32 bit host compiler) 5 | @rem Then cd to this directory and run this script. 6 | 7 | @if not defined INCLUDE goto :FAIL 8 | @if not defined XEDK goto :FAIL 9 | 10 | @setlocal 11 | @rem ---- Host compiler ---- 12 | @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE 13 | @set LJLINK=link /nologo 14 | @set LJMT=mt /nologo 15 | @set DASMDIR=..\dynasm 16 | @set DASM=%DASMDIR%\dynasm.lua 17 | @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 18 | 19 | %LJCOMPILE% host\minilua.c 20 | @if errorlevel 1 goto :BAD 21 | %LJLINK% /out:minilua.exe minilua.obj 22 | @if errorlevel 1 goto :BAD 23 | if exist minilua.exe.manifest^ 24 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe 25 | 26 | @rem Error out for 64 bit host compiler 27 | @minilua 28 | @if errorlevel 8 goto :FAIL 29 | 30 | @set DASMFLAGS=-D GPR64 -D FRAME32 -D PPE -D SQRT -D DUALNUM 31 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_ppc.dasc 32 | @if errorlevel 1 goto :BAD 33 | 34 | %LJCOMPILE% /I "." /I %DASMDIR% /D_XBOX_VER=200 /DLUAJIT_TARGET=LUAJIT_ARCH_PPC host\buildvm*.c 35 | @if errorlevel 1 goto :BAD 36 | %LJLINK% /out:buildvm.exe buildvm*.obj 37 | @if errorlevel 1 goto :BAD 38 | if exist buildvm.exe.manifest^ 39 | %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe 40 | 41 | buildvm -m peobj -o lj_vm.obj 42 | @if errorlevel 1 goto :BAD 43 | buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% 44 | @if errorlevel 1 goto :BAD 45 | buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% 46 | @if errorlevel 1 goto :BAD 47 | buildvm -m libdef -o lj_libdef.h %ALL_LIB% 48 | @if errorlevel 1 goto :BAD 49 | buildvm -m recdef -o lj_recdef.h %ALL_LIB% 50 | @if errorlevel 1 goto :BAD 51 | buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% 52 | @if errorlevel 1 goto :BAD 53 | buildvm -m folddef -o lj_folddef.h lj_opt_fold.c 54 | @if errorlevel 1 goto :BAD 55 | 56 | @rem ---- Cross compiler ---- 57 | @set LJCOMPILE="%XEDK%\bin\win32\cl" /nologo /c /MT /O2 /W3 /GF /Gm- /GR- /GS- /Gy /openmp- /D_CRT_SECURE_NO_DEPRECATE /DNDEBUG /D_XBOX /D_LIB /DLUAJIT_USE_SYSMALLOC 58 | @set LJLIB="%XEDK%\bin\win32\lib" /nologo 59 | @set INCLUDE="%XEDK%\include\xbox" 60 | 61 | @if "%1" neq "debug" goto :NODEBUG 62 | @shift 63 | @set LJCOMPILE="%LJCOMPILE%" /Zi 64 | :NODEBUG 65 | @if "%1"=="amalg" goto :AMALG 66 | %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c 67 | @if errorlevel 1 goto :BAD 68 | %LJLIB% /OUT:luajit20.lib lj_*.obj lib_*.obj 69 | @if errorlevel 1 goto :BAD 70 | @goto :NOAMALG 71 | :AMALG 72 | %LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c 73 | @if errorlevel 1 goto :BAD 74 | %LJLIB% /OUT:luajit20.lib ljamalg.obj lj_vm.obj 75 | @if errorlevel 1 goto :BAD 76 | :NOAMALG 77 | 78 | @del *.obj *.manifest minilua.exe buildvm.exe 79 | @echo. 80 | @echo === Successfully built LuaJIT for Xbox 360 === 81 | 82 | @goto :END 83 | :BAD 84 | @echo. 85 | @echo ******************************************************* 86 | @echo *** Build FAILED -- Please check the error messages *** 87 | @echo ******************************************************* 88 | @goto :END 89 | :FAIL 90 | @echo To run this script you must open a "Visual Studio .NET Command Prompt" 91 | @echo (32 bit host compiler). The Xbox 360 SDK must be installed, too. 92 | :END 93 | -------------------------------------------------------------------------------- /war3-lua-engine/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for installing Lua 2 | # See doc/readme.html for installation and customization instructions. 3 | 4 | # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= 5 | 6 | # Your platform. See PLATS for possible values. 7 | PLAT= none 8 | 9 | # Where to install. The installation starts in the Lua and doc directories, 10 | # so take care if INSTALL_TOP is not an absolute path. See the local target. 11 | # You may want to make INSTALL_LMOD and INSTALL_CMOD consistent with 12 | # LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h. 13 | INSTALL_TOP= /usr/local 14 | INSTALL_BIN= $(INSTALL_TOP)/bin 15 | INSTALL_INC= $(INSTALL_TOP)/include 16 | INSTALL_LIB= $(INSTALL_TOP)/lib 17 | INSTALL_MAN= $(INSTALL_TOP)/man/man1 18 | INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V 19 | INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V 20 | 21 | # How to install. If your install program does not support "-p", then 22 | # you may have to run ranlib on the installed liblua.a. 23 | INSTALL= install -p 24 | INSTALL_EXEC= $(INSTALL) -m 0755 25 | INSTALL_DATA= $(INSTALL) -m 0644 26 | # 27 | # If you don't have "install" you can use "cp" instead. 28 | # INSTALL= cp -p 29 | # INSTALL_EXEC= $(INSTALL) 30 | # INSTALL_DATA= $(INSTALL) 31 | 32 | # Other utilities. 33 | MKDIR= mkdir -p 34 | RM= rm -f 35 | 36 | # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= 37 | 38 | # Convenience platforms targets. 39 | PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris 40 | 41 | # What to install. 42 | TO_BIN= lua luac 43 | TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp 44 | TO_LIB= liblua.a 45 | TO_MAN= lua.1 luac.1 46 | 47 | # Lua version and release. 48 | V= 5.2 49 | R= $V.1 50 | 51 | # Targets start here. 52 | all: $(PLAT) 53 | 54 | $(PLATS) clean: 55 | cd Lua && $(MAKE) $@ 56 | 57 | test: dummy 58 | Lua/lua -v 59 | 60 | install: dummy 61 | cd Lua && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) 62 | cd Lua && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) 63 | cd Lua && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) 64 | cd Lua && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) 65 | cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN) 66 | 67 | uninstall: 68 | cd Lua && cd $(INSTALL_BIN) && $(RM) $(TO_BIN) 69 | cd Lua && cd $(INSTALL_INC) && $(RM) $(TO_INC) 70 | cd Lua && cd $(INSTALL_LIB) && $(RM) $(TO_LIB) 71 | cd doc && cd $(INSTALL_MAN) && $(RM) $(TO_MAN) 72 | 73 | local: 74 | $(MAKE) install INSTALL_TOP=../install 75 | 76 | none: 77 | @echo "Please do 'make PLATFORM' where PLATFORM is one of these:" 78 | @echo " $(PLATS)" 79 | @echo "See doc/readme.html for complete instructions." 80 | 81 | # make may get confused with test/ and install/ 82 | dummy: 83 | 84 | # echo config parameters 85 | echo: 86 | @cd Lua && $(MAKE) -s echo 87 | @echo "PLAT= $(PLAT)" 88 | @echo "V= $V" 89 | @echo "R= $R" 90 | @echo "TO_BIN= $(TO_BIN)" 91 | @echo "TO_INC= $(TO_INC)" 92 | @echo "TO_LIB= $(TO_LIB)" 93 | @echo "TO_MAN= $(TO_MAN)" 94 | @echo "INSTALL_TOP= $(INSTALL_TOP)" 95 | @echo "INSTALL_BIN= $(INSTALL_BIN)" 96 | @echo "INSTALL_INC= $(INSTALL_INC)" 97 | @echo "INSTALL_LIB= $(INSTALL_LIB)" 98 | @echo "INSTALL_MAN= $(INSTALL_MAN)" 99 | @echo "INSTALL_LMOD= $(INSTALL_LMOD)" 100 | @echo "INSTALL_CMOD= $(INSTALL_CMOD)" 101 | @echo "INSTALL_EXEC= $(INSTALL_EXEC)" 102 | @echo "INSTALL_DATA= $(INSTALL_DATA)" 103 | 104 | # echo pkg-config data 105 | pc: 106 | @echo "version=$R" 107 | @echo "prefix=$(INSTALL_TOP)" 108 | @echo "libdir=$(INSTALL_LIB)" 109 | @echo "includedir=$(INSTALL_INC)" 110 | 111 | # list targets that do not create files (but not all makes understand .PHONY) 112 | .PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho 113 | 114 | # (end of Makefile) 115 | -------------------------------------------------------------------------------- /war3-lua-engine/Offsets.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Offsets.h" 3 | 4 | DWORD GameBase = 0; 5 | 6 | DWORD GetGameBase() 7 | { 8 | if (!GameBase) 9 | return (GameBase = (DWORD)GetModuleHandle("Game.dll")); 10 | return GameBase; 11 | } 12 | -------------------------------------------------------------------------------- /war3-lua-engine/Offsets.h: -------------------------------------------------------------------------------- 1 | #ifndef OFFSETS_H 2 | #define OFFSETS_H 3 | 4 | DWORD GetGameBase(); 5 | extern DWORD GameBase; 6 | 7 | #define ADDPTR(NAME,VALUE) static DWORD _##NAME = GetGameBase() + VALUE; 8 | 9 | // CGame // 10 | ADDPTR(GetLocation,0x4743A0) 11 | ADDPTR(W3XPlayerData,0xAB65F4) 12 | ADDPTR(W3XGlobalClass,0xAB4F80) 13 | ADDPTR(GetHPlayerByNumber,0x3A1650) 14 | ADDPTR(UnitSelect,0x381710) 15 | ADDPTR(GetUnitArrayPtr,0x39B6E0) 16 | ADDPTR(W3XTlsIndex,0xAB7BF4) 17 | ADDPTR(IsUnitHero,0x33AA60) 18 | ADDPTR(MoveAttackCmd,0x339DD0) 19 | ADDPTR(MoveTargetCmd,0x339D50) 20 | ADDPTR(UnitClass,0x931934) 21 | ADDPTR(GetFloatStat,0x27AE90) 22 | ADDPTR(PauseGameConst,0x9342F8) 23 | ADDPTR(PauseGame,0x2F80A0) 24 | ADDPTR(ResumeGameConst,0x934304) 25 | ADDPTR(ResumeGame,0x2F7FE0) 26 | ADDPTR(W3XConversion,0xAB7368) 27 | ADDPTR(ConvertCoord1,0x6EEEF0) 28 | ADDPTR(ConvertCoord2,0x6EEC20) 29 | ADDPTR(W3XMinimap,0xAB6214) 30 | ADDPTR(BigAssFloat,0x875AB8) 31 | ADDPTR(MmapOffset,0x93A098) 32 | ADDPTR(JSIDToPointer,0x459640) 33 | ADDPTR(GetCurrentJassEnv,0x44B2E0) 34 | ADDPTR(6F41BF00,0x41B420) 35 | ADDPTR(6F473C20,0x473170) 36 | 37 | // CJass // 38 | ADDPTR(GetLocalPlayer,0x3BBB60); 39 | ADDPTR(DisplayTimedTextToPlayer,0x3CB9B0); 40 | ADDPTR(ChangeLevel,0x3BBC30); 41 | ADDPTR(PingMinimap,0x3B4650); 42 | ADDPTR(PingMinimapEx,0x3B8660); 43 | ADDPTR(IsUnitVisible,0x3C7AF0); 44 | ADDPTR(SelectUnit,0x3C7910); 45 | ADDPTR(ClearSelection,0x3BBAA0); 46 | ADDPTR(GetTriggerUnit,0x3BB240); 47 | ADDPTR(GetOwningPlayer,0x3C8190); 48 | ADDPTR(GetPlayerColor,0x3C1240); 49 | ADDPTR(CreateTextTag,0x3BC580); 50 | ADDPTR(SetTextTagText,0x3BC5D0); 51 | ADDPTR(SetTextTagPosUnit,0x3CB890); 52 | ADDPTR(SetTextTagColor,0x3BC6A0); 53 | ADDPTR(SetTextTagVelocity,0x3BC700); 54 | ADDPTR(SetTextTagFadepoint,0x3BC850); 55 | ADDPTR(SetTextTagLifespan,0x3BC820); 56 | ADDPTR(SetTextTagPermanent,0x3BC7C0); 57 | ADDPTR(SetTextTagVisibility,0x3BC760); 58 | ADDPTR(DialogCreate,0x3D2BC0); 59 | ADDPTR(DialogDisplay,0x3CA030); 60 | ADDPTR(DialogSetMessage,0x3C9F60); 61 | ADDPTR(DialogAddQuitButton,0x3C9FE0); 62 | ADDPTR(DialogAddButton,0x3C9F90); 63 | ADDPTR(ClearTextMessages,0x3B4E60); 64 | ADDPTR(JPauseGame,0x3BC4D0); 65 | ADDPTR(GetHeroLevel,0x3C6ED0); 66 | ADDPTR(GetUnitX,0x3C5510); 67 | ADDPTR(GetUnitY,0x3C5550); 68 | ADDPTR(GetPlayerId,0x3C9640); 69 | ADDPTR(IsUnitAlly,0x3C7A70); 70 | ADDPTR(IsUnitEnemy,0x3C7AD0); 71 | ADDPTR(IsPlayerAlly,0x3C9530); 72 | ADDPTR(IsPlayerEnemy,0x3C9580); 73 | ADDPTR(IsPlayerObserver,0x3C9600); 74 | ADDPTR(Player,0x3BBB30); 75 | ADDPTR(GetPlayerRace,0x3C9620); 76 | ADDPTR(DoNotSaveReplay,0x3B3550); 77 | ADDPTR(GetPlayerState,0x3C9B00); 78 | ADDPTR(GetPlayerScore,0x3C9B70); 79 | ADDPTR(IsVisibleToPlayer,0x3C98F0); 80 | ADDPTR(IsFoggedToPlayer,0x3C9980); 81 | ADDPTR(IsMaskedToPlayer,0x3C9A10); 82 | ADDPTR(ConvertRace,0x3B2600); 83 | ADDPTR(ConvertPlayerState,0x3B2650); 84 | ADDPTR(ConvertPlayerScore,0x3B2660); 85 | ADDPTR(GetPlayerSlotState,0x3C12D0); 86 | ADDPTR(ConvertPlayerSlotState,0x3B27D0); 87 | ADDPTR(ConvertUnitState,0x3B2680); 88 | ADDPTR(GetUnitState,0x3C5400); 89 | ADDPTR(GetUnitTypeId,0x3C5910); 90 | ADDPTR(GetPlayerName,0x3C0F60); 91 | ADDPTR(GetUnitName,0x3C5950); 92 | ADDPTR(GetItemName,0x3C4E90); 93 | ADDPTR(GetItemCharges,0x3C5050); 94 | #endif 95 | -------------------------------------------------------------------------------- /war3-lua-engine/Scripts.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/Scripts.cpp -------------------------------------------------------------------------------- /war3-lua-engine/Scripts.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma region Definitions 4 | 5 | #define NONEMOD 0 6 | #define ALTMOD 1 7 | #define SHIFTMOD 2 8 | #define CTRLMOD 4 9 | #define LWINMOD 8 10 | #define ALTPERMMOD 16 11 | #define SHIFTPERMMOD 32 12 | #define CTRLPERMMOD 64 13 | #define LWINPERMMOD 128 14 | #define RWINPERMMOD 256 15 | #define RESETMOD ALTPERMMOD+CTRLPERMMOD+SHIFTPERMMOD+LWINPERMMOD+RWINPERMMOD 16 | 17 | #define NUMKEYS 93 18 | typedef enum {CTRLDOWN, CTRLUP, ALTDOWN, ALTUP, SHIFTDOWN, SHIFTUP, 19 | LWINDOWN, LWINUP, RWINDOWN, RWINUP, ASC, NUMPADENTER, ALT} SK_SpecialKeys; 20 | 21 | #define SK_LOOKUP 0 22 | #define SK_SPECIAL 1 23 | 24 | 25 | #define IsPhysicallyDown(vk) ( (GetAsyncKeyState(vk) & 0x80000000) || ((GetKeyState(vk) & 0x8000)) ) 26 | 27 | #define MAXHOTKEYS 64 28 | 29 | #pragma endregion 30 | 31 | LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 32 | 33 | class CScripts 34 | { 35 | public: 36 | CScripts(void); 37 | ~CScripts(void); 38 | 39 | static int MouseClick(const char* Button, int x = -1, int y = -1, int Clicks = 1, int Speed = 10); 40 | static int HotKeySet(const char* Key, luabridge::LuaRef Func, lua_State* L); 41 | static void Util_Sleep(int nTimeOut); 42 | static void KeyPress(const char *szSendKeys); 43 | static bool HandleHotKey(void); 44 | 45 | private: 46 | static void ConvertCoords(int nCoordMode, POINT &pt); 47 | static void MouseMoveExecute(int x, int y, int nSpeed); 48 | static void Util_RegReadString(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, DWORD dwBufLen, char *szValue); 49 | static int Util_MouseDown(const char *szButton); 50 | static int Util_MouseUp(const char *szButton); 51 | static bool SetToggleState(UINT vk, bool bState); 52 | static int ReadToChar(char ch, const char *szLine, char *szResult, int &nPos); 53 | static bool IsVKExtended(UINT key); 54 | static void SimKeyDown(UINT vk, bool bForceExtended = false); 55 | static void SimKeyUp(UINT vk, bool bForceExtended = false); 56 | static void ResolveKeyModifiers(UINT vkres); 57 | static void SimModsDown(void); 58 | static void SimModsUp(void); 59 | static void SimKeystroke(UINT vk, bool bForceExtended = false); 60 | static void SendVk(UINT vk, int nRep, bool bExtended = false); 61 | static void SendCh(char ch, int nRep); 62 | static void SendSpecial(char *szTemp); 63 | static void SendSpecialCh(char ch); 64 | static bool GetSingleVKandMods(const char *szString, UINT &vk, bool &bShift, bool &bControl, bool &bAlt, bool &bWin); 65 | static void Initialize(void); 66 | 67 | }; 68 | 69 | struct HotKeyDetails { 70 | WPARAM wParam; // Hotkey ID 71 | LPARAM lParam; // Key and modifiers (control, alt, etc) 72 | luabridge::LuaRef *lFunction; // Function to call 73 | 74 | HotKeyDetails(): wParam(NULL), lParam(NULL), lFunction(NULL) {} 75 | }; 76 | 77 | 78 | extern HotKeyDetails *m_HotKeyDetails[64]; // Array for tracking hotkey details 79 | extern int m_nHotKeyQueuePos; // Position in the global hotkey queue 80 | extern bool Initialized; -------------------------------------------------------------------------------- /war3-lua-engine/Variables.cpp: -------------------------------------------------------------------------------- 1 | #include "Windows.h" 2 | #include "Variables.h" 3 | 4 | 5 | HMODULE DllModule; 6 | HWND wHandle; 7 | // HotKey stuff 8 | WPARAM g_HotKeyQueue[64]; // Queue for hotkeys pressed 9 | int g_HotKeyNext; // Next free hotkey position in queue 10 | 11 | bool bNeedToRegister; 12 | bool bRegisterFinished; -------------------------------------------------------------------------------- /war3-lua-engine/Variables.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct sCreateHotKey 4 | { 5 | int ID; 6 | UINT Mods; 7 | UINT vk; 8 | int FreeHandle; 9 | }; 10 | 11 | 12 | extern HMODULE DllModule; 13 | extern HWND wHandle; 14 | extern WPARAM g_HotKeyQueue[64]; // Queue for hotkeys pressed 15 | extern int g_HotKeyNext; // Next free hotkey position in queue 16 | 17 | extern bool bNeedToRegister; 18 | extern bool bRegisterFinished; -------------------------------------------------------------------------------- /war3-lua-engine/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | 3 | #include "stdafx.h" 4 | #include "war3_lua_engine.h" 5 | #include 6 | #include "Scripts.h" 7 | #include 8 | #include "resource.h" 9 | 10 | namespace fs = ::boost::filesystem; 11 | 12 | VOID LoadScript( LPVOID Args ) 13 | { 14 | 15 | char* ScriptName = (char*) Args; 16 | 17 | lua_State* L = luaL_newstate (); 18 | 19 | luaL_openlibs (L); 20 | 21 | int errorFunctionRef = War3LuaEngine::addTraceback (L); 22 | 23 | War3LuaEngine::addToState (L); 24 | 25 | 26 | // Execute lua files in order 27 | if (luaL_loadfile (L, ScriptName) != 0) 28 | { 29 | // compile-time error 30 | lua_close(L); 31 | delete [] ScriptName; 32 | return; 33 | } 34 | else if (lua_pcall(L, 0, 0, errorFunctionRef) != 0) 35 | { 36 | // runtime error 37 | lua_close(L); 38 | delete [] ScriptName; 39 | return; 40 | } 41 | 42 | 43 | 44 | // luabridge::LuaRef init_function = luabridge::getGlobal(L, "Init"); 45 | // if (!lua_isnil(L,init_function)) 46 | // init_function(); 47 | 48 | lua_close(L); 49 | delete [] ScriptName; 50 | return; 51 | } 52 | 53 | void GetScripts(const fs::path& root, const std::string& ext, std::vector& ret) 54 | { 55 | if (!fs::exists(root)) return; 56 | 57 | if (fs::is_directory(root)) 58 | { 59 | 60 | fs::recursive_directory_iterator it(root); 61 | fs::recursive_directory_iterator endit; 62 | 63 | while(it != endit) 64 | { 65 | if (fs::is_regular_file(*it) && it->path().extension() == ext) 66 | { 67 | ret.push_back(it->path().filename()); 68 | } 69 | ++it; 70 | } 71 | } 72 | 73 | } 74 | 75 | VOID MainThread( LPVOID ) 76 | { 77 | while (GetModuleHandle("Game.dll") == NULL) Sleep(1000); 78 | Sleep(5000); 79 | 80 | int iScripts = 0; 81 | 82 | std::vector Result; 83 | fs::path Path("Scripts"); 84 | GetScripts(Path,".lua",Result); 85 | iScripts = Result.size(); 86 | 87 | if (iScripts <= 0) return; 88 | 89 | for (int i = 0; i < iScripts; i++) 90 | { 91 | char ScriptPath[MAX_PATH] = "Scripts\\"; 92 | strcat_s(ScriptPath,Result[i].string().c_str()); 93 | char * myvariable = new char[MAX_PATH]; 94 | *myvariable=0; 95 | strncat_s(myvariable, sizeof(ScriptPath), ScriptPath,MAX_PATH); // this is equivalent to what the nonstandard strlcpy would do 96 | _beginthread(LoadScript,0, (LPVOID)myvariable); 97 | } 98 | 99 | return; 100 | } 101 | 102 | BOOL APIENTRY DllMain(HMODULE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) 103 | { 104 | switch (ul_reason_for_call) 105 | { 106 | case DLL_PROCESS_ATTACH: 107 | DllModule = hModule; 108 | DisableThreadLibraryCalls(hModule); 109 | _beginthread(MainThread,0, NULL); 110 | case DLL_THREAD_ATTACH: 111 | case DLL_THREAD_DETACH: 112 | case DLL_PROCESS_DETACH: 113 | break; 114 | } 115 | return TRUE; 116 | } 117 | -------------------------------------------------------------------------------- /war3-lua-engine/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/resource.h -------------------------------------------------------------------------------- /war3-lua-engine/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | #pragma message("Compiling precompiled header.\n") 8 | 9 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 10 | // Windows Header Files: 11 | #include 12 | #include 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | 17 | #include "LuaJIT\src\lua.hpp" 18 | #include "LuaBridge\LuaBridge.h" 19 | #include "Variables.h" 20 | -------------------------------------------------------------------------------- /war3-lua-engine/war3-lua-engine.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/war3-lua-engine.aps -------------------------------------------------------------------------------- /war3-lua-engine/war3-lua-engine.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luciouskami/war3-lua-engine/940b556505461ec70f2971c673a07dcc02485a05/war3-lua-engine/war3-lua-engine.rc -------------------------------------------------------------------------------- /war3-lua-engine/war3-lua-engine.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {3A7F16F7-17E0-435F-A05A-812C6AA6A872} 15 | Win32Proj 16 | war3luaengine 17 | 18 | 19 | 20 | DynamicLibrary 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | DynamicLibrary 27 | false 28 | v100 29 | true 30 | MultiByte 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | .mix 48 | 49 | 50 | 51 | Use 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_WINDOWS;_USRDLL;WAR3LUAENGINE_EXPORTS;%(PreprocessorDefinitions) 55 | true 56 | 57 | 58 | Windows 59 | true 60 | 61 | 62 | 63 | 64 | Level3 65 | NotUsing 66 | Full 67 | true 68 | true 69 | WIN32;NDEBUG;_WINDOWS;_USRDLL;WAR3LUAENGINE_EXPORTS;%(PreprocessorDefinitions) 70 | true 71 | Speed 72 | LuaJIT;G:\Boost\boost_1_55_0;%(AdditionalIncludeDirectories) 73 | MultiThreadedDLL 74 | true 75 | 76 | 77 | 78 | 79 | Windows 80 | true 81 | G:\Boost\boost_1_55_0\stage\lib;LuaJIT\src\;%(AdditionalLibraryDirectories) 82 | lua51.lib;%(AdditionalDependencies) 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | false 98 | 99 | 100 | false 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /war3-lua-engine/war3-lua-engine.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;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | Resource Files 66 | 67 | 68 | -------------------------------------------------------------------------------- /war3-lua-engine/war3-lua-engine.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /war3-lua-engine/war3_lua_engine.h: -------------------------------------------------------------------------------- 1 | #ifndef LUABRIDGE_TESTS_HEADER 2 | #define LUABRIDGE_TESTS_HEADER 3 | 4 | #include "stdafx.h" 5 | 6 | namespace War3LuaEngine 7 | { 8 | 9 | static void SendSpecialCh(char ch); 10 | static void SendSpecial(char *szTemp); 11 | static void SendCh(char ch, int nRep); 12 | static void SendVk(UINT vk, int nRep, bool bExtended = false); 13 | static void SimKeystroke(UINT vk, bool bForceExtended = false); 14 | static void SimModsUp(void); 15 | static void SimModsDown(void); 16 | static void ResolveKeyModifiers(UINT vkres); 17 | static void SimKeyUp(UINT vk, bool bForceExtended = false); 18 | static void SimKeyDown(UINT vk, bool bForceExtended = false); 19 | static bool IsVKExtended(UINT key); 20 | static int ReadToChar(char ch, const char *szLine, char *szResult, int &nPos); 21 | static bool SetToggleState(UINT vk, bool bState); 22 | 23 | extern void addToState (lua_State* L); 24 | 25 | /** 26 | Returns a registry reference to the message handler to 27 | use in subsequent calls to lua_pcall (). 28 | */ 29 | extern int addTraceback (lua_State* L); 30 | 31 | 32 | } 33 | 34 | #endif --------------------------------------------------------------------------------