Rectangle = "src.utils:Rectangle";
draw_arrow = "src.utils:draw_arrow";
+ revipairs = "src.utils:revipairs";
wasm_text = "src.wasm.text";
wasm_decompile = "src.wasm.decompile";
rect = Rectangle(0, 0, 200, 20)
})
+ ui.insert_child(self, with(ui.make_element("button", "Make tree")) {
+ click = function_context_menu.btn_make_tree;
+ rect = Rectangle(0, 20, 200, 20)
+ })
+
ui.focus(self)
end
for _, r in ipairs(lines) do print(r) end
end
+function function_context_menu:btn_make_tree(button, x, y)
+ local wasm_func = self.parent.parent
+ ui.fire_stoppable_event(globals.ui.root, "make_tree", wasm_func)
+end
+
local scrolling_area = {}
function scrolling_area:init()
self.offset = { x = 0; y = 0 }
end
end
+local function_blocks_container = {}
+function function_blocks_container:make_tree(root)
+ print("Creating tree!", root)
+
+ local funcs = {}
+ for _, f in ipairs(self.children) do
+ funcs[f.func.funcidx] = f
+ end
+
+ local sx = root.rect.x
+ local sy = root.rect.y
+
+ local padding = 10
+
+ local have_added = {}
+ local to_add = {}
+
+ table.insert(to_add, { block = root, x = sx, y = sy })
+
+ while #to_add > 0 do
+ local adding = to_add[1]
+ table.remove(to_add, 1)
+ table.insert(have_added, adding.block)
+ print("Processing", adding.block.func.funcidx)
+
+ adding.block.rect.x = adding.x
+ adding.block.rect.y = adding.y
+
+ if adding.block.func.callees then
+ local cc = #adding.block.func.callees
+
+ local x = adding.x
+ for i, calls in revipairs(adding.block.func.callees) do
+ local b = funcs[calls]
+ if not table.contains(have_added, b) then
+ table.insert(to_add, {
+ block = b,
+ x = x,
+ y = adding.y + adding.block.rect.h + padding
+ })
+
+ x = x + b.rect.w + padding
+ end
+ end
+ end
+ end
+
+ return true
+end
+
+
ui.register_component "rect" (rect)
ui.register_component "drag_rect" (drag_rect)
ui.register_component "button" (button)
ui.register_component "function_context_menu" (function_context_menu)
ui.register_component "scrolling_area" (scrolling_area)
ui.register_component "function_ref_lines" (function_ref_lines)
+ui.register_component "function_blocks_container" (function_blocks_container)
return module {
rect = rect;