@@ -23139,9 +23139,9 @@ log(mod.toString());`
2313923139 condition: terminator.condition,
2314023140 body: prependNode(preBody, bodyNode2)
2314123141 };
23142- const exitId2 = falseTarget;
23143- if (exitId2 !== regionEnd && !processed.has(exitId2 )) {
23144- const afterLoop = structureRegion(exitId2 , regionEnd);
23142+ const exitId = falseTarget;
23143+ if (exitId !== regionEnd && !processed.has(exitId )) {
23144+ const afterLoop = structureRegion(exitId , regionEnd);
2314523145 return { kind: "sequence", children: [whileNode2, afterLoop] };
2314623146 }
2314723147 return whileNode2;
@@ -23155,22 +23155,39 @@ log(mod.toString());`
2315523155 condition: negatedCondition,
2315623156 body: prependNode(preBody, bodyNode2)
2315723157 };
23158- const exitId2 = trueTarget;
23159- if (exitId2 !== regionEnd && !processed.has(exitId2 )) {
23160- const afterLoop = structureRegion(exitId2 , regionEnd);
23158+ const exitId = trueTarget;
23159+ if (exitId !== regionEnd && !processed.has(exitId )) {
23160+ const afterLoop = structureRegion(exitId , regionEnd);
2316123161 return { kind: "sequence", children: [whileNode2, afterLoop] };
2316223162 }
2316323163 return whileNode2;
2316423164 }
2316523165 }
2316623166 const bodyNode = structureLoopBody(headerId, headerId, loop);
2316723167 const whileNode = { kind: "while", condition: null, body: bodyNode };
23168- const exitId = findSingleExit(loop);
23169- if (exitId !== null && exitId !== regionEnd && !processed.has(exitId)) {
23170- const afterLoop = structureRegion(exitId, regionEnd);
23171- return { kind: "sequence", children: [whileNode, afterLoop] };
23168+ const afterChildren = [whileNode];
23169+ if (loop.exitIds.size > 0) {
23170+ const postDom = dominance.postImmediateDominator.get(headerId);
23171+ const convergenceId = postDom !== void 0 && !loop.bodyIds.has(postDom) ? postDom : null;
23172+ for (const exitId of loop.exitIds) {
23173+ if (exitId === regionEnd || processed.has(exitId)) {
23174+ continue;
23175+ }
23176+ if (exitId === convergenceId) {
23177+ continue;
23178+ }
23179+ const exitPath = structureRegion(exitId, convergenceId ?? regionEnd);
23180+ afterChildren.push(exitPath);
23181+ }
23182+ if (convergenceId !== null && convergenceId !== regionEnd && !processed.has(convergenceId)) {
23183+ const afterConvergence = structureRegion(convergenceId, regionEnd);
23184+ afterChildren.push(afterConvergence);
23185+ }
23186+ }
23187+ if (afterChildren.length === 1) {
23188+ return whileNode;
2317223189 }
23173- return whileNode ;
23190+ return { kind: "sequence", children: afterChildren } ;
2317423191 }
2317523192 function structureLoopBody(startId, headerId, loop) {
2317623193 const children = [];
@@ -23271,6 +23288,22 @@ log(mod.toString());`
2327123288 currentBlockId = ifResult.mergeBlockId;
2327223289 continue;
2327323290 }
23291+ if (terminator.kind === "branch_table") {
23292+ children.push(blockToNodeWithoutTerminator(block));
23293+ const switchResult = structureSwitch(terminator, null, currentBlockId);
23294+ children.push(switchResult.node);
23295+ currentBlockId = switchResult.mergeBlockId;
23296+ if (currentBlockId !== null) {
23297+ if (currentBlockId === headerId) {
23298+ children.push({ kind: "continue" });
23299+ currentBlockId = null;
23300+ } else if (!loop.bodyIds.has(currentBlockId)) {
23301+ children.push({ kind: "break" });
23302+ currentBlockId = null;
23303+ }
23304+ }
23305+ continue;
23306+ }
2327423307 children.push(blockToNode(block));
2327523308 break;
2327623309 }
@@ -23394,17 +23427,17 @@ log(mod.toString());`
2339423427 return { node: labeledBody, mergeBlockId: null };
2339523428 }
2339623429 function findSingleExit(loop) {
23430+ if (loop.exitIds.size === 0) {
23431+ return null;
23432+ }
2339723433 if (loop.exitIds.size === 1) {
2339823434 return loop.exitIds.values().next().value ?? null;
2339923435 }
23400- if (loop.exitIds.size > 1) {
23401- const postDom = dominance.postImmediateDominator.get(loop.headerId);
23402- if (postDom !== void 0 && !loop.bodyIds.has(postDom)) {
23403- return postDom;
23404- }
23405- return loop.exitIds.values().next().value ?? null;
23436+ const postDom = dominance.postImmediateDominator.get(loop.headerId);
23437+ if (postDom !== void 0 && !loop.bodyIds.has(postDom)) {
23438+ return postDom;
2340623439 }
23407- return null;
23440+ return loop.exitIds.values().next().value ?? null;
2340823441 }
2340923442 const result = structureRegion(ssaFunc.entryBlockId, ssaFunc.exitBlockId);
2341023443 const unvisited = [];
@@ -25962,6 +25995,9 @@ log(mod.toString());`
2596225995 case "expr":
2596325996 emit(`${formatExpression(stmt.value, 0)};`);
2596425997 break;
25998+ default:
25999+ emit(`/* unknown stmt: ${stmt.kind} */`);
26000+ break;
2596526001 }
2596626002 }
2596726003 function isIntrinsicOp(op) {
@@ -26064,6 +26100,9 @@ log(mod.toString());`
2606426100 case "field_access": {
2606526101 return formatFieldAccess(expr.base, expr.offset);
2606626102 }
26103+ default: {
26104+ return `/* unknown expr: ${expr.kind} */`;
26105+ }
2606726106 }
2606826107 }
2606926108 function formatStatementInline(stmt) {
@@ -28531,7 +28570,7 @@ ${tipSignature}
2853128570${funcEntry.body.length} bytes, ${totalLocals} locals`,
2853228571 heatColor
2853328572 };
28534- })
28573+ }).sort((a, b) => a.label.localeCompare(b.label, void 0, { numeric: true }))
2853528574 };
2853628575 root.children.push(functionsNode);
2853728576 }
@@ -30651,9 +30690,7 @@ ${funcEntry.body.length} bytes, ${totalLocals} locals`,
3065130690 const row = document.createElement("div");
3065230691 row.className = "detail-info-row";
3065330692 const nameLink = document.createElement("a");
30654- nameLink.className = "detail-info-link";
30655- nameLink.style.flex = "0 0 auto";
30656- nameLink.style.maxWidth = "50%";
30693+ nameLink.className = "detail-info-link module-interface-name";
3065730694 nameLink.textContent = importEntry.fieldName;
3065830695 nameLink.title = `${importEntry.moduleName}.${importEntry.fieldName}`;
3065930696 nameLink.href = "#";
@@ -30716,9 +30753,7 @@ ${funcEntry.body.length} bytes, ${totalLocals} locals`,
3071630753 const navSection = targetSection && targetItemIndex >= 0 ? targetSection : "export";
3071730754 const navIndex = targetSection && targetItemIndex >= 0 ? targetItemIndex : exportIndex;
3071830755 const nameLink = document.createElement("a");
30719- nameLink.className = "detail-info-link";
30720- nameLink.style.flex = "0 0 auto";
30721- nameLink.style.maxWidth = "50%";
30756+ nameLink.className = "detail-info-link module-interface-name";
3072230757 nameLink.textContent = exportEntry.name;
3072330758 nameLink.title = exportEntry.name;
3072430759 nameLink.href = "#";
0 commit comments