Package com.strobel.reflection.emit

Examples of com.strobel.reflection.emit.Label


    private void emitObjectBinaryOp(final ExpressionType op) {
        switch (op) {
            case Equal:
            case ReferenceEqual: {
                final Label ifNotEqual = generator.defineLabel();
                final Label exit = generator.defineLabel();

                generator.emit(OpCode.IF_ACMPNE, ifNotEqual);

                generator.emitBoolean(true);
                generator.emitGoto(exit);

                generator.markLabel(ifNotEqual);
                generator.emitBoolean(false);
                generator.emitGoto(exit);

                generator.markLabel(exit);

                break;
            }

            case NotEqual:
            case ReferenceNotEqual: {
                final Label ifEqual = generator.defineLabel();
                final Label exit = generator.defineLabel();

                generator.emit(OpCode.IF_ACMPEQ, ifEqual);

                generator.emitBoolean(true);
                generator.emitGoto(exit);
View Full Code Here


    private void emitBranchAnd(final boolean branch, final BinaryExpression node, final Label label) {
        // if (left) then
        //   if (right) branch label
        // endIf

        final Label endIf = generator.defineLabel();

        emitExpressionAndBranch(!branch, node.getLeft(), endIf);
        emitExpressionAndBranch(branch, node.getRight(), label);

        generator.markLabel(endIf);
View Full Code Here

        // if not, emit into IL
        if (typeBuilder != null) {
            // store into field in our type builder, we will initialize
            // the value only once.
            final FieldBuilder fb = createStaticField("ConstantArray", Type.getType(array));
            final Label l = generator.defineLabel();

            generator.getField(fb);
            generator.emit(OpCode.IFNONNULL, l);
            generator.emitConstantArray(array);
            generator.putField(fb);
View Full Code Here

            // We know the type can be assigned, but still need to check
            // for null at runtime.
            //
            assert !type.isPrimitive();

            final Label ifNull = generator.defineLabel();
            final Label exit = generator.defineLabel();

            emitExpression(node.getOperand());

            generator.emit(OpCode.IFNULL, ifNull);
            generator.emitBoolean(true);
View Full Code Here

                generator.emit(OpCode.ARRAYLENGTH);
                return;
            }

            case IsNull: {
                final Label ifNonNull = generator.defineLabel();
                final Label exit = generator.defineLabel();

                generator.emit(OpCode.IFNONNULL, ifNonNull);
                generator.emitBoolean(true);
                generator.emitGoto(exit);

                generator.markLabel(ifNonNull);
                generator.emitBoolean(false);

                generator.markLabel(exit);
                return;
            }

            case IsNotNull: {
                final Label ifNull = generator.defineLabel();
                final Label exit = generator.defineLabel();

                generator.emit(OpCode.IFNULL, ifNull);
                generator.emitBoolean(true);
                generator.emitGoto(exit);

                generator.markLabel(ifNull);
                generator.emitBoolean(false);

                generator.markLabel(exit);
                return;
            }
        }

        final Type unboxedType = TypeUtils.getUnderlyingPrimitiveOrSelf(operandType);

        if (operandIsBoxed) {
            generator.emitUnbox(operandType);
        }

        switch (op) {
            case Not:
            case OnesComplement: {
                switch (unboxedType.getKind()) {
                    case BOOLEAN: {
                        final Label ifTrue = generator.defineLabel();
                        final Label exit = generator.defineLabel();

                        generator.emitBoolean(false);
                        generator.emit(OpCode.IF_ICMPNE, ifTrue);
                        generator.emitBoolean(true);
                        generator.emitGoto(exit);

                        generator.markLabel(ifTrue);
                        generator.emitBoolean(false);

                        generator.markLabel(exit);

                        break;
                    }

                    case BYTE:
                    case SHORT:
                    case INT: {
                        generator.emitInteger(-1);
                        generator.emit(OpCode.IXOR);
                        break;
                    }

                    case LONG: {
                        generator.emitLong(-1L);
                        generator.emit(OpCode.LXOR);
                        break;
                    }

                    case CHAR: {
                        generator.emitInteger(-1);
                        generator.emit(OpCode.IXOR);
                        break;
                    }

                    default: {
                        throw Error.unaryOperatorNotDefined(op, unboxedType);
                    }
                }
                break;
            }

            case IsFalse: {
                final Label ifTrue = generator.defineLabel();
                final Label exit = generator.defineLabel();

                generator.emitBoolean(false);
                generator.emit(OpCode.IF_ICMPNE, ifTrue);
                generator.emitBoolean(true);
                generator.emitGoto(exit);

                generator.markLabel(ifTrue);
                generator.emitBoolean(false);

                generator.markLabel(exit);

                // Not an arithmetic operation -> no conversion
                return;
            }

            case IsTrue: {
                final Label ifFalse = generator.defineLabel();
                final Label exit = generator.defineLabel();

                generator.emitBoolean(false);
                generator.emit(OpCode.IF_ICMPEQ, ifFalse);
                generator.emitBoolean(true);
                generator.emitGoto(exit);
View Full Code Here

        //
        // Emit filter block. Filter blocks are untyped so we need to do
        // the type check ourselves.
        //
        final Label endFilter = generator.defineLabel();
        final Label rightType = generator.defineLabel();

        //
        // Skip if it's not our exception type, but save the exception if it is
        // so it's available to the filter.
        //
View Full Code Here

TOP

Related Classes of com.strobel.reflection.emit.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.