gsc-tool/src/iw5/xsk/disassembler.hpp

43 lines
1.6 KiB
C++
Raw Normal View History

2022-01-26 12:08:28 +01:00
// Copyright 2022 xensik. All rights reserved.
2020-05-21 13:32:38 +02:00
//
// Use of this source code is governed by a GNU GPLv3 license
// that can be found in the LICENSE file.
#pragma once
namespace xsk::gsc::iw5
{
class disassembler : public gsc::disassembler
{
std::string filename_;
2021-12-25 20:10:30 +01:00
utils::byte_buffer::ptr script_;
utils::byte_buffer::ptr stack_;
utils::byte_buffer::ptr output_;
std::vector<function::ptr> functions_;
2020-05-21 13:32:38 +02:00
std::unordered_map<std::uint32_t, std::string> labels_;
public:
2021-12-25 20:10:30 +01:00
auto output() -> std::vector<function::ptr>;
2020-05-21 13:32:38 +02:00
auto output_data() -> std::vector<std::uint8_t>;
void disassemble(const std::string& file, std::vector<std::uint8_t>& script, std::vector<std::uint8_t>& stack);
private:
2021-12-25 20:10:30 +01:00
void dissasemble_function(const function::ptr& func);
void dissasemble_instruction(const instruction::ptr& inst);
void disassemble_builtin_call(const instruction::ptr& inst, bool method, bool args);
void disassemble_local_call(const instruction::ptr& inst, bool thread);
void disassemble_far_call(const instruction::ptr& inst, bool thread);
void disassemble_switch(const instruction::ptr& inst);
void disassemble_end_switch(const instruction::ptr& inst);
2022-01-19 20:01:12 +01:00
void disassemble_field_variable(const instruction::ptr& inst);
void disassemble_jump(const instruction::ptr& inst, bool expr, bool back);
2020-05-21 13:32:38 +02:00
auto disassemble_offset() -> std::int32_t;
void resolve_local_functions();
auto resolve_function(const std::string& index) -> std::string;
2021-12-25 20:10:30 +01:00
void print_function(const function::ptr& func);
void print_instruction(const instruction::ptr& inst);
2020-05-21 13:32:38 +02:00
};
} // namespace xsk::gsc::iw5