private static string IsClass14Invocation(Exprent exprent, ClassWrapper wrapper, MethodWrapper meth) { if (exprent.type == Exprent.Exprent_Function) { FunctionExprent fexpr = (FunctionExprent)exprent; if (fexpr.GetFuncType() == FunctionExprent.Function_Iif) { if (fexpr.GetLstOperands()[0].type == Exprent.Exprent_Function) { FunctionExprent headexpr = (FunctionExprent)fexpr.GetLstOperands()[0]; if (headexpr.GetFuncType() == FunctionExprent.Function_Eq) { if (headexpr.GetLstOperands()[0].type == Exprent.Exprent_Field && headexpr.GetLstOperands ()[1].type == Exprent.Exprent_Const && ((ConstExprent)headexpr.GetLstOperands()[ 1]).GetConstType().Equals(VarType.Vartype_Null)) { FieldExprent field = (FieldExprent)headexpr.GetLstOperands()[0]; ClassesProcessor.ClassNode fieldnode = DecompilerContext.GetClassProcessor().GetMapRootClasses ().GetOrNull(field.GetClassname()); if (fieldnode != null && fieldnode.classStruct.qualifiedName.Equals(wrapper.GetClassStruct ().qualifiedName)) { // source class StructField fd = wrapper.GetClassStruct().GetField(field.GetName(), field.GetDescriptor ().descriptorString); // FIXME: can be null! why?? if (fd != null && fd.HasModifier(ICodeConstants.Acc_Static) && (fd.IsSynthetic() || DecompilerContext.GetOption(IFernflowerPreferences.Synthetic_Not_Set))) { if (fexpr.GetLstOperands()[1].type == Exprent.Exprent_Assignment && fexpr.GetLstOperands ()[2].Equals(field)) { AssignmentExprent asexpr = (AssignmentExprent)fexpr.GetLstOperands()[1]; if (asexpr.GetLeft().Equals(field) && asexpr.GetRight().type == Exprent.Exprent_Invocation) { InvocationExprent invexpr = (InvocationExprent)asexpr.GetRight(); if (invexpr.GetClassname().Equals(wrapper.GetClassStruct().qualifiedName) && invexpr .GetName().Equals(meth.methodStruct.GetName()) && invexpr.GetStringDescriptor(). Equals(meth.methodStruct.GetDescriptor())) { if (invexpr.GetLstParameters()[0].type == Exprent.Exprent_Const) { wrapper.GetHiddenMembers().Add(InterpreterUtil.MakeUniqueKey(fd.GetName(), fd.GetDescriptor ())); // hide synthetic field return(((ConstExprent)invexpr.GetLstParameters()[0]).GetValue().ToString()); } } } } } } } } } } } return(null); }
private static void LiftConstructor(ClassWrapper wrapper) { foreach (MethodWrapper method in wrapper.GetMethods()) { if (ICodeConstants.Init_Name.Equals(method.methodStruct.GetName()) && method.root != null) { Statement firstData = Statements.FindFirstData(method.root); if (firstData == null) { return; } int index = 0; List <Exprent> lstExprents = firstData.GetExprents(); foreach (Exprent exprent in lstExprents) { int action = 0; if (exprent.type == Exprent.Exprent_Assignment) { AssignmentExprent assignExpr = (AssignmentExprent)exprent; if (assignExpr.GetLeft().type == Exprent.Exprent_Field && assignExpr.GetRight().type == Exprent.Exprent_Var) { FieldExprent fExpr = (FieldExprent)assignExpr.GetLeft(); if (fExpr.GetClassname().Equals(wrapper.GetClassStruct().qualifiedName)) { StructField structField = wrapper.GetClassStruct().GetField(fExpr.GetName(), fExpr .GetDescriptor().descriptorString); if (structField != null && structField.HasModifier(ICodeConstants.Acc_Final)) { action = 1; } } } } else if (index > 0 && exprent.type == Exprent.Exprent_Invocation && Statements.IsInvocationInitConstructor ((InvocationExprent)exprent, method, wrapper, true)) { // this() or super() lstExprents.Add(0, lstExprents.RemoveAtReturningValue(index)); action = 2; } if (action != 1) { break; } index++; } } } }
public override TextBuffer ToJava(int indent, BytecodeMappingTracer tracer) { VarType leftType = left.GetExprType(); VarType rightType = right.GetExprType(); bool fieldInClassInit = false; bool hiddenField = false; if (left.type == Exprent.Exprent_Field) { // first assignment to a final field. Field name without "this" in front of it FieldExprent field = (FieldExprent)left; ClassesProcessor.ClassNode node = ((ClassesProcessor.ClassNode)DecompilerContext. GetProperty(DecompilerContext.Current_Class_Node)); if (node != null) { StructField fd = node.classStruct.GetField(field.GetName(), field.GetDescriptor() .descriptorString); if (fd != null) { if (field.IsStatic() && fd.HasModifier(ICodeConstants.Acc_Final)) { fieldInClassInit = true; } if (node.GetWrapper() != null && node.GetWrapper().GetHiddenMembers().Contains(InterpreterUtil .MakeUniqueKey(fd.GetName(), fd.GetDescriptor()))) { hiddenField = true; } } } } if (hiddenField) { return(new TextBuffer()); } TextBuffer buffer = new TextBuffer(); if (fieldInClassInit) { buffer.Append(((FieldExprent)left).GetName()); } else { buffer.Append(left.ToJava(indent, tracer)); } if (right.type == Exprent_Const) { ((ConstExprent)right).AdjustConstType(leftType); } TextBuffer res = right.ToJava(indent, tracer); if (condType == Condition_None && !leftType.IsSuperset(rightType) && (rightType.Equals (VarType.Vartype_Object) || leftType.type != ICodeConstants.Type_Object)) { if (right.GetPrecedence() >= FunctionExprent.GetPrecedence(FunctionExprent.Function_Cast )) { res.Enclose("(", ")"); } res.Prepend("(" + ExprProcessor.GetCastTypeName(leftType) + ")"); } buffer.Append(condType == Condition_None ? " = " : Operators[condType]).Append(res ); tracer.AddMapping(bytecode); return(buffer); }