Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.MethodReference


            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.getRole() == Roles.ARGUMENT) {
            final MemberReference member = parent.getUserData(Keys.MEMBER_REFERENCE);

            if (member instanceof MethodReference) {
                final MethodReference method = (MethodReference) parent.getUserData(Keys.MEMBER_REFERENCE);

                if (method == null || MetadataHelper.isOverloadCheckingRequired(method)) {
                    return false;
                }
            }
View Full Code Here

        performUnboxingRemoval(e, target);
    }

    private void performUnboxingRemoval(final InvocationExpression e, final MemberReferenceExpression target) {
        final Expression boxedValue = target.getTarget();
        final MethodReference unboxMethod = (MethodReference) e.getUserData(Keys.MEMBER_REFERENCE);
        final AstBuilder astBuilder = context.getUserData(Keys.AST_BUILDER);

        boxedValue.remove();

        e.replaceWith(
            new CastExpression(
                astBuilder.convertType(unboxMethod.getReturnType()),
                boxedValue
            )
        );
    }
View Full Code Here

                        isEnclosedBy(resolvedCreatedType, argumentType)) {

                        if (isContextWithinTypeInstance(argumentType) &&
                            firstArgument instanceof ThisReferenceExpression) {

                            final MethodReference constructor = (MethodReference) node.getUserData(Keys.MEMBER_REFERENCE);

                            if (constructor != null &&
                                arguments.size() == constructor.getParameters().size()) {

                                firstArgument.remove();
                            }
                        }
                        else {
View Full Code Here

        return resolvedInnerType != null &&
               isEnclosedBy(resolvedInnerType.getBaseType(), outerType);
    }

    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

            final Expression test = node.getExpression();
            final Match m = SWITCH_INPUT.match(test);

            if (m.success()) {
                final InvocationExpression switchMapMethodCall = first(m.<InvocationExpression>get("switchMapMethodCall"));
                final MethodReference switchMapMethod = (MethodReference) switchMapMethodCall.getUserData(Keys.MEMBER_REFERENCE);

                if (!isSwitchMapMethod(switchMapMethod)) {
                    return super.visitSwitchStatement(node, data);
                }

                final FieldDefinition switchMapField;

                try {
                    final FieldReference r = new MetadataParser(currentType.getResolver()).parseField(
                        currentType,
                        switchMapMethod.getName(),
                        switchMapMethod.getReturnType().getErasedSignature()
                    );

                    switchMapField = r.resolve();
                }
                catch (Throwable t) {
View Full Code Here

        if (!newArray.getAdditionalArraySpecifiers().hasSingleElement()) {
            return null;
        }

        final MethodReference method = (MethodReference) node.getUserData(Keys.MEMBER_REFERENCE);

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

        final MethodDefinition resolved = method.resolve();

        if (resolved == null || !resolved.isVarArgs()) {
            return null;
        }
View Full Code Here

    // get the behavior entry
    ClassEntry classEntry = new ClassEntry( ref.getDeclaringType().getInternalName() );
    BehaviorEntry behaviorEntry = null;
    if( ref instanceof MethodReference )
    {
      MethodReference methodRef = (MethodReference)ref;
      if( methodRef.isConstructor() )
      {
        behaviorEntry = new ConstructorEntry( classEntry, ref.getSignature() );
      }
      else if( methodRef.isTypeInitializer() )
      {
        behaviorEntry = new ConstructorEntry( classEntry );
      }
      else
      {
View Full Code Here

TOP

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

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.