< prev index next >

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

Print this page




  53     }
  54 
  55     public C getstatic(S owner, CharSequence name, T type) {
  56         emitOp(Opcode.GETSTATIC, type);
  57         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  58         return thisBuilder();
  59     }
  60 
  61     public C putstatic(S owner, CharSequence name, T type) {
  62         emitOp(Opcode.PUTSTATIC, type);
  63         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  64         return thisBuilder();
  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);


 109     public C invokeinterface(S owner, CharSequence name, T type) {
 110         emitOp(Opcode.INVOKEINTERFACE, type);
 111         code.writeChar(poolHelper.putMethodRef(owner, name, type, true));
 112         int nargs = 1;
 113         Iterator<T> it = typeHelper.parameterTypes(type);
 114         while (it.hasNext()) {
 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) {




  53     }
  54 
  55     public C getstatic(S owner, CharSequence name, T type) {
  56         emitOp(Opcode.GETSTATIC, type);
  57         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  58         return thisBuilder();
  59     }
  60 
  61     public C putstatic(S owner, CharSequence name, T type) {
  62         emitOp(Opcode.PUTSTATIC, type);
  63         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  64         return thisBuilder();
  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 putfield(S owner, CharSequence name, T type) {
  74         emitOp(Opcode.PUTFIELD, type);
  75         code.writeChar(poolHelper.putFieldRef(owner, name, type));
  76         return thisBuilder();
  77     }
  78 
  79     public C vwithfield(S owner, CharSequence name, T type) {
  80         emitOp(Opcode.VWITHFIELD, 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);


 103     public C invokeinterface(S owner, CharSequence name, T type) {
 104         emitOp(Opcode.INVOKEINTERFACE, type);
 105         code.writeChar(poolHelper.putMethodRef(owner, name, type, true));
 106         int nargs = 1;
 107         Iterator<T> it = typeHelper.parameterTypes(type);
 108         while (it.hasNext()) {
 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 vdefault(S target) {
 127         emitOp(Opcode.VDEFAULT, target);
 128         code.writeChar(poolHelper.putClass(target));
 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) {


< prev index next >