Package com.strobel.decompiler.semantics

Examples of com.strobel.decompiler.semantics.ResolveResult


            return typeResult;
        }

        @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: {
                    switch (operandType.getSimpleType()) {
                        case Byte:
                        case Character:
                        case Short:
                            resultType = BuiltinTypes.Integer;
                            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

            return new ResolveResult(resultType);
        }

        @Override
        public ResolveResult visitInstanceOfExpression(final InstanceOfExpression node, final Void data) {
            final ResolveResult childResult = node.getExpression().acceptVisitor(this, data);

            if (childResult == null) {
                return new ResolveResult(BuiltinTypes.Boolean);
            }

            final TypeReference childType = childResult.getType();
            final ResolveResult typeResult = resolveType(node.getType());

            if (childType == null || typeResult == null || typeResult.getType() == null) {
                return new ResolveResult(BuiltinTypes.Boolean);
            }

            return new PrimitiveResolveResult(
                BuiltinTypes.Boolean,
                MetadataHelper.isSubType(typeResult.getType(), childType)
            );
        }
View Full Code Here

            );
        }

        @Override
        public ResolveResult visitIndexerExpression(final IndexerExpression node, final Void data) {
            final ResolveResult childResult = node.getTarget().acceptVisitor(this, data);

            if (childResult == null || childResult.getType() == null || !childResult.getType().isArray()) {
                return null;
            }

            final TypeReference elementType = childResult.getType().getElementType();

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

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

            return new ResolveResult(elementType);
        }

        @Override
        public ResolveResult visitUnaryOperatorExpression(final UnaryOperatorExpression node, final Void data) {
            final ResolveResult childResult = node.getExpression().acceptVisitor(this, data);

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

            final TypeReference resultType;

            switch (childResult.getType().getSimpleType()) {
                case Byte:
                case Character:
                case Short:
                case Integer:
                    resultType = BuiltinTypes.Integer;
                    break;

                default:
                    resultType = childResult.getType();
            }

            if (childResult.isCompileTimeConstant()) {
                final Object resultValue = UnaryOperations.doUnary(node.getOperator(), childResult.getConstantValue());

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

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

            return new ResolveResult(resultType);
        }

        @Override
        public ResolveResult visitConditionalExpression(final ConditionalExpression node, final Void data) {
            final ResolveResult conditionResult = node.getCondition().acceptVisitor(this, data);

            if (conditionResult != null &&
                conditionResult.isCompileTimeConstant()) {

                if (Boolean.TRUE.equals(conditionResult.getConstantValue())) {
                    return node.getTrueExpression().acceptVisitor(this, data);
                }

                if (Boolean.FALSE.equals(conditionResult.getConstantValue())) {
                    return node.getFalseExpression().acceptVisitor(this, data);
                }
            }

            final ResolveResult leftResult = node.getTrueExpression().acceptVisitor(this, data);

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

            final ResolveResult rightResult = node.getFalseExpression().acceptVisitor(this, data);

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

            final TypeReference resultType = MetadataHelper.findCommonSuperType(
                leftResult.getType(),
                rightResult.getType()
            );

            if (resultType != null) {
                if (leftResult.getType().isPrimitive() || rightResult.getType().isPrimitive()) {
                    return new ResolveResult(MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(resultType));
                }
                return new ResolveResult(resultType);
            }

            return null;
        }
View Full Code Here

            for (int i = 0; i < rank; i++) {
                arrayType = arrayType.makeArrayType();
            }

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

            return new ResolveResult(arrayType);
        }

        @Override
        public ResolveResult visitAssignmentExpression(final AssignmentExpression node, final Void data) {
            final ResolveResult leftResult = node.getLeft().acceptVisitor(this, data);

            if (leftResult != null && leftResult.getType() != null) {
                return new ResolveResult(leftResult.getType());
            }

            return null;
        }
View Full Code Here

            return createConnectedEndNode(node, data);
        }

        @Override
        public ControlFlowNode visitSwitchStatement(final SwitchStatement node, final ControlFlowNode data) {
            final ResolveResult constant = evaluateConstant(node.getExpression());

            SwitchSection defaultSection = null;
            SwitchSection sectionMatchedByConstant = null;

            for (final SwitchSection section : node.getSwitchSections()) {
                for (final CaseLabel label : section.getCaseLabels()) {
                    if (label.getExpression().isNull()) {
                        defaultSection = section;
                    }
                    else if (constant != null && constant.isCompileTimeConstant()) {
                        final ResolveResult labelConstant = evaluateConstant(label.getExpression());

                        if (areEqualConstants(constant, labelConstant)) {
                            sectionMatchedByConstant = section;
                        }
                    }
View Full Code Here

                        parent.getParent().isReference()) {

                        return null;
                    }

                    final ResolveResult lambdaResult = _resolver.apply(e);
                    final TypeReference functionalInterfaceType;

                    if (lambdaResult != null && lambdaResult.getType() != null) {
                        final TypeReference asSubType = MetadataHelper.asSubType(lambdaResult.getType(), topCastType);

                        functionalInterfaceType = asSubType != null ? asSubType
                                                                    : lambdaResult.getType();
                    }
                    else {
                        //
                        // TODO: Implement getFunctionalInterfaceType().
                        //
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.