runs the IR through the codecs and hands back raw plaintext bytecode.
| 215 | |
| 216 | // runs the IR through the codecs and hands back raw plaintext bytecode. |
| 217 | static std::vector<std::uint8_t> encode_bytecode(const IRProgram& prog, const VMConfig& vm, const CodecRegistry& codecs) { |
| 218 | BytecodeBuilder bb; |
| 219 | |
| 220 | // data refs get resolved later once the data island layout is known |
| 221 | for (const auto& blk : prog.blocks) { |
| 222 | bb.mark_block(blk.id); |
| 223 | |
| 224 | for (const auto& insn : blk.insns) { |
| 225 | const std::string fam = codec_family_for(insn.op); |
| 226 | const Codec* c = codecs.by_family(fam); |
| 227 | if (!c) throw Error("no codec for family " + fam); |
| 228 | c->encode(bb, insn, vm); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | bb.resolve_branches(); |
| 233 | return std::move(bb).take(); |
| 234 | } |
| 235 | |
| 236 | PackageResult package_shellcode(Span<std::uint8_t> shellcode, const PackageOptions& opt) { |
| 237 | SeedRng rng{opt.seed}; |
nothing calls this directly
no test coverage detected