public void Bake(out byte[] init_bytes, out byte[] code_bytes, out Ip2SrcLine ip2src_line) { PatchOffsets(); { var bytecode = new Bytecode(); for (int i = 0; i < init.Count; ++i) { init[i].Write(bytecode); } init_bytes = bytecode.GetBytes(); } { var bytecode = new Bytecode(); for (int i = 0; i < code.Count; ++i) { code[i].Write(bytecode); } code_bytes = bytecode.GetBytes(); } ip2src_line = new Ip2SrcLine(); int pos = 0; for (int i = 0; i < code.Count; ++i) { pos += code[i].def.size; ip2src_line.Add(pos - 1, code[i].line_num); } }
public void Write(Bytecode code) { code.Write8((uint)op); for (int i = 0; i < operands.Length; ++i) { int op_val = operands[i]; int width = def.operand_width[i]; switch (width) { case 1: code.Write8((uint)op_val); break; case 2: code.Write16((uint)op_val); break; case 3: code.Write24((uint)op_val); break; case 4: code.Write32((uint)op_val); break; default: throw new Exception("Not supported operand width: " + width + " for opcode:" + op); } } }
public void Write(Bytecode buffer) { buffer.WriteTo(stream); }