Package com.strobel.decompiler.ast

Examples of com.strobel.decompiler.ast.Expression


        if (variable.getType().getSimpleType() == JvmType.Integer) {
            boolean isLoopCounter = false;

        loopSearch:
            for (final Loop loop : methodBody.getSelfAndChildrenRecursive(Loop.class)) {
                Expression e = loop.getCondition();

                while (e != null && e.getCode() == AstCode.LogicalNot) {
                    e = e.getArguments().get(0);
                }

                if (e != null) {
                    switch (e.getCode()) {
                        case CmpEq:
                        case CmpNe:
                        case CmpLe:
                        case CmpGt:
                        case CmpGe:
                        case CmpLt: {
                            final StrongBox<Variable> loadVariable = new StrongBox<>();
                            if (PatternMatching.matchGetOperand(e.getArguments().get(0), AstCode.Load, loadVariable) &&
                                loadVariable.get() == variable) {

                                isLoopCounter = true;
                                break loopSearch;
                            }
                            break;
                        }
                    }
                }
            }

            if (isLoopCounter) {
                for (char c = 'i'; c < MAX_LOOP_VARIABLE_NAME; c++) {
                    final String name = String.valueOf(c);

                    if (!_typeNames.containsKey(name)) {
                        proposedName = name;
                        break;
                    }
                }
            }
        }

        if (StringUtilities.isNullOrEmpty(proposedName)) {
            String proposedNameForStore = null;

            for (final Expression e : methodBody.getSelfAndChildrenRecursive(Expression.class)) {
                if (e.getCode() == AstCode.Store && e.getOperand() == variable) {
                    final String name = getNameFromExpression(e.getArguments().get(0));

                    if (name != null/* && !_fieldNamesInCurrentType.contains(name)*/) {
                        if (proposedNameForStore != null) {
                            proposedNameForStore = null;
                            break;
                        }

                        proposedNameForStore = name;
                    }
                }
            }

            if (proposedNameForStore != null) {
                proposedName = proposedNameForStore;
            }
        }

        if (StringUtilities.isNullOrEmpty(proposedName)) {
            String proposedNameForLoad = null;

            for (final Expression e : methodBody.getSelfAndChildrenRecursive(Expression.class)) {
                final List<Expression> arguments = e.getArguments();

                for (int i = 0; i < arguments.size(); i++) {
                    final Expression a = arguments.get(i);
                    if (a.getCode() == AstCode.Load && a.getOperand() == variable) {
                        final String name = getNameForArgument(e, i);

                        if (name != null/* && !_fieldNamesInCurrentType.contains(name)*/) {
                            if (proposedNameForLoad != null) {
                                proposedNameForLoad = null;
View Full Code Here


        if (variable.getType().getSimpleType() == JvmType.Integer) {
            boolean isLoopCounter = false;

        loopSearch:
            for (final Loop loop : methodBody.getSelfAndChildrenRecursive(Loop.class)) {
                Expression e = loop.getCondition();

                while (e != null && e.getCode() == AstCode.LogicalNot) {
                    e = e.getArguments().get(0);
                }

                if (e != null) {
                    switch (e.getCode()) {
                        case CmpEq:
                        case CmpNe:
                        case CmpLe:
                        case CmpGt:
                        case CmpGe:
                        case CmpLt: {
                            final StrongBox<Variable> loadVariable = new StrongBox<>();
                            if (PatternMatching.matchGetOperand(e.getArguments().get(0), AstCode.Load, loadVariable) &&
                                loadVariable.get() == variable) {

                                isLoopCounter = true;
                                break loopSearch;
                            }
                            break;
                        }
                    }
                }
            }

            if (isLoopCounter) {
                for (char c = 'i'; c < MAX_LOOP_VARIABLE_NAME; c++) {
                    final String name = String.valueOf(c);

                    if (!_typeNames.containsKey(name)) {
                        proposedName = name;
                        break;
                    }
                }
            }
        }

        if (StringUtilities.isNullOrEmpty(proposedName)) {
            String proposedNameForStore = null;

            for (final Expression e : methodBody.getSelfAndChildrenRecursive(Expression.class)) {
                if (e.getCode() == AstCode.Store && e.getOperand() == variable) {
                    final String name = getNameFromExpression(e.getArguments().get(0));

                    if (name != null/* && !_fieldNamesInCurrentType.contains(name)*/) {
                        if (proposedNameForStore != null) {
                            proposedNameForStore = null;
                            break;
                        }

                        proposedNameForStore = name;
                    }
                }
            }

            if (proposedNameForStore != null) {
                proposedName = proposedNameForStore;
            }
        }

        if (StringUtilities.isNullOrEmpty(proposedName)) {
            String proposedNameForLoad = null;

            for (final Expression e : methodBody.getSelfAndChildrenRecursive(Expression.class)) {
                final List<Expression> arguments = e.getArguments();

                for (int i = 0; i < arguments.size(); i++) {
                    final Expression a = arguments.get(i);
                    if (a.getCode() == AstCode.Load && a.getOperand() == variable) {
                        final String name = getNameForArgument(e, i);

                        if (name != null/* && !_fieldNamesInCurrentType.contains(name)*/) {
                            if (proposedNameForLoad != null) {
                                proposedNameForLoad = null;
View Full Code Here

TOP

Related Classes of com.strobel.decompiler.ast.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.