Package com.strobel.core

Examples of com.strobel.core.MutableInteger


    public AstType convertType(final TypeReference type) {
        return convertType(type, new ConvertTypeOptions());
    }

    public AstType convertType(final TypeReference type, final ConvertTypeOptions options) {
        return convertType(type, new MutableInteger(0), options);
    }
View Full Code Here


        if (!(n instanceof Expression)) {
            return false;
        }

        final StrongBox<Expression> parent = new StrongBox<>();
        final MutableInteger position = new MutableInteger();

        if (findLoadInNext((Expression) n, variable, inlinedExpression, parent, position) == Boolean.TRUE) {

            if (!aggressive &&
                !variable.isGenerated() &&
                !nonAggressiveInlineInto((Expression) n, parent.get())) {

                return false;
            }

            final List<Expression> parentArguments = parent.get().getArguments();

            //
            // Assign the ranges of the Load instruction.
            //
            inlinedExpression.getRanges().addAll(
                parentArguments.get(position.getValue()).getRanges()
            );

            parentArguments.set(position.getValue(), inlinedExpression);

            return true;
        }

        return false;
View Full Code Here

                return false;
        }
    }

    private static int count(final Map<Variable, MutableInteger> map, final Variable variable) {
        final MutableInteger count = map.get(variable);
        return count != null ? count.getValue() : 0;
    }
View Full Code Here

        final MutableInteger count = map.get(variable);
        return count != null ? count.getValue() : 0;
    }

    private static void increment(final Map<Variable, MutableInteger> map, final Variable variable) {
        final MutableInteger count = map.get(variable);

        if (count == null) {
            map.put(variable, new MutableInteger(1));
        }
        else {
            count.increment();
        }
    }
View Full Code Here

    private boolean shouldCache(final ParameterExpression v) {
        if (referenceCount == null) {
            return false;
        }

        final MutableInteger refCount = referenceCount.get(v);

        return refCount != null &&
               shouldCache(v, refCount.getValue());
    }
View Full Code Here

        }
    }

    @Test
    public void testTryFinally() throws Exception {
        final MutableInteger counter = new MutableInteger(0);
        final Expression counterConstant = constant(counter);
        final ParameterExpression shouldThrow = parameter(PrimitiveTypes.Boolean);

        final LambdaExpression<ShouldThrowDelegate> lambda = lambda(
            Type.of(ShouldThrowDelegate.class),
            tryFinally(
                call(Type.of(CompilerTests.class), "maybeThrow", shouldThrow),
                call(counterConstant, "increment")
            ),
            shouldThrow
        );

        System.out.println();
        System.out.println(lambda);

        final ShouldThrowDelegate delegate = lambda.compile();

        System.out.printf("\n[%s]\n", delegate.getClass().getSimpleName());

        try {
            delegate.maybeThrow(false);
        }
        catch (Throwable t) {
            fail("Exception should not have been thrown.");
        }

        assertEquals(1, counter.getValue());
        counter.setValue(0);

        try {
            delegate.maybeThrow(true);
            fail("Exception should have been thrown.");
        }
        catch (Throwable ignored) {
        }

        assertEquals(1, counter.getValue());
    }
View Full Code Here

            }
        }
        catch (ClassNotFoundException ignored) {
        }

        return parseTopLevelSignature(value, new MutableInteger());
    }
View Full Code Here

    }

    public static Type<?> parseSignature(final String signature) {
        VerifyArgument.notNullOrWhitespace(signature, "signature");

        return parseTopLevelSignature(signature, new MutableInteger());
    }
View Full Code Here

        }
    }

    @Test
    public void testTryFinally() throws Exception {
        final MutableInteger counter = new MutableInteger(0);
        final Expression counterConstant = constant(counter);
        final ParameterExpression shouldThrow = parameter(PrimitiveTypes.Boolean);

        final LambdaExpression<ShouldThrowDelegate> lambda = lambda(
            Type.of(ShouldThrowDelegate.class),
            tryFinally(
                call(Type.of(CompilerTests.class), "maybeThrow", shouldThrow),
                call(counterConstant, "increment")
            ),
            shouldThrow
        );

        System.out.println();
        System.out.println(lambda);

        final ShouldThrowDelegate delegate = lambda.compile();

        System.out.printf("\n[%s]\n", delegate.getClass().getSimpleName());

        try {
            delegate.maybeThrow(false);
        }
        catch (Throwable t) {
            fail("Exception should not have been thrown.");
        }

        assertEquals(1, counter.getValue());
        counter.setValue(0);

        try {
            delegate.maybeThrow(true);
            fail("Exception should have been thrown.");
        }
        catch (Throwable ignored) {
        }

        assertEquals(1, counter.getValue());
    }
View Full Code Here

    private void incrementReferenceCount(final ParameterExpression node, final CompilerScope scope) {
        if (scope.referenceCount == null) {
            scope.referenceCount = new HashMap<>();
        }

        final MutableInteger refCount = scope.referenceCount.get(node);

        if (refCount == null) {
            scope.referenceCount.put(node, new MutableInteger(1));
        }
        else {
            refCount.increment();
        }
    }
View Full Code Here

TOP

Related Classes of com.strobel.core.MutableInteger

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.