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

Method insert

output/java8/1.4.17/CompilationState.java:154–176  ·  view source on GitHub ↗
(int addr, short opcode, String s)

Source from the content-addressed store, hash-verified

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