Package com.strobel.decompiler.ast

Examples of com.strobel.decompiler.ast.Variable


    @SuppressWarnings("ConstantConditions")
    public void run(final AstNode node) {
        run(node, null);

        for (final VariableToDeclare v : variablesToDeclare) {
            final Variable variable = v.getVariable();
            final AssignmentExpression replacedAssignment = v.getReplacedAssignment();

            if (replacedAssignment == null) {
                final BlockStatement block = (BlockStatement) v.getInsertionPoint().getParent();
                final AnalysisResult analysisResult = analyze(v, block);
                final VariableDeclarationStatement declaration = new VariableDeclarationStatement(v.getType().clone(), v.getName(), Expression.MYSTERY_OFFSET);

                if (variable != null) {
                    declaration.getVariables().firstOrNullObject().putUserData(Keys.VARIABLE, variable);
                }

                if (analysisResult.isSingleAssignment) {
                    declaration.addModifier(Modifier.FINAL);
                }
                else if (analysisResult.needsInitializer && variable != null) {
                    declaration.getVariables().firstOrNullObject().setInitializer(
                        AstBuilder.makeDefaultValue(variable.getType())
                    );
                }

                Statement insertionPoint = v.getInsertionPoint();

                while (insertionPoint.getPreviousSibling() instanceof LabelStatement) {
                    insertionPoint = (Statement) insertionPoint.getPreviousSibling();
                }

                block.getStatements().insertBefore(insertionPoint, declaration);
            }
        }

        //
        // Do all the insertions before the replacements.  This is necessary because a replacement
        // might remove our reference point from the AST.
        //

        for (final VariableToDeclare v : variablesToDeclare) {
            final Variable variable = v.getVariable();
            final AssignmentExpression replacedAssignment = v.getReplacedAssignment();

            if (replacedAssignment != null) {
                final VariableInitializer initializer = new VariableInitializer(v.getName());
                final Expression right = replacedAssignment.getRight();
View Full Code Here


            }

            for (final VariableDeclarationStatement declaration : variables) {
                final VariableInitializer initializer = declaration.getVariables().firstOrNullObject();
                final String variableName = initializer.getName();
                final Variable variable = declaration.getUserData(Keys.VARIABLE);

                declareVariableInBlock(analysis, block, declaration.getType(), variableName, variable, true);
            }
        }
View Full Code Here

                            if (usedByInitializer) {
                                return false;
                            }

                            final Variable variable = identifier.getUserData(Keys.VARIABLE);

                            if (variable == null || variable.isParameter()) {
                                return false;
                            }

                            final TypeReference variableType = variable.getType();

                            if (lastInitializerType == null) {
                                lastInitializerType = variableType;
                            }
                            else if (!MetadataHelper.isSameType(lastInitializerType, variableType)) {
View Full Code Here

TOP

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

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.