diff --git a/include/xsk/arc/common/types.hpp b/include/xsk/arc/common/types.hpp index 4fb4a838..fc2accbd 100644 --- a/include/xsk/arc/common/types.hpp +++ b/include/xsk/arc/common/types.hpp @@ -29,10 +29,18 @@ enum class instance : u8 enum class build : u8 { - dev, - prod, + prod = 0 << 0, + dev_blocks = 1 << 0, + dev_maps = 1 << 1, + + dev = dev_blocks | dev_maps, }; +inline build operator&(build lhs, build rhs) +{ + return static_cast(static_cast::type>(lhs) & static_cast::type>(rhs)); +} + enum class endian : u8 { little, diff --git a/include/xsk/gsc/common/types.hpp b/include/xsk/gsc/common/types.hpp index eea61fa2..896b903f 100644 --- a/include/xsk/gsc/common/types.hpp +++ b/include/xsk/gsc/common/types.hpp @@ -29,10 +29,18 @@ enum class instance : u8 enum class build : u8 { - dev, - prod, + prod = 0 << 0, + dev_blocks = 1 << 0, + dev_maps = 1 << 1, + + dev = dev_blocks | dev_maps, }; +inline build operator&(build lhs, build rhs) +{ + return static_cast(static_cast::type>(lhs) & static_cast::type>(rhs)); +} + enum class endian : u8 { little, diff --git a/src/arc/assembler.cpp b/src/arc/assembler.cpp index 91cf1017..a94a7eee 100644 --- a/src/arc/assembler.cpp +++ b/src/arc/assembler.cpp @@ -279,10 +279,14 @@ auto assembler::assemble_function(function& func) -> void auto assembler::assemble_instruction(instruction const& inst) -> void { script_.write(static_cast(ctx_->opcode_id(inst.opcode))); - devmap_.write(script_.pos()); - devmap_.write(inst.pos.line); - devmap_.write(inst.pos.column); - devmap_count_++; + + if ((ctx_->build() & build::dev_maps) != build::prod) + { + devmap_.write(script_.pos()); + devmap_.write(inst.pos.line); + devmap_.write(inst.pos.column); + devmap_count_++; + } switch (inst.opcode) { diff --git a/src/arc/lexer.cpp b/src/arc/lexer.cpp index 2440a15a..f716783b 100644 --- a/src/arc/lexer.cpp +++ b/src/arc/lexer.cpp @@ -77,7 +77,7 @@ auto lexer::lex() -> token if (indev_) throw comp_error(loc_, "cannot recurse devblock ('/#')"); - if (ctx_->build() == build::dev) + if ((ctx_->build() & build::dev_blocks) != build::prod) { indev_ = true; return token{ token::DEVBEGIN, spacing_, loc_ }; diff --git a/src/gsc/assembler.cpp b/src/gsc/assembler.cpp index 3dd5ed0e..7849efec 100644 --- a/src/gsc/assembler.cpp +++ b/src/gsc/assembler.cpp @@ -70,10 +70,14 @@ auto assembler::assemble_function(function const& func) -> void auto assembler::assemble_instruction(instruction const& inst) -> void { script_.write(ctx_->opcode_id(inst.opcode)); - devmap_.write(script_.pos()); - devmap_.write(inst.pos.line); - devmap_.write(inst.pos.column); - devmap_count_++; + + if ((ctx_->build() & build::dev_maps) != build::prod) + { + devmap_.write(script_.pos()); + devmap_.write(inst.pos.line); + devmap_.write(inst.pos.column); + devmap_count_++; + } switch (inst.opcode) { diff --git a/src/gsc/lexer.cpp b/src/gsc/lexer.cpp index 5fa82971..02938c34 100644 --- a/src/gsc/lexer.cpp +++ b/src/gsc/lexer.cpp @@ -77,7 +77,7 @@ auto lexer::lex() -> token if (indev_) throw comp_error(loc_, "cannot recurse devblock ('/#')"); - if (ctx_->build() == build::dev) + if ((ctx_->build() & build::dev_blocks) != build::prod) { indev_ = true; return token{ token::DEVBEGIN, spacing_, loc_ }; diff --git a/src/tool/main.cpp b/src/tool/main.cpp index ebdc6a4e..1bcd5833 100644 --- a/src/tool/main.cpp +++ b/src/tool/main.cpp @@ -296,7 +296,7 @@ auto compile_file(game game, mach mach, fs::path file, fs::path rel) -> result utils::file::save(fs::path{ "compiled" } / rel, result); std::cout << fmt::format("compiled {}\n", rel.generic_string()); - if (contexts[game][mach]->build() == build::dev) + if ((contexts[game][mach]->build() & build::dev_maps) != build::prod) { utils::file::save(fs::path{ "compiled" } / fs::path{ "developer_maps" } / rel.replace_extension(".gscmap"), std::get<2>(outbin).data, std::get<2>(outbin).size); std::cout << fmt::format("saved developer map {}\n", rel.generic_string()); @@ -803,7 +803,7 @@ auto compile_file(game game, mach mach, fs::path const& file, fs::path rel) -> r utils::file::save(fs::path{ "compiled" } / rel, outbin.first.data, outbin.first.size); std::cout << fmt::format("compiled {}\n", rel.generic_string()); - if (contexts[game][mach]->build() == build::dev) + if ((contexts[game][mach]->build() & build::dev_maps) != build::prod) { utils::file::save(fs::path{ "compiled" } / fs::path{ "developer_maps" } / rel.replace_extension((rel.extension().string().starts_with(".gsc") ? ".gscmap" : ".cscmap")), outbin.second.data, outbin.second.size); std::cout << fmt::format("saved developer map {}\n", rel.generic_string());