Skip to content

Commit

Permalink
refactor: cleanup structs
Browse files Browse the repository at this point in the history
  • Loading branch information
xensik committed Dec 21, 2024
1 parent ab72aa7 commit d07177a
Show file tree
Hide file tree
Showing 40 changed files with 73 additions and 68 deletions.
2 changes: 1 addition & 1 deletion include/xsk/arc/assembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class assembler
auto process_function(function const& func) -> void;
auto process_instruction(instruction const& inst) -> void;
auto align_instruction(instruction& inst) -> void;
auto resolve_label(std::string const& name) -> usize;
auto resolve_label(std::string const& name) const -> usize;
auto resolve_string(std::string const& name) -> u16;
auto add_stringref(std::string const& str, string_type type, u32 ref) -> void;
auto add_importref(std::vector<std::string> const& data, u32 ref) -> void;
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/arc/decompiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class decompiler
auto find_location_index(stmt_list const& stm, std::string const& loc) -> usize;
auto last_location_index(stmt_list const& stm, usize index) -> bool;
auto lvalues_match(stmt_expr const& stm1, stmt_expr const& stm2) -> bool;
auto resolve_label(std::string const& name) -> usize;
auto resolve_label(std::string const& name) const -> usize;
auto process_function(decl_function& func) -> void;
auto process_stmt(stmt& stm) -> void;
auto process_stmt_list(stmt_list& stm) -> void;
Expand Down
9 changes: 5 additions & 4 deletions include/xsk/gsc/assembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
namespace xsk::gsc
{

class assembler
struct assembler
{
private:
context const* ctx_;
function const* func_;
assembly const* assembly_;
Expand All @@ -22,7 +23,7 @@ class assembler
u32 devmap_count_;

public:
assembler(context const* ctx);
explicit assembler(context const* ctx);
auto assemble(assembly const& data) -> std::tuple<buffer, buffer, buffer>;

private:
Expand All @@ -38,8 +39,8 @@ class assembler
auto assemble_switch(instruction const& inst) -> void;
auto assemble_switch_table(instruction const& inst) -> void;
auto assemble_offset(i32 offs) -> void;
auto resolve_function(std::string const& name) -> usize;
auto resolve_label(std::string const& name) -> usize;
auto resolve_function(std::string const& name) const -> usize;
auto resolve_label(std::string const& name) const -> usize;
auto encrypt_string(std::string const& str) -> std::string;
};

Expand Down
20 changes: 10 additions & 10 deletions include/xsk/gsc/common/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@
namespace xsk::gsc
{

class error : public std::runtime_error
struct error : public std::runtime_error
{
public:
error(std::string const& what);
explicit error(std::string const& what);
};

class asm_error : public std::runtime_error
struct asm_error : public std::runtime_error
{
public:
asm_error(std::string const& what);
explicit asm_error(std::string const& what);
};

class disasm_error : public std::runtime_error
struct disasm_error : public std::runtime_error
{
public:
disasm_error(std::string const& what);
explicit disasm_error(std::string const& what);
};

class ppr_error : public std::runtime_error
struct ppr_error : public std::runtime_error
{
public:
ppr_error(location const& loc, std::string const& what);
};

class comp_error : public std::runtime_error
struct comp_error : public std::runtime_error
{
public:
comp_error(location const& loc, std::string const& what);
};

class decomp_error : public std::runtime_error
struct decomp_error : public std::runtime_error
{
public:
decomp_error(std::string const& what);
explicit decomp_error(std::string const& what);
};

} // namespace xsk::gsc
4 changes: 2 additions & 2 deletions include/xsk/gsc/common/location.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace xsk::gsc
{

class position
struct position
{
public:
typedef const std::string filename_type;
Expand Down Expand Up @@ -78,7 +78,7 @@ std::basic_ostream<T>& operator<<(std::basic_ostream<T> &ostr, const position &p
return ostr << pos.line << '.' << pos.column;
}

class location
struct location
{
public:
typedef position::filename_type filename_type;
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/common/lookahead.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct lookahead

lookahead(char const* data, usize size);
auto advance() -> void;
auto ended() { return available == 0; };
auto ended() const { return available == 0; };
};

} // namespace xsk::gsc
3 changes: 1 addition & 2 deletions include/xsk/gsc/common/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ enum class switch_type
string,
};

// fordward decl for modules ref
class context;
struct context;

} // namespace xsk::gsc
5 changes: 3 additions & 2 deletions include/xsk/gsc/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
namespace xsk::gsc
{

class compiler
struct compiler
{
private:
context* ctx_;
assembly::ptr assembly_;
function::ptr function_;
Expand All @@ -31,7 +32,7 @@ class compiler
bool animload_;

public:
compiler(context* ctx);
explicit compiler(context* ctx);
auto compile(program const& data) -> assembly::ptr;
auto compile(std::string const& file, std::vector<u8>& data) -> assembly::ptr;

Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace xsk::gsc
{

class context
struct context
{
public:
using fs_callback = std::function<std::pair<buffer, std::vector<u8>>(context const*, std::string const&)>;
Expand Down
5 changes: 3 additions & 2 deletions include/xsk/gsc/decompiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
namespace xsk::gsc
{

class decompiler
struct decompiler
{
private:
context const* ctx_;
program::ptr program_;
decl_function::ptr func_;
Expand All @@ -23,7 +24,7 @@ class decompiler
locjmp locs_;

public:
decompiler(context const* ctx);
explicit decompiler(context const* ctx);
auto decompile(assembly const& data) -> program::ptr;

private:
Expand Down
5 changes: 3 additions & 2 deletions include/xsk/gsc/disassembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
namespace xsk::gsc
{

class disassembler
struct disassembler
{
private:
context const* ctx_;
function::ptr func_;
assembly::ptr assembly_;
utils::reader script_;
utils::reader stack_;

public:
disassembler(context const* ctx);
explicit disassembler(context const* ctx);
auto disassemble(buffer const& script, buffer const& stack) -> assembly::ptr;
auto disassemble(std::vector<u8> const& script, std::vector<u8> const& stack) -> assembly::ptr;
auto disassemble(u8 const* script, usize script_size, u8 const* stack, usize stack_size) -> assembly::ptr;
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/h1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 1415;
constexpr usize token_count = 42947;
constexpr u32 max_string_id = 42989;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/h2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 1491;
constexpr usize token_count = 42524;
constexpr u32 max_string_id = 54743;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/iw5_pc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 780;
constexpr usize token_count = 6306;
constexpr u32 max_string_id = 33386;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/iw5_ps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 777;
constexpr usize token_count = 14221;
constexpr u32 max_string_id = 33360;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/iw5_xb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 779;
constexpr usize token_count = 14221;
constexpr u32 max_string_id = 33386;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/iw6_pc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 1066;
constexpr usize token_count = 38306;
constexpr u32 max_string_id = 38305;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/iw6_ps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 0;
constexpr usize token_count = 0;
constexpr u32 max_string_id = 0x95A1;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/iw6_xb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 0;
constexpr usize token_count = 0;
constexpr u32 max_string_id = 0x8EFA;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/iw7.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 1500;
constexpr usize token_count = 682;
constexpr u32 max_string_id = 0x13FCC;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/iw8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 2032;
constexpr usize token_count = 72014;
constexpr u32 max_string_id = 0x1472F;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/iw9.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 1469;
constexpr usize path_count = 1467;
constexpr usize hash_count = 73500;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/s1_pc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 1389;
constexpr usize token_count = 42942;
constexpr u32 max_string_id = 0xA7DC;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
4 changes: 2 additions & 2 deletions include/xsk/gsc/engine/s1_ps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ constexpr usize code_count = 154;
constexpr usize func_count = 3;
constexpr usize meth_count = 0;
constexpr usize token_count = 0;
constexpr u32 max_string_id = 0xA51D; // TODO
constexpr u32 max_string_id = 0xA51D;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/s1_xb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 0;
constexpr usize token_count = 0;
constexpr u32 max_string_id = 0xA51D;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/s2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 1700;
constexpr usize token_count = 5;
constexpr u32 max_string_id = 0xACEE;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/s4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ constexpr usize meth_count = 37;
constexpr usize token_count = 4;
constexpr u32 max_string_id = 0x110F3;

class context : public gsc::context
struct context : public gsc::context
{
public:
context();
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/t4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace xsk::gsc::t4
{

enum class opcode : std::uint8_t
enum class opcode : u8
{
OP_End = 0x0,
OP_Return = 0x1,
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/gsc/engine/t5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace xsk::gsc::t5
{

enum class opcode : std::uint8_t
enum class opcode : u8
{
OP_End = 0x0,
OP_Return = 0x1,
Expand Down
3 changes: 2 additions & 1 deletion include/xsk/gsc/lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
namespace xsk::gsc
{

class lexer
struct lexer
{
private:
context const* ctx_;
lookahead reader_;
location loc_;
Expand Down
3 changes: 2 additions & 1 deletion include/xsk/gsc/preprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
namespace xsk::gsc
{

class preprocessor
struct preprocessor

Check failure on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, x86)

the following warning is treated as an error [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check warning on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, x86)

'xsk::gsc::preprocessor': type name first seen using 'class' now seen using 'struct' [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check failure on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, x64)

the following warning is treated as an error [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check warning on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, x64)

'xsk::gsc::preprocessor': type name first seen using 'class' now seen using 'struct' [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check failure on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, arm64)

the following warning is treated as an error [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check warning on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, arm64)

'xsk::gsc::preprocessor': type name first seen using 'class' now seen using 'struct' [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check failure on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, x86)

the following warning is treated as an error [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check warning on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, x86)

'xsk::gsc::preprocessor': type name first seen using 'class' now seen using 'struct' [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check failure on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, x64)

the following warning is treated as an error [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check warning on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, x64)

'xsk::gsc::preprocessor': type name first seen using 'class' now seen using 'struct' [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check failure on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, arm64)

the following warning is treated as an error [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]

Check warning on line 14 in include/xsk/gsc/preprocessor.hpp

View workflow job for this annotation

GitHub Actions / Build Windows (release, arm64)

'xsk::gsc::preprocessor': type name first seen using 'class' now seen using 'struct' [D:\a\gsc-tool\gsc-tool\build\xsk-gsc.vcxproj]
{
private:
context* ctx_;
std::stack<lexer> lexer_;
std::vector<std::string> includes_;
Expand Down
Loading

0 comments on commit d07177a

Please sign in to comment.