Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.ParameterDefinition


            output.write("(");

            final List<ParameterDefinition> parameters = method.getParameters();

            for (int i = 0; i < parameters.size(); i++) {
                final ParameterDefinition parameter = parameters.get(i);

                if (i != 0) {
                    output.write(", ");
                }

                DecompilerHelpers.writeType(output, parameter.getParameterType(), NameSyntax.TYPE_NAME);
                output.write(' ');
                output.writeReference(parameter.getName(), parameter);
            }

            output.write(")");
        }
    }
View Full Code Here


                        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);

                                    if (parameterIndex == 0 &&
View Full Code Here

        @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) {
                        node.replaceWith(replacement.clone());
                        return null;
View Full Code Here

        node.getBaseType().acceptVisitor(this, ignored);

        boolean isVarArgs = false;

        if (node.getParent() instanceof ParameterDeclaration) {
            final ParameterDefinition parameter = node.getParent().getUserData(Keys.PARAMETER_DEFINITION);

            if (parameter.getPosition() == parameter.getMethod().getParameters().size() - 1 &&
                parameter.getParameterType().isArray() &&
                parameter.getMethod() instanceof MethodReference) {

                final MethodReference method = (MethodReference) parameter.getMethod();
                final MethodDefinition resolvedMethod = method.resolve();

                if (resolvedMethod != null && Flags.testAny(resolvedMethod.getFlags(), Flags.ACC_VARARGS | Flags.VARARGS)) {
                    isVarArgs = true;
                }
View Full Code Here

        if (node instanceof Identifier && node.getParent() != null) {
            node = node.getParent();
        }

        final ParameterDefinition parameter = node.getUserData(Keys.PARAMETER_DEFINITION);

        if (parameter != null) {
            return parameter;
        }
View Full Code Here

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

            ParameterDefinition parameter = left.getUserData(Keys.PARAMETER_DEFINITION);

            if (parameter == null && left instanceof IdentifierExpression) {
                parameter = _parametersByName.get(((IdentifierExpression) left).getIdentifier());
            }
View Full Code Here

            switch (node.getOperator()) {
                case INCREMENT:
                case DECREMENT:
                case POST_INCREMENT:
                case POST_DECREMENT: {
                    ParameterDefinition parameter = operand.getUserData(Keys.PARAMETER_DEFINITION);

                    if (parameter == null && operand instanceof IdentifierExpression) {
                        parameter = _parametersByName.get(((IdentifierExpression) operand).getIdentifier());
                    }
View Full Code Here

            final AstNodeCollection<ParameterDeclaration> parameters = node.getChildrenByRole(Roles.PARAMETER);
            final Map<ParameterDefinition, ParameterDeclaration> declarationMap = new HashMap<>();
            final Map<String, ParameterDefinition> parametersByName = new HashMap<>();

            for (final ParameterDeclaration parameter : parameters) {
                final ParameterDefinition definition = parameter.getUserData(Keys.PARAMETER_DEFINITION);

                if (definition != null) {
                    unassignedParameters.add(definition);
                    declarationMap.put(definition, parameter);
                    parametersByName.put(parameter.getName(), definition);
View Full Code Here

  }
 
  @Override
  public Void visitParameterDeclaration( ParameterDeclaration node, SourceIndex index )
  {
    ParameterDefinition def = node.getUserData( Keys.PARAMETER_DEFINITION );
    ClassEntry classEntry = new ClassEntry( def.getDeclaringType().getInternalName() );
    MethodDefinition methodDef = (MethodDefinition)def.getMethod();
    BehaviorEntry behaviorEntry;
    if( methodDef.isConstructor() )
    {
      behaviorEntry = new ConstructorEntry( classEntry, methodDef.getSignature() );
    }
    else
    {
      behaviorEntry = new MethodEntry( classEntry, methodDef.getName(), methodDef.getSignature() );
    }
    ArgumentEntry argumentEntry = new ArgumentEntry( behaviorEntry, def.getPosition(), node.getName() );
    index.addDeclaration( node.getNameToken(), argumentEntry );
   
    return recurse( node, index );
  }
View Full Code Here

TOP

Related Classes of com.strobel.assembler.metadata.ParameterDefinition

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.