Package org.mvel2.asm

Examples of org.mvel2.asm.Label


            mv.visitInsn(ICONST_1);
            mv.visitLabel(rightNotNullLabel);
        }

        private Label jitNullSafeOperationStart() {
            Label nullLabel = new Label();
            load(LEFT_OPERAND);
            mv.visitJumpInsn(IFNULL, nullLabel);
            return nullLabel;
        }
View Full Code Here


            mv.visitJumpInsn(IFNULL, nullLabel);
            return nullLabel;
        }

        private Label jitNullSafeCoercion(Class<?> fromType, Class<?> toType) {
            Label nullLabel = new Label();
            load(LEFT_OPERAND);
            mv.visitJumpInsn(IFNULL, nullLabel);
            castOrCoerceTo(LEFT_OPERAND, fromType, toType, nullLabel);
            return nullLabel;
        }
View Full Code Here

            castOrCoerceTo(LEFT_OPERAND, fromType, toType, nullLabel);
            return nullLabel;
        }

        private Label jitLeftIsNull(Label nullLabel) {
            Label notNullLabel = new Label();
            mv.visitJumpInsn(GOTO, notNullLabel);
            mv.visitLabel(nullLabel);
            return notNullLabel;
        }
View Full Code Here

            mv.visitLabel(nullLabel);
            return notNullLabel;
        }

        private void castOrCoerceTo(int regNr, Class<?> fromType, Class<?> toType, Label nullLabel) {
            Label nonInstanceOfLabel = new Label();
            Label endOfCoercionLabel = new Label();
            load(regNr);
            instanceOf(toType);
            mv.visitJumpInsn(IFEQ, nonInstanceOfLabel);
            load(regNr);
            cast(toType);
            store(regNr, toType);
            mv.visitJumpInsn(GOTO, endOfCoercionLabel);

            mv.visitLabel(nonInstanceOfLabel);

            boolean isNumber = Number.class.isAssignableFrom(toType);

            Label tryOk = null;
            Label inCatch = null;
            if (isNumber) {
                Label beforeTry = new Label();
                tryOk = new Label();
                inCatch = new Label();
                mv.visitTryCatchBlock(beforeTry, tryOk, inCatch, "java/lang/NumberFormatException");
                mv.visitLabel(beforeTry);
            }

            mv.visitTypeInsn(NEW, internalName(toType));
            mv.visitInsn(DUP);
            load(regNr);
            coerceByConstructor(fromType, toType);
            store(regNr, toType);

            if (isNumber) {
                Label afterCatch = new Label();
                mv.visitLabel(tryOk);
                mv.visitJumpInsn(GOTO, afterCatch);
                mv.visitLabel(inCatch);
                mv.visitInsn(POP);
                mv.visitInsn(ACONST_NULL);
View Full Code Here

        }

        private void jitPrimitiveOperation(BooleanOperator op, Class<?> type) {
            int opCode = toOpCode(op, type);

            Label trueBranchLabel = new Label();
            Label returnLabel = new Label();
            if (type == double.class) {
                mv.visitInsn(DCMPL);
            } else if (type == long.class) {
                mv.visitInsn(LCMP);
            } else if (type == float.class) {
View Full Code Here

            mv.visitInsn(ICONST_1);
            mv.visitLabel(returnLabel);
        }

        private void jitNegation() {
            Label trueBranch = new Label();
            Label falseBranch = new Label();
            mv.visitJumpInsn(IFNE, trueBranch);
            mv.visitInsn(ICONST_1);
            mv.visitJumpInsn(GOTO, falseBranch);
            mv.visitLabel(trueBranch);
            mv.visitInsn(ICONST_0);
View Full Code Here

        mv.visitVarInsn( ASTORE,
                         1 );
        mv.visitVarInsn( ALOAD,
                         1 );
        Label l0 = new Label();

        mv.visitJumpInsn( IFNULL,
                          l0 );
        mv.visitVarInsn( ALOAD,
                         1 );

        mv.visitMethodInsn( INVOKEINTERFACE,
                            "org/drools/core/util/Triple",
                            "getValue",
                            "()Ljava/lang/Object;" );
        Label l1 = new Label();
        mv.visitJumpInsn( IFNONNULL,
                          l1 );
        mv.visitLabel( l0 );
        mv.visitInsn( BuildUtils.zero( type ) );
        mv.visitInsn( BuildUtils.returnType( type ) );
View Full Code Here

            mv.visitCode();
            mv.visitVarInsn( ALOAD,
                             0 );
            mv.visitVarInsn( ALOAD,
                             1 );
            Label l0 = new Label();
            mv.visitJumpInsn( IF_ACMPNE,
                              l0 );
            mv.visitInsn( ICONST_1 );
            mv.visitInsn( IRETURN );
            mv.visitLabel( l0 );
            mv.visitVarInsn( ALOAD,
                             1 );
            mv.visitTypeInsn( CHECKCAST,
                              "org/drools/factmodel/traits/TraitProxy" );
            mv.visitVarInsn( ASTORE,
                             2 );
            mv.visitVarInsn( ALOAD,
                             0 );
            mv.visitMethodInsn( INVOKEVIRTUAL,
                                proxyType,
                                "getFields",
                                "()Ljava/util/Map;" );
            mv.visitVarInsn( ALOAD,
                             2 );
            mv.visitMethodInsn( INVOKEVIRTUAL,
                                "org/drools/factmodel/traits/TraitProxy",
                                "getFields",
                                "()Ljava/util/Map;" );
            mv.visitMethodInsn( INVOKEVIRTUAL,
                                "java/lang/Object",
                                "equals",
                                "(Ljava/lang/Object;)Z" );
            Label l1 = new Label();
            mv.visitJumpInsn( IFNE,
                              l1 );
            mv.visitInsn( ICONST_0 );
            mv.visitInsn( IRETURN );
            mv.visitLabel( l1 );
            mv.visitVarInsn( ALOAD,
                             0 );
            mv.visitMethodInsn( INVOKEVIRTUAL,
                                proxyType,
                                "getObject",
                                "()Ljava/lang/Object;" );
            mv.visitVarInsn( ALOAD,
                             2 );
            mv.visitMethodInsn( INVOKEVIRTUAL,
                                "org/drools/factmodel/traits/TraitProxy",
                                "getObject",
                                "()Ljava/lang/Object;" );
            mv.visitMethodInsn( INVOKEVIRTUAL,
                                "java/lang/Object",
                                "equals",
                                "(Ljava/lang/Object;)Z" );
            Label l2 = new Label();
            mv.visitJumpInsn( IFNE,
                              l2 );
            mv.visitInsn( ICONST_0 );
            mv.visitInsn( IRETURN );
            mv.visitLabel( l2 );
View Full Code Here

        mv.visitVarInsn( ALOAD,
                         0 );
        mv.visitVarInsn( ALOAD,
                         1 );
        Label l0 = new Label();
        mv.visitJumpInsn( IF_ACMPNE,
                          l0 );
        mv.visitInsn( ICONST_1 );
        mv.visitInsn( IRETURN );

        mv.visitLabel( l0 );
        mv.visitVarInsn( ALOAD,
                         1 );
        Label l1 = new Label();
        mv.visitJumpInsn( IFNULL,
                          l1 );
        mv.visitVarInsn( ALOAD,
                         0 );
        mv.visitMethodInsn( INVOKEVIRTUAL,
                            "java/lang/Object",
                            "getClass",
                            "()Ljava/lang/Class;" );
        mv.visitVarInsn( ALOAD,
                         1 );
        mv.visitMethodInsn( INVOKEVIRTUAL,
                            "java/lang/Object",
                            "getClass",
                            "()Ljava/lang/Class;" );
        Label l2 = new Label();
        mv.visitJumpInsn( IF_ACMPEQ,
                          l2 );
        mv.visitLabel( l1 );
        mv.visitInsn( ICONST_0 );
        mv.visitInsn( IRETURN );
        mv.visitLabel( l2 );

        mv.visitVarInsn( ALOAD,
                         1 );
        mv.visitTypeInsn( CHECKCAST,
                          proxyType );
        mv.visitVarInsn( ASTORE,
                         2 );

        int x = 2;

        int count = 0;

        for (FieldDefinition field : classDef.getFieldsDefinitions()) {
            if (field.isKey()) {
                count++;

                if (!BuildUtils.isPrimitive( field.getTypeName() )) {

                    mv.visitVarInsn( ALOAD,
                                     0 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    Label l11 = new Label();
                    mv.visitJumpInsn( IFNULL,
                                      l11 );
                    mv.visitVarInsn( ALOAD,
                                     0 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    mv.visitVarInsn( ALOAD,
                                     2 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        BuildUtils.getInternalType( field.getTypeName() ),
                                        "equals",
                                        "(Ljava/lang/Object;)Z" );
                    Label l12 = new Label();
                    mv.visitJumpInsn( IFNE,
                                      l12 );
                    Label l13 = new Label();
                    mv.visitJumpInsn( GOTO,
                                      l13 );
                    mv.visitLabel( l11 );
                    mv.visitVarInsn( ALOAD,
                                     2 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    mv.visitJumpInsn( IFNULL,
                                      l12 );
                    mv.visitLabel( l13 );
                    mv.visitInsn( ICONST_0 );
                    mv.visitInsn( IRETURN );
                    mv.visitLabel( l12 );

                } else if ("double".equals( field.getTypeName() )) {

                    mv.visitVarInsn( ALOAD,
                                     2 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    mv.visitVarInsn( ALOAD,
                                     0 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    mv.visitMethodInsn( INVOKESTATIC,
                                        "java/lang/Double",
                                        "compare",
                                        "(DD)I" );
                    Label l5 = new Label();
                    mv.visitJumpInsn( IFEQ,
                                      l5 );
                    mv.visitInsn( ICONST_0 );
                    mv.visitInsn( IRETURN );
                    mv.visitLabel( l5 );

                    x = Math.max( x,
                                  4 );

                } else if ("float".equals( field.getTypeName() )) {

                    mv.visitVarInsn( ALOAD,
                                     2 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    mv.visitVarInsn( ALOAD,
                                     0 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    mv.visitMethodInsn( INVOKESTATIC,
                                        "java/lang/Float",
                                        "compare",
                                        "(FF)I" );
                    Label l6 = new Label();
                    mv.visitJumpInsn( IFEQ,
                                      l6 );
                    mv.visitInsn( ICONST_0 );
                    mv.visitInsn( IRETURN );
                    mv.visitLabel( l6 );

                } else if ("long".equals( field.getTypeName() )) {

                    mv.visitVarInsn( ALOAD,
                                     0 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    mv.visitVarInsn( ALOAD,
                                     2 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    mv.visitInsn( LCMP );
                    Label l8 = new Label();
                    mv.visitJumpInsn( IFEQ,
                                      l8 );
                    mv.visitInsn( ICONST_0 );
                    mv.visitInsn( IRETURN );
                    mv.visitLabel( l8 );

                    x = Math.max( x,
                                  4 );

                } else {

                    mv.visitVarInsn( ALOAD,
                                     0 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    mv.visitVarInsn( ALOAD,
                                     2 );
                    mv.visitMethodInsn( INVOKEVIRTUAL,
                                        proxyType,
                                        BuildUtils.getterName( field.getName(),
                                                               field.getTypeName() ),
                                        "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                    Label l4 = new Label();
                    mv.visitJumpInsn( IF_ICMPEQ,
                                      l4 );
                    mv.visitInsn( ICONST_0 );
                    mv.visitInsn( IRETURN );
                    mv.visitLabel( l4 );
View Full Code Here

                        mv.visitMethodInsn( INVOKEVIRTUAL,
                                            proxyType,
                                            BuildUtils.getterName( field.getName(),
                                                                   field.getTypeName() ),
                                            "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                        Label l8 = new Label();
                        mv.visitJumpInsn( IFNULL,
                                          l8 );
                        mv.visitVarInsn( ALOAD,
                                         0 );
                        mv.visitMethodInsn( INVOKEVIRTUAL,
                                            proxyType,
                                            BuildUtils.getterName( field.getName(),
                                                                   field.getTypeName() ),
                                            "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                        mv.visitMethodInsn( INVOKEVIRTUAL,
                                            BuildUtils.getInternalType( field.getTypeName() ),
                                            "hashCode",
                                            "()I" );
                        Label l9 = new Label();
                        mv.visitJumpInsn( GOTO,
                                          l9 );
                        mv.visitLabel( l8 );
                        mv.visitInsn( ICONST_0 );
                        mv.visitLabel( l9 );
                        mv.visitInsn( IADD );
                        mv.visitVarInsn( ISTORE,
                                         1 );

                    } else if ("double".equals( field.getTypeName() )) {

                        mv.visitVarInsn( ALOAD,
                                         0 );
                        mv.visitMethodInsn( INVOKEVIRTUAL,
                                            proxyType,
                                            BuildUtils.getterName( field.getName(),
                                                                   field.getTypeName() ),
                                            "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                        mv.visitInsn( DCONST_0 );
                        mv.visitInsn( DCMPL );
                        Label l2 = new Label();
                        mv.visitJumpInsn( IFEQ,
                                          l2 );
                        mv.visitVarInsn( ALOAD,
                                         0 );
                        mv.visitMethodInsn( INVOKEVIRTUAL,
                                            proxyType,
                                            BuildUtils.getterName( field.getName(),
                                                                   field.getTypeName() ),
                                            "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                        mv.visitMethodInsn( INVOKESTATIC,
                                            "java/lang/Double",
                                            "doubleToLongBits",
                                            "(D)J" );
                        Label l3 = new Label();
                        mv.visitJumpInsn( GOTO,
                                          l3 );
                        mv.visitLabel( l2 );
                        mv.visitInsn( LCONST_0 );
                        mv.visitLabel( l3 );
                        mv.visitVarInsn( LSTORE,
                                         2 );
                        mv.visitIntInsn( BIPUSH,
                                         31 );
                        mv.visitVarInsn( ILOAD,
                                         1 );
                        mv.visitInsn( IMUL );
                        mv.visitVarInsn( LLOAD,
                                         2 );
                        mv.visitVarInsn( LLOAD,
                                         2 );
                        mv.visitIntInsn( BIPUSH,
                                         32 );
                        mv.visitInsn( LUSHR );
                        mv.visitInsn( LXOR );
                        mv.visitInsn( L2I );
                        mv.visitInsn( IADD );
                        mv.visitVarInsn( ISTORE,
                                         1 );

                        x = Math.max( 6,
                                      x );
                        y = Math.max( 4,
                                      y );

                    } else if ("boolean".equals( field.getTypeName() )) {

                        mv.visitIntInsn( BIPUSH,
                                         31 );
                        mv.visitVarInsn( ILOAD,
                                         1 );
                        mv.visitInsn( IMUL );
                        mv.visitVarInsn( ALOAD,
                                         0 );
                        mv.visitMethodInsn( INVOKEVIRTUAL,
                                            proxyType,
                                            BuildUtils.getterName( field.getName(),
                                                                   field.getTypeName() ),
                                            "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                        Label l4 = new Label();
                        mv.visitJumpInsn( IFEQ,
                                          l4 );
                        mv.visitInsn( ICONST_1 );
                        Label l5 = new Label();
                        mv.visitJumpInsn( GOTO,
                                          l5 );
                        mv.visitLabel( l4 );
                        mv.visitInsn( ICONST_0 );
                        mv.visitLabel( l5 );
                        mv.visitInsn( IADD );
                        mv.visitVarInsn( ISTORE,
                                         1 );

                    } else if ("float".equals( field.getTypeName() )) {

                        mv.visitIntInsn( BIPUSH,
                                         31 );
                        mv.visitVarInsn( ILOAD,
                                         1 );
                        mv.visitInsn( IMUL );
                        mv.visitVarInsn( ALOAD,
                                         0 );
                        mv.visitMethodInsn( INVOKEVIRTUAL,
                                            proxyType,
                                            BuildUtils.getterName( field.getName(),
                                                                   field.getTypeName() ),
                                            "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                        mv.visitInsn( FCONST_0 );
                        mv.visitInsn( FCMPL );
                        Label l6 = new Label();
                        mv.visitJumpInsn( IFEQ,
                                          l6 );
                        mv.visitVarInsn( ALOAD,
                                         0 );
                        mv.visitMethodInsn( INVOKEVIRTUAL,
                                            proxyType,
                                            BuildUtils.getterName( field.getName(),
                                                                   field.getTypeName() ),
                                            "()" + BuildUtils.getTypeDescriptor( field.getTypeName() ) );
                        mv.visitMethodInsn( INVOKESTATIC,
                                            "java/lang/Float",
                                            "floatToIntBits",
                                            "(F)I" );
                        Label l7 = new Label();
                        mv.visitJumpInsn( GOTO,
                                          l7 );
                        mv.visitLabel( l6 );
                        mv.visitInsn( ICONST_0 );
                        mv.visitLabel( l7 );
View Full Code Here

TOP

Related Classes of org.mvel2.asm.Label

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.