MCPcopy Create free account
hub / github.com/antlr/codebuff / insert

Method insert

output/java8/1.4.13/CompilationState.java:150–172  ·  view source on GitHub ↗
(int addr, short opcode, String s)

Source from the content-addressed store, hash-verified

148 }
149
150 public void insert(int addr, short opcode, String s) {
151 //System.out.println("before insert of "+opcode+"("+s+"):"+ Arrays.toString(impl.instrs));
152 ensureCapacity(1+Bytecode.OPND_SIZE_IN_BYTES);
153 int instrSize = 1+Bytecode.OPND_SIZE_IN_BYTES;
154 System.arraycopy(impl.instrs, addr, impl.instrs, addr+instrSize, ip-addr); // make room for opcode, opnd
155 int save = ip;
156 ip = addr;
157 emit1(null, opcode, s);
158 ip = save+instrSize;
159 //System.out.println("after insert of "+opcode+"("+s+"):"+ Arrays.toString(impl.instrs));
160 // adjust addresses for BR and BRF
161 int a = addr+instrSize;
162 while ( a<ip ) {
163 byte op = impl.instrs[a];
164 Bytecode.Instruction I = Bytecode.instructions[op];
165 if ( op== Bytecode.INSTR_BR || op== Bytecode.INSTR_BRF ) {
166 int opnd = BytecodeDisassembler.getShort(impl.instrs, a+1);
167 writeShort(impl.instrs, a+1, (short)(opnd+instrSize));
168 }
169 a += I.nopnds*Bytecode.OPND_SIZE_IN_BYTES+1;
170 }
171 //System.out.println("after insert of "+opcode+"("+s+"):"+ Arrays.toString(impl.instrs));
172 }
173
174 public void write(int addr, short value) {
175 writeShort(impl.instrs, addr, value);

Callers

nothing calls this directly

Calls 4

ensureCapacityMethod · 0.95
emit1Method · 0.95
getShortMethod · 0.95
writeShortMethod · 0.95

Tested by

no test coverage detected