mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
LunaCON: for *-already-defined style warnings/errors, show location of old def.
git-svn-id: https://svn.eduke32.com/eduke32@4151 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
987eb858d3
commit
82fb8a0724
2 changed files with 40 additions and 22 deletions
|
@ -206,7 +206,7 @@ LunaCON makes a clear distinction between ``outer'' commands that have an
|
||||||
effect when translating a CON file (_directives_ such as `gamevar`,
|
effect when translating a CON file (_directives_ such as `gamevar`,
|
||||||
`definesound` or `spritenvg`) and ``inner'' commands meant to be effective at
|
`definesound` or `spritenvg`) and ``inner'' commands meant to be effective at
|
||||||
execution time of `actor`/`useractor`, `state`, `event` and `eventloadactor`
|
execution time of `actor`/`useractor`, `state`, `event` and `eventloadactor`
|
||||||
blocks. This, issuing directives inside of these will make LunaCON reject the
|
blocks. Thus, issuing directives inside of these will make LunaCON reject the
|
||||||
input file due to a syntax error, as will an attempt to use run-time commands
|
input file due to a syntax error, as will an attempt to use run-time commands
|
||||||
such as `sizeat` at file scope.
|
such as `sizeat` at file scope.
|
||||||
|
|
||||||
|
|
|
@ -503,7 +503,7 @@ local function get_cache_sap_code()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- fwd-decls
|
-- fwd-decls
|
||||||
local warnprintf, errprintf, pwarnprintf, perrprintf
|
local warnprintf, errprintf, pwarnprintf, perrprintf, contprintf
|
||||||
|
|
||||||
local on = {}
|
local on = {}
|
||||||
|
|
||||||
|
@ -643,29 +643,29 @@ local function increment_numerrors()
|
||||||
end
|
end
|
||||||
|
|
||||||
function perrprintf(pos, fmt, ...)
|
function perrprintf(pos, fmt, ...)
|
||||||
printf("%s %s: error: "..fmt, g_filename, linecolstr(pos), ...)
|
printf("%s %s: error: "..fmt, g_filename,
|
||||||
|
pos and linecolstr(pos) or "???", ...)
|
||||||
increment_numerrors()
|
increment_numerrors()
|
||||||
end
|
end
|
||||||
|
|
||||||
function errprintf(fmt, ...)
|
function errprintf(fmt, ...)
|
||||||
if (g_lastkwpos) then
|
|
||||||
perrprintf(g_lastkwpos, fmt, ...)
|
perrprintf(g_lastkwpos, fmt, ...)
|
||||||
else
|
|
||||||
printf("%s ???: error: "..fmt, g_filename, ...)
|
|
||||||
increment_numerrors()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function pwarnprintf(pos, fmt, ...)
|
function pwarnprintf(pos, fmt, ...)
|
||||||
printf("%s %s: warning: "..fmt, g_filename, linecolstr(pos), ...)
|
printf("%s %s: warning: "..fmt, g_filename,
|
||||||
|
pos and linecolstr(pos) or "???", ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
function warnprintf(fmt, ...)
|
function warnprintf(fmt, ...)
|
||||||
if (g_lastkwpos) then
|
|
||||||
pwarnprintf(g_lastkwpos, fmt, ...)
|
pwarnprintf(g_lastkwpos, fmt, ...)
|
||||||
else
|
end
|
||||||
printf("%s ???: warning: "..fmt, g_filename, ...)
|
|
||||||
end
|
-- Print a continuation line to an error or warning.
|
||||||
|
function contprintf(iserr, fmt, ...)
|
||||||
|
printf("%s %s: %s "..fmt, g_filename,
|
||||||
|
g_lastkwpos and linecolstr(g_lastkwpos) or "???",
|
||||||
|
iserr and " " or " ", ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function parse_number(pos, numstr)
|
local function parse_number(pos, numstr)
|
||||||
|
@ -731,6 +731,7 @@ local LABEL_PREFIX = { [2]="M", [3]="I", [5]="C" } -- _C, _M, _I in the gen'd c
|
||||||
local g_labeldef = {} -- Lua numbers for numbers, strings for composites
|
local g_labeldef = {} -- Lua numbers for numbers, strings for composites
|
||||||
local g_labeltype = {}
|
local g_labeltype = {}
|
||||||
local g_labelspecial = {} -- [<label>] = true
|
local g_labelspecial = {} -- [<label>] = true
|
||||||
|
local g_labelloc = {} -- [<label>] = { filename, linenum, colnum }
|
||||||
|
|
||||||
local function reset_labels()
|
local function reset_labels()
|
||||||
g_badids = {}
|
g_badids = {}
|
||||||
|
@ -834,6 +835,16 @@ local function check_sysvar_def_attempt(identifier)
|
||||||
end
|
end
|
||||||
|
|
||||||
local Define = {}
|
local Define = {}
|
||||||
|
function Define.inform_olddef_location(identifier, iserr) -- XXX: too much locals
|
||||||
|
local loc = g_labelloc[identifier]
|
||||||
|
if (loc) then
|
||||||
|
contprintf(iserr, "Old definition is at %s %d:%d",
|
||||||
|
loc[1], loc[2], loc[3])
|
||||||
|
else
|
||||||
|
contprintf(iserr, "Old definition is built-in")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Define.label(identifier, num)
|
function Define.label(identifier, num)
|
||||||
if (check_sysvar_def_attempt(identifier)) then
|
if (check_sysvar_def_attempt(identifier)) then
|
||||||
return
|
return
|
||||||
|
@ -844,14 +855,16 @@ function Define.label(identifier, num)
|
||||||
|
|
||||||
if (oldval) then
|
if (oldval) then
|
||||||
if (oldtype ~= LABEL.NUMBER) then
|
if (oldtype ~= LABEL.NUMBER) then
|
||||||
errprintf("refusing to overwrite `%s' label \"%s\" with a `define'd number",
|
errprintf("Refusing to overwrite `%s' label \"%s\" with a `define'd number.",
|
||||||
LABEL[oldtype], identifier)
|
LABEL[oldtype], identifier)
|
||||||
|
Define.inform_olddef_location(identifier, true)
|
||||||
else
|
else
|
||||||
-- conl.labels[...]: don't warn for wrong PROJ_ redefinitions
|
-- conl.labels[...]: don't warn for wrong PROJ_ redefinitions
|
||||||
if (g_warn["not-redefined"]) then
|
if (g_warn["not-redefined"]) then
|
||||||
if (oldval ~= num and conl.PROJ[identifier]==nil) then
|
if (oldval ~= num and conl.PROJ[identifier]==nil) then
|
||||||
warnprintf("label \"%s\" not redefined with new value %d (old: %d)",
|
warnprintf("Label \"%s\" not redefined with new value %d (old: %d).",
|
||||||
identifier, num, oldval)
|
identifier, num, oldval)
|
||||||
|
Define.inform_olddef_location(identifier, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -868,6 +881,7 @@ function Define.label(identifier, num)
|
||||||
-- New definition of a label
|
-- New definition of a label
|
||||||
g_labeldef[identifier] = num
|
g_labeldef[identifier] = num
|
||||||
g_labeltype[identifier] = LABEL.NUMBER
|
g_labeltype[identifier] = LABEL.NUMBER
|
||||||
|
g_labelloc[identifier] = { g_filename, getlinecol(g_lastkwpos) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -928,11 +942,13 @@ function Define.composite(labeltype, identifier, ...)
|
||||||
|
|
||||||
if (oldval) then
|
if (oldval) then
|
||||||
if (oldtype ~= labeltype) then
|
if (oldtype ~= labeltype) then
|
||||||
errprintf("refusing to overwrite `%s' label \"%s\" with a `%s' value",
|
errprintf("Refusing to overwrite `%s' label \"%s\" with a `%s' value.",
|
||||||
LABEL[oldtype], identifier, LABEL[labeltype])
|
LABEL[oldtype], identifier, LABEL[labeltype])
|
||||||
|
Define.inform_olddef_location(identifier, true)
|
||||||
else
|
else
|
||||||
warnprintf("duplicate `%s' definition of \"%s\" ignored",
|
warnprintf("Duplicate `%s' definition of \"%s\" ignored.",
|
||||||
LABEL[labeltype], identifier)
|
LABEL[labeltype], identifier)
|
||||||
|
Define.inform_olddef_location(identifier, false)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -985,6 +1001,7 @@ function Define.composite(labeltype, identifier, ...)
|
||||||
|
|
||||||
g_labeldef[identifier] = refcode
|
g_labeldef[identifier] = refcode
|
||||||
g_labeltype[identifier] = labeltype
|
g_labeltype[identifier] = labeltype
|
||||||
|
g_labelloc[identifier] = { g_filename, getlinecol(g_lastkwpos) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1468,17 +1485,18 @@ function Cmd.gamevar(identifier, initval, flags)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
errprintf("duplicate gamevar definition `%s' has different flags", identifier)
|
errprintf("duplicate definition of gamevar `%s' has different flags", identifier)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
warnprintf("duplicate gamevar definition `%s' ignored", identifier)
|
warnprintf("duplicate definition of gamevar `%s' ignored", identifier)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ltype = g_labeltype[identifier]
|
local ltype = g_labeltype[identifier]
|
||||||
if (ltype ~= nil) then
|
if (ltype ~= nil) then
|
||||||
warnprintf("symbol `%s' already used for a defined %s", identifier, LABEL[ltype])
|
warnprintf("Symbol `%s' already used for a defined %s.", identifier, LABEL[ltype])
|
||||||
|
Define.inform_olddef_location(identifier, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (isSessionVar) then
|
if (isSessionVar) then
|
||||||
|
|
Loading…
Reference in a new issue