From f3938024184df77965c2ab91c48facdb9cb0ad3c Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sun, 29 May 2022 10:47:50 +0200 Subject: [PATCH] fix BranchNode order for some complex constructs. #43 --- .../jwebassembly/module/BranchManager.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/de/inetsoftware/jwebassembly/module/BranchManager.java b/src/de/inetsoftware/jwebassembly/module/BranchManager.java index 52aae044..e57bafd3 100644 --- a/src/de/inetsoftware/jwebassembly/module/BranchManager.java +++ b/src/de/inetsoftware/jwebassembly/module/BranchManager.java @@ -554,7 +554,7 @@ private void calculateIf( BranchNode parent, IfParsedBlock startBlock, List= endPos ) { @@ -566,17 +566,14 @@ private void calculateIf( BranchNode parent, IfParsedBlock startBlock, List breakBlock.breakPos ) { + branch.add( i, breakNode ); + return; + } + } branch.add( breakNode ); } @@ -1720,7 +1726,7 @@ private static class BranchNode extends ArrayList { public boolean add( BranchNode node ) { node.parent = this; assert node.startOp == null || (node.startPos >= startPos && node.endPos <= endPos): "Node outside parent: " + this + " + " + node; -// assert !overlapped( node.startPos ) : "Node on wrong level: " + node + "; parent: " + this + "; last: " + get( size() - 1 ); + assert node.startOp == null || !overlapped( node.startPos ) : "Node on wrong level: " + node + "; parent: " + this + "; last: " + get( size() - 1 ); return super.add( node ); }