ui.fire_propagating_event(globals.ui.function_blocks_container, "dummy")
local i = 0
- for _, func in ipairs(globals.wasm_module.funcs) do
+ local funcs = globals.wasm_module.funcs
+ while globals.wasm_module.funcs[i] do
ui.insert_child(
globals.ui.function_blocks_container,
- with(ui.make_element("function_block", func, globals.wasm_module)) {
- rect = Rectangle(math.random() * 1000, math.random() * 1000, 400, 400);
- layer = #globals.wasm_module.funcs - i
+ with(ui.make_element("function_block", funcs[i], globals.wasm_module)) {
+ rect = Rectangle(math.random() * 5000, math.random() * 5000, 400, 400);
+ layer = #funcs - i
})
i = i + 1
local func_blocks = globals.ui.function_blocks_container.children
local funcs = {}
for _, f in ipairs(func_blocks) do
- print(f.func.funcidx - 1)
- funcs[f.func.funcidx - 1] = f
+ funcs[f.func.funcidx] = f
end
- print "------------"
-
self.arrows = {}
for _, from in ipairs(func_blocks) do
if from.func.callees then
if from.func.callers then
for _, to in ipairs(from.func.callers) do
- table.insert(self.arrows, { from = funcs[to - 1]; to = from; color = COLORS.secondary_dark })
+ table.insert(self.arrows, { from = funcs[to]; to = from; color = COLORS.secondary_dark })
end
end
end
function function_ref_lines:predraw()
for _, arr in ipairs(self.arrows) do
- local from = arr.from.rect
- local to = arr.to.rect
- love.graphics.setColor(arr.color)
- draw_arrow(
- from.x + from.w / 2, from.y + from.h / 2,
- to.x + to.w / 2, to.y + to.h / 2)
+ if arr.from and arr.to then
+ local from = arr.from.rect
+ local to = arr.to.rect
+ love.graphics.setColor(arr.color)
+ draw_arrow(
+ from.x + from.w / 2, from.y + from.h / 2,
+ to.x + to.w / 2, to.y + to.h / 2)
+ end
end
end