Package com.strobel.decompiler.semantics

Examples of com.strobel.decompiler.semantics.ResolveResult


        return resolveType(type.toTypeReference());
    }

    private static ResolveResult resolveType(final TypeReference type) {
        return type == null ? null : new ResolveResult(type);
    }
View Full Code Here


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

        if (member instanceof FieldReference) {
            return new ResolveResult(((FieldReference) member).getFieldType());
        }

        if (member instanceof MethodReference) {
            final MethodReference method = (MethodReference) member;

            if (method.isConstructor()) {
                return new ResolveResult(method.getDeclaringType());
            }

            return new ResolveResult(method.getReturnType());
        }

        return null;
    }
View Full Code Here

            return node.getType().acceptVisitor(this, _);
        }

        @Override
        public ResolveResult visitAnonymousObjectCreationExpression(final AnonymousObjectCreationExpression node, final Void _) {
            final ResolveResult result = resolveTypeFromMember(node.getUserData(Keys.MEMBER_REFERENCE));

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

            return resolveType(node.toTypeReference());
        }

        @Override
        public ResolveResult visitIdentifier(final Identifier node, final Void _) {
            final ResolveResult result = resolveTypeFromMember(node.getUserData(Keys.MEMBER_REFERENCE));

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

            return resolveTypeFromVariable(node.getUserData(Keys.VARIABLE));
        }

        @Override
        public ResolveResult visitIdentifierExpression(final IdentifierExpression node, final Void data) {
            ResolveResult result = resolveTypeFromMember(node.getUserData(Keys.MEMBER_REFERENCE));

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

            return resolveLambda(node);
        }

        @Override
        public ResolveResult visitMemberReferenceExpression(final MemberReferenceExpression node, final Void _) {
            final ResolveResult targetResult = node.getTarget().acceptVisitor(this, _);

            MemberReference memberReference = node.getUserData(Keys.MEMBER_REFERENCE);

            if (memberReference == null) {
                if (StringUtilities.equals(node.getMemberName(), "length")) {
                    if (targetResult != null &&
                        targetResult.getType() != null &&
                        targetResult.getType().isArray()) {

                        return new ResolveResult(BuiltinTypes.Integer);
                    }
                }
                if (node.getParent() instanceof InvocationExpression) {
                    memberReference = node.getParent().getUserData(Keys.MEMBER_REFERENCE);
                }
            }
            else if (targetResult != null &&
                     targetResult.getType() != null) {

                if (memberReference instanceof FieldReference) {
                    final FieldDefinition resolvedField = ((FieldReference) memberReference).resolve();

                    memberReference = MetadataHelper.asMemberOf(
                        resolvedField != null ? resolvedField : (FieldReference) memberReference,
                        targetResult.getType()
                    );
                }
                else {
                    final MethodDefinition resolvedMethod = ((MethodReference) memberReference).resolve();

                    memberReference = MetadataHelper.asMemberOf(
                        resolvedMethod != null ? resolvedMethod : (MethodReference) memberReference,
                        targetResult.getType()
                    );
                }
            }

            return resolveTypeFromMember(memberReference);
View Full Code Here

            return resolveTypeFromMember(memberReference);
        }

        @Override
        public ResolveResult visitInvocationExpression(final InvocationExpression node, final Void _) {
            final ResolveResult result = resolveTypeFromMember(node.getUserData(Keys.MEMBER_REFERENCE));

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

            return node.getTarget().acceptVisitor(this, _);
        }

        @Override
        protected ResolveResult visitChildren(final AstNode node, final Void _) {
            ResolveResult result = null;

            AstNode next;

            for (AstNode child = node.getFirstChild(); child != null; child = next) {
                //
                // Store next to allow the loop to continue if the visitor removes/replaces child.
                //
                next = child.getNextSibling();

                if (child instanceof JavaTokenNode) {
                    continue;
                }

                final ResolveResult childResult = child.acceptVisitor(this, _);

                if (childResult == null) {
                    return null;
                }
                else if (result == null) {
                    result = childResult;
                }
                else if (result.isCompileTimeConstant() &&
                         childResult.isCompileTimeConstant() &&
                         Comparer.equals(result.getConstantValue(), childResult.getConstantValue())) {

                    //noinspection UnnecessaryContinue
                    continue;
                }
                else {
                    final TypeReference commonSuperType = doBinaryPromotion(result, childResult);

                    if (commonSuperType != null) {
                        result = new ResolveResult(commonSuperType);
                    }
                    else {
                        return null;
                    }
                }
View Full Code Here

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

            if (BuiltinTypes.Class.isGenericType()) {
                return new ResolveResult(BuiltinTypes.Class.makeGenericType(type));
            }

            return new ResolveResult(BuiltinTypes.Class);
        }
View Full Code Here

            return new ResolveResult(BuiltinTypes.Class);
        }

        @Override
        public ResolveResult visitCastExpression(final CastExpression node, final Void data) {
            final ResolveResult childResult = node.getExpression().acceptVisitor(this, data);
            final ResolveResult typeResult = resolveType(node.getType());

            if (typeResult == null) {
                return childResult;
            }

            final TypeReference resolvedType = typeResult.getType();

            if (resolvedType != null) {
                if (resolvedType.isPrimitive() &&
                    childResult != null &&
                    childResult.isCompileTimeConstant()) {

                    return new PrimitiveResolveResult(
                        resolvedType,
                        JavaPrimitiveCast.cast(resolvedType.getSimpleType(), childResult.getConstantValue())
                    );
                }

                return new ResolveResult(resolvedType);
            }

            return typeResult;
        }
View Full Code Here

TOP

Related Classes of com.strobel.decompiler.semantics.ResolveResult

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.