Exemplo n.º 1
0
 private void forUpdate(GeneratorAdapter adapter, int step, boolean isLocal) {
   if (isLocal) {
     adapter.visitVarInsn(ILOAD, i);
     adapter.loadLocal(step);
     adapter.visitInsn(IADD);
     adapter.visitVarInsn(ISTORE, i);
   } else adapter.visitIincInsn(i, step);
 }
Exemplo n.º 2
0
  private static void createProperty(ClassWriter cw, String classType, ASMProperty property)
      throws PageException {
    String name = property.getName();
    Type type = property.getASMType();
    Class clazz = property.getClazz();

    cw.visitField(Opcodes.ACC_PRIVATE, name, type.toString(), null, null).visitEnd();

    int load = loadFor(type);
    // int sizeOf=sizeOf(type);

    // get<PropertyName>():<type>
    Type[] types = new Type[0];
    Method method =
        new Method(
            (clazz == boolean.class ? "get" : "get") + StringUtil.ucFirst(name), type, types);
    GeneratorAdapter adapter = new GeneratorAdapter(Opcodes.ACC_PUBLIC, method, null, null, cw);

    Label start = new Label();
    adapter.visitLabel(start);

    adapter.visitVarInsn(Opcodes.ALOAD, 0);
    adapter.visitFieldInsn(Opcodes.GETFIELD, classType, name, type.toString());
    adapter.returnValue();

    Label end = new Label();
    adapter.visitLabel(end);
    adapter.visitLocalVariable("this", "L" + classType + ";", null, start, end, 0);
    adapter.visitEnd();

    adapter.endMethod();

    // set<PropertyName>(object):void
    types = new Type[] {type};
    method = new Method("set" + StringUtil.ucFirst(name), Types.VOID, types);
    adapter = new GeneratorAdapter(Opcodes.ACC_PUBLIC, method, null, null, cw);

    start = new Label();
    adapter.visitLabel(start);
    adapter.visitVarInsn(Opcodes.ALOAD, 0);
    adapter.visitVarInsn(load, 1);
    adapter.visitFieldInsn(Opcodes.PUTFIELD, classType, name, type.toString());

    adapter.visitInsn(Opcodes.RETURN);
    end = new Label();
    adapter.visitLabel(end);
    adapter.visitLocalVariable("this", "L" + classType + ";", null, start, end, 0);
    adapter.visitLocalVariable(name, type.toString(), null, start, end, 1);
    // adapter.visitMaxs(0, 0);//.visitMaxs(sizeOf+1, sizeOf+1);// hansx
    adapter.visitEnd();

    adapter.endMethod();
  }
Exemplo n.º 3
0
 private void forInit(GeneratorAdapter adapter, int start, boolean isLocal) {
   i = adapter.newLocal(Types.INT_VALUE);
   if (isLocal) adapter.loadLocal(start, Types.INT_VALUE);
   else adapter.push(start);
   adapter.visitVarInsn(ISTORE, i);
 }