Package com.strobel.decompiler.semantics

Examples of com.strobel.decompiler.semantics.ResolveResult


            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) {
            final ResolveResult result = resolveTypeFromVariable(node.getUserData(Keys.VARIABLE));

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

            return resolveTypeFromMember(node.getUserData(Keys.MEMBER_REFERENCE));
        }

        @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 childResult;
        }
View Full Code Here

            return childResult;
        }

        @Override
        public ResolveResult visitNullReferenceExpression(final NullReferenceExpression node, final Void data) {
            return new ResolveResult(BuiltinTypes.Null);
        }
View Full Code Here

            return new ResolveResult(BuiltinTypes.Null);
        }

        @Override
        public ResolveResult visitBinaryOperatorExpression(final BinaryOperatorExpression node, final Void data) {
            final ResolveResult leftResult = node.getLeft().acceptVisitor(this, data);
            final ResolveResult rightResult = node.getRight().acceptVisitor(this, data);

            if (leftResult == null || rightResult == null) {
                return null;
            }

            final TypeReference leftType = leftResult.getType();
            final TypeReference rightType = rightResult.getType();

            if (leftType == null || rightType == null) {
                return null;
            }

            final TypeReference operandType = doBinaryPromotionStrict(leftResult, rightResult);

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

            final TypeReference resultType;

            switch (node.getOperator()) {
                case LOGICAL_AND:
                case LOGICAL_OR:
                case GREATER_THAN:
                case GREATER_THAN_OR_EQUAL:
                case EQUALITY:
                case INEQUALITY:
                case LESS_THAN:
                case LESS_THAN_OR_EQUAL:
                    resultType = BuiltinTypes.Boolean;
                    break;

                default:
                    resultType = operandType;
                    break;
            }

            if (leftResult.isCompileTimeConstant() && rightResult.isCompileTimeConstant()) {
                if (operandType.isPrimitive()) {
                    final Object result = BinaryOperations.doBinary(
                        node.getOperator(),
                        operandType.getSimpleType(),
                        leftResult.getConstantValue(),
                        rightResult.getConstantValue()
                    );

                    if (result != null) {
                        return new PrimitiveResolveResult(resultType, result);
                    }
                }
            }

            return new ResolveResult(resultType);
        }
View Full Code Here

        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()) {
            return null;
        }

        argTypes.remove(argTypes.size() - 1);

        final ArrayInitializerExpression initializer = newArray.getInitializer();
        final boolean hasElements = !initializer.isNull() && !initializer.getElements().isEmpty();

        if (hasElements) {
            for (final Expression argument : initializer.getElements()) {
                final ResolveResult argResult = _resolver.apply(argument);

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

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

        final MethodBinder.BindResult c2 = MethodBinder.selectMethod(candidates, argTypes);
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.