use of org.mapleir.ir.code.ExpressionStack in project maple-ir by LLVM-but-worse.
the class GenerationPass method handler.
protected void handler(TryCatchBlockNode tc) {
LabelNode label = tc.handler;
BasicBlock handler = resolveTarget(label);
marks.add(tc.start);
marks.add(tc.end);
if (getInputStackFor(handler) != null) {
// System.err.println("Double handler: " + handler.getId() + " " + tc);
return;
}
ExpressionStack stack = new ExpressionStack(16);
setInputStack(handler, stack);
CaughtExceptionExpr expr = new CaughtExceptionExpr(tc.type);
Type type = expr.getType();
VarExpr var = _var_expr(0, type, true);
CopyVarStmt stmt = copy(var, expr, handler);
handler.add(stmt);
stack.push(load_stack(0, type));
queue(label);
stacks.set(handler.getNumericId());
}
use of org.mapleir.ir.code.ExpressionStack in project maple-ir by LLVM-but-worse.
the class GenerationVerifier method find_verify_matches.
List<VerifierRule> find_verify_matches() {
throwNoContext();
int op = currentContext.insn.opcode();
ExpressionStack stack = currentContext.stack;
List<VerifierRule> rules = vrules.get(op);
if (rules == null) {
System.err.println("Cannot verify " + Printer.OPCODES[op] + " (no rules). Stack: " + stack);
return null;
}
List<VerifierRule> possible = new ArrayList<>();
for (VerifierRule r : rules) {
if (r.match_attempt(stack, true)) {
possible.add(r);
}
}
if (possible.isEmpty() && !rules.isEmpty()) {
throw new VerifyException(ExceptionStage.PRE, currentContext);
}
return possible;
}
Aggregations