Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(userspace/engine): remove unused lua functions and state vars #1908

Merged
merged 1 commit into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions userspace/engine/lua/modules/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,31 +113,6 @@ function expand_macros(ast, defs, changed)
return true, changed
end

function get_macros(ast, set)
if (ast.type == "Macro") then
set[ast.value] = true
return set
end

if ast.type == "Filter" then
return get_macros(ast.value, set)
end

if ast.type == "BinaryBoolOp" then
local left = get_macros(ast.left, {})
local right = get_macros(ast.right, {})

for m, _ in pairs(left) do set[m] = true end
for m, _ in pairs(right) do set[m] = true end

return set
end
if ast.type == "UnaryBoolOp" then
return get_macros(ast.argument, set)
end
return set
end

function get_filters(ast)

local filters = {}
Expand Down
21 changes: 1 addition & 20 deletions userspace/engine/lua/rule_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,6 @@ local function create_filter_obj(node, lua_parser, parent_bool_op)
return nil
end

function set_output(output_format, state)

if(output_ast.type == "OutputFormat") then

local format

else
error ("Unexpected type in set_output: ".. output_ast.type)
end
end

-- This should be keep in sync with parser.lua
defined_comp_operators = {
["="]=1,
Expand Down Expand Up @@ -197,7 +186,7 @@ defined_list_comp_operators = {
-- object. The by_name index is used for things like describing rules,
-- and the by_idx index is used to map the relational node index back
-- to a rule.
local state = {macros={}, lists={}, filter_ast=nil, rules_by_name={},
local state = {macros={}, lists={}, rules_by_name={},
skipped_rules_by_name={}, macros_by_name={}, lists_by_name={},
n_rules=0, rules_by_idx={}, ordered_rule_names={}, ordered_macro_names={}, ordered_list_names={}}

Expand Down Expand Up @@ -1067,14 +1056,6 @@ function load_rules(rules_content,
end
end

-- Rule ASTs are merged together into one big AST, with "OR" between each
-- rule.
if (state.filter_ast == nil) then
state.filter_ast = filter_ast.filter.value
else
state.filter_ast = { type = "BinaryBoolOp", operator = "or", left = state.filter_ast, right = filter_ast.filter.value }
end

-- Enable/disable the rule
if (v['enabled'] == nil) then
v['enabled'] = true
Expand Down