diff --git a/rpcs3/Emu/Cell/PPUProgramCompiler.cpp b/rpcs3/Emu/Cell/PPUProgramCompiler.cpp index e74e741a95..b82688ce92 100644 --- a/rpcs3/Emu/Cell/PPUProgramCompiler.cpp +++ b/rpcs3/Emu/Cell/PPUProgramCompiler.cpp @@ -12,7 +12,7 @@ InstrBase* GetInstruction(T* list, const std::string& str) if(instr) { - if(instr->GetName().compare(str) == 0) + if(instr->GetName() == str) { return instr; } @@ -59,7 +59,7 @@ s64 FindOp(const std::string& text, const std::string& op, s64 from) return -1; } -ArrayF sections_list; +std::vector sections_list; u32 section_name_offs = 0; u32 section_offs = 0; @@ -68,7 +68,8 @@ SectionInfo::SectionInfo(const std::string& _name) name = _name; memset(&shdr, 0, sizeof(Elf64_Shdr)); - section_num = sections_list.Add(this); + sections_list.push_back(this); + section_num = sections_list.size() - 1; shdr.sh_offset = section_offs; shdr.sh_name = section_name_offs; @@ -81,37 +82,37 @@ void SectionInfo::SetDataSize(u32 size, u32 align) if(align) shdr.sh_addralign = align; if(shdr.sh_addralign) size = Memory.AlignAddr(size, shdr.sh_addralign); - if(code.GetCount()) + if(!code.empty()) { - for(u32 i=section_num + 1; ishdr.sh_offset -= code.size(); } - section_offs -= code.GetCount(); + section_offs -= code.size(); } - code.SetCount(size); + code.resize(size); section_offs += size; - for(u32 i=section_num + 1; ishdr.sh_offset += size; } } SectionInfo::~SectionInfo() { - sections_list.RemoveFAt(section_num); + sections_list.erase(sections_list.begin() + section_num); - for(u32 i=section_num + 1; ishdr.sh_offset -= code.size(); + sections_list[i]->shdr.sh_name -= name.length(); } - section_offs -= code.GetCount(); + section_offs -= code.size(); section_name_offs -= name.length(); } @@ -371,9 +372,9 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) if(str.length() > 1) { - for(u32 i=0; i= 32) { @@ -417,7 +417,7 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) return; } - switch((char)str[0]) + switch(str[0]) { case 'r': arg.type = ARG_REG_R; break; case 'f': arg.type = ARG_REG_F; break; @@ -475,7 +475,8 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) return; } - if(str.length() > 2 && str.substr(0, 2).compare("0x") == 0) + // Hex numbers + if(str.length() > 2 && str.substr(0, 2) == "0x") { for(u32 i=2; i 0; + m_end_args = m_args.size() > 0; } -u32 CompilePPUProgram::GetBranchValue(const std::string& branch) +u32 CompilePPUProgram::GetBranchValue(const std::string& branch_name) { - for(u32 i=0; i= 0) return m_text_addr + m_branches[i].m_pos * 4; - return m_branches[i].m_addr; + if(branch.m_pos >= 0) + return m_text_addr + branch.m_pos * 4; + + return branch.m_addr; } return 0; @@ -548,7 +546,7 @@ bool CompilePPUProgram::SetNextArgType(u32 types, bool show_err) { if(m_error) return false; - if(m_cur_arg >= m_args.GetCount()) + if(m_cur_arg >= m_args.size()) { if(show_err) { @@ -581,7 +579,7 @@ bool CompilePPUProgram::SetNextArgBranch(u8 aa, bool show_err) const u32 pos = m_cur_arg; const bool ret = SetNextArgType(ARG_BRANCH | ARG_IMM, show_err); - if(!aa && pos < m_args.GetCount()) + if(!aa && pos < m_args.size()) { switch(m_args[pos].type) { @@ -665,11 +663,12 @@ bool CompilePPUProgram::IsSpOp(const std::string& op) CompilePPUProgram::Branch& CompilePPUProgram::GetBranch(const std::string& name) { - for(u32 i=0; iClear(); } - m_code.Clear(); - - for(u32 i=0; i m_imports; + std::vector m_imports; Module(const std::string& name, u32 import) : m_name(name) { @@ -1024,17 +1020,17 @@ void CompilePPUProgram::Compile() void Add(u32 import) { - m_imports.AddCpy(import); + m_imports.push_back(import); } void Clear() { m_name.clear(); - m_imports.Clear(); + m_imports.clear(); } }; - Array modules; + std::vector modules; FirstChar(); while(!IsEnd()) @@ -1049,9 +1045,9 @@ void CompilePPUProgram::Compile() while(p > 0 && m_asm[(size_t)p] != '[') p--; p++; - std::string module, name, id; + std::string module_name, name, id; - if(!GetArg(module)) + if(!GetArg(module_name)) { WriteError("module not found. style: [module, name, id]"); m_error = true; @@ -1059,7 +1055,7 @@ void CompilePPUProgram::Compile() continue; } - Arg a_module(module); + Arg a_module(module_name); DetectArgInfo(a_module); if(~ARG_ERR & a_module.type) @@ -1118,26 +1114,28 @@ void CompilePPUProgram::Compile() if(!CheckEnd()) continue; - m_branches.Move(new Branch(name, a_id.value, 0)); //TODO: HACK: new and free() mixed - const u32 import = m_branches.GetCount() - 1; + m_branches.emplace_back(name, a_id.value, 0); + const u32 import = m_branches.size() - 1; bool founded = false; - for(u32 i=0; i args; - args.SetCount(m_args.GetCount()); + args.SetCount(m_args.size()); for(uint i=0; iThaw(); diff --git a/rpcs3/Emu/Cell/PPUProgramCompiler.h b/rpcs3/Emu/Cell/PPUProgramCompiler.h index 2581754c78..6312331876 100644 --- a/rpcs3/Emu/Cell/PPUProgramCompiler.h +++ b/rpcs3/Emu/Cell/PPUProgramCompiler.h @@ -1,20 +1,21 @@ #pragma once +#include #include "PPUInstrTable.h" #include "Loader/ELF64.h" enum ArgType { - ARG_ERR = 0, - ARG_NUM = 1 << 0, - ARG_NUM16 = 1 << 1, - ARG_TXT = 1 << 2, - ARG_REG_R = 1 << 3, - ARG_REG_F = 1 << 4, - ARG_REG_V = 1 << 5, - ARG_REG_CR = 1 << 6, - ARG_BRANCH = 1 << 7, - ARG_INSTR = 1 << 8, - ARG_IMM = ARG_NUM | ARG_NUM16 | ARG_BRANCH, + ARG_ERR = 0, + ARG_NUM = 1 << 0, + ARG_NUM16 = 1 << 1, + ARG_TXT = 1 << 2, + ARG_REG_R = 1 << 3, + ARG_REG_F = 1 << 4, + ARG_REG_V = 1 << 5, + ARG_REG_CR = 1 << 6, + ARG_BRANCH = 1 << 7, + ARG_INSTR = 1 << 8, + ARG_IMM = ARG_NUM | ARG_NUM16 | ARG_BRANCH, }; struct Arg @@ -35,7 +36,7 @@ struct SectionInfo { Elf64_Shdr shdr; std::string name; - Array code; + std::vector code; u32 section_num; SectionInfo(const std::string& name); @@ -46,14 +47,13 @@ struct SectionInfo struct ProgramInfo { - Array code; + std::vector code; Elf64_Phdr phdr; bool is_preload; ProgramInfo() { is_preload = false; - code.Clear(); memset(&phdr, 0, sizeof(Elf64_Phdr)); } }; @@ -92,9 +92,9 @@ class CompilePPUProgram wxTextCtrl* m_hex_list; wxTextCtrl* m_err_list; bool m_error; - Array m_code; + std::vector m_code; bool m_end_args; - Array m_branches; + std::vector m_branches; s32 m_branch_pos; u32 m_text_addr; std::string m_file_path; @@ -111,8 +111,8 @@ class CompilePPUProgram } }; - Array m_sp_string; - Array m_args; + std::vector m_sp_string; + std::vector m_args; u32 m_cur_arg; public: