Package org.jplastic.core

Examples of org.jplastic.core.InstructionBuilderCallback


    {
        check();

        if (!isMethodImplemented(TO_STRING_METHOD_DESCRIPTION))
        {
            introduceMethod(TO_STRING_METHOD_DESCRIPTION).changeImplementation(new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    builder.loadConstant(toStringValue).returnResult();
                }
View Full Code Here


            // TODO: Better handling error case where delegating to a primitive or object array.

            // TODO: Is there a easy way to ensure that the type has the necessary method? I don't
            // like that errors along those lines may be deferred until execution time.

            changeImplementation(new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    // Load the field
View Full Code Here

                throw new IllegalArgumentException(
                        String.format(
                                "Method %s is not usable as a delegate provider; it must be a void method that takes no arguments.",
                                delegateProvidingMethod));

            changeImplementation(new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    // Load the field
View Full Code Here

         */
        void extendShimInvoke(SwitchBlock block)
        {
            final String accessMethodName = setupMethodHandleAccess();

            block.addCase(methodIndex, false, new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    builder.startTryCatch(new TryCatchCallback()
                    {
                        public void doBlock(TryCatchBlock block)
                        {
                            block.addTry(new InstructionBuilderCallback()
                            {
                                public void doBuild(InstructionBuilder builder)
                                {
                                    // The third argument is an Object array; get each
                                    for (int i = 0; i < description.argumentTypes.length; i++)
                                    {
                                        String argumentType = description.argumentTypes[i];

                                        builder.loadArgument(2);
                                        builder.loadArrayElement(i, Object.class.getName());
                                        builder.castOrUnbox(argumentType);
                                    }

                                    builder.invokeVirtual(className, description.returnType, accessMethodName,
                                            description.argumentTypes);

                                    // TODO: hate see "void" just there.

                                    if (description.returnType.equals("void"))
                                        builder.loadNull();
                                    else
                                        builder.boxPrimitive(description.returnType);

                                    builder.newInstance(SuccessMethodInvocationResult.class).dupe(1).swap();
                                    builder.invokeConstructor(SuccessMethodInvocationResult.class, Object.class);
                                    builder.returnResult();
                                }
                            });

                            for (String exceptionType : description.checkedExceptionTypes)
                            {
                                block.addCatch(exceptionType, new InstructionBuilderCallback()
                                {
                                    public void doBuild(InstructionBuilder builder)
                                    {
                                        builder.newInstance(FailureMethodInvocationResult.class).dupe(1).swap();
                                        builder.invokeConstructor(FailureMethodInvocationResult.class, Throwable.class);
View Full Code Here

        callback.doSwitch(this);

        if (!defaultAdded)
        {
            addDefault(new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    builder.throwException(IllegalArgumentException.class,
                            "Switch value not matched in case statement.");
View Full Code Here

            String capitalized = PlasticInternalUtils.capitalize(propertyName);

            if (accessType != PropertyAccessType.WRITE_ONLY)
            {
                introduceMethod(new MethodDescription(getTypeName(), "get" + capitalized, null)).changeImplementation(
                        new InstructionBuilderCallback()
                        {
                            public void doBuild(InstructionBuilder builder)
                            {
                                builder.loadThis().getField(className, node.name, getTypeName()).returnResult();
                            }
                        });
            }

            if (accessType != PropertyAccessType.READ_ONLY)
            {
                introduceMethod(new MethodDescription("void", "set" + capitalized, getTypeName()))
                        .changeImplementation(new InstructionBuilderCallback()
                        {
                            public void doBuild(InstructionBuilder builder)
                            {
                                builder.loadThis().loadArgument(0);
                                builder.putField(className, node.name, getTypeName());
View Full Code Here

                accessMethodName = method.name;
            }

            final String methodToInvoke = accessMethodName;

            switchBlock.addCase(fieldIndex, false, new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    builder.invokeVirtual(className, typeName, methodToInvoke).boxPrimitive(typeName).returnResult();
                }
View Full Code Here

                accessMethodName = method.name;
            }

            final String methodToInvoke = accessMethodName;

            switchBlock.addCase(fieldIndex, true, new InstructionBuilderCallback()
            {

                public void doBuild(InstructionBuilder builder)
                {
                    builder.castOrUnbox(typeName);
View Full Code Here

                    {
                        for (int i = 0; i < description.argumentTypes.length; i++)
                        {
                            final int index = i;

                            block.addCase(i, false, new InstructionBuilderCallback()
                            {

                                public void doBuild(InstructionBuilder builder)
                                {
                                    String type = description.argumentTypes[index];
View Full Code Here

                    {
                        for (int i = 0; i < description.argumentTypes.length; i++)
                        {
                            final int index = i;

                            block.addCase(i, true, new InstructionBuilderCallback()
                            {

                                public void doBuild(InstructionBuilder builder)
                                {
                                    String type = description.argumentTypes[index];
View Full Code Here

TOP

Related Classes of org.jplastic.core.InstructionBuilderCallback

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.