Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.MethodDefinition


                            return cleanUpVariableName(methodName.substring(3));
                        }
                    }

                    final MethodDefinition definition = method.resolve();

                    if (definition != null) {
                        final ParameterDefinition p = getOrDefault(
                            definition.getParameters(),
                            parent.getCode() != AstCode.InitObject && !definition.isStatic() ? i - 1 : i
                        );

                        if (p != null && p.hasName() && !StringUtilities.isNullOrEmpty(p.getName())) {
                            return cleanUpVariableName(p.getName());
                        }
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

    @Override
    public Void visitMethodDeclaration(final MethodDeclaration node, final Void _) {
        startNode(node);
        writeAnnotations(node.getAnnotations(), true);

        final MethodDefinition definition = node.getUserData(Keys.METHOD_DEFINITION);

        if (definition != null && definition.isDefault()) {
            writeKeyword(Roles.DEFAULT_KEYWORD);
        }

        writeModifiers(node.getModifiers());

        if (definition == null || !definition.isTypeInitializer()) {
            final AstNodeCollection<TypeParameterDeclaration> typeParameters = node.getTypeParameters();

            if (any(typeParameters)) {
                space();
                writeTypeParameters(typeParameters);
View Full Code Here

            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

        }

        @Override
        public Void visitAssignmentExpression(final AssignmentExpression node, final Void data) {
            final TypeDefinition currentType = context.getCurrentType();
            final MethodDefinition currentMethod = context.getCurrentMethod();

            if (_isSwitchMapWrapper &&
                currentType != null &&
                currentMethod != null &&
                currentMethod.isTypeInitializer()) {

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

                if (left instanceof IndexerExpression &&
View Full Code Here

            return super.visitFieldDeclaration(node, data);
        }

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

            if (isSwitchMapMethod(methodDefinition)) {
                final Match m = SWITCH_TABLE_METHOD_BODY.match(node.getBody());

                if (m.success()) {
View Full Code Here

        private static boolean isSwitchMapMethod(final MethodReference method) {
            if (method == null) {
                return false;
            }

            final MethodDefinition definition = method instanceof MethodDefinition ? (MethodDefinition) method
                                                                                   : method.resolve();

            return definition != null &&
                   definition.isSynthetic() &&
                   definition.isStatic() &&
                   definition.isPackagePrivate() &&
                   StringUtilities.startsWith(definition.getName(), "$SWITCH_TABLE$") &&
                   MetadataResolver.areEquivalent(BuiltinTypes.Integer.makeArrayType(), definition.getReturnType());
        }
View Full Code Here

            return;
        }

        final MethodDeclaration staticInitializer = (MethodDeclaration) parent.getParent().getParent();
        final MethodDefinition methodDefinition = staticInitializer.getUserData(Keys.METHOD_DEFINITION);

        if (methodDefinition == null || !methodDefinition.isTypeInitializer()) {
            return;
        }

        final Expression field = first(m.<IdentifierExpression>get("$assertionsDisabled"));
        final ClassOfExpression type = m.<ClassOfExpression>get("type").iterator().next();
View Full Code Here

    public Void visitMethodGroupExpression(final MethodGroupExpression node, final Void data) {
        final MemberReference reference = node.getUserData(Keys.MEMBER_REFERENCE);

        if (reference instanceof MethodReference) {
            final MethodReference method = (MethodReference) reference;
            final MethodDefinition resolvedMethod = method.resolve();
            final DynamicCallSite callSite = node.getUserData(Keys.DYNAMIC_CALL_SITE);

            if (resolvedMethod != null && resolvedMethod.isSynthetic() && callSite != null) {
                inlineLambda(node, resolvedMethod);
                return null;
            }
        }
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.