Package org.objectweb.asm

Examples of org.objectweb.asm.MethodVisitor.visitLdcInsn()


        boolean asPrimitive = ClassHelper.isPrimitiveType(type);
       
        if (value == null) {
            mv.visitInsn(ACONST_NULL);
        } else if (asPrimitive) {
            mv.visitLdcInsn(value);
        } else if (value instanceof Character) {
            mv.visitLdcInsn(value);
            BytecodeHelper.box(mv, type); // does not change this.stack field contents
        } else if (value instanceof Number) {
            if (value instanceof BigDecimal) {
View Full Code Here


        if (value == null) {
            mv.visitInsn(ACONST_NULL);
        } else if (asPrimitive) {
            mv.visitLdcInsn(value);
        } else if (value instanceof Character) {
            mv.visitLdcInsn(value);
            BytecodeHelper.box(mv, type); // does not change this.stack field contents
        } else if (value instanceof Number) {
            if (value instanceof BigDecimal) {
                String className = BytecodeHelper.getClassInternalName(value.getClass().getName());
                mv.visitTypeInsn(NEW, className);
View Full Code Here

        } else if (value instanceof Number) {
            if (value instanceof BigDecimal) {
                String className = BytecodeHelper.getClassInternalName(value.getClass().getName());
                mv.visitTypeInsn(NEW, className);
                mv.visitInsn(DUP);
                mv.visitLdcInsn(value.toString());
                mv.visitMethodInsn(INVOKESPECIAL, className, "<init>", "(Ljava/lang/String;)V");
            } else if (value instanceof BigInteger) {
                String className = BytecodeHelper.getClassInternalName(value.getClass().getName());
                mv.visitTypeInsn(NEW, className);
                mv.visitInsn(DUP);
View Full Code Here

                mv.visitMethodInsn(INVOKESPECIAL, className, "<init>", "(Ljava/lang/String;)V");
            } else if (value instanceof BigInteger) {
                String className = BytecodeHelper.getClassInternalName(value.getClass().getName());
                mv.visitTypeInsn(NEW, className);
                mv.visitInsn(DUP);
                mv.visitLdcInsn(value.toString());
                mv.visitMethodInsn(INVOKESPECIAL, className, "<init>", "(Ljava/lang/String;)V");
            } else if (value instanceof Long) {
                long l = (Long) value;
                if (l==0) {
                    mv.visitInsn(LCONST_0);
View Full Code Here

                if (l==0) {
                    mv.visitInsn(LCONST_0);
                } else if (l==1) {
                    mv.visitInsn(LCONST_1);
                } else {
                    mv.visitLdcInsn(value);
                }
                BytecodeHelper.box(mv, ClassHelper.getUnwrapper(type)); // does not change this.stack field contents
                BytecodeHelper.doCast(mv, type);
            } else {
                mv.visitLdcInsn(value);
View Full Code Here

                    mv.visitLdcInsn(value);
                }
                BytecodeHelper.box(mv, ClassHelper.getUnwrapper(type)); // does not change this.stack field contents
                BytecodeHelper.doCast(mv, type);
            } else {
                mv.visitLdcInsn(value);
                BytecodeHelper.box(mv, ClassHelper.getUnwrapper(type)); // does not change this.stack field contents
                BytecodeHelper.doCast(mv, type);
            }
        } else if (value instanceof Boolean) {
            Boolean bool = (Boolean) value;
View Full Code Here

        } else if (value instanceof Boolean) {
            Boolean bool = (Boolean) value;
            String text = (bool.booleanValue()) ? "TRUE" : "FALSE";
            mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", text, "Ljava/lang/Boolean;");
        } else if (value instanceof String) {
            mv.visitLdcInsn(value);
        } else {
            throw new ClassGeneratorException(
                    "Cannot generate bytecode for constant: " + value + " of type: " + type.getName());
        }
       
View Full Code Here

      for (Entry<String, Boolean> variable : variables.entrySet()) {
        if (variable.getValue().booleanValue()) {
          int value = LOCAL_START + variableNames.size();
          String key = variable.getKey();
          mw.visitVarInsn(ALOAD, CONTEXT);
          mw.visitLdcInsn(key);
          mw.visitMethodInsn(INVOKEVIRTUAL, Context.NAME, "get",
              "(Ljava/lang/String;)Ljava/lang/Object;");
          mw.visitVarInsn(ASTORE, value);
          variableNames.put(key, Integer.valueOf(value));
        }
View Full Code Here

        setter.visitVarInsn(type.isPrimitive()
                ? Primitive.getPrimitive(internalType).getSetOpCode()
                : ALOAD, 1);
        setter.visitFieldInsn(PUTFIELD, className, getPropertyName(name), internalType);
        setter.visitVarInsn(ALOAD, 0);
        setter.visitLdcInsn(name);
        setter.visitMethodInsn(INVOKEVIRTUAL, className, "fieldSet", "(Ljava/lang/String;)V");
        setter.visitInsn(RETURN);
        setter.visitMaxs(0, 0);
        setter.visitEnd();
    }
View Full Code Here

        setter.visitVarInsn(type.isPrimitive()
                ? Primitive.getPrimitive(internalType).getSetOpCode()
                : ALOAD, 1);
        setter.visitFieldInsn(PUTFIELD, className, getPropertyName(name), internalType);
        setter.visitVarInsn(ALOAD, 0);
        setter.visitLdcInsn(name);
        setter.visitMethodInsn(INVOKEVIRTUAL, className, "fieldSet", "(Ljava/lang/String;)V");
        setter.visitInsn(RETURN);
        setter.visitMaxs(0, 0);
        setter.visitEnd();
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.