Search in sources :

Example 6 with ExpressionStack

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());
}
Also used : Type(org.objectweb.asm.Type) ComparisonType(org.mapleir.ir.code.stmt.ConditionalJumpStmt.ComparisonType) ValueComparisonType(org.mapleir.ir.code.expr.ComparisonExpr.ValueComparisonType) ArrayType(org.mapleir.ir.TypeUtils.ArrayType) CopyVarStmt(org.mapleir.ir.code.stmt.copy.CopyVarStmt) BasicBlock(org.mapleir.ir.cfg.BasicBlock) ExpressionStack(org.mapleir.ir.code.ExpressionStack)

Example 7 with ExpressionStack

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;
}
Also used : ArrayList(java.util.ArrayList) ExpressionStack(org.mapleir.ir.code.ExpressionStack)

Aggregations

ExpressionStack (org.mapleir.ir.code.ExpressionStack)7 ArrayType (org.mapleir.ir.TypeUtils.ArrayType)2 BasicBlock (org.mapleir.ir.cfg.BasicBlock)2 Expr (org.mapleir.ir.code.Expr)2 ValueComparisonType (org.mapleir.ir.code.expr.ComparisonExpr.ValueComparisonType)2 InvocationExpr (org.mapleir.ir.code.expr.invoke.InvocationExpr)2 ComparisonType (org.mapleir.ir.code.stmt.ConditionalJumpStmt.ComparisonType)2 Type (org.objectweb.asm.Type)2 ArrayList (java.util.ArrayList)1 CopyVarStmt (org.mapleir.ir.code.stmt.copy.CopyVarStmt)1