mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +00:00
Lunatic: remove DBG_ variable for _DEBUG_LUNATIC=0.
git-svn-id: https://svn.eduke32.com/eduke32@3966 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
ac3a6a1bd2
commit
7860fb8c01
2 changed files with 37 additions and 25 deletions
|
@ -1704,6 +1704,11 @@ local function our_require(modname, ...)
|
||||||
error("module name must be a nonempty string", 2)
|
error("module name must be a nonempty string", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- For _LUNATIC_DBG
|
||||||
|
if (modname:match("^_LUNATIC") and ffiC._DEBUG_LUNATIC == 0) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
-- Handle the section between module() and require("end_gamevars").
|
-- Handle the section between module() and require("end_gamevars").
|
||||||
if (modname == "end_gamevars") then
|
if (modname == "end_gamevars") then
|
||||||
local thismodname = getcurmodname("require")
|
local thismodname = getcurmodname("require")
|
||||||
|
@ -2371,42 +2376,45 @@ gv = setmtonce(gv_, tmpmt)
|
||||||
defs_c.create_globals(_G)
|
defs_c.create_globals(_G)
|
||||||
|
|
||||||
-- REMOVE this for release
|
-- REMOVE this for release
|
||||||
DBG_ = {}
|
if (ffiC._DEBUG_LUNATIC ~= 0) then
|
||||||
DBG_.debug = require("debug")
|
local DBG_ = {}
|
||||||
DBG_.printkv = printkv
|
DBG_.debug = require("debug")
|
||||||
DBG_.loadstring = loadstring
|
DBG_.printkv = printkv
|
||||||
DBG_.oom = function()
|
DBG_.loadstring = loadstring
|
||||||
local s = "1"
|
DBG_.oom = function()
|
||||||
for i=1,math.huge do
|
local s = "1"
|
||||||
s = s..s
|
for i=1,math.huge do
|
||||||
|
s = s..s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Test reading from all struct members
|
-- Test reading from all struct members
|
||||||
function DBG_.testmembread()
|
DBG_.testmembread = function()
|
||||||
for _1, sac in pairs { con_lang.StructAccessCode, con_lang.StructAccessCode2 } do
|
for _1, sac in pairs { con_lang.StructAccessCode, con_lang.StructAccessCode2 } do
|
||||||
for what, labels in pairs(sac) do
|
for what, labels in pairs(sac) do
|
||||||
if (what~="tspr") then
|
if (what~="tspr") then
|
||||||
for _3, membaccode in pairs(labels) do
|
for _3, membaccode in pairs(labels) do
|
||||||
if (type(membaccode)=="table") then
|
if (type(membaccode)=="table") then
|
||||||
membaccode = membaccode[1]
|
membaccode = membaccode[1]
|
||||||
end
|
end
|
||||||
if (membaccode) then
|
if (membaccode) then
|
||||||
local codestr = [[
|
local codestr = [[
|
||||||
do
|
do
|
||||||
local _bit,_math=require'bit',require'math'
|
local _bit,_math=require'bit',require'math'
|
||||||
local _band,_gv=_bit.band,gv
|
local _band,_gv=_bit.band,gv
|
||||||
local tmp=]]..
|
local tmp=]]..
|
||||||
membaccode:gsub("%%s","0").." end"
|
membaccode:gsub("%%s","0").." end"
|
||||||
local code = assert(loadstring(codestr))
|
local code = assert(loadstring(codestr))
|
||||||
code()
|
code()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
allowed_modules._LUNATIC_DBG = DBG_
|
||||||
|
end
|
||||||
|
|
||||||
---=== Finishing environment setup ===---
|
---=== Finishing environment setup ===---
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ local bit = require("bit")
|
||||||
local math = require("math")
|
local math = require("math")
|
||||||
|
|
||||||
local pcall = pcall
|
local pcall = pcall
|
||||||
local DBG_ = DBG_
|
local DBG_ = require("_LUNATIC_DBG")
|
||||||
|
|
||||||
print('---=== ELua Test script ===---')
|
print('---=== ELua Test script ===---')
|
||||||
|
|
||||||
|
@ -15,6 +15,10 @@ local function printf(fmt, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function checkfail(funcstr, expectedmsg)
|
local function checkfail(funcstr, expectedmsg)
|
||||||
|
if (DBG_ == nil) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local status, errmsg = pcall(DBG_.loadstring(funcstr))
|
local status, errmsg = pcall(DBG_.loadstring(funcstr))
|
||||||
if (status) then
|
if (status) then
|
||||||
print('^21ERROR:^O '..funcstr.." DIDN'T fail")
|
print('^21ERROR:^O '..funcstr.." DIDN'T fail")
|
||||||
|
@ -275,7 +279,7 @@ gameevent
|
||||||
gv.EVENT_ENTERLEVEL,
|
gv.EVENT_ENTERLEVEL,
|
||||||
|
|
||||||
function()
|
function()
|
||||||
if (gv._DEBUG_LUNATIC) then
|
if (DBG_ ~= nil) then
|
||||||
DBG_.testmembread()
|
DBG_.testmembread()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue