Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.MethodDefinition


    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


            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

        }

        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

                    return true;
                }
            }

            for (final MethodDeclaration method : ofType(type.getMembers(), MethodDeclaration.class)) {
                final MethodDefinition methodDefinition = method.getUserData(Keys.METHOD_DEFINITION);

                if (methodDefinition != null) {
                    if (StringUtilities.equals(methodDefinition.getReturnType().getInternalName(), localType.getInternalName())) {
                        return true;
                    }

                    for (final ParameterDefinition parameter : methodDefinition.getParameters()) {
                        if (StringUtilities.equals(parameter.getParameterType().getInternalName(), localType.getInternalName())) {
                            return true;
                        }
                    }
                }
View Full Code Here

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

        final MethodDefinition resolved = method.resolve();

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

        final List<MethodReference> candidates;
        final Expression invocationTarget = target.getTarget();

        if (invocationTarget == null || invocationTarget.isNull()) {
            candidates = MetadataHelper.findMethods(
                context.getCurrentType(),
                MetadataFilters.matchName(resolved.getName())
            );
        }
        else {
            final ResolveResult targetResult = _resolver.apply(invocationTarget);

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

            candidates = MetadataHelper.findMethods(
                targetResult.getType(),
                MetadataFilters.matchName(resolved.getName())
            );
        }

        final List<TypeReference> argTypes = new ArrayList<>();
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

  @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

  }
 
  @Override
  public Void visitMethodDeclaration( MethodDeclaration node, SourceIndex index )
  {
    MethodDefinition def = node.getUserData( Keys.METHOD_DEFINITION );
    ClassEntry classEntry = new ClassEntry( def.getDeclaringType().getInternalName() );
    BehaviorEntry behaviorEntry = BehaviorEntryFactory.create( classEntry, def.getName(), def.getSignature() );
    AstNode tokenNode = node.getNameToken();
    if( behaviorEntry instanceof ConstructorEntry )
    {
      ConstructorEntry constructorEntry = (ConstructorEntry)behaviorEntry;
      if( constructorEntry.isStatic() )
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.