Package com.strobel.reflection

Examples of com.strobel.reflection.MethodInfo


    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // BOXING AND CONVERSION OPERATIONS                                                                                   //
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public void emitBox(final Type<?> type) {
        final MethodInfo boxMethod = TypeUtils.getBoxMethod(
            VerifyArgument.notNull(type, "type")
        );

        if (boxMethod != null) {
            call(OpCode.INVOKESTATIC, boxMethod);
View Full Code Here


            call(OpCode.INVOKESTATIC, boxMethod);
        }
    }

    public void emitUnbox(final Type<?> type) {
        final MethodInfo unboxMethod = TypeUtils.getUnboxMethod(
            VerifyArgument.notNull(type, "type")
        );

        if (unboxMethod != null) {
            call(OpCode.INVOKEVIRTUAL, unboxMethod);
View Full Code Here

    private void emitBoxedToUnboxedNumericConversion(final Type<?> sourceType, final Type<?> targetType) {
        assert TypeUtils.isAutoUnboxed(sourceType) && !TypeUtils.isAutoUnboxed(targetType)
            : "TypeUtils.isAutoUnboxed(sourceType) && !TypeUtils.isAutoUnboxed(targetType)";

        final MethodInfo coercionMethod = TypeUtils.getCoercionMethod(sourceType, targetType);

        if (coercionMethod != null) {
            call(coercionMethod);
        }
        else {
View Full Code Here

            Modifier.PUBLIC | Modifier.FINAL,
            Types.Object,
            Type.list(lambda.getType())
        );

        final MethodInfo interfaceMethod = lambda.getType().getMethods().get(0);

        methodBuilder = typeBuilder.defineMethod(
            interfaceMethod.getName(),
            Modifier.PUBLIC | Modifier.FINAL,
            interfaceMethod.getReturnType(),
            interfaceMethod.getParameters().getParameterTypes(),
            interfaceMethod.getThrownTypes()
        );

        final ParameterExpressionList lambdaParameters = lambda.getParameters();

        for (int i = 0, n = lambdaParameters.size(); i < n; i++) {
View Full Code Here

        // Emit argument.
        generator.emitLoad(operandStorage);

        freeLocal(operandStorage);

        final MethodInfo method = Expression.getInvokeMethod(lambda);

        // Emit call to invoke.
        generator.call(method);

        generator.markLabel(end);
View Full Code Here

        }
        return expression;
    }

    private void emitBinaryMethod(final BinaryExpression b, final int flags) {
        final MethodInfo method = b.getMethod();
        final Expression left = b.getLeft();
        final Expression right = b.getRight();
        final Expression instance;

        if (method.isStatic()) {
            emitMethodCallExpression(Expression.call(null, method, left, right), flags);
        }
        else if (TypeUtils.isSameOrSubType(method.getDeclaringType(), left.getType())) {
            emitMethodCallExpression(Expression.call(left, method, right), flags);
        }
        else {
            emitMethodCallExpression(Expression.call(right, method, left), flags);
        }
View Full Code Here

    private void emitMethodCall(final MethodInfo method, final IArgumentProvider args, final Type<?> objectType, final int flags) {
        // Emit arguments
        emitArguments(method, args);

        if ((flags & CompilationFlags.EmitAsSuperCall) != 0) {
            final MethodInfo superMethod = objectType.getMethod(
                method.getName(),
                BindingFlags.AllInstance,
                method.getParameters().getParameterTypes().toArray()
            );

            generator.call(OpCode.INVOKESPECIAL, superMethod);
        }
        else {
            generator.call(method);
        }

        final Type returnType = method.getReturnType();

        if (returnType != PrimitiveTypes.Void &&
            (method.isGenericMethod() || method.getDeclaringType().isGenericType())) {

            final MethodInfo erasedDefinition = method.getErasedMethodDefinition();
            if (erasedDefinition != null) {
                generator.emitConversion(
                    erasedDefinition.getReturnType(),
                    returnType);
            }
        }
    }
View Full Code Here

        //
        if (!TypeUtils.areEquivalent(type, Types.String)) {
            return false;
        }

        final MethodInfo comparison = node.getComparison();
        final MethodInfo comparerEquals = Types.Comparer.getMethod(
            "equals",
            BindingFlags.PublicStatic,
            Types.Object,
            Types.Object
        );

        //
        // If we have a comparison other than string equality, bail.
        //
        if (comparison.getRawMethod() != comparerEquals.getRawMethod()) {
            return false;
        }

        int tests = 0;
View Full Code Here

            throw Error.coalesceUsedOnNonNullableType();
        }

        final Type<?> delegateType = conversion.getType();

        final MethodInfo method = getInvokeMethod(conversion);

        if (method.getReturnType() == PrimitiveTypes.Void) {
            throw Error.operatorMethodMustNotReturnVoid(method);
        }

        final ParameterList parameters = method.getParameters();

        assert parameters.size() == conversion.getParameters().size();

        if (parameters.size() != 1) {
            throw Error.incorrectNumberOfMethodCallArguments(method);
        }

        //
        // The return type must match exactly.
        //
        if (!TypeUtils.areEquivalent(method.getReturnType(), right.getType())) {
            throw Error.operandTypesDoNotMatchParameters(ExpressionType.Coalesce, method);
        }

        //
        // The parameter of the conversion lambda must either be assignable from the erased
View Full Code Here

    }

    public static InvocationExpression invoke(final Expression expression, final ExpressionList<? extends Expression> arguments) {
        verifyCanRead(expression, "expression");

        final MethodInfo method = getInvokeMethod(expression);

        return new InvocationExpression(expression, arguments, method.getReturnType());
    }
View Full Code Here

TOP

Related Classes of com.strobel.reflection.MethodInfo

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.