Package com.strobel.decompiler.semantics

Examples of com.strobel.decompiler.semantics.ResolveResult


        // </editor-fold>

        // <editor-fold defaultstate="collapsed" desc="Helper Methods">

        protected TypeReference getType(final AstNode node) {
            final ResolveResult result = _resolver.apply(node);
            return result != null ? result.getType() : null;
        }
View Full Code Here


    private static boolean checkSameExpression(final Expression template, final Expression expression) {
        return Comparer.equals(template, skipParenthesesDown(expression));
    }

    private static TypeReference getType(@NotNull final Function<AstNode, ResolveResult> resolver, @NotNull final AstNode node) {
        final ResolveResult result = resolver.apply(node);
        return result != null ? result.getType() : null;
    }
View Full Code Here

        return Comparer.equals(c1.getConstantValue(), c2.getConstantValue());
    }

    protected Boolean evaluateCondition(final Expression e) {
        final ResolveResult result = evaluateConstant(e);

        if (result != null && result.isCompileTimeConstant()) {
            final Object constantValue = result.getConstantValue();

            if (constantValue instanceof Boolean) {
                return (Boolean) constantValue;
            }
View Full Code Here

                binary.getRight() instanceof NullReferenceExpression) {

                return false;
            }

            final ResolveResult leftResult = _resolver.apply(binary.getLeft());
            final ResolveResult rightResult = _resolver.apply(binary.getRight());

            return leftResult != null &&
                   rightResult != null &&
                   leftResult.getType() != null &&
                   rightResult.getType() != null &&
                   (node == binary.getLeft() ? rightResult.getType().isPrimitive()
                                             : leftResult.getType().isPrimitive());
        }

        //
        // TODO: Remove the `if` below once overload resolution is written and integrated.
View Full Code Here

        final MemberReferenceExpression target,
        final ConditionalExpression parent) {

        final boolean leftSide = parent.getTrueExpression().isAncestorOf(e);
        final Expression otherSide = leftSide ? parent.getFalseExpression() : parent.getTrueExpression();
        final ResolveResult otherResult = _resolver.apply(otherSide);

        if (otherResult == null || otherResult.getType() == null || !otherResult.getType().isPrimitive()) {
            return;
        }

        performUnboxingRemoval(e, target);
    }
View Full Code Here

        // it must be simplified to `g((short)i.intValue())`.  A boxed type `S` can only
        // be cast to a primitive type `t` if there exists an implicit conversion from
        // the underlying primitive type `s` to `t`.
        //

        final ResolveResult boxedValueResult = _resolver.apply(boxedValue);

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

        final TypeReference targetType = ((MethodReference) outerBoxMethod).getReturnType();
        final TypeReference sourceType = boxedValueResult.getType();

        switch (MetadataHelper.getNumericConversionType(targetType, sourceType)) {
            case IDENTITY:
            case IMPLICIT: {
                //
View Full Code Here

        if (targetType == null || !targetType.isPrimitive()) {
            return;
        }

        final Expression boxedValue = target.getTarget();
        final ResolveResult boxedValueResult = _resolver.apply(boxedValue);

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

        final TypeReference sourceType = boxedValueResult.getType();
        final ConversionType conversionType = MetadataHelper.getNumericConversionType(targetType, sourceType);

        switch (conversionType) {
            case IMPLICIT:
            case EXPLICIT:
View Full Code Here

            return;
        }

        final AstNodeCollection<Expression> arguments = node.getArguments();
        final Expression underlyingValue = arguments.firstOrNullObject();
        final ResolveResult valueResult = _resolver.apply(underlyingValue);

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

        final TypeReference sourceType = valueResult.getType();
        final TypeReference targetType = ((MethodReference) reference).getReturnType();
        final ConversionType conversionType = MetadataHelper.getNumericConversionType(targetType, sourceType);

        switch (conversionType) {
            case IMPLICIT: {
View Full Code Here

                if (castType != null &&
                    castType.isPrimitive() &&
                    castedValue instanceof BinaryOperatorExpression) {

                    final ResolveResult leftResult = _resolver.apply(left);

                    if (leftResult != null &&
                        MetadataResolver.areEquivalent(castType, leftResult.getType()) &&
                        tryRewriteBinaryAsAssignment(node, left, castedValue)) {

                        final Expression newValue = castExpression.getExpression();

                        newValue.remove();
View Full Code Here

                    tryRewriteBinaryAsUnary(node, node.getLeft(), node.getRight());
                    return true;
                }
            }
            else if (binaryOp.isCommutative() && innerRight.matches(left)) {
                final ResolveResult leftResult = _resolver.apply(left);
                final ResolveResult innerLeftResult = _resolver.apply(innerLeft);

                //
                // The transform from `t = n + t` to `t += n` is legal for numeric types, but the
                // commutative property does not hold for string concatenation (i.e., the result
                // depends on the order of the operands).  If the assignment target does not match
                // the left operand, and either operand is a string, then do not apply a compound
                // assignment transform.
                //

                if (leftResult == null || leftResult.getType() == null ||
                    innerLeftResult == null || innerLeftResult.getType() == null) {

                    return false;
                }

                if (CommonTypeReferences.String.isEquivalentTo(leftResult.getType()) ||
                    CommonTypeReferences.String.isEquivalentTo(innerLeftResult.getType())) {

                    return false;
                }

                final AssignmentOperatorType assignOp = AssignmentExpression.getCorrespondingAssignmentOperator(binaryOp);
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.