1-
21local cpp = {}
32
43local typed = require (" plugins.ffi.c-parser.typed" )
54local c99 = require (" plugins.ffi.c-parser.c99" )
65
76local SEP = package.config :sub (1 ,1 )
87
9- local shl , shr
10- if jit then
11- shl = function (a , b )
12- return bit .lshift (a , b )
13- end
14- shr = function (a , b )
15- return bit .rshift (a , b )
16- end
17- else
18- shl , shr = load ([[
19- local function shl(a, b)
20- return a << b
21- end
22- local function shr(a, b)
23- return a >> b
24- end
25- return shl, shr
26- ]] )()
8+ local function shl (a , b )
9+ return a << b
10+ end
11+ local function shr (a , b )
12+ return a >> b
2713end
2814
29- local function debug () end
15+ local function debug (... ) end
3016--[[
3117local inspect = require("inspect")
3218local function debug(...)
@@ -623,6 +609,7 @@ cpp.parse_file = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(filenam
623609 ctx = {
624610 incdirs = cpp_include_paths (),
625611 defines = gcc_default_defines (),
612+ --- @type any[]
626613 ifmode = { true },
627614 output = {},
628615 current_dir = {}
@@ -785,7 +772,7 @@ cpp.parse_context = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(cont
785772 for cur , lineitem in ipairs (linelist ) do
786773 local line = lineitem .line
787774 local tk = lineitem .tk
788- debug (filename , cur , ifmode [# ifmode ], # ifmode , line )
775+ debug (cur , ifmode [# ifmode ], # ifmode , line )
789776
790777 if # ifmode == 1 and (tk .directive == " elif" or tk .directive == " else" or tk .directive == " endif" ) then
791778 return nil , " unexpected directive " .. tk .directive
@@ -812,6 +799,7 @@ cpp.parse_context = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(cont
812799 elseif tk .directive == " if" then
813800 table.insert (ifmode , run_expression (ctx , tk .exp ))
814801 elseif tk .directive == " elif" then
802+ --- @diagnostic disable-next-line : assign-type-mismatch
815803 ifmode [# ifmode ] = " skip"
816804 elseif tk .directive == " else" then
817805 ifmode [# ifmode ] = not ifmode [# ifmode ]
0 commit comments