だから、私は lua バイトコード命令をベクターに emplace_back しようとしています。問題は、これが含まれている関数がベクターの型を持っていることです。トランスレータのベクトル。元:
std::vector<Instruction*> translate_instr(lua_State* L, Proto* vP, int idx) {
auto vanilla_instr = vP->code[inum];
auto vanilla_op = GET_OPCODE(vanilla_instr);
auto custom_instr_32 = U_CREATE_INSTR(); // Creates new custom instruction
switch (vanilla_op) {
case OP_CALL:
case OP_TAILCALL: {
U_SET_OPCODE(luau_instr_32, custom_opcodes::MLUA_OP_CALL); // Set opcode's byte identifier to custom byte identifier of OP_CALL
U_SETARG_A(luau_instr_32, GETARG_A(vanilla_instr)); // Set first arg to custom a arg
U_SETARG_B(luau_instr_32, GETARG_B(vanilla_instr)); // Set 2nd arg to custom B arg
U_SETARG_C(luau_instr_32, GETARG_B(vanilla_instr)); // Set third arg to custom C arg
translate_instr.push_back(custom_instr_32);
break;
}
}
}
回線translate_instr.push_back(custom_instr_32);
が機能しません。
これが私がそれをどのように呼びたいかです:
auto* L = luaL_newstate();
luaL_openlibs(L);
auto lcl = reinterpret_cast<const LClosure*>(lua_topointer(L, -1));
auto p = lcl->p;
for (auto i = 0; i < p->sizecode; ++i) {
std::vector<Instruction*> custom_instr_vec[i] = translate_instr(L, P, i);
}
似たようなものは何でもいいのですが、疲れていて何もわかりません。