Package com.strobel.decompiler.semantics

Examples of com.strobel.decompiler.semantics.ResolveResult


            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;
            }

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

                if (resultValue != null) {
                    return new PrimitiveResolveResult(childResult.getType(), resultValue);
                }
            }

            return new ResolveResult(childResult.getType());
        }
View Full Code Here

            return new ResolveResult(childResult.getType());
        }

        @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 TypeReference resultType = doBinaryPromotionStrict(
                node.getTrueExpression().acceptVisitor(this, data),
                node.getFalseExpression().acceptVisitor(this, data)
            );

            if (resultType != null) {
                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

    }

    @Override
    public final boolean matches(final INode other, final Match match) {
        if (other instanceof Expression && !other.isNull()) {
            final ResolveResult result = _resolver.apply((Expression) other);

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

            final boolean isMatch;

            if (testAny(_options, OPTION_EXACT)) {
                isMatch = MetadataHelper.isSameType(
                    _expressionType,
                    result.getType(),
                    testAny(_options, OPTION_STRICT)
                );
            }
            else {
                isMatch = MetadataHelper.isAssignableFrom(
                    _expressionType,
                    result.getType(),
                    testAny(_options, OPTION_ALLOW_UNCHECKED)
                );
            }

            if (isMatch) {
View Full Code Here

    protected ResolveResult evaluateConstant(final Expression e) {
        return resolver.apply(e);
    }

    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

        options.setAllowWildcards(false);

        for (int i = 0, n = arguments.size(); i < n; i++) {
            final Expression argument = arguments.get(i);
            final ResolveResult resolvedArgument = resolver.apply(argument);

            if (resolvedArgument == null ||
                argument instanceof LambdaExpression /*||
                argument instanceof MethodGroupExpression*/) {

                continue;
            }

            final ParameterDefinition p = parameters.get(i);

            final TypeReference aType = resolvedArgument.getType();
            final TypeReference pType = p.getParameterType();

            if (isCastRequired(pType, aType, true)) {
                arguments.set(
                    i,
View Full Code Here

            type = variable.isParameter() ? variable.getOriginalParameter().getParameterType()
                                          : variable.getOriginalVariable().getVariableType();
        }

        if (type != null) {
            return new ResolveResult(type);
        }

        return null;
    }
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.