use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class BlockProcessor method computeBlockDF.
private static void computeBlockDF(MethodNode mth, BlockNode block) {
if (block.getDomFrontier() != null) {
return;
}
List<BlockNode> blocks = mth.getBasicBlocks();
BitSet domFrontier = null;
for (BlockNode s : block.getSuccessors()) {
if (s.getIDom() != block) {
if (domFrontier == null) {
domFrontier = new BitSet(blocks.size());
}
domFrontier.set(s.getId());
}
}
for (BlockNode c : block.getDominatesOn()) {
BitSet frontier = c.getDomFrontier();
if (frontier == null) {
throw new JadxRuntimeException("Dominance frontier not calculated for dominated block: " + c + ", from: " + block);
}
for (int p = frontier.nextSetBit(0); p >= 0; p = frontier.nextSetBit(p + 1)) {
if (blocks.get(p).getIDom() != block) {
if (domFrontier == null) {
domFrontier = new BitSet(blocks.size());
}
domFrontier.set(p);
}
}
}
if (domFrontier == null || domFrontier.isEmpty()) {
domFrontier = EMPTY;
}
block.setDomFrontier(domFrontier);
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class BlockProcessor method calcImmediateDominators.
private static void calcImmediateDominators(MethodNode mth, List<BlockNode> basicBlocks, BlockNode entryBlock) {
for (BlockNode block : basicBlocks) {
if (block == entryBlock) {
continue;
}
BlockNode idom;
List<BlockNode> preds = block.getPredecessors();
if (preds.size() == 1) {
idom = preds.get(0);
} else {
BitSet bs = new BitSet(block.getDoms().length());
bs.or(block.getDoms());
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
BlockNode dom = basicBlocks.get(i);
bs.andNot(dom.getDoms());
}
if (bs.cardinality() != 1) {
throw new JadxRuntimeException("Can't find immediate dominator for block " + block + " in " + bs + " preds:" + preds);
}
idom = basicBlocks.get(bs.nextSetBit(0));
}
block.setIDom(idom);
idom.addDominatesOn(block);
}
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class FontUtils method loadByStr.
public static Font loadByStr(String fontDesc) {
String[] parts = fontDesc.split("/");
if (parts.length != 3) {
throw new JadxRuntimeException("Unsupported font description format: " + fontDesc);
}
String name = parts[0];
int style = parseFontStyle(parts[1]);
int size = Integer.parseInt(parts[2]);
StyleContext sc = StyleContext.getDefaultStyleContext();
Font font = sc.getFont(name, style, size);
if (font == null) {
throw new JadxRuntimeException("Font not found: " + fontDesc);
}
return font;
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class UiUtils method openSvgIcon.
public static FlatSVGIcon openSvgIcon(String name) {
String iconPath = "icons/" + name + ".svg";
FlatSVGIcon icon = new FlatSVGIcon(iconPath);
boolean found;
try {
found = icon.hasFound();
} catch (Exception e) {
throw new JadxRuntimeException("Failed to load icon: " + iconPath, e);
}
if (!found) {
throw new JadxRuntimeException("Icon not found: " + iconPath);
}
return icon;
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class UiUtils method openIcon.
public static ImageIcon openIcon(String name) {
String iconPath = "/icons-16/" + name + ".png";
URL resource = UiUtils.class.getResource(iconPath);
if (resource == null) {
throw new JadxRuntimeException("Icon not found: " + iconPath);
}
return new ImageIcon(resource);
}
Aggregations