From afd13f2bf5049374124679f9e108cfef8a4c2f29 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 5 May 1999 20:54:51 +0000 Subject: [PATCH] Expression rework (ComplexExpression removed) FieldAnalyzer.setClassConstant used git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@770 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/flow/CreateClassField.java | 38 +++++++++++----------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/jode/jode/flow/CreateClassField.java b/jode/jode/flow/CreateClassField.java index 73b8218..f0440e7 100644 --- a/jode/jode/flow/CreateClassField.java +++ b/jode/jode/flow/CreateClassField.java @@ -33,10 +33,9 @@ public class CreateClassField { // to // if (classname.class == null) { // } - if (!(ifBlock.cond instanceof ComplexExpression) - || !(ifBlock.cond.getOperator() instanceof CompareUnaryOperator) - || !(ifBlock.cond.getOperator().getOperatorIndex() - == Operator.EQUALS_OP) + if (!(ifBlock.cond instanceof CompareUnaryOperator) + || !(((Operator)ifBlock.cond) + .getOperatorIndex() == Operator.EQUALS_OP) || !(ifBlock.thenBlock instanceof InstructionBlock) || ifBlock.elseBlock != null) return false; @@ -47,39 +46,32 @@ public class CreateClassField { != ifBlock.thenBlock.jump.destination))) return false; - ComplexExpression cmp = (ComplexExpression) ifBlock.cond; + CompareUnaryOperator cmp = (CompareUnaryOperator) ifBlock.cond; Expression instr = ((InstructionBlock)ifBlock.thenBlock).getInstruction(); if (!(cmp.getSubExpressions()[0] instanceof GetFieldOperator) - || !(instr instanceof ComplexExpression) - || !(instr.getOperator() instanceof PutFieldOperator)) + || !(instr instanceof StoreInstruction)) return false; - ComplexExpression ass = (ComplexExpression) instr; - PutFieldOperator put = (PutFieldOperator) ass.getOperator(); - if (!put.getField().isSynthetic() + StoreInstruction store = (StoreInstruction) instr; + if (!(store.getLValue() instanceof PutFieldOperator)) + return false; + PutFieldOperator put = (PutFieldOperator) store.getLValue(); + if (put.getField() == null || !put.matches((GetFieldOperator)cmp.getSubExpressions()[0]) - || !(ass.getSubExpressions()[0] instanceof ComplexExpression) - || !(ass.getSubExpressions()[0].getOperator() - instanceof InvokeOperator)) + || !(store.getSubExpressions()[1] instanceof InvokeOperator)) return false; - InvokeOperator invoke = (InvokeOperator) - ass.getSubExpressions()[0].getOperator(); - Expression param = - ((ComplexExpression)ass.getSubExpressions()[0]) - .getSubExpressions()[0]; + InvokeOperator invoke = (InvokeOperator) store.getSubExpressions()[1]; + Expression param = invoke.getSubExpressions()[0]; + if (invoke.isGetClass() && param instanceof ConstOperator && param.getType().equals(Type.tString)) { String clazz = ((ConstOperator)param).getValue(); - if (put.getFieldName() - .equals("class$" + clazz.replace('.', '$')) - || put.getFieldName() - .equals("class$L" + clazz.replace('.', '$'))) { + if (put.getField().setClassConstant(clazz)) { cmp.setSubExpressions (0, new ClassFieldOperator(Type.tClass(clazz))); - put.getField().analyzedSynthetic(); EmptyBlock empty = new EmptyBlock(); empty.moveJump(ifBlock.thenBlock.jump); ifBlock.setThenBlock(empty);