From 17f3577d70c4d11ba7e09bad0e460c4538f14970 Mon Sep 17 00:00:00 2001 From: fesily Date: Mon, 22 May 2023 16:12:22 +0800 Subject: remove jit --- script/plugins/ffi/c-parser/cpp.lua | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'script/plugins') diff --git a/script/plugins/ffi/c-parser/cpp.lua b/script/plugins/ffi/c-parser/cpp.lua index 989bca66..eaa34330 100644 --- a/script/plugins/ffi/c-parser/cpp.lua +++ b/script/plugins/ffi/c-parser/cpp.lua @@ -1,5 +1,3 @@ ----@diagnostic disable: undefined-global, assign-type-mismatch - local cpp = {} local typed = require("plugins.ffi.c-parser.typed") @@ -7,24 +5,11 @@ local c99 = require("plugins.ffi.c-parser.c99") local SEP = package.config:sub(1,1) -local shl, shr -if jit then - shl = function(a, b) - return bit.lshift(a, b) - end - shr = function(a, b) - return bit.rshift(a, b) - end -else - shl, shr = load([[ - local function shl(a, b) - return a << b - end - local function shr(a, b) - return a >> b - end - return shl, shr - ]])() +local function shl(a, b) + return a << b +end +local function shr(a, b) + return a >> b end local function debug(...) end @@ -624,6 +609,7 @@ cpp.parse_file = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(filenam ctx = { incdirs = cpp_include_paths(), defines = gcc_default_defines(), + ---@type any[] ifmode = { true }, output = {}, current_dir = {} @@ -786,7 +772,7 @@ cpp.parse_context = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(cont for cur, lineitem in ipairs(linelist) do local line = lineitem.line local tk = lineitem.tk - debug(filename, cur, ifmode[#ifmode], #ifmode, line) + debug(cur, ifmode[#ifmode], #ifmode, line) if #ifmode == 1 and (tk.directive == "elif" or tk.directive == "else" or tk.directive == "endif") then return nil, "unexpected directive " .. tk.directive @@ -813,6 +799,7 @@ cpp.parse_context = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(cont elseif tk.directive == "if" then table.insert(ifmode, run_expression(ctx, tk.exp)) elseif tk.directive == "elif" then +---@diagnostic disable-next-line: assign-type-mismatch ifmode[#ifmode] = "skip" elseif tk.directive == "else" then ifmode[#ifmode] = not ifmode[#ifmode] -- cgit v1.2.3