Package com.strobel.decompiler.ast

Examples of com.strobel.decompiler.ast.Block


        final DecompilerContext context = new DecompilerContext();

        context.setCurrentMethod(method);
        context.setCurrentType(method.getDeclaringType());

        final Block methodAst = new Block();

        output.writeLine(" {");
        output.indent();

        try {
            methodAst.getBody().addAll(AstBuilder.build(body, _inlineVariables, context));

            if (_abortBeforeStep != null) {
                AstOptimizer.optimize(context, methodAst, _abortBeforeStep);
            }

            final Set<Variable> allVariables = new LinkedHashSet<>();

            for (final Expression e : methodAst.getSelfAndChildrenRecursive(Expression.class)) {
                final Object operand = e.getOperand();

                if (operand instanceof Variable && !((Variable) operand).isParameter()) {
                    allVariables.add((Variable) operand);
                }
            }

            if (!allVariables.isEmpty()) {
                for (final Variable variable : allVariables) {
                    output.writeDefinition(variable.getName(), variable);

                    final TypeReference type = variable.getType();

                    if (type != null) {
                        output.write(" : ");
                        DecompilerHelpers.writeType(output, type, NameSyntax.SHORT_TYPE_NAME);
                    }

                    if (variable.isGenerated()) {
                        output.write(" [generated]");
                    }

                    output.writeLine();
                }

                output.writeLine();
            }

            methodAst.writeTo(output);
        }
        catch (Throwable t) {
            writeError(output, t);
        }
        finally {
View Full Code Here


        final DecompilerContext context = new DecompilerContext();

        context.setCurrentMethod(method);
        context.setCurrentType(method.getDeclaringType());

        final Block methodAst = new Block();

        output.writeLine(" {");
        output.indent();

        try {
            methodAst.getBody().addAll(AstBuilder.build(body, _inlineVariables, context));

            if (_abortBeforeStep != null) {
                AstOptimizer.optimize(context, methodAst, _abortBeforeStep);
            }

            final Set<Variable> allVariables = new LinkedHashSet<>();

            for (final Expression e : methodAst.getSelfAndChildrenRecursive(Expression.class)) {
                final Object operand = e.getOperand();

                if (operand instanceof Variable && !((Variable) operand).isParameter()) {
                    allVariables.add((Variable) operand);
                }
            }

            if (!allVariables.isEmpty()) {
                for (final Variable variable : allVariables) {
                    output.writeDefinition(variable.getName(), variable);

                    final TypeReference type = variable.getType();

                    if (type != null) {
                        output.write(" : ");
                        DecompilerHelpers.writeType(output, type, NameSyntax.SHORT_TYPE_NAME);
                    }

                    if (variable.isGenerated()) {
                        output.write(" [generated]");
                    }

                    output.writeLine();
                }

                output.writeLine();
            }

            methodAst.writeTo(output);
        }
        catch (Throwable t) {
            writeError(output, t);
        }
        finally {
View Full Code Here

TOP

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

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.