Package com.strobel.decompiler.ast

Examples of com.strobel.decompiler.ast.Variable


            }

            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


        }

        @Override
        public Boolean visitAssignmentExpression(final AssignmentExpression node, final Void _) {
            final Expression left = node.getLeft();
            final Variable variable = left.getUserData(Keys.VARIABLE);

            if (variable != null && variable.isParameter()) {
                _unassignedParameters.remove(variable.getOriginalParameter());
                return super.visitAssignmentExpression(node, _);
            }

            ParameterDefinition parameter = left.getUserData(Keys.PARAMETER_DEFINITION);
View Full Code Here

            return;
        }

        if (operand instanceof Variable) {
            final Variable variable = (Variable) operand;

            if (variable.isParameter()) {
                writer.writeReference(variable.getName(), variable.getOriginalParameter());
            }
            else {
                writer.writeReference(variable.getName(), variable.getOriginalVariable());
            }

            return;
        }
View Full Code Here

    @Override
    public boolean matches(final INode other, final Match match) {
        if (other instanceof IdentifierExpression) {
            final IdentifierExpression identifier = (IdentifierExpression) other;
            final Variable variable = identifier.getUserData(Keys.VARIABLE);

            if (variable != null &&
                variable.isParameter() &&
                variable.getOriginalParameter().getPosition() == _parameterPosition) {

                if (_groupName != null) {
                    match.add(_groupName, identifier);
                }
View Full Code Here

        }

        @Override
        public Set<Object> visitCatchClause(final CatchClause node, final String name) {
            if (_mode == NameResolveMode.EXPRESSION && StringUtilities.equals(node.getVariableName(), name)) {
                final Variable exceptionVariable = node.getUserData(Keys.VARIABLE);

                if (exceptionVariable != null) {
                    return Collections.<Object>singleton(exceptionVariable);
                }
            }
View Full Code Here

        public Set<Object> visitVariableDeclaration(final VariableDeclarationStatement node, final String name) {
            if (_mode == NameResolveMode.EXPRESSION) {
                final VariableInitializer v = node.getVariable(name);

                if (v != null) {
                    final Variable variable = v.getUserData(Keys.VARIABLE);

                    if (variable != null) {
                        return Collections.<Object>singleton(variable);
                    }
                }
View Full Code Here

        @Override
        public Set<Object> visitForEachStatement(final ForEachStatement node, final String name) {
            if (_mode == NameResolveMode.EXPRESSION) {
                if (StringUtilities.equals(node.getVariableName(), name)) {
                    final Variable v = node.getUserData(Keys.VARIABLE);

                    if (v != null) {
                        return Collections.<Object>singleton(v);
                    }
                }
View Full Code Here

            final Expression left = node.getLeft();
            final Expression right = node.getRight();

            if (left instanceof MemberReferenceExpression) {
                if (right instanceof IdentifierExpression) {
                    final Variable variable = right.getUserData(Keys.VARIABLE);

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

                    final MemberReferenceExpression memberReference = (MemberReferenceExpression) left;
                    final MemberReference member = memberReference.getUserData(Keys.MEMBER_REFERENCE);

                    if (member instanceof FieldReference &&
                        memberReference.getTarget() instanceof ThisReferenceExpression) {

                        final FieldDefinition resolvedField = ((FieldReference) member).resolve();

                        if (resolvedField != null && resolvedField.isSynthetic()) {
                            final ParameterDefinition parameter = variable.getOriginalParameter();

                            int parameterIndex = parameter.getPosition();

                            if (parameter.getMethod().getParameters().size() > _originalArguments.size()) {
                                parameterIndex -= (parameter.getMethod().getParameters().size() - _originalArguments.size());
                            }

                            if (parameterIndex >= 0 && parameterIndex < _originalArguments.size()) {
                                final Expression argument = _originalArguments.get(parameterIndex);

                                if (argument == null) {
                                    return null;
                                }

                                _nodesToRemove.add(argument);

                                if (argument instanceof ThisReferenceExpression) {
                                    //
                                    // Don't replace outer class references; they will be rewritten later.
                                    //
                                    markConstructorParameterForRemoval(node, parameter);
                                    return null;
                                }

                                _parametersToRemove.add(parameter);

                                final String fullName = member.getFullName();

                                if (!hasSideEffects(argument)) {
                                    _replacements.put(fullName, argument);
                                }
                                else {
                                    context.getForcedVisibleMembers().add(resolvedField);
                                    _initializers.put(fullName, argument);
                                }

                                if (node.getParent() instanceof ExpressionStatement) {
                                    _nodesToRemove.add(node.getParent());
                                }

                                markConstructorParameterForRemoval(node, parameter);
                            }
                        }
                        else if (_baseConstructorCalled &&
                                 resolvedField != null &&
                                 context.getCurrentMethod().isConstructor() &&
                                 (!context.getCurrentMethod().isSynthetic() ||
                                  context.getSettings().getShowSyntheticMembers())) {

                            final MemberReferenceExpression leftMemberReference = (MemberReferenceExpression) left;
                            final MemberReference leftMember = leftMemberReference.getUserData(Keys.MEMBER_REFERENCE);
                            final Variable rightVariable = right.getUserData(Keys.VARIABLE);

                            if (rightVariable.isParameter()) {
                                final ParameterDefinition parameter = variable.getOriginalParameter();
                                final int parameterIndex = parameter.getPosition();

                                if (parameterIndex >= 0 && parameterIndex < _originalArguments.size()) {
                                    final Expression argument = _originalArguments.get(parameterIndex);
View Full Code Here

            _result.remove();
        }

        @Override
        public Void visitIdentifierExpression(final IdentifierExpression node, final Void _) {
            final Variable variable = node.getUserData(Keys.VARIABLE);

            if (variable != null && variable.isParameter()) {
                final ParameterDefinition parameter = variable.getOriginalParameter();

                if (areMethodsEquivalent((MethodReference) parameter.getMethod(), context.getCurrentMethod())) {
                    final AstNode replacement = _argumentMappings.get(parameter);

                    if (replacement != null) {
View Full Code Here

            if (result != null) {
                return result;
            }

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

            if (variable == null) {
                return null;
            }
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.