< prev index next >

jdk/src/java.base/share/classes/jdk/experimental/bytecode/CodeBuilder.java

Print this page
rev 14083 : vwithfield class/field access


  65     }
  66 
  67     public C getfield(S owner, CharSequence name, T type) {
  68         emitOp(Opcode.GETFIELD, type);
  69         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  70         return thisBuilder();
  71     }
  72 
  73     public C vgetfield(S owner, CharSequence name, T type) {
  74         emitOp(Opcode.VGETFIELD, type);
  75         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  76         return thisBuilder();
  77     }
  78 
  79     public C putfield(S owner, CharSequence name, T type) {
  80         emitOp(Opcode.PUTFIELD, type);
  81         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  82         return thisBuilder();
  83     }
  84 






  85     public C invokevirtual(S owner, CharSequence name, T type, boolean isInterface) {
  86         emitOp(Opcode.INVOKEVIRTUAL, type);
  87         code.writeChar(poolHelper.putMethodRef(owner, name, type, isInterface));
  88         return thisBuilder();
  89     }
  90 
  91     public C invokespecial(S owner, CharSequence name, T type, boolean isInterface) {
  92         emitOp(Opcode.INVOKESPECIAL, type);
  93         code.writeChar(poolHelper.putMethodRef(owner, name, type, isInterface));
  94         return thisBuilder();
  95     }
  96 
  97     public C invokestatic(S owner, CharSequence name, T type, boolean isInterface) {
  98         emitOp(Opcode.INVOKESTATIC, type);
  99         code.writeChar(poolHelper.putMethodRef(owner, name, type, isInterface));
 100         return thisBuilder();
 101     }
 102 
 103     public C invokeinterface(S owner, CharSequence name, T type) {
 104         emitOp(Opcode.INVOKEINTERFACE, type);


 109             nargs += typeHelper.tag(it.next()).width;
 110         }
 111         code.writeByte(nargs);
 112         code.writeByte(0);
 113         return thisBuilder();
 114     }
 115 
 116     public C invokedynamic(CharSequence invokedName, T invokedType, S bsmClass, CharSequence bsmName, T bsmType, Object... staticArgs) {
 117         throw new UnsupportedOperationException("Not supported yet");
 118     }
 119 
 120     public C new_(S clazz) {
 121         emitOp(Opcode.NEW, clazz);
 122         code.writeChar(poolHelper.putClass(clazz));
 123         return thisBuilder();
 124     }
 125 
 126     public C vnew_(S clazz, CharSequence name, T desc) {
 127         emitOp(Opcode.VNEW, clazz);
 128         code.writeChar(poolHelper.putMethodRef(clazz, name, desc, false));






 129         return thisBuilder();
 130     }
 131 
 132     public C newarray(TypeTag tag) {
 133         emitOp(Opcode.NEWARRAY, tag);
 134         int newarraycode = tag.newarraycode;
 135         if (newarraycode == -1) {
 136             throw new IllegalStateException("Bad tag " + tag);
 137         }
 138         code.writeByte(newarraycode);
 139         return thisBuilder();
 140     }
 141 
 142     public C anewarray(S array) {
 143         emitOp(Opcode.ANEWARRAY, array);
 144         code.writeChar(poolHelper.putClass(array));
 145         return thisBuilder();
 146     }
 147 
 148     public C checkcast(S target) {




  65     }
  66 
  67     public C getfield(S owner, CharSequence name, T type) {
  68         emitOp(Opcode.GETFIELD, type);
  69         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  70         return thisBuilder();
  71     }
  72 
  73     public C vgetfield(S owner, CharSequence name, T type) {
  74         emitOp(Opcode.VGETFIELD, type);
  75         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  76         return thisBuilder();
  77     }
  78 
  79     public C putfield(S owner, CharSequence name, T type) {
  80         emitOp(Opcode.PUTFIELD, type);
  81         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  82         return thisBuilder();
  83     }
  84 
  85     public C vwithfield(S owner, CharSequence name, T type) {
  86         emitOp(Opcode.VWITHFIELD, type);
  87         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  88         return thisBuilder();
  89     }
  90 
  91     public C invokevirtual(S owner, CharSequence name, T type, boolean isInterface) {
  92         emitOp(Opcode.INVOKEVIRTUAL, type);
  93         code.writeChar(poolHelper.putMethodRef(owner, name, type, isInterface));
  94         return thisBuilder();
  95     }
  96 
  97     public C invokespecial(S owner, CharSequence name, T type, boolean isInterface) {
  98         emitOp(Opcode.INVOKESPECIAL, type);
  99         code.writeChar(poolHelper.putMethodRef(owner, name, type, isInterface));
 100         return thisBuilder();
 101     }
 102 
 103     public C invokestatic(S owner, CharSequence name, T type, boolean isInterface) {
 104         emitOp(Opcode.INVOKESTATIC, type);
 105         code.writeChar(poolHelper.putMethodRef(owner, name, type, isInterface));
 106         return thisBuilder();
 107     }
 108 
 109     public C invokeinterface(S owner, CharSequence name, T type) {
 110         emitOp(Opcode.INVOKEINTERFACE, type);


 115             nargs += typeHelper.tag(it.next()).width;
 116         }
 117         code.writeByte(nargs);
 118         code.writeByte(0);
 119         return thisBuilder();
 120     }
 121 
 122     public C invokedynamic(CharSequence invokedName, T invokedType, S bsmClass, CharSequence bsmName, T bsmType, Object... staticArgs) {
 123         throw new UnsupportedOperationException("Not supported yet");
 124     }
 125 
 126     public C new_(S clazz) {
 127         emitOp(Opcode.NEW, clazz);
 128         code.writeChar(poolHelper.putClass(clazz));
 129         return thisBuilder();
 130     }
 131 
 132     public C vnew_(S clazz, CharSequence name, T desc) {
 133         emitOp(Opcode.VNEW, clazz);
 134         code.writeChar(poolHelper.putMethodRef(clazz, name, desc, false));
 135         return thisBuilder();
 136     }
 137 
 138     public C vdefault(S target) {
 139         emitOp(Opcode.VDEFAULT, target);
 140         code.writeChar(poolHelper.putClass(target));
 141         return thisBuilder();
 142     }
 143 
 144     public C newarray(TypeTag tag) {
 145         emitOp(Opcode.NEWARRAY, tag);
 146         int newarraycode = tag.newarraycode;
 147         if (newarraycode == -1) {
 148             throw new IllegalStateException("Bad tag " + tag);
 149         }
 150         code.writeByte(newarraycode);
 151         return thisBuilder();
 152     }
 153 
 154     public C anewarray(S array) {
 155         emitOp(Opcode.ANEWARRAY, array);
 156         code.writeChar(poolHelper.putClass(array));
 157         return thisBuilder();
 158     }
 159 
 160     public C checkcast(S target) {


< prev index next >