Search in sources :

Example 1 with StringLiteral

use of org.candle.decompiler.intermediate.expression.StringLiteral in project candle-decompiler by bradsdavis.

the class MethodIntermediateVisitor method visitLDC2_W.

public void visitLDC2_W(LDC2_W instruction) {
    // load from constant pool.
    LOG.debug("Loading from constant pool" + instruction.getClass());
    MethodGen mg = context.getMethodGen();
    ConstantPoolGen cpg = mg.getConstantPool();
    Type type = instruction.getType(cpg);
    Object instructionValue = instruction.getValue(cpg);
    if (Type.STRING == type) {
        Expression resolved = new StringLiteral(context.getCurrentInstruction(), instructionValue.toString());
        context.getExpressions().push(resolved);
        return;
    } else {
    }
    StringBuilder resolvedValue = new StringBuilder();
    if (instructionValue instanceof ConstantClass) {
        String clzName = getClassName((ConstantClass) instructionValue, cpg.getConstantPool());
        resolvedValue.append(clzName);
    } else {
        resolvedValue.append(instructionValue.toString());
    }
    Expression resolved = new Resolved(context.getCurrentInstruction(), type, resolvedValue.toString());
    context.getExpressions().push(resolved);
}
Also used : OperationType(org.candle.decompiler.intermediate.expression.OperationType) ArithmeticType(org.candle.decompiler.intermediate.expression.ArithmeticType) StringLiteral(org.candle.decompiler.intermediate.expression.StringLiteral) TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) Resolved(org.candle.decompiler.intermediate.expression.Resolved) ConstantClass(org.apache.bcel.classfile.ConstantClass)

Aggregations

ConstantClass (org.apache.bcel.classfile.ConstantClass)1 ArithmeticType (org.candle.decompiler.intermediate.expression.ArithmeticType)1 Expression (org.candle.decompiler.intermediate.expression.Expression)1 OperationType (org.candle.decompiler.intermediate.expression.OperationType)1 Resolved (org.candle.decompiler.intermediate.expression.Resolved)1 StringLiteral (org.candle.decompiler.intermediate.expression.StringLiteral)1 TypedExpression (org.candle.decompiler.intermediate.expression.TypedExpression)1