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:
helixhorned 2013-07-19 12:49:06 +00:00
parent ac3a6a1bd2
commit 7860fb8c01
2 changed files with 37 additions and 25 deletions

View file

@ -1704,6 +1704,11 @@ local function our_require(modname, ...)
error("module name must be a nonempty string", 2)
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").
if (modname == "end_gamevars") then
local thismodname = getcurmodname("require")
@ -2371,42 +2376,45 @@ gv = setmtonce(gv_, tmpmt)
defs_c.create_globals(_G)
-- REMOVE this for release
DBG_ = {}
DBG_.debug = require("debug")
DBG_.printkv = printkv
DBG_.loadstring = loadstring
DBG_.oom = function()
local s = "1"
for i=1,math.huge do
s = s..s
if (ffiC._DEBUG_LUNATIC ~= 0) then
local DBG_ = {}
DBG_.debug = require("debug")
DBG_.printkv = printkv
DBG_.loadstring = loadstring
DBG_.oom = function()
local s = "1"
for i=1,math.huge do
s = s..s
end
end
end
-- Test reading from all struct members
function DBG_.testmembread()
for _1, sac in pairs { con_lang.StructAccessCode, con_lang.StructAccessCode2 } do
for what, labels in pairs(sac) do
if (what~="tspr") then
for _3, membaccode in pairs(labels) do
if (type(membaccode)=="table") then
membaccode = membaccode[1]
end
if (membaccode) then
local codestr = [[
-- Test reading from all struct members
DBG_.testmembread = function()
for _1, sac in pairs { con_lang.StructAccessCode, con_lang.StructAccessCode2 } do
for what, labels in pairs(sac) do
if (what~="tspr") then
for _3, membaccode in pairs(labels) do
if (type(membaccode)=="table") then
membaccode = membaccode[1]
end
if (membaccode) then
local codestr = [[
do
local _bit,_math=require'bit',require'math'
local _band,_gv=_bit.band,gv
local tmp=]]..
membaccode:gsub("%%s","0").." end"
local code = assert(loadstring(codestr))
code()
local code = assert(loadstring(codestr))
code()
end
end
end
end
end
end
end
allowed_modules._LUNATIC_DBG = DBG_
end
---=== Finishing environment setup ===---

View file

@ -6,7 +6,7 @@ local bit = require("bit")
local math = require("math")
local pcall = pcall
local DBG_ = DBG_
local DBG_ = require("_LUNATIC_DBG")
print('---=== ELua Test script ===---')
@ -15,6 +15,10 @@ local function printf(fmt, ...)
end
local function checkfail(funcstr, expectedmsg)
if (DBG_ == nil) then
return
end
local status, errmsg = pcall(DBG_.loadstring(funcstr))
if (status) then
print('^21ERROR:^O '..funcstr.." DIDN'T fail")
@ -275,7 +279,7 @@ gameevent
gv.EVENT_ENTERLEVEL,
function()
if (gv._DEBUG_LUNATIC) then
if (DBG_ ~= nil) then
DBG_.testmembread()
end