1- --- @diagnostic disable : undefined-global , assign-type-mismatch
2-
31local cpp = {}
42
53local typed = require (" plugins.ffi.c-parser.typed" )
64local c99 = require (" plugins.ffi.c-parser.c99" )
75
86local SEP = package.config :sub (1 ,1 )
97
10- local shl , shr
11- if jit then
12- shl = function (a , b )
13- return bit .lshift (a , b )
14- end
15- shr = function (a , b )
16- return bit .rshift (a , b )
17- end
18- else
19- shl , shr = load ([[
20- local function shl(a, b)
21- return a << b
22- end
23- local function shr(a, b)
24- return a >> b
25- end
26- return shl, shr
27- ]] )()
8+ local function shl (a , b )
9+ return a << b
10+ end
11+ local function shr (a , b )
12+ return a >> b
2813end
2914
3015local function debug (...) end
@@ -624,6 +609,7 @@ cpp.parse_file = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(filenam
624609 ctx = {
625610 incdirs = cpp_include_paths (),
626611 defines = gcc_default_defines (),
612+ --- @type any[]
627613 ifmode = { true },
628614 output = {},
629615 current_dir = {}
@@ -786,7 +772,7 @@ cpp.parse_context = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(cont
786772 for cur , lineitem in ipairs (linelist ) do
787773 local line = lineitem .line
788774 local tk = lineitem .tk
789- debug (filename , cur , ifmode [# ifmode ], # ifmode , line )
775+ debug (cur , ifmode [# ifmode ], # ifmode , line )
790776
791777 if # ifmode == 1 and (tk .directive == " elif" or tk .directive == " else" or tk .directive == " endif" ) then
792778 return nil , " unexpected directive " .. tk .directive
@@ -813,6 +799,7 @@ cpp.parse_context = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(cont
813799 elseif tk .directive == " if" then
814800 table.insert (ifmode , run_expression (ctx , tk .exp ))
815801 elseif tk .directive == " elif" then
802+ --- @diagnostic disable-next-line : assign-type-mismatch
816803 ifmode [# ifmode ] = " skip"
817804 elseif tk .directive == " else" then
818805 ifmode [# ifmode ] = not ifmode [# ifmode ]
0 commit comments