Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.MethodDefinition


        }
    }

    @Override
    public Void visitConstructorDeclaration(final ConstructorDeclaration node, final Void _) {
        final MethodDefinition oldInitializer = _currentInitializerMethod;
        final MethodDefinition method = node.getUserData(Keys.METHOD_DEFINITION);

        if (method != null &&
            method.isConstructor() &&
            method.isSynthetic()) {

            _currentInitializerMethod = method;
        }
        else {
            _currentInitializerMethod = null;
View Full Code Here


        }
    }

    @Override
    public Void visitMethodDeclaration(final MethodDeclaration node, final Void _) {
        final MethodDefinition oldInitializer = _currentInitializerMethod;
        final MethodDefinition method = node.getUserData(Keys.METHOD_DEFINITION);

        if (method != null &&
            method.isTypeInitializer() &&
            method.getDeclaringType().isInterface()) {

            _currentInitializerMethod = method;
        }
        else {
            _currentInitializerMethod = null;
View Full Code Here

        return super.visitFieldDeclaration(node, data);
    }

    @Override
    public Void visitMethodDeclaration(final MethodDeclaration node, final Void _) {
        final MethodDefinition method = node.getUserData(Keys.METHOD_DEFINITION);

        if (method != null) {
            if (AstBuilder.isMemberHidden(method, context)) {
                node.remove();
                return null;
            }

            if (method.isTypeInitializer()) {
                if (node.getBody().getStatements().isEmpty()) {
                    node.remove();
                    return null;
                }
            }
View Full Code Here

        );
    }

    @Override
    public Void visitConstructorDeclaration(final ConstructorDeclaration node, final Void _) {
        final MethodDefinition method = node.getUserData(Keys.METHOD_DEFINITION);

        if (method != null) {
            if (AstBuilder.isMemberHidden(method, context)) {
                node.remove();
                return null;
            }

            if (!context.getSettings().getShowSyntheticMembers() &&
                node.getParameters().isEmpty() &&
                DEFAULT_CONSTRUCTOR_BODY.matches(node.getBody())) {

                //
                // Remove redundant default constructors.
                //

                final TypeDefinition declaringType = method.getDeclaringType();

                if (declaringType != null) {
                    final boolean hasOtherConstructors = any(
                        declaringType.getDeclaredMethods(),
                        new Predicate<MethodDefinition>() {
                            @Override
                            public boolean test(final MethodDefinition m) {
                                return m.isConstructor() &&
                                       !m.isSynthetic() &&
                                       !StringUtilities.equals(m.getErasedSignature(), method.getErasedSignature());
                            }
                        }
                    );

                    if (!hasOtherConstructors) {
View Full Code Here

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

        final MethodDefinition resolved = method.resolve();

        if (resolved == null || !resolved.isVarArgs()) {
            return null;
        }

        final ResolveResult targetResult = _resolver.apply(target.getTarget());

        if (targetResult == null || targetResult.getType() == null) {
            return null;
        }

        final List<TypeReference> argTypes = new ArrayList<>();

        for (final Expression argument : arguments) {
            final ResolveResult argResult = _resolver.apply(argument);

            if (argResult == null || argResult.getType() == null) {
                return null;
            }

            argTypes.add(argResult.getType());
        }

        final List<MethodReference> candidates = MetadataHelper.findMethods(
            targetResult.getType(),
            MetadataFilters.matchName(resolved.getName())
        );

        final MethodBinder.BindResult c1 = MethodBinder.selectMethod(candidates, argTypes);

        if (c1.isFailure() || c1.isAmbiguous()) {
View Full Code Here

        }

        for (AstNode child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
            if (child instanceof TypeDeclaration) {
                final TypeDefinition currentType = context.getCurrentType();
                final MethodDefinition currentMethod = context.getCurrentMethod();

                context.setCurrentType(null);
                context.setCurrentMethod(null);

                try {
View Full Code Here

    private boolean isContextWithinTypeInstance(final TypeReference type) {
        final MethodReference method = context.getCurrentMethod();

        if (method != null) {
            final MethodDefinition resolvedMethod = method.resolve();

            if (resolvedMethod != null && resolvedMethod.isStatic()) {
                return false;
            }
        }

        final TypeReference scope = context.getCurrentType();

        for (TypeReference current = scope;
             current != null;
             current = current.getDeclaringType()) {

            if (MetadataResolver.areEquivalent(current, type)) {
                return true;
            }

            final TypeDefinition resolved = current.resolve();

            if (resolved != null && resolved.isLocalClass()) {
                final MethodReference declaringMethod = resolved.getDeclaringMethod();

                if (declaringMethod != null) {
                    final MethodDefinition resolvedDeclaringMethod = declaringMethod.resolve();

                    if (resolvedDeclaringMethod != null && resolvedDeclaringMethod.isStatic()) {
                        break;
                    }
                }
            }
        }
View Full Code Here

            }
        }

        @Override
        protected Void visitChildren(final AstNode node, final Void _) {
            final MethodDefinition currentMethod = context.getCurrentMethod();

            if (currentMethod != null && !(currentMethod.isConstructor()/* && currentMethod.isSynthetic()*/)) {
                return null;
            }

            return super.visitChildren(node, _);
        }
View Full Code Here

        VerifyArgument.notNull(method, "method");
        VerifyArgument.notNull(argumentMappings, "argumentMappings");

        final DecompilerContext context = new DecompilerContext();
        final MethodDefinition definition = method.getUserData(Keys.METHOD_DEFINITION);

        if (definition != null) {
            context.setCurrentType(definition.getDeclaringType());
        }

        final InliningVisitor visitor = new InliningVisitor(context, argumentMappings);

        visitor.run(method);
View Full Code Here

        this.context = VerifyArgument.notNull(context, "context");
    }

    public TResult visitTypeDeclaration(final TypeDeclaration typeDeclaration, final Void _) {
        final TypeDefinition oldType = context.getCurrentType();
        final MethodDefinition oldMethod = context.getCurrentMethod();

        try {
            context.setCurrentType(typeDeclaration.getUserData(Keys.TYPE_DEFINITION));
            context.setCurrentMethod(null);
            return super.visitTypeDeclaration(typeDeclaration, _);
View Full Code Here

TOP

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

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.