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

Method insert

output/java8/1.4.14/CompilationState.java:152–174  ·  view source on GitHub ↗
(int addr, short opcode, String s)

Source from the content-addressed store, hash-verified

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